|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jenes.chromosome.IntegerChromosome
public final class IntegerChromosome
An IntegerChromosome is made of an array of integers. Each value (i.e. allele) is within the range [lowerBound,upperBound]. Both bounds are included. These bounds are specified ad the instantiation time. IntegerChromosome is a fixed length chromosome. Thus the numebr of genes is specified at the instantiation time and cannot be modified after.
Chromosome
Constructor Summary | |
---|---|
IntegerChromosome(IntegerChromosome chromosome)
Creates a new IntegerIndividual with the specified chromosome |
|
IntegerChromosome(int length,
int lowerBound,
int upperBound)
Creates a new IntegerIndividual with each allele in the range [lowerBound, upperBound] |
Method Summary | |
---|---|
IntegerChromosome |
clone()
Performs a chromosome deep-cloning. |
void |
cross(IntegerChromosome chromosome,
int from)
Exchanges the genes chromosome starting from a given position |
void |
cross(IntegerChromosome chromosome,
int from,
int to)
Exchanges the genes chromosome within the range [from,to] |
boolean |
equals(IntegerChromosome chromosome)
Compares the chromosome with another. |
int |
getDefaultValue()
Returns the default value of this chromosome |
int |
getLowerBound()
Returns the lower bound value for a gene of this chromosome |
int |
getUpperBound()
Returns the upper bound value for a gene of this chromosome |
int |
getValue(int pos)
Returns the integer value at the specified position |
int[] |
getValues()
Returns the integer values |
int[] |
getValues(int[] 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(IntegerChromosome chromosome)
Makes the chromosome a copy of another chromosome. |
void |
setDefaultValue(int defaultValue)
Sets the default value of this chromosome |
void |
setDefaultValueAt(int pos)
Sets the default value at a given position |
void |
setValue(int pos,
int 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 IntegerChromosome(IntegerChromosome chromosome)
chromosome
- the parameters source chromosomepublic IntegerChromosome(int length, int lowerBound, int upperBound)
length
- the chromosome lengthlowerBound
- the allele lower boundupperBound
- the allele upper boundMethod Detail |
---|
public final int getLowerBound()
public final int getUpperBound()
public final void setDefaultValueAt(int pos)
Chromosome
setDefaultValueAt
in interface Chromosome<IntegerChromosome>
pos
- the position where to set the default valuepublic final IntegerChromosome clone()
Chromosome
clone
in interface Chromosome<IntegerChromosome>
clone
in class java.lang.Object
public final void randomize()
Chromosome
randomize
in interface Chromosome<IntegerChromosome>
public final void swap(int pos1, int pos2)
Chromosome
swap
in interface Chromosome<IntegerChromosome>
pos1
- the position of first genepos2
- the position of second genepublic final void randomize(int pos)
Chromosome
randomize
in interface Chromosome<IntegerChromosome>
pos
- a position where to set the random valuepublic final void leftShift(int from, int to)
Chromosome
leftShift
in interface Chromosome<IntegerChromosome>
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<IntegerChromosome>
from
- the start position to be shiftedto
- the final position to be shiftedpublic final int length()
Chromosome
length
in interface Chromosome<IntegerChromosome>
public final void setAs(IntegerChromosome chromosome)
Chromosome
setAs
in interface Chromosome<IntegerChromosome>
chromosome
- the chromosome to be copiedpublic final void cross(IntegerChromosome chromosome, int from)
Chromosome
cross
in interface Chromosome<IntegerChromosome>
chromosome
- the chromosome to cross withfrom
- the start position of the genes to exchangepublic final void cross(IntegerChromosome chromosome, int from, int to)
Chromosome
cross
in interface Chromosome<IntegerChromosome>
chromosome
- the chromosome to cross withfrom
- the start position of the genes to exchangeto
- the final position of the genes to exchangepublic final int getValue(int pos)
pos
- a position into this population
public final int[] getValues()
public final int[] getValues(int[] values)
values
- the array to fill
public final void setDefaultValue(int defaultValue)
defaultValue
- the new default value to be usedpublic final int getDefaultValue()
public final void setValue(int pos, int 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 boolean equals(IntegerChromosome chromosome)
equals
in interface Chromosome<IntegerChromosome>
chromosome
- the chromosome to compare to.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |