|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Gene
Genes represent the discrete components of a potential solution (the Chromosome). This interface exists so that custom gene implementations can be easily plugged-in, which can add a great deal of flexibility and convenience for many applications. Note that it's very important that implementations of this interface also implement the equals() method. Without a proper implementation of equals(), some genetic operations will fail to work properly.
When implementing a new Gene type, extend it from BaseGene!
| Field Summary | |
|---|---|
static java.lang.String |
CVS_REVISION
String containing the CVS revision. |
static java.lang.String |
PERSISTENT_FIELD_DELIMITER
Represents the delimiter that is used to separate fields in the persistent representation. |
| 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. |
java.lang.Object |
getAllele()
Retrieves the value represented by this Gene. |
java.lang.Object |
getApplicationData()
Retrieves the application-specific data that is attached to this Gene. |
Configuration |
getConfiguration()
|
double |
getEnergy()
|
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. |
boolean |
isCompareApplicationData()
|
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 |
setApplicationData(java.lang.Object a_newData)
This sets the application-specific data that is attached to this Gene. |
void |
setCompareApplicationData(boolean a_doCompare)
Should we also consider the application data when comparing? |
void |
setConstraintChecker(IGeneConstraintChecker a_constraintChecker)
Sets the constraint checker to be used for this gene whenever method setAllele(Object) is called. |
void |
setEnergy(double a_energy)
Sets the energy of the gene |
void |
setToRandomValue(RandomGenerator a_numberGenerator)
Sets the value of this Gene to a random legal value for the implementation. |
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()
|
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Methods inherited from interface org.jgap.IUniqueKey |
|---|
getUniqueID, getUniqueIDTemplate, setUniqueIDTemplate |
| Field Detail |
|---|
static final java.lang.String CVS_REVISION
static final java.lang.String PERSISTENT_FIELD_DELIMITER
| Method Detail |
|---|
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.
void setAllele(java.lang.Object a_newValue)
a_newValue - the new value of this Gene instancejava.lang.Object getAllele()
java.lang.String getPersistentRepresentation()
throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - to indicate that no implementation
is provided for this method
void setValueFromPersistentRepresentation(java.lang.String a_representation)
throws java.lang.UnsupportedOperationException,
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 representationvoid setToRandomValue(RandomGenerator a_numberGenerator)
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 choicevoid cleanup()
java.lang.String toString()
toString in class java.lang.Objectint size()
void applyMutation(int index,
double a_percentage)
index - index of atomic element, between 0 and size()-1a_percentage - percentage of mutation (greater than -1 and smaller
than 1).void setApplicationData(java.lang.Object a_newData)
a_newData - the new application-specific data to attach to this
Genejava.lang.Object getApplicationData()
void setCompareApplicationData(boolean a_doCompare)
a_doCompare - true: consider application data in method compareToboolean isCompareApplicationData()
double getEnergy()
void setEnergy(double a_energy)
a_energy - the energy to setvoid setConstraintChecker(IGeneConstraintChecker a_constraintChecker)
a_constraintChecker - the constraint checker to be setConfiguration getConfiguration()
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||