I'm trying to optimize a system of 10-20 differential equations in Matlab using a genetic algorithm. The problem is, when I call the ode function, whether it be ode45, ode23, ode15, etc., it sometimes gets stuck in an infinite loop. The genetic algorithm no longer progresses and I have to Ctrl+C out of it.(adsbygoogle = window.adsbygoogle || []).push({});

My guess is that the ode solver is diverging, yet not throwing an error that it is stuck. It just gets stuck and doesn't timeout. I'm wondering if there is a way that I can test if the ode solver is converging, and if it isn't, force the GA solver to try a different point. The equations that I am trying to fit are all exponentials that range over 20 orders of magnitude or so, so there are many solution sets that won't converge.

This behavior isn't limited to only GA algorithms. I get the same behavior if I'm running a pattern search on the same set.

Any ideas?

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Genetic Algorithms with Stiff ODEs in Matlab

**Physics Forums | Science Articles, Homework Help, Discussion**