|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgap.Allele
org.jgap.impl.BooleanAllele
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 | |
protected static java.lang.Boolean |
FALSE_BOOLEAN
Shared constant representing the "false" boolean value. |
protected Configuration |
m_activeConfiguration
The current active configuration that is in use. |
protected java.lang.Boolean |
m_value
References the internal boolean value of this Gene. |
protected static java.lang.Boolean |
TRUE_BOOLEAN
Shared constant representing the "true" boolean value. |
Constructor Summary | |
BooleanAllele()
Constructs a new BooleanGene with default settings. |
|
BooleanAllele(java.lang.Long an_id)
Constructs a new BooleanGene with default settings. |
Method Summary | |
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. |
Allele |
cloneAllele()
|
double |
distance(Allele target)
|
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.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. |
void |
setToRandomValue(java.util.Random a_numberGenerator)
Sets the value (allele) of this Gene to a random legal value. |
void |
setValue(java.lang.Object a_newValue)
Sets the value of this Gene to the new given 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. |
java.lang.String |
toString()
Retrieves a string representation of this BooleanGene's value that may be useful for display purposes. |
Methods inherited from class org.jgap.Allele |
compareTo, getGene, getGenes, getInnovationId |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final java.lang.Boolean TRUE_BOOLEAN
protected static final java.lang.Boolean FALSE_BOOLEAN
protected java.lang.Boolean m_value
protected Configuration m_activeConfiguration
Constructor Detail |
public BooleanAllele()
public BooleanAllele(java.lang.Long an_id)
an_id
- Method Detail |
public Allele cloneAllele()
cloneAllele
in class Allele
public void setValue(java.lang.Object a_newValue)
a_newValue
- the new value of this Gene instance.public java.lang.String getPersistentRepresentation() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- to indicate that no implementation
is provided for this method.public void setValueFromPersistentRepresentation(java.lang.String a_representation) throws UnsupportedRepresentationException
a_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 boolean booleanValue()
public void setToRandomValue(java.util.Random 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 class Allele
a_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 boolean equals(java.lang.Object other)
equals
in class Allele
other
- the object to compare to this BooleanGene for equality.
Object.equals(java.lang.Object)
public int hashCode()
hashCode
in class Allele
Object.hashCode()
public java.lang.String toString()
toString
in class Allele
Object.toString()
public void cleanup()
public double distance(Allele target)
distance
in class Allele
target
- should be same implementation class and same innovation ID as this gene
Allele.distance(org.jgap.Allele)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |