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.