2011-06-01 113 views
1

假设您想查找哪个输入导致函数x输出值y,并且知道可能输入的(有限)范围。算法优化

输入和输出都是数字,并且正相关。

什么是最佳的方式来优化呢?

我目前只是循环所有可能的输入。

谢谢。

+3

这个小信息很难猜测。你在寻找一个特定的输出吗?如果你有函数x的衍生物,[牛顿法](http://en.wikipedia.org/wiki/Newton's_method)速度很快。如果您没有衍生产品,[secant方法](http://en.wikipedia.org/wiki/Secant_method)是合理的第二选择。如果函数相对于输入变量单调递增或递减,则[二进制搜索](http://en.wikipedia.org/wiki/Binary_search_algorithm)可能就是该工具。 – sarnold 2011-06-01 02:31:18

回答

1

一个解决方案是在可能的输入的二进制搜索。

流量:

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 
+0

完美,谢谢! – senak 2011-06-01 02:43:39

0

如果范围是有限的,小的,如果你有一些设置专门的预先计算的查找表可能是最快的方式

0

“X”数据产生“Y”你可以在训练和测试集之间进行分配并使用神经网络。