필터 지우기
필터 지우기

fminsearch - how to skip unstable parameter sets/solutions

조회 수: 3 (최근 30일)
micronaut
micronaut 2020년 5월 12일
답변: Walter Roberson 2020년 5월 12일
I am optimizating a system of ordinary differential equations using mfinsearch.
I have to use a wide range of parameter values which means that some of them produce unstable solutions that cause the ode solver to run for a very long time or become unstable. Is there a way to detect this and halt these iterations, moving on to another set of parameters?
I have attempted to use custom stop function with the optimizer, but this causes the entire script to exit when I exceed the time limit. Is there a way to implement this e.g inside the objective function code to "skip" rather than exit?
Thanks for any help.

채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 12일
There is a way... it just is not a nice way.
Create a shared variable.
Create an Output function that tests the current function value for not being finite, and if so signals to stop without changing the shared variable (this call), and otherwise sets the shared variable to contain information about the current vector and fvalue.
Now each time you have a set of starting inputs:
  • initialize the shared variable to emptyness
  • try/catch/end the fminsearch call, passing in the options structure to tell it to use the output function
  • Ignore the output of fminsearch. Instead, retrieve the value of the shared variable: it will reflect the state before the termination condition -- so the last finite location, the last value before running out of iterations, and so on.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by