|
JGAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgap.FitnessFunction
examples.constraint.SampleFitnessFunction
public class SampleFitnessFunction
Sample fitness function for the MakeChange example.
Field Summary | |
---|---|
static int |
MAX_BOUND
|
Fields inherited from class org.jgap.FitnessFunction |
---|
DELTA, NO_FITNESS_VALUE |
Constructor Summary | |
---|---|
SampleFitnessFunction(int a_targetAmount)
|
Method Summary | |
---|---|
static double |
amountOfChange(IChromosome a_potentialSolution)
Calculates the total amount of change (in cents) represented by the given potential solution and returns that amount. |
protected double |
changeDifferenceBonus(double a_maxFitness,
int a_changeDifference)
Bonus calculation of fitness value. |
protected double |
computeCoinNumberPenalty(double a_maxFitness,
int a_coins)
Calculates the penalty to apply to the fitness value based on the ammount of coins in the solution |
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 org.jgap.FitnessFunction |
---|
clone, getFitnessValue, getLastComputedFitnessValue |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_BOUND
Constructor Detail |
---|
public SampleFitnessFunction(int a_targetAmount)
Method Detail |
---|
public double evaluate(IChromosome a_subject)
evaluate
in class FitnessFunction
a_subject
- the Chromosome instance to evaluate
protected double changeDifferenceBonus(double a_maxFitness, int a_changeDifference)
a_maxFitness
- maximum fitness value appliablea_changeDifference
- change difference in coins for the coins problem
protected double computeCoinNumberPenalty(double a_maxFitness, int a_coins)
a_maxFitness
- maximum fitness value alloweda_coins
- number of coins in the solution
public static double amountOfChange(IChromosome a_potentialSolution)
a_potentialSolution
- the potential solution to evaluate
public static int getNumberOfCoinsAtGene(IChromosome a_potentialSolution, int a_position)
a_potentialSolution
- the potential solution to evaluatea_position
- the gene position to evaluate
public static int getTotalNumberOfCoins(IChromosome a_potentialsolution)
a_potentialsolution
- the potential solution to evaluate
|
JGAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |