【发布时间】:2019-05-04 10:15:01
【问题描述】:
目前我正在使用 scipy 库中的盆地跳跃来找到优化我的目标函数的最优 x(其中 x 总共由 4 个因子组成)。当我让它运行几次时,每次运行都会给我不同的结果。有没有办法使结果更加一致(即函数在多次迭代中最小化参数相同)?
cons = [
{
'type': 'eq',
'fun': lambda x: x[0] + x[1] + x[2] - 1
},
{
'type': 'ineq',
'fun': lambda x: (w_0 / prob_death(T)[T-1]) - x[3]
},
{
'type': 'ineq',
'fun': lambda x: x[3] - 10000
}
]
bounds = ( (0, 1), (0, 1), (0, 1), (0, 1'000'000)) )
res = basinhopping(func = utility_expected,
x0 = np.array([0.33, 0.33, 0.33, 50000]),
minimizer_kwargs = {"method": 'SLSQP',
"bounds": bounds,
"constraints": cons,
"options": {
"eps": 0.01,
"ftol": 0.001
}
},
disp = False,
interval = 40,
niter = 250)
【问题讨论】:
-
这感觉像是一个非常广泛的优化问题;可能应该属于 math.SE,但即使在那里它也可能过于宽泛。
-
盆地跳跃是一种随机算法。您可以设置种子以使运行可重现。
标签: python python-3.x optimization scipy