|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ec.Individual | +--ec.gp.GPIndividual
GPIndividual is an Individual used for GP evolution runs. GPIndividuals contain, at the very least, a nonempty array of GPTrees. You can use GPIndividual directly, or subclass it to extend it as you see fit.
Parameters
base.numtrees int >= 1 |
(number of trees in the GPIndividual) |
base.tree.n classname, inherits or = ec.gp.GPTree |
(class of tree n in the individual) |
Default Base
gp.individual
Parameter bases
base.tree.n | tree n in the individual |
Field Summary | |
static java.lang.String |
EVALUATED_PREAMBLE
|
static java.lang.String |
P_INDIVIDUAL
|
static java.lang.String |
P_NUMTREES
|
static java.lang.String |
P_TREE
|
GPTree[] |
trees
|
Fields inherited from class ec.Individual |
evaluated,
fitness |
Constructor Summary | |
GPIndividual()
|
Method Summary | |
Parameter |
defaultBase()
Returns the default base for this prototype. |
boolean |
equals(java.lang.Object ind)
Returns true if I am genetically "equal" to ind. |
int |
hashCode()
Returns a hashcode for the individual, such that individuals which are equals(...) each other always return the same hash code. |
void |
printIndividual(EvolutionState state,
int log,
int verbosity)
Prints the individual in a way that it can be read in again by computer. |
void |
printIndividual(EvolutionState state,
int thread,
java.io.PrintWriter writer)
Prints the individual in a way that it can be read in again by computer. |
void |
printIndividualForHumans(EvolutionState state,
int log,
int verbosity)
A printer for the individual in a reasonable human-readable, fashion. |
java.lang.Object |
protoClone()
Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context. |
void |
readIndividual(EvolutionState state,
int thread,
java.io.LineNumberReader reader)
Reads in the individual from a form printed by printIndividual(). |
void |
setup(EvolutionState state,
Parameter base)
Sets up a prototypical GPIndividual with those features which it shares with other GPIndividuals in its species, and nothing more. |
Methods inherited from class ec.Individual |
protoCloneSimple |
Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String P_INDIVIDUAL
public static final java.lang.String P_NUMTREES
public static final java.lang.String P_TREE
public static final java.lang.String EVALUATED_PREAMBLE
public GPTree[] trees
Constructor Detail |
public GPIndividual()
Method Detail |
public Parameter defaultBase()
public boolean equals(java.lang.Object ind)
public int hashCode()
public void setup(EvolutionState state, Parameter base)
Prototype.setup(EvolutionState,Parameter)
public void printIndividualForHumans(EvolutionState state, int log, int verbosity)
public void printIndividual(EvolutionState state, int log, int verbosity)
public void printIndividual(EvolutionState state, int thread, java.io.PrintWriter writer)
public void readIndividual(EvolutionState state, int thread, java.io.LineNumberReader reader) throws java.io.IOException, java.lang.CloneNotSupportedException
public java.lang.Object protoClone() throws java.lang.CloneNotSupportedException
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |