fminsearch - how to skip unstable parameter sets/solutions

2 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Mayo de 2020
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.

Más respuestas (0)

Categorías

Más información sobre Financial Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by