<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>I want to make an optimization problem to solve a quadratic equation (y=X*X+5*X+6).</DIV>
<DIV>I designed a program but it's showing some non desired result. I'm beginner in GA please tell me what I have to do. Is the following progam is right?</DIV>
<DIV> </DIV>
<DIV>Somnath.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>#include <stdio.h><BR>#include <ga/ga.h><BR>#include <ga/std_stream.h></DIV>
<DIV>#define cout STD_COUT</DIV>
<DIV>float objective(GAGenome &);</DIV>
<DIV>int<BR>main(int argc, char **argv)<BR>{<BR> cout << "This program finds the minimum value in the function\n";<BR> cout << " y=x*x + 5*x + 6 ";<BR> cout << "with the constraints\n";<BR> cout << " -3 <= x <= -2\n";<BR> cout << "\n\n"; cout.flush();</DIV>
<DIV> unsigned int seed = 0;<BR> for(int i=1; i<argc; i++) {<BR> if(strcmp(argv[i++],"seed") == 0) {<BR> seed = atoi(argv[i]);<BR> }<BR> }</DIV>
<DIV> int popsize = 30;<BR> int ngen = 100;<BR> float pmut = 0.01;<BR> float pcross = 0.6;</DIV>
<DIV> GABin2DecPhenotype map;<BR> map.add(16, -3, -2);<BR> map.add(16, -3, -2);</DIV>
<DIV> <BR> GABin2DecGenome genome(map, objective);</DIV>
<DIV> GASimpleGA ga(genome);<BR> GASigmaTruncationScaling scaling;<BR> ga.minimize();<BR> ga.populationSize(popsize);<BR> ga.nGenerations(ngen);<BR> ga.pMutation(pmut);<BR> ga.pCrossover(pcross);<BR> ga.scaling(scaling);<BR> ga.scoreFilename("bog.dat");<BR> ga.scoreFrequency(10);<BR> ga.flushFrequency(50);<BR> ga.evolve(seed);</DIV>
<DIV> genome = ga.statistics().bestIndividual();<BR> cout << "the ga found an optimum at the point (";<BR> cout << genome.phenotype(0) << ", " << genome.phenotype(1) << ")\n\n";</DIV>
<DIV> return 0;<BR>}<BR> </DIV>
<DIV>float<BR>objective(GAGenome & c)<BR>{<BR> GABin2DecGenome & genome = (GABin2DecGenome &)c;</DIV>
<DIV> float y;<BR> y = genome.phenotype(0) * genome.phenotype(0) + 5 * genome.phenotype(0) + 6;<BR> return y;<BR>}<BR></DIV></div><br>
<!--1--><hr size=1></hr> Why delete messages? Unlimited storage is <a href="http://in.rd.yahoo.com/tagline_mail_1/*http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/">just a click away.</a></body></html>