public abstract class VectorIndividual extends Individual
This class contains two methods, defaultCrossover and defaultMutate, which can be overridden if all you need is a simple crossover and a simple mutate mechanism. the VectorCrossoverPipeline and VectorMutationPipeline classes use these methods to do their handiwork. For more sophisticated crossover and mutation, you'll need to write a custom breeding pipeline.
The kind of default crossover and mutation, and associated information, is stored in the VectorIndividual's VectorSpecies object, which is obtained through the species variable. For example, VectorIndividual assumes three common types of crossover as defined in VectorSpecies which you should implement in your defaultCrossover method: one-point, two-point, and any-point (otherwise known as "uniform") crossover.
VectorIndividual is typically used for fixed-length vector representations; however, it can also be used with variable-length representations. Two methods have been provided in all subclasses of VectorIndividual to help you there: split and join, which you can use to break up and reconnect VectorIndividuals in a variety of ways. Note that you may want to override the reset() method to create individuals with different initial lengths.
VectorIndividuals must belong to the species VectorSpecies (or some subclass of it).
From ec.Individual:
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 gene array. If you add instance variables to a VectorIndividual or subclass, you'll need to read/write those variables as well.
evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species
Constructor and Description |
---|
VectorIndividual() |
Modifier and Type | Method and Description |
---|---|
void |
cloneGenes(java.lang.Object piece)
Clones the genes in pieces, and replaces the genes with their copies.
|
void |
defaultCrossover(EvolutionState state,
int thread,
VectorIndividual ind)
Destructively crosses over the individual with another in some default manner.
|
void |
defaultMutate(EvolutionState state,
int thread)
Destructively mutates the individual in some default manner.
|
int |
genomeLength()
Returns the length of the gene array.
|
java.lang.Object |
getGenome()
Returns the gene array.
|
void |
join(java.lang.Object[] pieces)
Joins the n pieces and sets the genome to their concatenation.
|
abstract void |
reset(EvolutionState state,
int thread)
Initializes the individual.
|
void |
reset(EvolutionState state,
int thread,
int newSize)
Initializes the individual to a new size.
|
void |
setGenome(java.lang.Object gen)
Sets the gene array.
|
void |
setGenomeLength(int len)
Sets the genome length.
|
long |
size()
Returns the "size" of the individual.
|
void |
split(int[] points,
java.lang.Object[] pieces)
Splits the genome into n pieces, according to points, which *must* be sorted.
|
clone, compareTo, distanceTo, equals, genotypeToString, genotypeToStringForHumans, hashCode, merge, parseGenotype, printIndividual, printIndividual, printIndividual, printIndividualForHumans, printIndividualForHumans, readGenotype, readIndividual, readIndividual, setup, toString, writeGenotype, writeIndividual
finalize, getClass, notify, notifyAll, wait, wait, wait
defaultBase
public void defaultCrossover(EvolutionState state, int thread, VectorIndividual ind)
public void defaultMutate(EvolutionState state, int thread)
public abstract void reset(EvolutionState state, int thread)
public java.lang.Object getGenome()
public void setGenome(java.lang.Object gen)
public int genomeLength()
public void reset(EvolutionState state, int thread, int newSize)
public void setGenomeLength(int len)
public void split(int[] points, java.lang.Object[] pieces)
public void join(java.lang.Object[] pieces)
public void cloneGenes(java.lang.Object piece)
public long size()
Individual
size
in class Individual