|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectec.Fitness
ec.simple.SimpleFitness
public class SimpleFitness
A simple default fitness, consisting of a single floating-point value where fitness A is superior to fitness B if and only if A > B. Fitness values may range from (-infinity,infinity) exclusive -- that is, you may not have infinite fitnesses.
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
Field Summary | |
---|---|
protected float |
fitness
|
protected boolean |
isIdeal
|
Fields inherited from class ec.Fitness |
---|
FITNESS_PREAMBLE, P_FITNESS, trials |
Constructor Summary | |
---|---|
SimpleFitness()
|
Method Summary | |
---|---|
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. |
float |
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). |
java.lang.String |
fitnessToString()
Print to a string the fitness in a fashion intended to be parsed in again via readFitness(...). |
java.lang.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,
java.io.DataInput dataInput)
Reads the binary form of an individual from a DataInput. |
void |
readFitness(EvolutionState state,
java.io.LineNumberReader reader)
Presently does not decode the fact that the fitness is ideal or not |
void |
setFitness(EvolutionState state,
float _f)
Deprecated. |
void |
setFitness(EvolutionState state,
float _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,
java.io.DataOutput dataOutput)
Writes the binary form of an individual out to a DataOutput. |
Methods inherited from class ec.Fitness |
---|
clone, compareTo, printFitness, printFitness, printFitness, printFitnessForHumans, printFitnessForHumans |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected float fitness
protected boolean isIdeal
Constructor Detail |
---|
public SimpleFitness()
Method Detail |
---|
public Parameter defaultBase()
Prototype
public void setFitness(EvolutionState state, float _f)
public void setFitness(EvolutionState state, float _f, boolean _isIdeal)
public float fitness()
Fitness
You 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.
fitness
in class Fitness
public void setup(EvolutionState state, Parameter base)
Prototype
For 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.
setup
in interface Prototype
setup
in interface Setup
setup
in class Fitness
public boolean isIdealFitness()
Fitness
isIdealFitness
in class Fitness
public boolean equivalentTo(Fitness _fitness)
Fitness
equivalentTo
in class Fitness
public boolean betterThan(Fitness _fitness)
Fitness
betterThan
in class Fitness
public java.lang.String fitnessToString()
Fitness
fitnessToString
in class Fitness
public java.lang.String fitnessToStringForHumans()
Fitness
fitnessToStringForHumans
in class Fitness
public void readFitness(EvolutionState state, java.io.LineNumberReader reader) throws java.io.IOException
readFitness
in class Fitness
java.io.IOException
public void writeFitness(EvolutionState state, java.io.DataOutput dataOutput) throws java.io.IOException
Fitness
writeFitness
in class Fitness
java.io.IOException
public void readFitness(EvolutionState state, java.io.DataInput dataInput) throws java.io.IOException
Fitness
readFitness
in class Fitness
java.io.IOException
public void setToMeanOf(EvolutionState state, Fitness[] fitnesses)
Fitness
setToMeanOf
in class Fitness
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |