[galib] put bestIndividual into a variable
"Łukasz Kuczkowski"
lkuczkowski at ely.pg.gda.pl
Tue Jul 31 04:16:27 EDT 2012
Hi Alin,
you have to use a score method. You simply write:
float test = ga.statistic().bestIndividual().score();
If you want to use a value of gene then:
ga.statistic().bestIndividual().gene(0);
All the answers are in documentation and examples (in this case in ex 21 &
23 where the GARealGenome was used).
I hope that my answer helped. Wish a fun with GALib!
Regards
Lukasz Kuczkowski, PhD. student
Gdansk University of Technology
Faculty of Electrical and Control Engineering
G.Narutowicza 11/12 street
80-233 Gdansk, Poland
>
> Hello everyone,
> I am fairly new to GAlib and I was wondering if you could help me with
> something.
> I created a GARealGenome:
> GARealAlleleSet alleles(MIN_VALUE, MAX_VALUE); GARealGenome
> genome(1, alleles, Objective); GASimpleGA ga(genome);
> After the GA has finished I would like to further work with the best
> individual.I can print it out with the following command: cout <<
> ga.statistics().bestIndividual();
>
> My question is the following : How can I assign the value to a
> variable for example a double (each individual has just a value which is a
> real). I tried to do something like this: double test =
> ga.statistics().bestIndividual(); (this obviously doesn't work since
> the type ga.statistics().bestIndividual() is const GAGenome&
> bestIndividual(unsigned int n=0) const )
>
> Can you please tell me how I can get the value from
> ga.statistics().bestIndividual() into a double variable.
> Thanks,Alin
> _______________________________________________
> galib mailing list
> galib at mit.edu
> http://mailman.mit.edu/mailman/listinfo/galib
>
More information about the galib
mailing list