|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectec.Individual
ec.vector.VectorIndividual
ec.vector.BitVectorIndividual
public class BitVectorIndividual
BitVectorIndividual is a VectorIndividual whose genome is an array of booleans. The default mutation method simply flips bits with mutationProbability.
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
| Field Summary | |
|---|---|
boolean[] |
genome
|
static java.lang.String |
P_BITVECTORINDIVIDUAL
|
| Fields inherited from class ec.Individual |
|---|
evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species |
| Constructor Summary | |
|---|---|
BitVectorIndividual()
|
|
| Method Summary | |
|---|---|
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. |
boolean |
equals(java.lang.Object ind)
Returns true if I am genetically "equal" to ind. |
long |
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. |
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. |
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 flipping the bits |
void |
setGenome(java.lang.Object gen)
Sets the gene array. |
void |
setup(EvolutionState state,
Parameter base)
Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. |
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. |
| Methods inherited from class ec.vector.VectorIndividual |
|---|
reset, setGenomeLength, size |
| Methods inherited from class ec.Individual |
|---|
printIndividual, printIndividual, printIndividualForHumans, readIndividual, readIndividual, toString, writeIndividual |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String P_BITVECTORINDIVIDUAL
public boolean[] genome
| Constructor Detail |
|---|
public BitVectorIndividual()
| Method Detail |
|---|
public Parameter defaultBase()
Prototype
public java.lang.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 Individual
public void setup(EvolutionState state,
Parameter base)
PrototypeFor prototypes, setup(...) is typically called once for the prototype instance; cloned instances do not receive the setup(...) call. setup(...) may be called more than once; the only guarantee is that it will get called at least once on an instance or some "parent" object from which it was ultimately cloned.
setup in interface Prototypesetup in interface Setupsetup in class Individual
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 VectorIndividualpublic void join(java.lang.Object[] pieces)
join in class VectorIndividual
public void defaultMutate(EvolutionState state,
int thread)
defaultMutate in class VectorIndividual
public void reset(EvolutionState state,
int thread)
reset in class VectorIndividualpublic int hashCode()
Individual
hashCode in class Individualpublic java.lang.String genotypeToStringForHumans()
Individual
genotypeToStringForHumans in class Individualpublic 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 Individualjava.io.IOExceptionpublic boolean equals(java.lang.Object ind)
Individual
equals in class Individualpublic java.lang.Object getGenome()
VectorIndividual
getGenome in class VectorIndividualpublic void setGenome(java.lang.Object gen)
VectorIndividual
setGenome in class VectorIndividualpublic long genomeLength()
VectorIndividual
genomeLength in class VectorIndividual
public void writeGenotype(EvolutionState state,
java.io.DataOutput dataOutput)
throws java.io.IOException
IndividualdataOutput.writeInt(integers.length); for(int x=0;x
writeGenotype in class Individualjava.io.IOException
public void readGenotype(EvolutionState state,
java.io.DataInput dataInput)
throws java.io.IOException
Individualintegers = new int[dataInput.readInt()]; for(int x=0;x
readGenotype in class Individualjava.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||