ECJ-INTEREST-L Archives

November 2006

ECJ-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
ECJ Evolutionary Computation Toolkit <[log in to unmask]>
Date:
Tue, 28 Nov 2006 14:15:44 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (45 lines)
Sure, there are lots of ways. The easiest and perhaps best:

If you're using tournament selection, then it's a piece of cake.   
Just subclass your Fitness function to (a) store both fitness  
elements inside it and (b) override the equivalentTo and betterThan  
methods to do a lexicographic ordering between the two fitness elements.

Sean

On Nov 28, 2006, at 12:50 PM, John Woodward wrote:

> 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.

ATOM RSS1 RSS2