如何仅使用整数输入来最小化实函数 [英] How to minimize a real function with only integer input

查看:78
本文介绍了如何仅使用整数输入来最小化实函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪种优化算法适用于整数输入,浮点输出?

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当然可以解决此问题,但是对于大量输入,可以缩短其收敛时间.像布伦特优化之类的混合动力会更好.

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

示例

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

推荐答案

对于整数搜索空间,用比二分法更好的方法进行根查找没有意义,因为整数搜索空间已经非常快了.例如,一万亿个值的收敛速度不到33个步骤.

Root finding with something better than bisection doesn't make sense for integer search space as it's already very very fast. A trillion values converges in less than 33 steps for example.

(请参阅上面AirSquid的评论)

(See comment from AirSquid above)

这篇关于如何仅使用整数输入来最小化实函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆