examples
Class MinimizingFitnessFunctionCached
java.lang.Object
org.jgap.FitnessFunction
org.jgap.CachedFitnessFunction
examples.MinimizingFitnessFunctionCached
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, ICloneable
public class MinimizingFitnessFunctionCached
- extends CachedFitnessFunction
For any Javadoc see MinimizingMakeChangeFitnessFunction.
Additionally, this fitness function is cached.
- Since:
- 3.2
- See Also:
- Serialized Form
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
MinimizingFitnessFunctionCached
public MinimizingFitnessFunctionCached(int a_targetAmount)
evaluate
public double evaluate(IChromosome a_subject)
- Description copied from class:
FitnessFunction
- 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:
- positive double reflecting the fitness rating of the given
Chromosome. Note that if a non-positive double is returned, a
RuntimeException should be generated
changeDifferenceBonus
protected double changeDifferenceBonus(double a_maxFitness,
int a_changeDifference)
computeCoinNumberPenalty
protected double computeCoinNumberPenalty(double a_maxFitness,
int a_coins)
amountOfChange
public static int amountOfChange(IChromosome a_potentialSolution)
getNumberOfCoinsAtGene
public static int getNumberOfCoinsAtGene(IChromosome a_potentialSolution,
int a_position)
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:
- total number of coins represented by the given Chromosome
- Since:
- 1.0