Pure binary search algorithm for finding the p_value that achieves a target metric (final weight or total consumption).
binary_search_p_value(
target_value,
fit_type,
lower_bound,
upper_bound,
simulation_function,
tolerance = 0.001,
max_iterations = 25
)List with fitted p_value and convergence information
Target value (final weight or total consumption)
Type of fitting ("weight" or "consumption")
Lower bound for p_value search
Upper bound for p_value search
Function that runs simulation and returns metric
Tolerance for convergence
Maximum number of iterations