<DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<P>Unfortunately, it is not a quite simple problem. Since bestIndividual is of type GaGenome&amp; you could not access its value directly. I solved this problem by first printing the bestIndividual value to a file, then reading its value from that file and assigning it to a new variable.</P>
<P>One way is to use file stream operators as follows:</P>
<P>ofstream fout;</P>
<P>fout.open("bestInd.txt", ios::in);</P>
<P>if (!fout.fail()){</P>
<P>fout &lt;&lt; ga.statistics().bestIndividual() ;</P>
<P>fout.close();</P>
<P>}</P>
<P>ifstream fin;</P>
<P>fin.open("bestInd.txt", ios::out);</P>
<P>if (!fin.fail()){</P>
<P>float bestInd,</P>
<P>fin &gt;&gt; bestInd; // read the value from file and write it to bestInd</P>
<P>fin.close();</P>
<P>}</P>
<P>Hope this helps ...</P>
<P><BR>Today's Topics:<BR><BR>1. Obtain "bestIndividual()" value (Luca Moscatelli)<BR>2. Obtain "bestIndividual()" value (Luca Moscatelli)<BR><BR><BR>&gt; ATTACHMENT part 3.1 message/rfc822 <BR>Date: Tue, 2 Nov 2004 18:36:29 +0100<BR>From: Luca Moscatelli <LUCASTER@GMAIL.COM><BR>To: galib@mit.edu<BR>Subject: [galib] Obtain "bestIndividual()" value<BR><BR>Hi to all.<BR><BR>I'm new with this library and I have a simple problem (I hope it's<BR>simple... However, it is quite stupid :D).<BR><BR>I tried the first examples and they are all clear, but I saw that the<BR>best individual is only printed at the end of each program, but what<BR>have I to do if I want to use it?<BR><BR>I'll try to be more clear:<BR>I created a GARealAlleleSet, filled with some values and inserted into<BR>the GARealGenome, then I evolved it.<BR>If I print the best individual like in the examples with "cout &lt;&lt;<BR>ga.statistics().bestIndividual() I see the right value, but now I<BR>want, for example, t!
 o add 1
 to this value...<BR><BR>Now, I looked the documentation and I saw that the<BR>ga.statistics().bestIndividual() returns a GaGenome&amp;, how can the cout<BR>print it?<BR>And, how can I put this value(s) in a float variable(s)?<BR><BR>I hope that my problem is quite clear to you... :)<BR><BR>Thanks in advance to all of you!<BR>Bye,<BR>Luca<BR></P></BLOCKQUOTE></DIV><p>
        
                <hr size=1>Do you Yahoo!?<br> 
Check out the new Yahoo! Front Page. <a href="http://www.yahoo.com">www.yahoo.com</a>