public class GPIndividual extends Individual
GPIndividuals have two clone methods: clone() and lightClone(). clone() is a deep clone method as usual. lightClone() is a light clone which does not copy the trees.
In addition to serialization for checkpointing, Individuals may read and write themselves to streams in three ways.
In general, the various readers and writers do three things: they tell the Fitness to read/write itself, they read/write the evaluated flag, and they read/write the GPTree array (by having each GPTree read/write itself). If you add instance variables to GPIndividual, you'll need to read/write those variables as well.
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 |
| Modifier and Type | Field and Description |
|---|---|
static String |
P_NUMTREES |
static String |
P_TREE |
private static long |
serialVersionUID |
GPTree[] |
trees |
evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species| Constructor and Description |
|---|
GPIndividual() |
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Deep-clones the GPIndividual.
|
Parameter |
defaultBase()
Returns the default base for this prototype.
|
boolean |
equals(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.
|
GPIndividual |
lightClone()
Like clone(), but doesn't force the GPTrees to deep-clone themselves.
|
void |
parseGenotype(EvolutionState state,
LineNumberReader reader)
This method is used only by the default version of readIndividual(state,reader),
and it is intended to be overridden to parse in that part of the individual that
was outputted in the genotypeToString() method.
|
void |
printIndividual(EvolutionState state,
int log)
Should print the individual in a way that can be read by computer,
including its fitness, with a verbosity of Output.V_NO_GENERAL.
|
void |
printIndividual(EvolutionState state,
PrintWriter writer)
Should print the individual in a way that can be read by computer,
including its fitness.
|
void |
printIndividualForHumans(EvolutionState state,
int log)
Should print the individual out in a pleasing way for humans,
with a verbosity of Output.V_NO_GENERAL.
|
void |
printTrees(EvolutionState state,
int log)
Prints just the trees of the GPIndividual.
|
void |
readGenotype(EvolutionState state,
DataInput dataInput)
Overridden for the GPIndividual genotype.
|
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.
|
long |
size()
Returns the "size" of the individual, namely, the number of nodes
in all of its subtrees.
|
void |
verify(EvolutionState state)
Verification of validity of the GPIndividual -- strictly for debugging purposes only
|
void |
writeGenotype(EvolutionState state,
DataOutput dataOutput)
Overridden for the GPIndividual genotype.
|
compareTo, distanceTo, genotypeToString, genotypeToStringForHumans, merge, printIndividual, printIndividualForHumans, readIndividual, readIndividual, toString, writeIndividualprivate static final long serialVersionUID
public static final String P_NUMTREES
public static final String P_TREE
public GPTree[] trees
public Parameter defaultBase()
Prototypepublic boolean equals(Object ind)
Individualequals in class Individualpublic int hashCode()
IndividualhashCode in class Individualpublic void setup(EvolutionState state, Parameter base)
setup in interface Prototypesetup in interface Setupsetup in class IndividualPrototype.setup(EvolutionState,Parameter)public void verify(EvolutionState state)
public void printTrees(EvolutionState state, int log)
public void printIndividualForHumans(EvolutionState state, int log)
IndividualprintIndividualForHumans in class Individualpublic void printIndividual(EvolutionState state, int log)
IndividualprintIndividual in class Individualpublic void printIndividual(EvolutionState state, PrintWriter writer)
IndividualThe default form of this method simply prints out whether or not the individual has been evaluated, its fitness, and then calls Individual.genotypeToString(). Feel free to override this to produce more sophisticated behavior, though it is rare to need to -- instead you could just override genotypeToString().
printIndividual in class Individualpublic void writeGenotype(EvolutionState state, DataOutput dataOutput) throws IOException
writeGenotype in class IndividualIOExceptionpublic void readGenotype(EvolutionState state, DataInput dataInput) throws IOException
readGenotype in class IndividualIOExceptionpublic void parseGenotype(EvolutionState state, LineNumberReader reader) throws IOException
IndividualparseGenotype in class IndividualIOExceptionpublic Object clone()
clone in interface Prototypeclone in class Individualpublic GPIndividual lightClone()
public long size()
size in class IndividualCopyright © 2014 Evolutionary Computation Laboratory at George Mason University. All rights reserved.