JGAP

examples.distinctGenes
Class SampleFitnessFunction

java.lang.Object
  extended by org.jgap.FitnessFunction
      extended by examples.distinctGenes.SampleFitnessFunction
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ICloneable

public class SampleFitnessFunction
extends FitnessFunction

Fitness function for our example. It's without sense, it's just to demonstrate how to evaluate a chromosome with 40 4-field-genes and one 3-field gene. Each toplevel-gene is a CompositeGene, each "field" within a CompositeGene is a BooleanGene here (arbitrarily chosen).

Since:
3.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jgap.FitnessFunction
DELTA, NO_FITNESS_VALUE
 
Constructor Summary
SampleFitnessFunction()
           
 
Method Summary
 double evaluate(IChromosome a_subject)
          Calculate the fitness value of a Chromosome.
 
Methods inherited from class org.jgap.FitnessFunction
clone, getFitnessValue, getLastComputedFitnessValue
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampleFitnessFunction

public SampleFitnessFunction()
Method Detail

evaluate

public double evaluate(IChromosome a_subject)
Calculate the fitness value of a Chromosome.

Specified by:
evaluate in class FitnessFunction
Parameters:
a_subject - the Chromosome to be evaluated
Returns:
defect rate of our problem (the smaller the better)
Since:
3.0

JGAP