A fitness measure class is responsible for two tasks.
It firstly provides a way of tracking the fitness of some entity (e.g. an individual program) and thus is a member of the IProgram
class. The methods implemented in the abstract base class IFitnessMeasure
all treat a lower fitness as better and a fitness of 0 as best.
Secondly, an instance of IFitnessMeasure is also responsible for calculating by how much a program's fitness should be increased based on its response to some IFitnessCase
. This is another place the error-based or lower-is-fitter assumption manifests itself. This functionality is represented by the UpdateError
method, which must be implemented by some subclass.
How this method will work in detail depends on the type of problem the subclass of IFitnessMeasure
is designed to be used with, however the general overall structure of an implementation of this method is as follows:
fc
to the expected type of fitness case.IFitnessCase fc
subclass, the final register values of the program (stored in fRV
) and the methods of this subclass of IFitnessMeasure
to update the stored fitness measure in this.
Because different measures of fitness will store different extra data in addition to the base measure of overall fitness (a single double) the conversion of a fitness measure to a string representation will be different for each class. Thus each subclass of IFitnessMeasure
needs to implement its own ToString
method, which will print out a raw string representation of the fitness of this fitness measure (i.e. by "raw string" we mean not prefixed by any // or other comment indicator, as this should be prepended as needed by the caller).
Christopher Fogelberg
fogelbchri@mcs.vuw.ac.nz or cgf.unimail@syntilect.com