我在Python中尝试优化函数scipy.optimize.minimize
。从结果来看,它不起作用。这是我的代码的一部分。我只想最小化两个值之差的平方和。
def calibrate(x):
# Real equity value and equity volatility from market data
equity_val = 30.0
equity_vol = 0.556
diff_s = 10000*(geske(x)[0]-equity_val)**2
diff_vol = 10000*(geske(x)[1]-equity_vol)**2
diff = diff_s+diff_vol
return diff
# Here geske is a function defined before, which takes two input parameter and returns several values
bnds = ((0,None), (0,None))
opt = sco.minimize(calibrate, [100,0.3], method='SLSQP', bounds=bnds)
但是,opt
的结果如下:
从结果来看,似乎优化函数不起作用,它只返回我给出的初始猜测值。为什么?我的校准功能是否存在错误?