假设您想要找出哪个输入导致函数x输出值y,并且您知道可能输入的(有限)范围。
输入和输出都是数字,并且是正相关的。
优化它的最好方法是什么?
我目前正在遍历所有可能的输入。
谢谢。
发布于 2011-06-01 10:31:29
一种解决方案是对可能的输入进行二进制搜索。
流程:
find the median input x
get the output from function(x)
if the output is less than the desired y
start over using the smaller half of the possible inputs
else
start over using the larger half of the possible inputs
发布于 2011-06-01 10:31:28
也许是一种二进制搜索算法?
http://en.wikipedia.org/wiki/Binary_search_algorithm
发布于 2011-06-01 10:39:21
如果范围有限且小,则预先计算的查找表可能是最快的方法。
https://stackoverflow.com/questions/6195589
复制相似问题