问题
Which optimization algorithms work for integer input, float output?
One thought is just using Brent search but making up a method that interpolates two nearest points to fake a real number input as opposed to an integer input.
My second thought is that seems like such a common need, there must already be something in scipy to do it and/or an algorithm more suited for it?
Bisect certainly works for this, but for huge inputs, its convergence time could be improved. Something hybrid like Brent optimization would be better.
https://docs.scipy.org/doc/scipy/reference/optimize.html
Example
a = []
for i in range(10):
a.append(i-5+.8)
# a = [-4.2, -3.2, -2.2, -1.2, -0.19999999999999996, 0.8, 1.8, 2.8, 3.8, 4.8]
# How to find a[x] such that a is as close to 0 as possible? x = 4, a = -0.2
来源:https://stackoverflow.com/questions/62959501/how-to-minimize-a-real-function-with-only-integer-input