[galib] galib Digest, Vol 52, Issue 6
Anselmo Pitombeira
anselmop at sc.usp.br
Mon Nov 19 14:00:41 EST 2007
You must be a good teacher. I hardly ever see such an elegant answer!
Anselmo Pitombeira
galib-request at mit.edu escreveu:
> Send galib mailing list submissions to
> galib at mit.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mailman.mit.edu/mailman/listinfo/galib
> or, via email, send a message with subject or body 'help' to
> galib-request at mit.edu
>
> You can reach the person managing the list at
> galib-owner at mit.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of galib digest..."
>
>
> Today's Topics:
>
> 1. Re: GA program (Peter Jay Salzman)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 16 Nov 2007 16:45:11 -0500
> From: Peter Jay Salzman <p at dirac.org>
> Subject: Re: [galib] GA program
> To: GALib Mailing List <galib at mit.edu>
> Message-ID: <20071116214511.GA24158 at dirac.org>
> Content-Type: text/plain; charset=iso-8859-1
>
> Hi Somnath,
>
>
> On Sat 17 Nov 07, 12:17 AM, Somnath Bhattacharjee <sn.bhattacharjee at yahoo.co.in> said:
>
>> I want to solve the Quadratic equation y= x*x+5*x+6.
>> According to manual calculation the result will be two roots ( -3 and -2 ,
>> for these values of x the function value will be ZERO ).
>>
>
> OK, that's what I suspected.
>
>
>> Now by GA the
>> results (means the roots) should be nearly -3 and -2 (not exactly -3,-2).
>> I'm not sure that it is right or not. I'm beginner in GA so your
>> suggestion will be benchmark for me.
>>
>
> There's nothing wrong with being a beginner. I'm a beginner too, both with
> GAs in general and with GALib. Let me point out a few things that I noticed
> about your code.
>
>
> First off, you have the following line of code in your program:
>
>
>> ga.minimize();
>>
>
> What do you suppose this line of code does? Compare that with what you want
> to accomplish.
>
>
>
> Secondly, look at your objective function:
>
>
>> GABin2DecPhenotype map;
>> map.add(16, -3, -2);
>> map.add(16, -3, -2);
>>
>> ...
>>
>> float
>> objective(GAGenome & c)
>> {
>> GABin2DecGenome & genome = (GABin2DecGenome &)c;
>> float y=6.0;
>> y += genome.phenotype(0) * genome.phenotype(0);
>> y += 5 * genome.phenotype(0);
>> return y;
>> }
>>
>
> You have two genes in your genome.
>
> Your objective function is a function of only one variable. It says a whole
> lot about genome.phenotype(0). What does it have to say about
> genome.phenotype(1)? GALib knows how fit phenotype(0) is because
> objective() returns a fitness score that's a function of phenotype(0).
>
> But the objective is not a function of phenotype(1). How does GALib know
> how fit phenotype(1) is?
>
>
> Thirdly, look at the "roots" that GALib is giving to you. You have two
> numbers (note: increase the number of generations to see the "root values"
> more clearly.) Now focus on the meaning of this:
>
>
>> ga.minimize();
>>
>
> Notice anything? If so, you've just discovered what genome.phenotype(0)
> really is. Now the question is, what is genome.phenotype(1)?
>
> To find out what phenotype(1) is, turn your mutation and crossover
> probabilities way, way down to almost zero. Take a look at what the
> starting values are for your two genes, before you evolve the system. Now
> evolve the system and look at the final values.
>
> You should be able to guess what genome.phenotype(1) is from this.
>
>
> Lastly, you set your gene value boundaries to fall exactly on the two
> numbers you were expecting GALib to find. I don't really know much about
> GAs myself, but I wonder if that's a good strategy. It could be. But until
> I learned a bit more about GAs, I'd probably put the expected values on the
> "inside" of the search domain, not on its boundary.
>
> Weird things can happen on boundaries.
>
>
> Again, I'm new to all this too, so perhaps all this is wrong, so take
> everything I say with a grain of salt.
>
> Pete
>
>
More information about the galib
mailing list