|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgap.impl.StringGene
A Gene implementation that supports a string for its allele. The valid alphabet as well as the minimum and maximum length of the string can be specified.
An alphabet == null indicates that all characters are seen as valid.
An alphabet == "" indicates that no character is seen to be valid.
Partly copied from IntegerGene.
| Field Summary | |
static java.lang.String |
ALPHABET_CHARACTERS_DIGITS
|
static java.lang.String |
ALPHABET_CHARACTERS_LOWER
|
static java.lang.String |
ALPHABET_CHARACTERS_SPECIAL
|
static java.lang.String |
ALPHABET_CHARACTERS_UPPER
|
| Fields inherited from interface org.jgap.Gene |
PERSISTENT_FIELD_DELIMITER |
| Constructor Summary | |
StringGene()
|
|
StringGene(int a_minLength,
int a_maxLength)
|
|
StringGene(int a_minLength,
int a_maxLength,
java.lang.String a_alphabet)
|
|
| Method Summary | |
void |
applyMutation(int index,
double a_percentage)
Applies a mutation of a given intensity (percentage) onto the atomic element at given index (NumberGenes only have one atomic element) |
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 StringGene with the specified object (which must also be a StringGene) for order, which is determined by the String value of this Gene compared to the one provided for comparison. |
boolean |
equals(java.lang.Object other)
Compares this Gene with the given object and returns true if the other object is a Gene of this type and has the same value (allele) as this Gene. |
java.lang.Object |
getAllele()
Retrieves the value (allele) represented by this Gene. |
java.lang.String |
getAlphabet()
|
IGeneConstraintChecker |
getConstraintChecker()
|
int |
getMaxLength()
|
int |
getMinLength()
|
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 for this StringGene. |
Gene |
newGene()
Provides an implementation-independent means for creating new Gene instances. |
void |
setAllele(java.lang.Object a_newValue)
Sets the value (allele) of this Gene to the new given value. |
void |
setAlphabet(java.lang.String a_alphabet)
Sets the valid alphabet of the StringGene |
void |
setConstraintChecker(IGeneConstraintChecker a_constraintChecker)
Sets the constraint checker to be used for this gene whenever method setAllele(Object a_newValue) is called |
void |
setMaxLength(int m_maxLength)
|
void |
setMinLength(int m_minLength)
|
void |
setToRandomValue(RandomGenerator a_numberGenerator)
Sets the value (allele) of this Gene to a random String according to the valid alphabet and boundaries of length |
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 |
stringValue()
Retrieves the String value of this Gene, which may be more convenient in some cases than the more general getAllele() method. |
java.lang.String |
toString()
Retrieves a string representation of this StringGene's value that may be useful for display purposes. |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String ALPHABET_CHARACTERS_UPPER
public static final java.lang.String ALPHABET_CHARACTERS_LOWER
public static final java.lang.String ALPHABET_CHARACTERS_DIGITS
public static final java.lang.String ALPHABET_CHARACTERS_SPECIAL
| Constructor Detail |
public StringGene()
public StringGene(int a_minLength,
int a_maxLength)
a_minLength - minimum valid length of allelea_maxLength - maximum valid length of allele
public StringGene(int a_minLength,
int a_maxLength,
java.lang.String a_alphabet)
a_minLength - minimum valid length of allelea_maxLength - maximum valid length of allelea_alphabet - valid aplhabet for allele| Method Detail |
public void cleanup()
cleanup in interface Genepublic void setToRandomValue(RandomGenerator a_numberGenerator)
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 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.String getPersistentRepresentation()
throws java.lang.UnsupportedOperationException
getPersistentRepresentation in interface Genejava.lang.UnsupportedOperationException - to indicate that no implementation
is provided for this method.public java.lang.Object getAllele()
getAllele in interface Genepublic void setAllele(java.lang.Object a_newValue)
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 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 int compareTo(java.lang.Object other)
compareTo in interface java.lang.Comparableother - the StringGene to be compared to this StringGene.
java.lang.ClassCastException - if the specified object's type prevents it
from being compared to this StringGene.public int size()
size in interface Genepublic int getMaxLength()
public int getMinLength()
public void setMinLength(int m_minLength)
public void setMaxLength(int m_maxLength)
public java.lang.String getAlphabet()
public void setAlphabet(java.lang.String a_alphabet)
a_alphabet - valid aplhabet for allelepublic java.lang.String toString()
toString in interface Genepublic boolean equals(java.lang.Object other)
other - the object to compare to this Gene for equality.
public int hashCode()
public java.lang.String stringValue()
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 | |||||||||