Hi guys,

I am running a costly simulation and trying to optimize the output. I'd have a fixed range over which the parameter of interest can vary, and about 100 values it can take in between. We know the result we are looking for and want to find the parameter value that comes closest to this. Instead of iterating the parameter incrementally, from say 0 to 100, I'd like to implement some sort of binary search algorithm. I am sure there is a "best" value on this range, so there's no need to worry about duplicate values.

The algorithm in my head should go something like:

Parameter low bound (p=0): Value known
Parameter high bound (p=100): Value known

Compare=0-50 and 50-100

Choose range at which best estimate is found. For example 0-50 is closest.

Bisect this range again...
0-25 vs. 25-50

Can anyone recommend a module or something that is suited to this type of thing? I know bisect is the module of choice for binary searches, but am having trouble seeing exactly which aspects of it are suitable to my needs.


4 Years
Discussion Span
Last Post by hughesadam_87

I would try the root solvers in scipy.optimize first (like scipy.optimize.fsolve or scipy.optimize.bisect, etc...).

Theoretically speaking, this problem depends mainly on the monotonicity properties of the values in your array. Are they increasing or decreasing values, or randomly chosen values (or something else?). These properties should govern your strategy. For example I don't understand

Compare=0-50 and 50-100.

What will you compare ?


Ok thanks guys. Let me look at your suggestions, reevaluate my problem, then come back if I still have questions.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.