|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgap.impl.BooleanGene
A Gene implementation that supports two possible values (alleles) for each gene: true and false.
NOTE: Since this Gene implementation only supports two different values (true and false), 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.
| Field Summary |
| Fields inherited from interface org.jgap.Gene |
PERSISTENT_FIELD_DELIMITER |
| Constructor Summary | |
BooleanGene()
Constructs a new BooleanGene with default settings. |
|
| Method Summary | |
void |
applyMutation(int index,
double a_percentage)
Applies a mutation of a given intensity (percentage) onto the atomic element at given index |
boolean |
booleanValue()
Retrieves the boolean value of this Gene. |
void |
cleanup()
Executed by the genetic engine when this Gene instance is no longer needed and should perform any necessary resource cleanup. |
int |
compareTo(java.lang.Object other)
Compares this BooleanGene with the specified object for order. |
boolean |
equals(java.lang.Object other)
Compares this BooleanGene with the given object and returns true if the other object is a BooleanGene and has the same value as this BooleanGene. |
java.lang.Object |
getAllele()
Retrieves the value represented by this Gene. |
java.lang.String |
getPersistentRepresentation()
Retrieves a string representation of this Gene 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 BooleanGene. |
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 |
setToRandomValue(RandomGenerator a_numberGenerator)
Sets the value (allele) of this Gene to a random legal 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()
|
java.lang.String |
toString()
Retrieves a string representation of this BooleanGene's value that may be useful for display purposes. |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public BooleanGene()
| Method Detail |
public Gene newGene()
It 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 void setAllele(java.lang.Object a_newValue)
setAllele in interface Genea_newValue - the new value of this Gene instance.
public java.lang.String getPersistentRepresentation()
throws java.lang.UnsupportedOperationException
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 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 java.lang.Object getAllele()
getAllele in interface Genepublic boolean booleanValue()
public void setToRandomValue(RandomGenerator a_numberGenerator)
NOTE: Since this Gene implementation only supports two different values (true and false), there's only a 50% chance that invocation of this 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.
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 int compareTo(java.lang.Object other)
compareTo in interface java.lang.Comparableother - the BooleanGene to be compared.
java.lang.ClassCastException - if the specified object's type prevents it
from being compared to this BooleanGene.public boolean equals(java.lang.Object other)
other - the object to compare to this BooleanGene for equality.
public int hashCode()
public java.lang.String toString()
toString in interface Genepublic void cleanup()
cleanup in interface Genepublic int size()
size in interface Gene
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).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||