|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgap.impl.FixedBinaryGene
A Gene implementation that supports two possible values (alleles, 1 and 0) with a fixed length of alleles
NOTE: Since this Gene implementation only supports two different values (1 and 0), there's only a 50% chance that invocation of the setToRandomValue() method will actually change the value of this Gene (if it has a value). As a result, it may be desirable to use a higher overall mutation rate when this Gene implementation is in use.
Partly adapted stuff from the JAGA (Java API for Genetic Algorithms) package (see http://www.jaga.org).
| Field Summary |
| Fields inherited from interface org.jgap.Gene |
PERSISTENT_FIELD_DELIMITER |
| Constructor Summary | |
FixedBinaryGene(FixedBinaryGene toCopy)
|
|
FixedBinaryGene(int a_length)
|
|
| Method Summary | |
void |
applyMutation(int index,
double a_percentage)
Applies a mutation of a given intensity (percentage) onto the atomic element at given index |
void |
cleanup()
Executed by the genetic engine when this Gene instance is no longer needed and should perform any necessary resource cleanup. |
java.lang.Object |
clone()
|
int |
compareTo(java.lang.Object other)
Compares this Gene with the specified object for order. |
boolean |
equals(java.lang.Object other)
Compares this Gene with the given object and returns true if the other object is a FixedBinaryGene and has the same value as this Gene. |
void |
flip(int index)
|
java.lang.Object |
getAllele()
Retrieves the value represented by this Gene. |
boolean |
getBit(int m_index)
|
IGeneConstraintChecker |
getConstraintChecker()
|
int[] |
getIntValues()
|
int |
getLength()
|
java.lang.String |
getPersistentRepresentation()
Retrieves a string representation of the value of this Gene instance that includes any information required to reconstruct it at a later time, such as its value and internal state. |
int |
hashCode()
Retrieves the hash code value of this Gene. |
Gene |
newGene()
Provides an implementation-independent means for creating new Gene instances. |
void |
setAllele(java.lang.Object a_newValue)
Sets the value of this Gene to the new given value. |
void |
setBit(int m_index,
boolean m_value)
|
void |
setBit(int m_index,
int m_value)
|
void |
setBit(int m_from,
int m_to,
boolean m_value)
|
void |
setBit(int from,
int to,
FixedBinaryGene values)
|
void |
setConstraintChecker(IGeneConstraintChecker a_constraintChecker)
Sets the constraint checker to be used for this gene whenever method setAllele(Object a_newValue) is called |
void |
setToRandomValue(RandomGenerator a_numberGenerator)
Sets the value of this Gene to a random legal value for the implementation. |
void |
setUnchecked(int index,
boolean value)
|
void |
setValueFromPersistentRepresentation(java.lang.String a_representation)
Sets the value and internal state of this Gene from the string representation returned by a previous invocation of the getPersistentRepresentation() method. |
int |
size()
|
FixedBinaryGene |
substring(int m_from,
int m_to)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public FixedBinaryGene(int a_length)
a_length - the fixed length of the genepublic FixedBinaryGene(FixedBinaryGene toCopy)
| Method Detail |
public Gene newGene()
GeneIt should be noted that nothing is guaranteed about the actual value of the returned Gene and it should therefore be considered to be undefined.
newGene in interface Genepublic int getLength()
public java.lang.Object clone()
public void setAllele(java.lang.Object a_newValue)
Gene
setAllele in interface Genea_newValue - the new value of this Gene instance.public void setConstraintChecker(IGeneConstraintChecker a_constraintChecker)
a_constraintChecker - the constraint checker to be setpublic IGeneConstraintChecker getConstraintChecker()
public java.lang.Object getAllele()
Gene
getAllele in interface Genepublic int[] getIntValues()
public boolean getBit(int m_index)
public void setBit(int m_index,
boolean m_value)
public void setBit(int m_index,
int m_value)
public void setBit(int m_from,
int m_to,
boolean m_value)
public void setBit(int from,
int to,
FixedBinaryGene values)
public FixedBinaryGene substring(int m_from,
int m_to)
public void flip(int index)
public void setUnchecked(int index,
boolean value)
public java.lang.String getPersistentRepresentation()
throws java.lang.UnsupportedOperationException
Gene
getPersistentRepresentation in interface Genejava.lang.UnsupportedOperationException - to indicate that no implementation
is provided for this method.
public void setValueFromPersistentRepresentation(java.lang.String a_representation)
throws java.lang.UnsupportedOperationException,
UnsupportedRepresentationException
setValueFromPersistentRepresentation in interface Genea_representation - the string representation retrieved from a
prior call to the getPersistentRepresentation()
method.
java.lang.UnsupportedOperationException - to indicate that no implementation
is provided for this method.
UnsupportedRepresentationException - if this Gene implementation
does not support the given string representation.public void setToRandomValue(RandomGenerator a_numberGenerator)
Gene
setToRandomValue in interface Genea_numberGenerator - The random number generator that should be
used to create any random values. It's important
to use this generator to maintain the user's
flexibility to configure the genetic engine
to use the random number generator of their
choice.public void cleanup()
cleanup in interface Genepublic java.lang.String toString()
toString in interface Genepublic int size()
size in interface Genepublic int hashCode()
public void applyMutation(int index,
double a_percentage)
applyMutation in interface Geneindex - index of atomic element, between 0 and size()-1a_percentage - percentage of mutation (greater than -1 and smaller
than 1).public boolean equals(java.lang.Object other)
other - the object to compare to this Gene for equality.
public int compareTo(java.lang.Object other)
compareTo in interface java.lang.Comparableother - the FixedBinaryGene to be compared.
java.lang.ClassCastException - if the specified object's type prevents it
from being compared to this Gene.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||