public class IntegerVectorIndividual extends VectorIndividual
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.
Default Base
vector.int-vect-ind
Modifier and Type | Field and Description |
---|---|
int[] |
genome |
static java.lang.String |
P_INTEGERVECTORINDIVIDUAL |
evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species
Constructor and Description |
---|
IntegerVectorIndividual() |
Modifier and Type | Method and Description |
---|---|
void |
clamp()
Clips each gene value to be within its specified [min,max] range.
|
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.
|
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.
|
double |
distanceTo(Individual otherInd)
Returns the metric distance to another individual, if such a thing can be measured.
|
boolean |
equals(java.lang.Object ind)
Returns true if I am genetically "equal" to ind.
|
int |
genomeLength()
Returns the length of the gene array.
|
java.lang.String |
genotypeToString()
Print to a string the genotype of the Individual in a fashion intended
to be parsed in again via parseGenotype(...).
|
java.lang.String |
genotypeToStringForHumans()
Print to a string the genotype of the Individual in a fashion readable by humans, and not intended
to be parsed in again.
|
java.lang.Object |
getGenome()
Returns the gene array.
|
int |
hashCode()
Returns a hashcode for the individual, such that individuals which
are equals(...) each other always return the same
hash code.
|
boolean |
isInRange()
Returns true if each gene value is within is specified [min,max] range.
|
void |
join(java.lang.Object[] pieces)
Joins the n pieces and sets the genome to their concatenation.
|
protected void |
parseGenotype(EvolutionState state,
java.io.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.
|
int |
randomValueFromClosedInterval(int min,
int max,
MersenneTwisterFast random)
Returns a random value from between min and max inclusive.
|
void |
readGenotype(EvolutionState state,
java.io.DataInput dataInput)
Reads in the genotypic information from a DataInput, erasing the previous genotype
of this Individual.
|
void |
reset(EvolutionState state,
int thread)
Initializes the individual by randomly choosing Integers uniformly from mingene to maxgene.
|
void |
setGenome(java.lang.Object gen)
Sets the gene array.
|
void |
setGenomeLength(int len)
Sets the genome length.
|
void |
setup(EvolutionState state,
Parameter base)
This should be used to set up only those things which you share in common
with all other individuals in your species; individual-specific items
which make you you should be filled in by Species.newIndividual(...),
and modified by breeders.
|
void |
split(int[] points,
java.lang.Object[] pieces)
Splits the genome into n pieces, according to points, which *must* be sorted.
|
void |
writeGenotype(EvolutionState state,
java.io.DataOutput dataOutput)
Writes the genotypic information to a DataOutput.
|
cloneGenes, reset, size
compareTo, merge, printIndividual, printIndividual, printIndividual, printIndividualForHumans, printIndividualForHumans, readIndividual, readIndividual, toString, writeIndividual
public static final java.lang.String P_INTEGERVECTORINDIVIDUAL
public int[] genome
public Parameter defaultBase()
Prototype
public java.lang.Object clone()
Prototype
Typically this should be a full "deep" clone. However, you may share certain elements with other objects rather than clone hem, depending on the situation:
Implementations.
public Object clone()
{
try
{
return super.clone();
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
}
public Object clone()
{
try
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
return myobj;
}
public Object clone()
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
return myobj;
}
clone
in interface Prototype
clone
in class Individual
public void setup(EvolutionState state, Parameter base)
Individual
setup
in interface Prototype
setup
in interface Setup
setup
in class Individual
Prototype.setup(EvolutionState,Parameter)
public void defaultCrossover(EvolutionState state, int thread, VectorIndividual ind)
VectorIndividual
defaultCrossover
in class VectorIndividual
public void split(int[] points, java.lang.Object[] pieces)
split
in class VectorIndividual
public void join(java.lang.Object[] pieces)
join
in class VectorIndividual
public int randomValueFromClosedInterval(int min, int max, MersenneTwisterFast random)
public void defaultMutate(EvolutionState state, int thread)
defaultMutate
in class VectorIndividual
public void reset(EvolutionState state, int thread)
reset
in class VectorIndividual
public int hashCode()
Individual
hashCode
in class Individual
public java.lang.String genotypeToStringForHumans()
Individual
genotypeToStringForHumans
in class Individual
public java.lang.String genotypeToString()
Individual
genotypeToString
in class Individual
protected void parseGenotype(EvolutionState state, java.io.LineNumberReader reader) throws java.io.IOException
Individual
parseGenotype
in class Individual
java.io.IOException
public boolean equals(java.lang.Object ind)
Individual
equals
in class Individual
public java.lang.Object getGenome()
VectorIndividual
getGenome
in class VectorIndividual
public void setGenome(java.lang.Object gen)
VectorIndividual
setGenome
in class VectorIndividual
public int genomeLength()
VectorIndividual
genomeLength
in class VectorIndividual
public void writeGenotype(EvolutionState state, java.io.DataOutput dataOutput) throws java.io.IOException
Individual
dataOutput.writeInt(integers.length); for(int x=0;x
writeGenotype
in class Individual
java.io.IOException
public void readGenotype(EvolutionState state, java.io.DataInput dataInput) throws java.io.IOException
Individual
integers = new int[dataInput.readInt()]; for(int x=0;x
readGenotype
in class Individual
java.io.IOException
public void clamp()
public void setGenomeLength(int len)
VectorIndividual
setGenomeLength
in class VectorIndividual
public boolean isInRange()
public double distanceTo(Individual otherInd)
Individual
distanceTo
in class Individual