Tell scipy.optimize.minimize to fail

亡梦爱人 提交于 2019-12-05 18:46:38

You have 2 options I can think of:

  • opt for constrained optimization
  • modify your objective function to diverge whenever your numerical simulation does not converge. Basically this means returning a large value, large compared to a 'normal' value, which depends on your problem at hand. minimize will then try to optimize going in another direction

I am however a bit surprised that minimize does not understand inf as a large value, and does not try to look for a solution in another direction. Could it be that it returns with 0 iterations only when your objective function returns nan? You could try debugging the issue by printing the value just before the return statement in your objective function.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!