|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jgap.FitnessFunction
examples.knapsack.KnapsackFitnessFunction
public class KnapsackFitnessFunction
Fitness function for the knapsack example.
| Field Summary | |
|---|---|
static double |
MAX_BOUND
|
| Fields inherited from class org.jgap.FitnessFunction |
|---|
DELTA, NO_FITNESS_VALUE |
| Constructor Summary | |
|---|---|
KnapsackFitnessFunction(double a_knapsackVolume)
|
|
| Method Summary | |
|---|---|
protected double |
computeItemNumberPenalty(double a_maxFitness,
int a_items)
Calculates the penalty to apply to the fitness value based on the amount of items in the solution. |
double |
evaluate(IChromosome a_subject)
Determine the fitness of the given Chromosome instance. |
static int |
getNumberOfItemsAtGene(IChromosome a_potentialSolution,
int a_position)
Retrieves the number of items represented by the given potential solution at the given gene position. |
static int |
getTotalNumberOfItems(IChromosome a_potentialSolution)
Returns the total number of items represented by all of the genes in the given potential solution. |
static double |
getTotalVolume(IChromosome a_potentialSolution)
Calculates the total amount of change (in cents) represented by the given potential solution and returns that amount. |
protected double |
volumeDifferenceBonus(double a_maxFitness,
double a_volumeDifference)
Bonus calculation of fitness value. |
| 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 double MAX_BOUND
| Constructor Detail |
|---|
public KnapsackFitnessFunction(double a_knapsackVolume)
| Method Detail |
|---|
public double evaluate(IChromosome a_subject)
evaluate in class FitnessFunctiona_subject - the Chromosome instance to evaluate
protected double volumeDifferenceBonus(double a_maxFitness,
double a_volumeDifference)
a_maxFitness - maximum fitness value appliablea_volumeDifference - volume difference in ccm for the items problem
protected double computeItemNumberPenalty(double a_maxFitness,
int a_items)
a_maxFitness - upper boundary for fitness value possiblea_items - number of items in the solution
public static double getTotalVolume(IChromosome a_potentialSolution)
a_potentialSolution - the potential solution to evaluate
public static int getNumberOfItemsAtGene(IChromosome a_potentialSolution,
int a_position)
a_potentialSolution - the potential solution to evaluatea_position - the gene position to evaluate
public static int getTotalNumberOfItems(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 | ||||||||