|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectec.Fitness
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). 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
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 |
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 |
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 float[] multifitness
Constructor Detail |
public MultiObjectiveFitness()
Method Detail |
public Parameter defaultBase()
Prototype
public java.lang.Object clone()
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()
{
return super.clone();
}
public Object protoClone()
{
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()
{
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.
clone
in interface Prototype
clone
in class Fitness
public float fitness()
fitness
in class Fitness
public void setup(EvolutionState state, Parameter base)
setup
in interface Prototype
setup
in class Fitness
public boolean isIdealFitness()
isIdealFitness
in class Fitness
public boolean equivalentTo(Fitness _fitness)
equivalentTo
in class Fitness
public boolean betterThan(Fitness _fitness)
betterThan
in class Fitness
public java.lang.String fitnessToString()
Fitness
fitnessToString
in class Fitness
public java.lang.String fitnessToStringForHumans()
Fitness
fitnessToStringForHumans
in class Fitness
public void readFitness(EvolutionState state, java.io.LineNumberReader reader) throws java.io.IOException
Fitness
readFitness
in class Fitness
java.io.IOException
public void writeFitness(EvolutionState state, java.io.DataOutput dataOutput) throws java.io.IOException
Fitness
writeFitness
in class Fitness
java.io.IOException
public void readFitness(EvolutionState state, java.io.DataInput dataInput) throws java.io.IOException
Fitness
readFitness
in class Fitness
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |