|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ec.multiobjective.MultiObjectiveFitness
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), and a flag (criterionIsAnd) which indicates whether or not the ideal multiple fitness is one with all its fitness values = 1.0, or one with at least one of its fitness values = 1.0.
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
Field Summary | |
boolean |
criterionIsAnd
is the ideal individual critereon one which does an AND over the "idealness" of each of the fitnesses (as opposed to an OR)? |
static java.lang.String |
FITNESS_POSTAMBLE
|
static java.lang.String |
FITNESS_PREAMBLE
|
float[] |
multifitness
The various fitnesses. |
static java.lang.String |
P_CRITERIONISAND
criterionIsAnd parameter |
static java.lang.String |
P_FITNESS
base parameter for defaults |
static java.lang.String |
P_NUMFITNESSES
parameter for size of multifitness |
Constructor Summary | |
MultiObjectiveFitness()
|
Method Summary | |
boolean |
betterThan(Fitness _fitness)
Returns true if I'm better than _fitness. |
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. |
boolean |
isIdealFitness()
Returns true if this fitness is the "ideal" fitness. |
void |
printFitness(EvolutionState state,
int log,
int verbosity)
Prints the fitness in the computer-readable form: |
void |
printFitness(EvolutionState state,
java.io.PrintWriter writer)
Prints the fitness in the computer-readable form: |
void |
printFitnessForHumans(EvolutionState state,
int log,
int verbosity)
Prints the fitness in the human-readable form: |
java.lang.Object |
protoClone()
Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context. |
java.lang.Object |
protoCloneSimple()
This should be implemented in a the top-level Prototype ONLY; in fact, it should probably be declared final. |
void |
readFitness(EvolutionState state,
java.io.LineNumberReader reader)
Reads in the fitness from a form printed by printFitness(). |
void |
setup(EvolutionState state,
Parameter base)
Sets up. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String FITNESS_PREAMBLE
public static final java.lang.String FITNESS_POSTAMBLE
public static final java.lang.String P_FITNESS
public static final java.lang.String P_NUMFITNESSES
public static final java.lang.String P_CRITERIONISAND
public boolean criterionIsAnd
public float[] multifitness
Constructor Detail |
public MultiObjectiveFitness()
Method Detail |
public final Parameter defaultBase()
Prototype
defaultBase
in interface Prototype
public final java.lang.Object protoClone() throws java.lang.CloneNotSupportedException
Prototype
The question here is whether or not this means to perform a "deep" or "light" ("shallow") clone, or something in-between. You may need to deep-clone parts of your object rather than simply copying their references, depending on the situation:
Implementations.
public Object protoClone() throws CloneNotSupportedException
{
return super.clone();
}
public Object protoClone() throws CloneNotSupportedException
{
myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
// ...you should use protoClone and not
// protoCloneSimple to clone subordinate objects...
return myobj;
}
public Object protoClone() throws CloneNotSupportedException
{
MyObject myobj = (MyObject)(super.protoClone());
// put your deep-cloning code here...
// ...you should use protoClone and not
// protoCloneSimple to clone subordinate objects...
return myobj;
}
If you know that your superclasses will never change their protoClone() implementations, you might try inlining them in your overridden protoClone() method. But this is dangerous (though it yields a small net increase).
In general, you want to keep your deep cloning to an absolute minimum, so that you don't have to call protoClone() but one time.
The approach taken here is the fastest that I am aware of while still permitting objects to be specified at runtime from a parameter file. It would be faster to use the "new" operator; but that would require hard-coding that we can't do. Although using java.lang.Object.clone() entails an extra layer that deals with stripping away the "protected" keyword and also wrapping the exception handling (which is a BIG hit, about three times as slow as using "new"), it's still MUCH faster than using java.lang.Class.newInstance(), and also much faster than rolling our own Clone() method.
protoClone
in interface Prototype
public final java.lang.Object protoCloneSimple()
Prototype
public final Object protoCloneSimple()
{
try { return protoClone(); }
catch (CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
}
protoCloneSimple
in interface Prototype
public final float fitness()
fitness
in interface Fitness
public final void setup(EvolutionState state, Parameter base)
setup
in interface Prototype
public final boolean isIdealFitness()
isIdealFitness
in interface Fitness
public final boolean equivalentTo(Fitness _fitness)
equivalentTo
in interface Fitness
public final boolean betterThan(Fitness _fitness)
betterThan
in interface Fitness
public void printFitness(EvolutionState state, int log, int verbosity)
Fitness: [fitness values encoded with ec.util.Code, separated by spaces]
printFitness
in interface Fitness
public final void printFitness(EvolutionState state, java.io.PrintWriter writer)
Fitness: [fitness values encoded with ec.util.Code, separated by spaces]
printFitness
in interface Fitness
public void printFitnessForHumans(EvolutionState state, int log, int verbosity)
Fitness: [fitness values separated by spaces]
printFitnessForHumans
in interface Fitness
public final void readFitness(EvolutionState state, java.io.LineNumberReader reader) throws java.io.IOException, java.lang.CloneNotSupportedException
Fitness
readFitness
in interface Fitness
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |