org.jgap.impl
Class NumberGene
- java.lang.Object
-
- org.jgap.BaseGene
-
- org.jgap.impl.NumberGene
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable, Gene, IBusinessKey, IUniqueKey
- Direct Known Subclasses:
- DoubleGene, IntegerGene, MutipleIntegerGene
public abstract class NumberGene extends BaseGene
Base class for all Genes based on numbers.- Since:
- 1.1 (most code moved and adapted from IntegerGene)
- See Also:
- Serialized Form
-
-
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
Constructors Constructor and Description NumberGene(Configuration a_config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intcompareTo(java.lang.Object a_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.voidsetAllele(java.lang.Object a_newValue)Sets the value (allele) of this Gene to the new given value.-
Methods inherited from class org.jgap.BaseGene
cleanup, equals, getAllele, getApplicationData, getBusinessKey, getConfiguration, getConstraintChecker, getEnergy, getUniqueID, getUniqueIDTemplate, hashCode, isCompareApplicationData, newGene, setApplicationData, setCompareApplicationData, setConstraintChecker, setEnergy, setUniqueIDTemplate, size, toString
-
Methods inherited from interface org.jgap.Gene
applyMutation, getPersistentRepresentation, setToRandomValue, setValueFromPersistentRepresentation
-
-
-
-
Constructor Detail
-
NumberGene
public NumberGene(Configuration a_config) throws InvalidConfigurationException
- Throws:
InvalidConfigurationException
-
-
Method Detail
-
compareTo
public int compareTo(java.lang.Object a_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.- Parameters:
a_other- the NumberGene to be compared to this NumberGene- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the object provided for comparison
- Throws:
java.lang.ClassCastException- if the specified object's type prevents it from being compared to this NumberGene- Since:
- 1.1
-
setAllele
public void setAllele(java.lang.Object a_newValue)
Sets the value (allele) of this Gene to the new given value. This class expects the value to be an instance of current type (e.g. Integer). If the value is above or below the upper or lower bounds, it will be mappped to within the allowable range.- Parameters:
a_newValue- the new value of this Gene instance- Since:
- 1.1
-
-
DMelt 3.0 © DataMelt by jWork.ORG