|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ec.multiobjective.spea2.SPEA2MultiObjectiveFitness
SPEA2MultiObjectiveFitness is a subclass of Fitness which implements basic multiobjective fitness functions along with support for the ECJ SPEA2 (Strength Pareto Evolutionary Algorithm) extensions.
The object contains two items: an array of floating point values representing the various multiple fitnesses (ranging from 0.0 (worst) to infinity (best)), and a single SPEA2 fitness value which represents the individual's overall fitness ( a function of the number of individuals it dominates and it's raw score where 0.0 is the best).
Parameters
base.numobjectives (else)multi.numobjectives int >= 1 |
(the number of fitnesses in the multifitness array) |
Default Base
spea2.fitness
Field Summary | |
static java.lang.String |
FITNESS_POSTAMBLE
|
static java.lang.String |
FITNESS_PREAMBLE
|
float[] |
multifitness
The various fitnesses. |
static java.lang.String |
P_FITNESS
base parameter for defaults |
static java.lang.String |
P_NUMFITNESSES
parameter for size of multifitness |
static java.lang.String |
SPEA2FIT_PREAMBLE
|
double |
SPEA2Fitness
SPEA2 overall fitness |
double |
SPEA2kthNNDistance
SPEA2 NN distance |
double |
SPEA2RawFitness
SPEA2 RAW fitness |
double |
SPEA2Strength
SPEA2 strength (# of nodes it dominates) |
Constructor Summary | |
SPEA2MultiObjectiveFitness()
|
Method Summary | |
boolean |
betterThan(Fitness _fitness)
Returns true if I'm better than _fitness. |
float |
calcDistance(SPEA2MultiObjectiveFitness otherFit)
Returns the sum of the squared differences between the vector fitness values. |
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 false. |
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 SPEA2FIT_PREAMBLE
public static final java.lang.String P_FITNESS
public static final java.lang.String P_NUMFITNESSES
public float[] multifitness
public double SPEA2Fitness
public double SPEA2Strength
public double SPEA2RawFitness
public double SPEA2kthNNDistance
Constructor Detail |
public SPEA2MultiObjectiveFitness()
Method Detail |
public final Parameter defaultBase()
Prototype
defaultBase
in interface Prototype
public 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 float calcDistance(SPEA2MultiObjectiveFitness otherFit)
public 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 float fitness()
fitness
in interface Fitness
public void setup(EvolutionState state, Parameter base)
setup
in interface Prototype
public boolean isIdealFitness()
isIdealFitness
in interface Fitness
public boolean equivalentTo(Fitness _fitness)
equivalentTo
in interface Fitness
public 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 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 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 |