|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jenes.chromosome.BooleanChromosome
public final class BooleanChromosome
A BooleanChromosome is made of an array of booleans. Each gene can assume the value true or false.
A faster and less memory demanding alternative to BooleanChromosome is provided by BitwiseChromosome
with BooleanCoding
.
Constructor Summary | |
---|---|
BooleanChromosome(BooleanChromosome chromosome)
Creates a new BooleanChromosome with the specified chromosome |
|
BooleanChromosome(int size)
Creates a new BooleanChromosome with the specified chromosome length |
Method Summary | |
---|---|
BooleanChromosome |
clone()
Performs a chromosome deep-cloning. |
void |
cross(BooleanChromosome chromosome,
int from)
Exchanges the genes chromosome starting from a given position |
void |
cross(BooleanChromosome chromosome,
int from,
int to)
Exchanges the genes chromosome within the range [from,to] |
boolean |
equals(BooleanChromosome chromosome)
Compares the chromosome with another. |
boolean |
getDefaultValue()
Returns the default value of this chromosome |
boolean |
getValue(int pos)
Returns the boolean value at the specified position |
boolean[] |
getValues()
Returns the boolean values |
boolean[] |
getValues(boolean[] 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(BooleanChromosome chromosome)
Makes the chromosome a copy of another chromosome. |
void |
setDefaultValue(boolean defaultValue)
Sets the default value of this chromosome |
void |
setDefaultValueAt(int pos)
Sets the default value at a given position |
void |
setValue(int pos,
boolean value)
Sets the specified value at the specified position |
void |
setValueAt(boolean value,
int position)
Sets a new boolean value at the specified position |
void |
swap(int pos1,
int pos2)
Exchanges two genes at the specified positions |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BooleanChromosome(BooleanChromosome chromosome)
chromosome
- the parameters source chromosomepublic BooleanChromosome(int size)
size
- the chromosome lengthMethod Detail |
---|
public final void setDefaultValueAt(int pos)
Chromosome
setDefaultValueAt
in interface Chromosome<BooleanChromosome>
pos
- the position where to set the default valuepublic final BooleanChromosome clone()
Chromosome
clone
in interface Chromosome<BooleanChromosome>
clone
in class java.lang.Object
public final void randomize()
Chromosome
randomize
in interface Chromosome<BooleanChromosome>
public final void randomize(int pos)
Chromosome
randomize
in interface Chromosome<BooleanChromosome>
pos
- a position where to set the random valuepublic final void swap(int pos1, int pos2)
Chromosome
swap
in interface Chromosome<BooleanChromosome>
pos1
- the position of first genepos2
- the position of second genepublic final void leftShift(int from, int to)
Chromosome
leftShift
in interface Chromosome<BooleanChromosome>
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<BooleanChromosome>
from
- the start position to be shiftedto
- the final position to be shiftedpublic final int length()
Chromosome
length
in interface Chromosome<BooleanChromosome>
public final void setAs(BooleanChromosome chromosome)
Chromosome
setAs
in interface Chromosome<BooleanChromosome>
chromosome
- the chromosome to be copiedpublic final void cross(BooleanChromosome chromosome, int from)
Chromosome
cross
in interface Chromosome<BooleanChromosome>
chromosome
- the chromosome to cross withfrom
- the start position of the genes to exchangepublic final void cross(BooleanChromosome chromosome, int from, int to)
Chromosome
cross
in interface Chromosome<BooleanChromosome>
chromosome
- the chromosome to cross withfrom
- the start position of the genes to exchangeto
- the final position of the genes to exchangepublic final boolean getValue(int pos)
pos
- a gene position
public final boolean[] getValues()
public final void setValueAt(boolean value, int position)
value
- the value to be setposition
- the position to modifypublic final boolean[] getValues(boolean[] values)
values
- the array to fill
public final void setDefaultValue(boolean defaultValue)
defaultValue
- the new default value to be usedpublic final boolean getDefaultValue()
public final void setValue(int pos, boolean value)
pos
- the position to be modifyvalue
- the value to be setpublic final java.lang.String toString()
toString
in class java.lang.Object
public final boolean equals(BooleanChromosome chromosome)
Chromosome
equals
in interface Chromosome<BooleanChromosome>
chromosome
- the cromosome to compare to.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |