ec.multiobjective
Class MultiObjectiveFitness

java.lang.Object
  extended by ec.Fitness
      extended by ec.multiobjective.MultiObjectiveFitness
All Implemented Interfaces:
Prototype, Setup, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
SPEA2MultiObjectiveFitness

public class MultiObjectiveFitness
extends Fitness

MultiObjectiveFitness is a subclass of Fitness which implements basic multi-objective mechanisms suitable for being used with a variety of multi-objective selection mechanisms, including ones using pareto-optimality.

The object contains two items: an array of floating point values representing the various multiple fitnesses (ranging from 0.0 (worst) to 1.0 inclusive). By default, isIdealFitness() always returns false; you'll probably want to override that [if appropriate to your problem].

Parameters

base.numobjectives
(else)multi.numobjectives
int >= 1
(the number of fitnesses in the multifitness array)
base.criterion-is-and
bool = true (default) or false
(is the ideal individual one whose fitness values are all 1.0 (as opposed to one which contains at least one fitness value of 1.0))

Default Base
multi.fitness

Version:
1.0
Author:
Sean Luke
See Also:
Serialized Form

Field Summary
static java.lang.String FITNESS_POSTAMBLE
           
 float[] multifitness
          The various fitnesses.
static java.lang.String P_NUMFITNESSES
          parameter for size of multifitness
 
Fields inherited from class ec.Fitness
FITNESS_PREAMBLE, P_FITNESS
 
Constructor Summary
MultiObjectiveFitness()
           
 
Method Summary
 boolean betterThan(Fitness _fitness)
          Returns true if I'm better than _fitness.
 java.lang.Object clone()
          Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context.
 Parameter defaultBase()
          Returns the default base for this prototype.
 boolean equivalentTo(Fitness _fitness)
          Returns true if I'm equivalent in fitness (neither better nor worse) to _fitness.
 float fitness()
          Returns the Max() of multifitnesses, which adheres to Fitness.java's protocol for this method.
 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()
          Returns true if this fitness is the "ideal" fitness.
 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)
          Reads in the fitness from a form outputted by fitnessToString() and thus printFitnessForHumans(...).
 void setup(EvolutionState state, Parameter base)
          Sets up.
 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
printFitness, printFitness, printFitnessForHumans
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FITNESS_POSTAMBLE

public static final java.lang.String FITNESS_POSTAMBLE
See Also:
Constant Field Values

P_NUMFITNESSES

public static final java.lang.String P_NUMFITNESSES
parameter for size of multifitness

See Also:
Constant Field Values

multifitness

public float[] multifitness
The various fitnesses.

Constructor Detail

MultiObjectiveFitness

public MultiObjectiveFitness()
Method Detail

defaultBase

public Parameter defaultBase()
Description copied from interface: Prototype
Returns the default base for this prototype. This should generally be implemented by building off of the static base() method on the DefaultsForm object for the prototype's package. This should be callable during setup(...).


clone

public java.lang.Object clone()
Description copied from interface: Prototype
Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context.

Typically this should be a full "deep" clone. However, you may share certain elements with other objects rather than clone hem, depending on the situation:

Implementations.

Specified by:
clone in interface Prototype
Overrides:
clone in class Fitness

fitness

public float fitness()
Returns the Max() of multifitnesses, which adheres to Fitness.java's protocol for this method. Though you should not rely on a selection or statistics method which requires this.

Specified by:
fitness in class Fitness

setup

public void setup(EvolutionState state,
                  Parameter base)
Sets up. This must be called at least once in the prototype before instantiating any fitnesses that will actually be used in evolution.

Specified by:
setup in interface Prototype
Specified by:
setup in interface Setup
Overrides:
setup in class Fitness

isIdealFitness

public boolean isIdealFitness()
Returns true if this fitness is the "ideal" fitness. Default always returns false. You may want to override this.

Specified by:
isIdealFitness in class Fitness

equivalentTo

public boolean equivalentTo(Fitness _fitness)
Returns true if I'm equivalent in fitness (neither better nor worse) to _fitness. The rule I'm using is this: If one of us is better in one or more criteria, and we are equal in the others, then equivalentTo is false. If each of us is better in one or more criteria each, or we are equal in all criteria, then equivalentTo is true.

Specified by:
equivalentTo in class Fitness

betterThan

public boolean betterThan(Fitness _fitness)
Returns true if I'm better than _fitness. The rule I'm using is this: if I am better in one or more criteria, and we are equal in the others, then betterThan is true, else it is false.

Specified by:
betterThan in class Fitness

fitnessToString

public java.lang.String fitnessToString()
Description copied from class: Fitness
Print to a string the fitness in a fashion intended to be parsed in again via readFitness(...). The fitness and evaluated flag should not be included. The default form simply calls toString(), which is almost certainly wrong, and you'll probably want to override this to something else.

Overrides:
fitnessToString in class Fitness

fitnessToStringForHumans

public java.lang.String fitnessToStringForHumans()
Description copied from class: Fitness
Print to a string the fitness in a fashion readable by humans, and not intended to be parsed in again. The default form simply calls toString(), but you'll probably want to override this to something else.

Overrides:
fitnessToStringForHumans in class Fitness

readFitness

public void readFitness(EvolutionState state,
                        java.io.LineNumberReader reader)
                 throws java.io.IOException
Description copied from class: Fitness
Reads in the fitness from a form outputted by fitnessToString() and thus printFitnessForHumans(...). The default version of this method exits the program with an "unimplemented" error.

Overrides:
readFitness in class Fitness
Throws:
java.io.IOException

writeFitness

public void writeFitness(EvolutionState state,
                         java.io.DataOutput dataOutput)
                  throws java.io.IOException
Description copied from class: Fitness
Writes the binary form of an individual out to a DataOutput. This is not for serialization: the object should only write out the data relevant to the object sufficient to rebuild it from a DataInput. The default version exits the program with an "unimplemented" error; you should override this.

Overrides:
writeFitness in class Fitness
Throws:
java.io.IOException

readFitness

public void readFitness(EvolutionState state,
                        java.io.DataInput dataInput)
                 throws java.io.IOException
Description copied from class: Fitness
Reads the binary form of an individual from a DataInput. This is not for serialization: the object should only read in the data written out via printIndividual(state,dataInput). The default version exits the program with an "unimplemented" error; you should override this.

Overrides:
readFitness in class Fitness
Throws:
java.io.IOException