|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgap.Allele
org.jgap.impl.IntegerAllele
A Gene implementation that supports a integer values for its allele. Upper and lower bounds may optionally be provided to restrict the range of legal values allowed by this Gene instance.
Field Summary | |
protected static long |
INTEGER_RANGE
Represents the constant range of values supported by integers. |
protected Configuration |
m_activeConfiguration
The current active configuration that is in use. |
protected long |
m_boundsUnitsToIntegerUnits
Stores the number of integer range units that a single bounds-range unit represents. |
protected int |
m_lowerBounds
The lower bounds of values represented by this Gene. |
protected int |
m_upperBounds
The upper bounds of values represented by this Gene. |
protected java.lang.Integer |
m_value
References the internal integer value (allele) of this Gene. |
protected static java.lang.String |
PERSISTENT_FIELD_DELIMITER
Represents the delimiter that is used to separate fields in the persistent representation of IntegerGene instances. |
Constructor Summary | |
IntegerAllele()
Constructs a new IntegerGene with default settings. |
|
IntegerAllele(Configuration a_activeConfiguration)
Constructs a new IntegerGene according to the given active configuration. |
|
IntegerAllele(Configuration a_activeConfiguration,
int a_lowerBounds,
int a_upperBounds)
Constructs a new IntegerGene with the given active configuration and the specified lower and upper bounds for values represented by this Gene. |
|
IntegerAllele(int a_lowerBounds,
int a_upperBounds)
Constructs a new IntegerGene with the specified lower and upper bounds for values (alleles) of this Gene instance. |
Method Summary | |
protected void |
calculateBoundsUnitsToIntegerUnitsRatio()
Calculates and sets the m_boundsUnitsToIntegerUnits field based on the current lower and upper bounds of this IntegerGene. |
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)
|
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. |
java.lang.Integer |
getValue()
|
int |
hashCode()
Retrieves the hash code value for this IntegerGene. |
int |
intValue()
Retrieves the int value of this Gene, which may be more convenient in some cases than the more general getAllele() method. |
protected void |
mapValueToWithinBounds()
Maps the value of this IntegerGene to within the bounds specified by the m_upperBounds and m_lowerBounds instance variables. |
Allele |
newAllele(Configuration a_activeConfiguration)
Provides an implementation-independent means for creating new Gene instances. |
void |
setToRandomValue(java.util.Random a_numberGenerator)
Sets the value (allele) of this Gene to a random Integer value between the lower and upper bounds (if any) of this Gene. |
void |
setValue(java.lang.Integer a_newValue)
Sets the value (allele) 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 IntegerGene's value that may be useful for display purposes. |
java.lang.String |
toXml()
|
Methods inherited from class org.jgap.Allele |
compareTo, equals, getGene, getGenes, getInnovationId |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final long INTEGER_RANGE
protected static final java.lang.String PERSISTENT_FIELD_DELIMITER
protected java.lang.Integer m_value
protected int m_upperBounds
protected int m_lowerBounds
protected long m_boundsUnitsToIntegerUnits
protected Configuration m_activeConfiguration
Constructor Detail |
public IntegerAllele()
public IntegerAllele(int a_lowerBounds, int a_upperBounds)
a_lowerBounds
- The lowest value that this Gene may possess, inclusive.a_upperBounds
- The highest value that this Gene may possess, inclusive.public IntegerAllele(Configuration a_activeConfiguration)
a_activeConfiguration
- The current active configuration.public IntegerAllele(Configuration a_activeConfiguration, int a_lowerBounds, int a_upperBounds)
a_activeConfiguration
- The current active configuration.a_lowerBounds
- The lowest value that this Gene may represent, inclusive.a_upperBounds
- The highest value that this Gene may represent, inclusive.Method Detail |
public java.lang.String toXml()
public double distance(Allele target)
distance
in class Allele
target
-
Allele.distance(Allele)
public Allele newAllele(Configuration a_activeConfiguration)
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.
a_activeConfiguration
- The current active configuration.
public Allele cloneAllele()
cloneAllele
in class Allele
Allele.cloneAllele()
public void setValue(java.lang.Integer a_newValue)
a_newValue
- the new value of this Gene instance.public java.lang.Integer getValue()
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 int intValue()
public void setToRandomValue(java.util.Random a_numberGenerator)
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 int hashCode()
hashCode
in class Allele
Object.hashCode()
public java.lang.String toString()
toString
in class Allele
Object.toString()
public void cleanup()
protected void mapValueToWithinBounds()
protected void calculateBoundsUnitsToIntegerUnitsRatio()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |