examples.audit
Class CoinsExampleFitnessFunction
java.lang.Object
org.jgap.FitnessFunction
examples.audit.CoinsExampleFitnessFunction
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, ICloneable
public class CoinsExampleFitnessFunction
- extends FitnessFunction
Sample fitness function for the coins example.
- Since:
- 2.2
- See Also:
- Serialized Form
Method Summary |
static int |
amountOfChange(IChromosome a_potentialSolution)
Calculates the total amount of change (in cents) represented by
the given potential solution and returns that amount. |
protected double |
computeCoinNumberBonus(int a_coins)
|
double |
evaluate(IChromosome a_subject)
Determine the fitness of the given Chromosome instance. |
static int |
getNumberOfCoinsAtGene(IChromosome a_potentialSolution,
int a_position)
Retrieves the number of coins represented by the given potential
solution at the given gene position. |
static int |
getTotalNumberOfCoins(IChromosome a_potentialsolution)
Returns the total number of coins represented by all of the genes in
the given potential solution. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MAX_BOUND
public static final int MAX_BOUND
- See Also:
- Constant Field Values
CoinsExampleFitnessFunction
public CoinsExampleFitnessFunction(int a_targetAmount)
evaluate
public double evaluate(IChromosome a_subject)
- Determine the fitness of the given Chromosome instance. The higher the
return value, the more fit the instance. This method should always
return the same fitness value for two equivalent Chromosome instances.
- Specified by:
evaluate
in class FitnessFunction
- Parameters:
a_subject
- the Chromosome instance to evaluate
- Returns:
- a positive integer reflecting the fitness rating of the given
Chromosome
- Since:
- 2.2
computeCoinNumberBonus
protected double computeCoinNumberBonus(int a_coins)
amountOfChange
public static int amountOfChange(IChromosome a_potentialSolution)
- Calculates the total amount of change (in cents) represented by
the given potential solution and returns that amount.
- Parameters:
a_potentialSolution
- the pontential solution to evaluate
- Returns:
- the total amount of change (in cents) represented by the
given solution
- Since:
- 2.2
getNumberOfCoinsAtGene
public static int getNumberOfCoinsAtGene(IChromosome a_potentialSolution,
int a_position)
- Retrieves the number of coins represented by the given potential
solution at the given gene position.
- Parameters:
a_potentialSolution
- the potential solution to evaluatea_position
- the gene position to evaluate
- Returns:
- the number of coins represented by the potential solution
at the given gene position.
- Since:
- 2.2
getTotalNumberOfCoins
public static int getTotalNumberOfCoins(IChromosome a_potentialsolution)
- Returns the total number of coins represented by all of the genes in
the given potential solution.
- Parameters:
a_potentialsolution
- The potential solution to evaluate.
- Returns:
- The total number of coins represented by the given Chromosome.
- Since:
- 2.2