[galib] How to define a population based objective function?
Christian Samuel Perone
christian_perone at yahoo.com.br
Wed Sep 28 09:49:40 EDT 2005
Hello,
You can define the Objective function first
declaring the function like this:
float Objective(GAGenome& g) {
GA2DBinaryStringGenome & genome =
(GA2DBinaryStringGenome &)g;
float score=0.0;
int count=0;
for(int i=0; i<genome.width(); i++){
for(int j=0; j<genome.height(); j++){
if(genome.gene(i,j) == 0 && count%2 == 0)
score += 1.0;
if(genome.gene(i,j) == 1 && count%2 != 0)
score += 1.0;
count++;
}
}
return score;
}
then in the declaration of the genome you
define like this:
GA2DBinaryStringGenome genome(width, height,
objective);
Read the ex1.C in the examples directory of default
galib package.
I hope this help you.
- Christian S. Perone
--- RPrasad <raghavendraprasad.nl at gmail.com> escreveu:
> Hello friends,
> I am working on a research project.
> I have a genome type GA2DBinaryStringGenome
> genome(1, n); //Specific reason
> to use this kind of genome
> For n=5, each genome will look like this
> 1
> 0
> 0
> 1
> 1
> GASteadyStateGA ga(genome); // creating genetic
> algorithm object
> ga.populationSize(5); // I want to invoke the
> population based objective
> function at this point
> Now the population will look something like this
> 10101
> 01101
> 01001
> 10110
> 00110
> Now I want to define a objective function for this
> population. How to
> create a population-based objective function?
> Please send me any code that might give a insight
> into this.
> Thanks N Regards
> Raghavendra Prasad NL
> RaghavendraPrasad.NL at gmail.com
> > _______________________________________________
> galib mailing list
> galib at mit.edu
> http://mailman.mit.edu/mailman/listinfo/galib
>
_______________________________________________________
Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e muito mais. Instale agora!
www.yahoo.com.br/messenger/
More information about the galib
mailing list