T
- The type of Chromosomes accepted as input and returned by operations.public interface Chromosome<T extends Chromosome>
extends java.lang.Cloneable
If necessary, a variable length chromosome can be implemented by subclassing this abstract class and specifying the abstract methods.
Modifier and Type | Interface and Description |
---|---|
static class |
Chromosome.Util |
Modifier and Type | Method and Description |
---|---|
T |
clone()
Performs a chromosome deep-cloning.
|
void |
cross(T chromosome,
int from)
Exchanges the genes chromosome starting from a given position
|
void |
cross(T chromosome,
int from,
int to)
Exchanges the genes chromosome within the range [from,to]
|
void |
difference(T chromosome,
double[] diff)
Computes the genetic difference between two chromosomes.
|
boolean |
equals(T chromosome)
Compares the chromosome with another.
|
void |
leftShift(int from,
int to)
Makes a left-shift of the genes between two positions.
|
int |
length()
Returns the number of genes contained in the chromosome.
|
void |
randomize()
Fills the chromosome with random value.
|
void |
randomize(int pos)
Sets a random value in the specified position
|
void |
rightShift(int from,
int to)
Makes a right-shift of the genes between two positions.
|
void |
setAs(T chromosome)
Makes the chromosome a copy of another chromosome.
|
void |
setDefaultValueAt(int pos)
Sets the default value at a given position
|
void |
swap(int pos1,
int pos2)
Exchanges two genes at the specified positions
|
java.lang.Object[] |
toArray()
Returns an array containing all of the genes in chromosome.
|
void swap(int pos1, int pos2)
pos1
- the position of first genepos2
- the position of second genevoid randomize(int pos)
pos
- a position where to set the random valuevoid leftShift(int from, int to)
from
- the start position to be shiftedto
- the final position to be shiftedvoid rightShift(int from, int to)
from
- the start position to be shiftedto
- the final position to be shiftedvoid setDefaultValueAt(int pos)
pos
- the position where to set the default valueT clone()
int length()
void randomize()
void setAs(T chromosome)
chromosome
- the chromosome to be copiedvoid cross(T chromosome, int from, int to)
chromosome
- the chromosome to cross withfrom
- the start position of the genes to exchangeto
- the final position of the genes to exchangevoid cross(T chromosome, int from)
chromosome
- the chromosome to cross withfrom
- the start position of the genes to exchangeboolean equals(T chromosome)
chromosome
- the cromosome to compare to.void difference(T chromosome, double[] diff)
diff
- - the variable to be filled by the minus valueschromosome
- - the chromosome to quantify the minus fromjava.lang.Object[] toArray()