Let us say I have a program called foo. It takes 1 argument (e.g. foo 42) and it spits out a single line containing a numerical value (e.g. 2034).
I want to find the optimal value for the input argument, so the output is minimized. Currently I do that by hand by (semi-)binary search, but that is slow - especially if foo is slow.
Is there an automated tool to find the optimal value for the input?
We assume the values are continuous, and it is OK to find a local optimum, so something that uses gradient descent would be ideal (especially if it can take n inputs).
As an example you can use this for foo:
perl -e 'print (1+(shift() - 10203040506)**2)'
In the example I want the tool to return 10203040506 since it gives the smallest value.
First version is now available: https://gitlab.com/ole.tange/tangetools/-/tree/master/find-optimal
It uses Nelder-Mead and it only works well on floats. It does very bad on integer values.
If you know of a "Nelder-Mead" for integers, let me know - especially if there is sample Python code for it.