public class SimpleFitness extends Fitness
Some kinds of selection methods require a more stringent definition of fitness. For example, FitProportionateSelection requires that fitnesses be non-negative (since it must place them into a proportionate distribution). You may wish to restrict yourself to values in [0,1] or [0,infinity) in such cases.
Default Base
simple.fitness
| Modifier and Type | Field and Description |
|---|---|
private double |
fitness |
protected boolean |
isIdeal |
context, FITNESS_PREAMBLE, P_FITNESS, trials| Constructor and Description |
|---|
SimpleFitness() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
betterThan(Fitness _fitness)
Should return true if this fitness is clearly better than _fitness;
You may assume that _fitness is of the same class as yourself.
|
Parameter |
defaultBase()
Returns the default base for this prototype.
|
boolean |
equivalentTo(Fitness _fitness)
Should return true if this fitness is in the same equivalence class
as _fitness, that is, neither is clearly better or worse than the
other.
|
double |
fitness()
Should return an absolute fitness value ranging from negative
infinity to infinity, NOT inclusive (thus infinity, negative
infinity, and NaN are NOT valid fitness values).
|
String |
fitnessToString()
Print to a string the fitness in a fashion intended
to be parsed in again via readFitness(...).
|
String |
fitnessToStringForHumans()
Print to a string the fitness in a fashion readable by humans, and not intended
to be parsed in again.
|
boolean |
isIdealFitness()
Should return true if this is a good enough fitness to end the run
|
void |
readFitness(EvolutionState state,
DataInput dataInput)
Reads the binary form of an individual from a DataInput.
|
void |
readFitness(EvolutionState state,
LineNumberReader reader)
Presently does not decode the fact that the fitness is ideal or not
|
void |
setFitness(EvolutionState state,
double _f)
Deprecated.
|
void |
setFitness(EvolutionState state,
double _f,
boolean _isIdeal) |
void |
setToMeanOf(EvolutionState state,
Fitness[] fitnesses)
Sets the fitness to be the same value as the mean of the provided fitnesses.
|
void |
setup(EvolutionState state,
Parameter base)
Sets up the object by reading it from the parameters stored
in state, built off of the parameter base base.
|
void |
writeFitness(EvolutionState state,
DataOutput dataOutput)
Writes the binary form of an individual out to a DataOutput.
|
clone, compareTo, contextIsBetterThan, getContext, merge, printFitness, printFitness, printFitness, printFitnessForHumans, printFitnessForHumans, readTrials, setContext, setContext, setToBestOf, setToMedianOf, writeTrialspublic Parameter defaultBase()
Prototypepublic void setFitness(EvolutionState state, double _f)
public void setFitness(EvolutionState state, double _f, boolean _isIdeal)
public double fitness()
FitnessYou are free to restrict this range any way you like: for example, your fitness values might fall in the range [-5.32, 2.3]
Selection methods relying on fitness proportionate information will assume the fitness is non-negative and should throw an error if it is not. Thus if you plan on using FitProportionateSelection, BestSelection, or GreedyOverselection, for example, your fitnesses should assume that 0 is the worst fitness and positive fitness are better. If you're using other selection methods (Tournament selection, various ES selection procedures, etc.) your fitness values can be anything.
Similarly, if you're writing a selection method and it needs positive fitnesses, you should check for negative values and issue an error; and if your selection method doesn't need an absolute fitness value, it should use the equivalentTo() and betterThan() methods instead.
If your fitness scheme does not use a metric quantifiable to a single positive value (for example, MultiObjectiveFitness), you should perform some reasonable translation.
public void setup(EvolutionState state, Parameter base)
PrototypeFor prototypes, setup(...) is typically called once for the prototype instance; cloned instances do not receive the setup(...) call. setup(...) may be called more than once; the only guarantee is that it will get called at least once on an instance or some "parent" object from which it was ultimately cloned.
public boolean isIdealFitness()
FitnessisIdealFitness in class Fitnesspublic boolean equivalentTo(Fitness _fitness)
FitnessequivalentTo in class Fitnesspublic boolean betterThan(Fitness _fitness)
FitnessbetterThan in class Fitnesspublic String fitnessToString()
FitnessfitnessToString in class Fitnesspublic String fitnessToStringForHumans()
FitnessfitnessToStringForHumans in class Fitnesspublic void readFitness(EvolutionState state, LineNumberReader reader) throws IOException
readFitness in class FitnessIOExceptionpublic void writeFitness(EvolutionState state, DataOutput dataOutput) throws IOException
FitnesswriteFitness in class FitnessIOExceptionpublic void readFitness(EvolutionState state, DataInput dataInput) throws IOException
FitnessreadFitness in class FitnessIOExceptionpublic void setToMeanOf(EvolutionState state, Fitness[] fitnesses)
FitnesssetToMeanOf in class FitnessCopyright © 2014 Evolutionary Computation Laboratory at George Mason University. All rights reserved.