Pass RSS as fitness error using GA tool optimisation
1 view (last 30 days)
Show older comments
I and need to use GA tool to optimize parameters for a system of ODE. I started with a simple ODE (dNdt=r*exp(-tN)). I loaded the data for N and t, so I need GA to optimize parameter r. Now I need to pass RSS as fitness function so instead of minimizing the function itself, I need to minimize the fitness error. I would greatly appreciate help (examples) with writing the fitness function.
0 Comments
Answers (2)
Alan Weiss
on 11 Mar 2014
2 Comments
Alan Weiss
on 12 Mar 2014
This doesn't sound like a MATLAB problem, it sounds as if you don't know how to write a formula for the fitness function. Is that correct? If not, then please tell us the formula for your fitness function, and we might be able to help you get it into GA syntax.
But if this is correct, then perhaps you can say in words what you would like to minimize, subject to what kind of constraints, and then maybe we can try to help you formulate your problem more mathematically.
Alan Weiss
MATLAB mathematical toolbox documentation
Sophie
on 13 Mar 2014
2 Comments
Alan Weiss
on 13 Mar 2014
Sophie, I am not sure what to tell you. It is possible that you have a simple model such as
dN/dt = -x*N(t)
which has the solution
N(t) = N(0)*exp(-x*t)
Or you could have the model that you say,
dN/dt = x*exp(-t*N(t))
which is a strange model to my eyes, but maybe that is what you have. In that case dN(t)/dt is strictly positive for positive values of x, so N(t) increases to some limiting value.
In any case, you have data Nobserved(Tobserved) for a number of times Tobserved. You want to find the parameter x, and possibly the parameter N(0), that makes you function N(t) fit the data best.
Usually the "best" fit is one that minimizes the sum of squares of the difference between the observations and the model. In other words, you want to minimize
sum( (Nobserved(Tobserved) - N(Tobserved))^2 )
To do so you need to make a function that takes your parameter x, or parameters x and N(0), and gives you a function N(T) for all values of T that you care about. You can get N(T) analytically for some models, or you can use ode45 or another MATLAB differential equation solver to give you the function N(T) for each x, N(0).
After that you can use any optimization routine you like, such as GA. I think you would be better served by lsqnonlin or lsqcurvefit, but your choice of optimization function is yours to make.
There is a bit of documentation about optimizing ODEs here. And there is an example of solving an ODE and optimizing it here.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!