微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

科学的差异演化给出了nan值

如何解决科学的差异演化给出了nan值

Im对期权价格进行建模,并对每个期权合约,使用Heston模型对基础资产的价格进行模拟。为了校准Heton参数,我正在尝试使用差分演化来优化成本函数

   def de(self):
        bounds = [(0,1),(0.01,15),1.),(-1,(0,1.0) ]
        differential_evolution(self.f_cost,bounds,args=(True,),maxiter=100)

每次我运行上面的代码时,它会为我提供五个参数的nan值,但是如果我删除args=(True,)它为我提供了真实的价值,但是我遇到了错误

    686         if np.all(np.isinf(self.population_energies)):
    687             self.population_energies[:] = self._calculate_population_energies(
--> 688                 self.population)
    689             self._promote_lowest_energy()
    690 

~\Anaconda3\lib\site-packages\scipy\optimize\_differentialevolution.py in _calculate_population_energies(self,population)
    792             # wrong number of arguments for _mapwrapper
    793             # or wrong length returned from the mapper
--> 794             raise RuntimeError("The map-like callable must be of the"
    795                                " form f(func,iterable),returning a sequence"
    796                                " of numbers the same length as 'iterable'")

RuntimeError: The map-like callable must be of the form f(func,returning a sequence of numbers the same length as 'iterable'

有人可以向我解释为什么会这样吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。