scipy.optimize,fmin进行多次相同的调用

时间:2015-12-20 15:45:52

标签: python scipy minimum

我注意到scipy.optimize.fmin功能的异常行为。我有这样的事情:

def func(phi):
    """ I'm looking for minimum value of this function """
    ....
    return value

fmin(func, [0], disp=0, full_output=1, retall=1)

在寻找最小值时,函数fmin使用相同的参数值进行10次连续调用。这是func报告的参数列表:

[0.0, 0.00025, 0.0005, 0.00075, 0.00125, 0.00175, 0.00275, 0.00375, 0.00575, 0.00775, 0.01175, 0.01575, 0.02375, 0.03175, 0.04775, 0.06375, 0.09575, 0.12775, 0.19175,
0.25575, 0.25575, <- consecutive calls here
0.31975, 0.31975, <- consecutive calls here
0.28775, 0.22375,
0.27175, 0.27175, <- consecutive calls here
0.23975,
0.26375, 0.26375, <- consecutive calls here
0.24775,
0.25975, 0.25975, <- consecutive calls here
0.25175,
0.25775, 0.25775, <- consecutive calls here
0.25375,
0.25675, 0.25675, <- consecutive calls here
0.25475,
0.25625, 0.25625, <- consecutive calls here
0.25525,
0.2555, 0.256, 0.2555,
0.255875, 0.255875, <- consecutive calls here
0.255625,
0.2558125, 0.2558125] <- consecutive calls here

为什么会这样做?这只是一个不优化scipy.optimize.fmin(在这种情况下,具有讽刺意味)的问题,还是有这种行为的目的?目前,由于func计算成本昂贵,我被迫编写一个缓存系统来处理大量冗余调用。

0 个答案:

没有答案