|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbodhidharma.classifiers.genetic_algorithms.Chromosome
public class Chromosome
Objects of this class represent the individuals that are evolved in a genetic algorithm. The genetic material of each chromosome is represented as an array of shorts, which are set to either 1 or 0.
Objects of this class store their fitness, as calculated by an Evaluator
object
that they are passed when they are instantiated. Evolution of Chromosome
objects is
controlled by Breeder
objects. Chromosome
objects have no understanding
of the meaning of these bit strings.
Objects of this class can be instantiated so that their array is randomly set, or they can be instantiated so that the array is composed of two given components. Objects of this class contain methods to return the entire array or sub-arrays split at a given point of division.
The getDNA
method of this class can be called to get the DNA of a Chromosome.
The getLeftDNA
method of this class can be called to get the first part of
the DNA of a Chromosome.
The getRightDNA
method of this class can be called to get the second part of
the DNA of a Chromosome.
The getFitness
method of this class can be called to get the stored fitness
of a Chromosome.
The mutate
method of this class can be called to cause the Chromosome to
undergo mutation.
Evaluator
,
Breeder
Constructor Summary | |
---|---|
Chromosome(int size,
Evaluator eval)
Randomly fill the genetic material of a Chromosome with 0's and 1's. |
|
Chromosome(short[] left_DNA,
short[] right_DNA,
Evaluator eval)
Generates a Chromosome with genetic material composed of the combination of the two given parent pieces of genetic material. |
Method Summary | |
---|---|
short[] |
getDNA()
Returns the entire genetic material of the Chromosome. |
double |
getFitness()
Returns the stored fitness of the Chromosome. |
short[] |
getLeftDNA(int split_point)
Returns the genetic material of the Chromosome up to and including the given split point (starting at 1, not 0). |
short[] |
getRightDNA(int split_point)
Returns the genetic material of the Chromosome after but not including the given split point (starting at 1, not 0). |
void |
mutate(double probability)
Flips bits in bit string with a probability per bit given by the probability parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Chromosome(int size, Evaluator eval) throws java.lang.Exception
An exception is thrown if there is a problem evaluating the fitness of the DNA.
size
- The number of bits in the Chromosome's DNA.eval
- The Evaluator
object that calculatues the fitness of each Chromosome.
java.lang.Exception
public Chromosome(short[] left_DNA, short[] right_DNA, Evaluator eval) throws java.lang.Exception
An exception is thrown if there is a problem evaluating the fitness of the DNA.
left_DNA
- The first part of the Chromosome's DNA.right_DNA
- The second part of the Chromosome's DNA.eval
- The Evaluator
object that calculatues the fitness of each Chromosome.
java.lang.Exception
Method Detail |
---|
public short[] getDNA()
public short[] getLeftDNA(int split_point)
public short[] getRightDNA(int split_point)
public double getFitness()
public void mutate(double probability)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |