ec
Interface Fitness

All Superinterfaces:
java.lang.Cloneable, Prototype, java.io.Serializable, Setup
All Known Implementing Classes:
KozaFitness, SimpleFitness, MultiObjectiveFitness, SPEA2MultiObjectiveFitness

public interface Fitness
extends Prototype

Fitness is a prototype which describes the fitness of an individual. Every individual contains exactly one Fitness object. Fitness objects are compared to each other with the equivalentTo() and betterThan(), etc. methods.

Rules:
comparisonmethod
a > ba.betterThan(b)
a >= ba.betterThan(b) || a.equivalentTo(b)
a = ba.equivalentTo(b)
This applies even to multiobjective pareto-style dominance, eg:

Parameter bases
fit default fitness base


Field Summary
static java.lang.String P_FITNESS
           
 
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.
 boolean equivalentTo(Fitness _fitness)
          Should return true if this fitness is in the same equivalence class as _fitness, that is, neither is clearly bettter or worse than the other.
 float fitness()
          Should return an absolute fitness value in the half-open range [0.0,infinity), where 0.0 is <= the worst possible value, and inifity is > the ideal fitness.
 boolean isIdealFitness()
          Should return true if this is a good enough fitness to end the run
 void printFitness(EvolutionState state, int log, int verbosity)
          Should print the fitness out in a computer-readable fashion, using state.output.println(...,verbosity,log).
 void printFitness(EvolutionState state, java.io.PrintWriter writer)
          Should print the fitness out in a computer-readable fashion, using state.output.println(...,verbosity,log).
 void printFitnessForHumans(EvolutionState state, int log, int verbosity)
          Should print the fitness out in a pleasing way to humans, using state.output.println(...,verbosity,log)
 void readFitness(EvolutionState state, java.io.LineNumberReader reader)
          Reads in the fitness from a form printed by printFitness().
 
Methods inherited from interface ec.Prototype
defaultBase, protoClone, protoCloneSimple, setup
 

Field Detail

P_FITNESS

public static final java.lang.String P_FITNESS
Method Detail

fitness

public float fitness()
Should return an absolute fitness value in the half-open range [0.0,infinity), where 0.0 is <= the worst possible value, and inifity is > the ideal fitness. You don't need to have your fitness values go all the way up to infinity -- doing them in the range [0.0,1.0], for example, is just fine.

This function should be used only by fitness-proportionate selection and other selection methods which require an absolute fitness value. All other approaches should use the equivalentTo() and betterThan() methods.

If your fitness scheme does not use a metric quantifiable to a single value (for example, MultiObjectiveFitness), you should perform some reasonable translation.


isIdealFitness

public boolean isIdealFitness()
Should return true if this is a good enough fitness to end the run

equivalentTo

public boolean equivalentTo(Fitness _fitness)
Should return true if this fitness is in the same equivalence class as _fitness, that is, neither is clearly bettter or worse than the other. You may assume that _fitness is of the same class as yourself. worseThan(), equivalentTo() and betterThan() should be disjoint sets.

betterThan

public 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. worseThan(), equivalentTo() and betterThan() should be disjoint sets.

printFitnessForHumans

public void printFitnessForHumans(EvolutionState state,
                                  int log,
                                  int verbosity)
Should print the fitness out in a pleasing way to humans, using state.output.println(...,verbosity,log)

printFitness

public void printFitness(EvolutionState state,
                         int log,
                         int verbosity)
Should print the fitness out in a computer-readable fashion, using state.output.println(...,verbosity,log). You should use ec.util.Code to encode fitness values.

printFitness

public void printFitness(EvolutionState state,
                         java.io.PrintWriter writer)
Should print the fitness out in a computer-readable fashion, using state.output.println(...,verbosity,log). You should use ec.util.Code to encode fitness values. Usually you should try to use printFitness(state,log,verbosity) instead -- use this method only if you can't print through the Output facility for some reason.

readFitness

public void readFitness(EvolutionState state,
                        java.io.LineNumberReader reader)
                 throws java.io.IOException,
                        java.lang.CloneNotSupportedException
Reads in the fitness from a form printed by printFitness().