结束 fminsearch 出于一时兴起。

huangapple go评论64阅读模式
英文:

Ending fminsearch on a whim

问题

我想能够取消fminsearch(例如使用Ctrl + C),并保留到目前为止的最佳解决方案。有没有办法做到这一点?我不确定要设置什么样的容忍度,我更愿意“凭感觉”操作,当我对解决方案满意时按下Ctrl + C。Matlab似乎毫无收益地继续下去。

英文:

Id like to be able to cancel fminsearch (eg using ctrl+c) and retaining the best solution so far. Is there a way to do this? I dont know exactly what sort of tolerance I want to set, I'd much rather "play by ear" and ctrl+c when I'm satisfied with the solution. Matlab keeps going onnn and on and on for what seems to be no gain.

答案1

得分: 3

fminsearch可以通过输出函数绘图函数提前终止。要从用户获取交互式需求,最直接的方式是使用不必等待代码执行完成就更新的图形界面,因此使用绘图函数是实现这一目标的最直接方式。默认的绘图函数图形中包含"Stop"和"Pause"按钮,如文档示例所示:

fminsearch(funfcn, x, optimset('PlotFcns', @optimplotfval))

结束 fminsearch 出于一时兴起。

如果单击"Stop"按钮,fminsearch将返回其最新迭代的结果,并默认显示以下信息:

Optimization terminated prematurely by user.
英文:

fminsearch can be terminated early by both output functions and plot functions. To get an interactive demand from the user, use of graphical interfaces that don't wait until code is finished executing to update is basically essential, so using a plot function would be the most straightforward way of achieving this. The default plot function figure has "Stop" and "Pause" buttons built in, as seen in the documentation's example for calling:

fminsearch(funfcn,x,optimset('PlotFcns',@optimplotfval))

结束 fminsearch 出于一时兴起。

If the Stop button is clicked, fminsearch returns the result of its latest iteration and by default displays the information:

Optimization terminated prematurely by user.

huangapple
  • 本文由 发表于 2023年2月9日 03:15:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390692.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定