Subject: | |
From: | |
Reply To: | |
Date: | Tue, 28 Nov 2006 17:50:23 +0000 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Hi,
I am working on a problem where I would like to compare two
individuals according to one fitness function (if one beats the other
then it is promoted to the next generation).
However, it is possible that two individuals have the same fitness, so
to differentiate them I call on a second fitness function.
Something like this
ind choice(ind ind1, ind ind2) {
if(ind1.fitness == ind2.fitness)//if they are equal
return choice2(ind1, ind2)//call on the second fitness function
else
if(ind1.fitness < ind2.fitness)
return ind1
else
return ind2
}
ind choice2(ind ind1, ind ind2) {
if(ind1.fitness2 < ind2.fitness2)
//fitness2 is the fitness according to the second
fitness function
return ind1
else
return ind2
}
--
Thanks,
John Woodward.
|
|
|