Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Genetic Algorithms with Stiff ODEs in Matlab

  1. Aug 15, 2011 #1
    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.

    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?
  2. jcsd
  3. Aug 15, 2011 #2


    User Avatar
    Gold Member

    I have a similar problem with a system of hundreds of dimensions.

    Thing is, it works fine if I handle each element with a for loop, but when I vectorize thee operations, I get diverging solutions that go NaN.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook