[galib] GA program
Peter Jay Salzman
p at dirac.org
Mon Nov 19 12:46:42 EST 2007
>> Peter <p at dirac.org> said:
>> Hi Somnath,
>>
>> Please state, clearly and precisely, the problem you want to solve. For
>> example:
>> "I want to find the 1st root of Bessel's function of 2nd order."
>> "I want to find the 3 cubic roots of unity."
>> "I want to minimize the gudermanian function."
>> "I want to find the intersection of tan(x) and tanh(x)."
>> If you can state your problem very clearly, I will try to help.
>>
>> On Mon 19 Nov 07, 4:40 PM, Somnath Bhattacharjee <sn.bhattacharjee at yahoo.co.in> said:
> Hi
> Pete.
>
> Like your 1st statement, "I want to find 2 roots of
> the given function (2nd order function)."
> y=X*X+5*X+6;
>
> Regards
> Somnath
Somnath, you keep saying you want to find the zeros of a function, but
in your code, you blindly call:
ga.minimize();
Since your fitness function does nothing but return the value of y(x), a fit
x is one that makes y(x) as small as possible (since you call minimize). An
unfit x make y(x) large (since you call minimize).
Your first gene's value was the minimum of x^2 + 5x + 6 and I believe your
2nd gene's value was nothing but the starting IC, evolved under mutation and
crossover.
If you want to find roots, you need to write a fitness function that returns
a high fitness when y(x) is close to zero and a low fitness when y(x) is far
from zero. Then you'd want to maximize your objective.
You *must* read the documentation. The demo programs are good, but they
won't give you all the info you need.
It sounds like you also need to read a GA tutorial. I'm not sure you quite
understand the relationship between the objective function and how a GA
arrives at a good candidate solution.
Pete
--
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
Last night I dreamt of 09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
"A mathematician is a machine for converting coffee p at dirac.org
into theorems." -- Paul Erdös http://www.dirac.org
More information about the galib
mailing list