- 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.
fminsearch - how to skip unstable parameter sets/solutions
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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:
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Financial Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!