public class BitVectorIndividual 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.bit-vect-ind
| Modifier and Type | Field and Description |
|---|---|
boolean[] |
genome |
static String |
P_BITVECTORINDIVIDUAL |
evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species| Constructor and Description |
|---|
BitVectorIndividual() |
| Modifier and Type | Method and Description |
|---|---|
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)
Implements distance as hamming distance.
|
boolean |
equals(Object ind)
Returns true if I am genetically "equal" to ind.
|
int |
genomeLength()
Returns the length of the gene array.
|
String |
genotypeToString()
Print to a string the genotype of the Individual in a fashion intended
to be parsed in again via parseGenotype(...).
|
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.
|
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.
|
void |
join(Object[] pieces)
Joins the n pieces and sets the genome to their concatenation.
|
protected 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 |
readGenotype(EvolutionState state,
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 flipping the bits
|
void |
setGenome(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,
Object[] pieces)
Splits the genome into n pieces, according to points, which *must* be sorted.
|
void |
writeGenotype(EvolutionState state,
DataOutput dataOutput)
Writes the genotypic information to a DataOutput.
|
cloneGenes, reset, sizecompareTo, merge, printIndividual, printIndividual, printIndividual, printIndividualForHumans, printIndividualForHumans, readIndividual, readIndividual, toString, writeIndividualpublic static final String P_BITVECTORINDIVIDUAL
public boolean[] genome
public Parameter defaultBase()
Prototypepublic Object clone()
PrototypeTypically 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 Prototypeclone in class Individualpublic void setup(EvolutionState state, Parameter base)
Individualsetup in interface Prototypesetup in interface Setupsetup in class IndividualPrototype.setup(EvolutionState,Parameter)public void defaultCrossover(EvolutionState state, int thread, VectorIndividual ind)
VectorIndividualdefaultCrossover in class VectorIndividualpublic void split(int[] points,
Object[] pieces)
split in class VectorIndividualpublic void join(Object[] pieces)
join in class VectorIndividualpublic void defaultMutate(EvolutionState state, int thread)
defaultMutate in class VectorIndividualpublic void reset(EvolutionState state, int thread)
reset in class VectorIndividualpublic int hashCode()
IndividualhashCode in class Individualpublic String genotypeToStringForHumans()
IndividualgenotypeToStringForHumans in class Individualpublic String genotypeToString()
IndividualgenotypeToString in class Individualprotected void parseGenotype(EvolutionState state, LineNumberReader reader) throws IOException
IndividualparseGenotype in class IndividualIOExceptionpublic boolean equals(Object ind)
Individualequals in class Individualpublic Object getGenome()
VectorIndividualgetGenome in class VectorIndividualpublic void setGenome(Object gen)
VectorIndividualsetGenome in class VectorIndividualpublic int genomeLength()
VectorIndividualgenomeLength in class VectorIndividualpublic void setGenomeLength(int len)
VectorIndividualsetGenomeLength in class VectorIndividualpublic void writeGenotype(EvolutionState state, DataOutput dataOutput) throws IOException
IndividualdataOutput.writeInt(integers.length); for(int x=0;x
writeGenotype in class IndividualIOExceptionpublic void readGenotype(EvolutionState state, DataInput dataInput) throws IOException
Individualintegers = new int[dataInput.readInt()]; for(int x=0;x
readGenotype in class IndividualIOExceptionpublic double distanceTo(Individual otherInd)
distanceTo in class IndividualCopyright © 2014 Evolutionary Computation Laboratory at George Mason University. All rights reserved.