<DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">Hallo </SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp;I have little experience with C++. I have the problem of integrating the GA in a part of a program that does GA and other things. Taking ex9 as acase study I have derived a function called getvalue and within this function. This I call this function in my program.as seen at the end this massage. In this sollution I have ignored the argc and argv and this part. The sollution seems to be OK.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">for(int ii=1; ii<BR><ARGC; ii++) {>if(strcmp(argv[ii++],"seed") == 0) {<BR>seed = atoi(argv[ii]);<BR>}<BR>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">What should I do for not ignoring them.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">Thank you in advance<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">float objective(GAGenome &amp;);<BR>int getvalue();<BR>int main()<BR>{<BR>&nbsp;getvalue();</SPAN></P><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB"></SPAN></DIV>
<DIV><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// here are the other parts of the program
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%">//</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%">//</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%">//<BR>&nbsp;return 0;<BR>}<BR>int getvalue()<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">{<BR>&nbsp; cout &lt;&lt; "Example 9\n\n";<BR>&nbsp; cout &lt;&lt; "This program finds the maximum value in the function\n";<BR>&nbsp; cout &lt;&lt; "&nbsp; y = - x1^2 - x2^2\n";<BR>&nbsp; cout &lt;&lt; "with the constraints\n";<BR>&nbsp; cout &lt;&lt; "&nbsp;&nbsp;&nbsp;&nbsp; -5 &lt;= x1 &lt;= 5\n";<BR>&nbsp; cout &lt;&lt; "&nbsp;&nbsp;&nbsp;&nbsp; -5 &lt;= x2 &lt;= 5\n";<BR>&nbsp; cout &lt;&lt; "\n\n"; cout.flush();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// See if we've been given a seed to use (for testing purposes).&nbsp; When you<BR>// specify a random seed, the evolution will be exactly the same each time<BR>// you use that seed number.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp; unsigned int seed = 0;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Declare variables for the GA parameters and set them to some default values.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp; int popsize&nbsp; = 30;<BR>&nbsp; int ngen&nbsp;&nbsp;&nbsp;&nbsp; = 100;<BR>&nbsp; float pmut&nbsp;&nbsp; = 0.01;<BR>&nbsp; float pcross = 0.6;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Create a phenotype for two variables.&nbsp; The number of bits you can use to<BR>// represent any number is limited by the type of computer you are using.&nbsp; In<BR>// this case, we use 16 bits to represent a floating point number whose value<BR>// can range from -5 to 5, inclusive.&nbsp; The bounds on x1 and x2 can be applied<BR>// here and/or in the objective function.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp; GABin2DecPhenotype map;<BR>&nbsp; map.add(16, -5, 5);<BR>&nbsp; map.add(16, -5, 5);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Create the template genome using the phenotype map we just made.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp; GABin2DecGenome genome(map, objective);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Now create the GA using the genome and run it.&nbsp; We'll use sigma truncation<BR>// scaling so that we can handle negative objective scores.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp; </SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial">GASimpleGA ga(genome);<BR>&nbsp; GASigmaTruncationScaling scaling;<BR>&nbsp; ga.populationSize(popsize);<BR>&nbsp; ga.nGenerations(ngen);<BR>&nbsp; ga.pMutation(pmut);<BR>&nbsp; ga.pCrossover(pcross);<BR>&nbsp; ga.scaling(scaling);<BR>&nbsp; ga.scoreFilename("bog.dat");<BR>&nbsp; ga.scoreFrequency(10);<BR>&nbsp; ga.flushFrequency(50);<BR>&nbsp; ga.evolve(seed);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// Dump the results of the GA to the screen.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp; genome = ga.statistics().bestIndividual();<BR>&nbsp; cout &lt;&lt; "the ga found an optimum at the point (";<BR>&nbsp; cout &lt;&lt; genome.phenotype(0) &lt;&lt; ", " &lt;&lt; genome.phenotype(1) &lt;&lt; ")\n\n";<BR>&nbsp; cout &lt;&lt; "best of generation data are in '" &lt;&lt; ga.scoreFilename() &lt;&lt; "'\n";<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp; return 0;<BR>}<BR>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">// This objective function tries to maximize the value of the function<BR>//<BR>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y = -(x1*x1 + x2*x2)<BR>//<BR>float<BR>objective(GAGenome &amp; c)<BR>{<BR>&nbsp; GABin2DecGenome &amp; genome = (GABin2DecGenome &amp;)c;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 12pt; LINE-HEIGHT: 121%"><SPAN lang=EN-GB style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 121%; FONT-FAMILY: Arial; mso-ansi-language: EN-GB">&nbsp; float y;<BR>&nbsp; y = -genome.phenotype(0) * genome.phenotype(0);<BR>&nbsp; y -= genome.phenotype(1) * genome.phenotype(1);<BR>&nbsp; return y;<BR>}<o:p></o:p></SPAN></P></DIV><p>
                <hr size=1>Do you Yahoo!?<br> 
The <a href="http://my.yahoo.com">all-new My Yahoo!</a> – What will yours do?