From: Hao on
> How do you calculate the fitness value for each member?

I'm trying to find parameters for a second order damping response.
I have my F = [ 0 1 ; - w^2 -2*w*z]
c = [1 0];
and my system is sys = ss[F, [], c, []);
because there are not external inputs and I set an initial value for x0.
So I calculate the output [y,t,x] = initial (sys,x0,t) for t = 0:0.25:5;
and compare that to my x_nominal, which is a vector.

I perform the comparison by calculating J = 0.5*(y - x_nom)' * (y-x_nom);

I tried running the script because I believe I got the roulette selection part carrect, but it appears that nothing changes in my population-I may be implementing selection incorrectly. I am going to review my code again.

Also, I was informed that when I run the matlab script on a server in the University network, it will be faster, but will the final results / information be stored in the script?

Thanks,
Hao

Should I put up my actual genetic algorithm?
From: Darren Rowland on
Hi Hao,

If every member of the initial population yields zero fitness then you either have too small a population or your fitness test is too stringent (or possibly inaccurate).

It is to be expected that the members of the initial population will be unfit for the problem at hand, however some individuals ought to be more fit than others. Continuing the genetic process when all members of the population are equally unfit will not get you anywhere.

Try relaxing the fitness tolerances for the first few generations of the run so that some somewhat fit individuals will appear. Then once the population begins to adapt to the problem, reintroduce the strict tolerances to solve to the desired level of accuracy.

Hth,
Darren
From: Hao on
Great, Thanks!
It turns out I was doing something wrong in generating my new pool of chromosomes after performing the roulette selection, but after fixing that, I still had 0 fitness.
I increased the mutation rate and cross-over rate, while also modifying my fitness function as per your suggestion, which was originally just exp(-J), where J was my cost function / error function to include exp(-J*k), with K being a number much smaller than one.

This allowed me to have a flatter fitness landscape and actually get a result, and graphing the fitness vs generation gave me a nice rapid fitness rise and a fairly steady fitness until the end of the iterations.

Thanks for the help!
Now I need to look up the transfer functions because I have been using a continuous time transfer function, but I am using it to describe a sampled data system.
Whilst looking through the help and tutorials and speaking with my advisor, I believe that instead of F being [ 0 1; -w^2 -2*w*z], it should be expm(F).
But doesnt adding a time step in this line [y,t,x] = initial(sys,x0,t) change it to discrete time? (My sys consists of sys = ss(F,[],c,[]), where c is just the output vector)

This is to model a 2nd order response, where w is the natural frequency and z is the damping ratio. Perhaps I should post this on a math forum?
From: Hao on
----
Ah, nevermind!
I've figured it out after going through a lot of documentation that doesn't really pertain to the particular method I am using to model the second order response.

my original state space model was for continuous time:
F = [0 1; -w(k).^2 -2*z(k)*w(k)];
c = [1 0];
sys = ss(F,[],c,[]);
(where F is the actual transfer function I think it is called, and c is output vector)

while a modified function where phi = expm(F*del_t) is used for discrete time, where del_t is the time interval, so my new system state model is:
F = [0 1; -w^2 -2*z*w];
c = [1 0];
sys = ss(expm(F*.25),[],c,[],.25);
the 0.25 is my time step, and this gives me a discrete model!
 | 
Pages: 1
Prev: read struct
Next: counting color image