|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jgap.FitnessFunction
examples.energy.CoinsEnergyFitnessFunction
public class CoinsEnergyFitnessFunction
Sample fitness function for the CoinsEnergy example. Adapted from examples.MinimizingMakeChangeFitnessFunction
| Field Summary | |
|---|---|
static int |
MAX_BOUND
|
static double |
MAX_WEIGHT
|
| Fields inherited from class org.jgap.FitnessFunction |
|---|
DELTA, NO_FITNESS_VALUE |
| Constructor Summary | |
|---|---|
CoinsEnergyFitnessFunction(int a_targetAmount,
double a_maxWeight)
|
|
| 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 |
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 |
protected double |
computeWeightPenalty(double a_maxFitness,
double a_weight)
|
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. |
static double |
getTotalWeight(IChromosome a_potentialSolution)
Returns the total weight of all coins. |
| 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
public static final double MAX_WEIGHT
| Constructor Detail |
|---|
public CoinsEnergyFitnessFunction(int a_targetAmount,
double a_maxWeight)
| Method Detail |
|---|
public double evaluate(IChromosome a_subject)
evaluate in class FitnessFunctiona_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 int 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
public static double getTotalWeight(IChromosome a_potentialSolution)
a_potentialSolution - the potential solution to evaluate
protected double computeWeightPenalty(double a_maxFitness,
double a_weight)
a_maxFitness - the maximum fitness value alloweda_weight - the coins weight of the current solution
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||