Genetic Algorithms with Stiff ODEs in Matlab

In summary, The conversation discusses the use of a genetic algorithm in Matlab to optimize a system of 10-20 differential equations. The issue is that the ode function sometimes gets stuck in an infinite loop, which causes the genetic algorithm to stop progressing. The cause of this behavior could be the ode solver diverging without throwing an error. The individual trying to solve the problem suggests testing for convergence and forcing the GA solver to try a different point if the solver is not converging. This issue is not limited to GA algorithms and also occurs when using a pattern search. Another individual joins the conversation and mentions a similar problem with a system of hundreds of dimensions, but they have found that using a for loop instead of vectorizing the operations resolves the issue
  • #1
mhmounty
10
0
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?
 
Physics news on Phys.org
  • #2
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.
 

1. What are genetic algorithms?

Genetic algorithms are a type of optimization algorithm that is inspired by the process of natural selection. They use principles of genetics and evolution to find solutions to complex problems.

2. How do genetic algorithms work?

Genetic algorithms work by creating a population of solutions, which are then evaluated and selected for their fitness. These solutions then undergo genetic operations such as crossover and mutation to produce new offspring, which are then evaluated and selected again. This process continues until a satisfactory solution is found.

3. What are stiff ODEs?

Stiff ODEs (ordinary differential equations) are a type of differential equation that have a large disparity in the time scales of their solutions. This means that there are some variables in the equation that change much faster than others, making it difficult for traditional numerical methods to accurately solve them.

4. How are genetic algorithms used to solve stiff ODEs in Matlab?

In Matlab, genetic algorithms can be used to find the optimal parameters for solving stiff ODEs. The genetic algorithm will create a population of potential solutions, which are then evaluated using a stiff ODE solver. The algorithm will then use the information from the evaluations to adjust the parameters and create a new population, continuing until a satisfactory solution is found.

5. What are the advantages of using genetic algorithms for solving stiff ODEs?

Genetic algorithms can handle complex problems with a large number of variables and constraints, making them suitable for solving stiff ODEs. They also have the ability to find global optima, meaning they can find the best solution rather than just a local one. Additionally, genetic algorithms can be easily parallelized, allowing for faster and more efficient solution finding.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • Programming and Computer Science
Replies
2
Views
902
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
Back
Top