How to minimize a real function with only integer input

北战南征 提交于 2021-02-11 15:33:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!