|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jenes.chromosome.DoubleChromosome
public final class DoubleChromosome
A DoubleChromosome is made of an array of double values. Each value is in the range [lowerBound,upperBound[. The lower bound is include included, the upper bound not. Both the bounds are specified ad the instantiation time. DoubleChromosome is a fixed length chromosome class, thus number of genes is specified at instantiation time and cannot be modified after.
Constructor Summary | |
---|---|
DoubleChromosome(DoubleChromosome chromosome)
Creates a new DoubleChromosome as a copy of the specified chromosome |
|
DoubleChromosome(int length,
double lowerBound,
double upperBound)
Creates a DoubleChromosome with each allele in the range [lowerBound, upperBound[ |
Method Summary | |
---|---|
DoubleChromosome |
clone()
Performs a chromosome deep-cloning. |
void |
cross(DoubleChromosome chromosome,
int from)
Exchanges the genes chromosome starting from a given position |
void |
cross(DoubleChromosome chromosome,
int from,
int to)
Exchanges the genes chromosome within the range [from,to] |
boolean |
equals(DoubleChromosome chromosome)
Compares the chromosome with another. |
double |
getDefaultValue()
Returns the default value of this chromosome |
double |
getLowerBound()
Returns the lower bound value for a gene of this chromosome |
double |
getUpperBound()
Returns the upper bound value for a gene of this chromosome |
double |
getValue(int pos)
Returns the double value at the specified position |
double[] |
getValues()
Returns the double values |
double[] |
getValues(double[] values)
Provides the gene values by the array passed as parameter and returning it on return. |
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(DoubleChromosome chromosome)
Makes the chromosome a copy of another chromosome. |
void |
setDefaultValue(double defaultValue)
Sets the default value of this chromosome |
void |
setDefaultValueAt(int pos)
Sets the default value at a given position |
void |
setValue(int pos,
double value)
Sets the specified value at the specified position |
void |
swap(int pos1,
int pos2)
Exchanges two genes at the specified positions |
java.lang.String |
toString()
Provides a textual chromosome representation |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DoubleChromosome(DoubleChromosome chromosome)
chromosome
- the chromosome to be copiedpublic DoubleChromosome(int length, double lowerBound, double upperBound)
length
- the chromosome lengthlowerBound
- the lower boundupperBound
- the upper boundMethod Detail |
---|
public final void setDefaultValueAt(int pos)
Chromosome
setDefaultValueAt
in interface Chromosome<DoubleChromosome>
pos
- the position where to set the default valuepublic final DoubleChromosome clone()
Chromosome
clone
in interface Chromosome<DoubleChromosome>
clone
in class java.lang.Object
public final void swap(int pos1, int pos2)
Chromosome
swap
in interface Chromosome<DoubleChromosome>
pos1
- the position of first genepos2
- the position of second genepublic final void randomize()
Chromosome
randomize
in interface Chromosome<DoubleChromosome>
public final void randomize(int pos)
Chromosome
randomize
in interface Chromosome<DoubleChromosome>
pos
- a position where to set the random valuepublic final void leftShift(int from, int to)
Chromosome
leftShift
in interface Chromosome<DoubleChromosome>
from
- the start position to be shiftedto
- the final position to be shiftedpublic final void rightShift(int from, int to)
Chromosome
rightShift
in interface Chromosome<DoubleChromosome>
from
- the start position to be shiftedto
- the final position to be shiftedpublic final int length()
Chromosome
length
in interface Chromosome<DoubleChromosome>
public final void setAs(DoubleChromosome chromosome)
Chromosome
setAs
in interface Chromosome<DoubleChromosome>
chromosome
- the chromosome to be copiedpublic final void cross(DoubleChromosome chromosome, int from)
Chromosome
cross
in interface Chromosome<DoubleChromosome>
chromosome
- the chromosome to cross withfrom
- the start position of the genes to exchangepublic final void cross(DoubleChromosome chromosome, int from, int to)
Chromosome
cross
in interface Chromosome<DoubleChromosome>
chromosome
- the chromosome to cross withfrom
- the start position of the genes to exchangeto
- the final position of the genes to exchangepublic final double getValue(int pos)
pos
- a position of this chromosome
public final double[] getValues()
public final double[] getValues(double[] values)
values
- the array to fill
public final void setDefaultValue(double defaultValue)
defaultValue
- the new default value to be usedpublic final double getDefaultValue()
public final void setValue(int pos, double value)
pos
- the position to be modifyvalue
- the value to be insertpublic final java.lang.String toString()
toString
in class java.lang.Object
public final double getLowerBound()
public final double getUpperBound()
public final boolean equals(DoubleChromosome chromosome)
equals
in interface Chromosome<DoubleChromosome>
chromosome
- the chromosome to compare to.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |