|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jgap.BaseGene
org.jgap.impl.SetGene
public class SetGene
ATTENTION: This class is preliminary and subject of future adaptations! Use with care or wait for a more mature version we are working on.
Creates a gene instance in which individual alleles have both a label (key) and a value with a distinct meaning. For example, IntegerGene only allows for values having a continuous range, and does not have a function where it is possible to specify setValue...
| Field Summary |
|---|
| Fields inherited from class org.jgap.BaseGene |
|---|
DELTA, S_APPLICATION_DATA |
| Fields inherited from interface org.jgap.Gene |
|---|
PERSISTENT_FIELD_DELIMITER |
| Constructor Summary | |
|---|---|
SetGene()
Default constructor. |
|
SetGene(Configuration a_conf)
|
|
| Method Summary | |
|---|---|
void |
addAllele(java.lang.Object a_value)
Adds a potential allele value to the collection. |
void |
addAlleles(java.util.Collection a_alleles)
Add a set of potential allele values to the collection |
void |
applyMutation(int a_index,
double a_percentage)
See interface Gene for description of applyMutation. |
int |
compareTo(java.lang.Object other)
Compares this NumberGene with the specified object (which must also be a NumberGene) for order, which is determined by the number value of this Gene compared to the one provided for comparison. |
protected java.lang.Object |
getInternalValue()
Each Gene implementation holds its own m_value object keeping the allele value. |
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()
Modified hashCode() function to return different hashcodes for differently ordered genes in a chromosome |
protected Gene |
newGeneInternal()
|
void |
removeAlleles(java.lang.Object a_key)
Removes a potential allele or set of alleles from the collection. |
void |
setAllele(java.lang.Object a_newValue)
Sets the value (allele) of this Gene to the new given value. |
void |
setToRandomValue(RandomGenerator a_numberGenerator)
Sets the allele value to be a random value using a defined random number generator. |
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. |
| Methods inherited from class org.jgap.BaseGene |
|---|
cleanup, compareApplicationData, decode, encode, equals, getAllele, getApplicationData, getBusinessKey, getConfiguration, getConstraintChecker, getEnergy, isCompareApplicationData, newGene, setApplicationData, setCompareApplicationData, setConstraintChecker, setEnergy, size, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SetGene()
throws InvalidConfigurationException
Attention: The configuration used is the one set with the static method Genotype.setConfiguration.
InvalidConfigurationException
public SetGene(Configuration a_conf)
throws InvalidConfigurationException
a_conf - the configuration to use
InvalidConfigurationException| Method Detail |
|---|
protected Gene newGeneInternal()
newGeneInternal in class BaseGenepublic void addAllele(java.lang.Object a_value)
a_value - the Integer value to be addedpublic void addAlleles(java.util.Collection a_alleles)
a_alleles - the set of alleles to be addedpublic void removeAlleles(java.lang.Object a_key)
a_key - the unique value(s) of the object(s) to be removedpublic void setToRandomValue(RandomGenerator a_numberGenerator)
setToRandomValue in interface Genea_numberGenerator - RandomGenerator
public void applyMutation(int a_index,
double a_percentage)
applyMutation in interface Genea_index - ignored herea_percentage - ignored here
public void setValueFromPersistentRepresentation(java.lang.String a_representation)
throws UnsupportedRepresentationException
setValueFromPersistentRepresentation in interface GenesetValueFromPersistentRepresentation in interface IPersistentRepresentationa_representation - the string representation retrieved from a
prior call to the getPersistentRepresentation() 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 GenegetPersistentRepresentation in interface IPersistentRepresentationjava.lang.UnsupportedOperationException - to indicate that no implementation
is provided for this methodpublic void setAllele(java.lang.Object a_newValue)
setAllele in interface Genea_newValue - the new value of this Gene instance.public int compareTo(java.lang.Object other)
compareTo in interface java.lang.Comparableother - the NumberGene to be compared to this NumberGene
java.lang.ClassCastException - if the specified object's type prevents it
from being compared to this NumberGeneprotected java.lang.Object getInternalValue()
BaseGeneBooleanGene for example)
getInternalValue in class BaseGenepublic int hashCode()
hashCode in class BaseGene
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||