| java.lang.Object org.jgap.BaseGene org.jgap.impl.NumberGene org.jgap.impl.IntegerGene
IntegerGene | public class IntegerGene extends NumberGene implements IPersistentRepresentation(Code) | | A Gene implementation that supports an 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.
author: Neil Rotstan author: Klaus Meffert since: 1.0 |
Field Summary | |
final protected static long | INTEGER_RANGE Represents the constant range of values supported by integers. |
Constructor Summary | |
public | IntegerGene() Constructs a new IntegerGene with default settings. | public | IntegerGene(Configuration a_config) Constructs a new IntegerGene with default settings. | public | IntegerGene(Configuration a_config, 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 | |
public void | applyMutation(int a_index, double a_percentage) See interface Gene for description. | protected int | compareToNative(Object a_o1, Object a_o2) Compares to objects by first casting them into their expected type
(e.g. | public int | getLowerBounds() | public 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. | public int | getUpperBounds() | public int | hashCode() Modified hashCode() function to return different hashcodes for differently
ordered genes in a chromosome. | public 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. | protected Gene | newGeneInternal() Provides implementation-independent means for creating new Gene
instances. | public void | setToRandomValue(RandomGenerator 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.
Parameters: a_numberGenerator - the random number generator that should beused to create any random values. | public void | setValueFromPersistentRepresentation(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. | public String | toString() |
INTEGER_RANGE | final protected static long INTEGER_RANGE(Code) | | Represents the constant range of values supported by integers.
|
IntegerGene | public IntegerGene() throws InvalidConfigurationException(Code) | | Constructs a new IntegerGene with default settings. No bounds will
be put into effect for values (alleles) of this Gene instance, other
than the standard range of integer values.
Attention: The configuration used is the one set with the static method
Genotype.setConfiguration.
throws: InvalidConfigurationException - author: Neil Rostan author: Klaus Meffert since: 1.0 |
IntegerGene | public IntegerGene(Configuration a_config) throws InvalidConfigurationException(Code) | | Constructs a new IntegerGene with default settings. No bounds will
be put into effect for values (alleles) of this Gene instance, other
than the standard range of integer values.
Parameters: a_config - the configuration to use throws: InvalidConfigurationException - author: Klaus Meffert since: 3.0 |
IntegerGene | public IntegerGene(Configuration a_config, int a_lowerBounds, int a_upperBounds) throws InvalidConfigurationException(Code) | | Constructs a new IntegerGene with the specified lower and upper
bounds for values (alleles) of this Gene instance.
Parameters: a_config - the configuration to use Parameters: a_lowerBounds - the lowest value that this Gene may possess,inclusive Parameters: a_upperBounds - the highest value that this Gene may possess,inclusive throws: InvalidConfigurationException - author: Klaus Meffert since: 2.0 |
applyMutation | public void applyMutation(int a_index, double a_percentage)(Code) | | See interface Gene for description.
Parameters: a_index - ignored (because there is only 1 atomic element) Parameters: a_percentage - percentage of mutation (greater than -1 and smallerthan 1) author: Klaus Meffert since: 1.1 |
compareToNative | protected int compareToNative(Object a_o1, Object a_o2)(Code) | | Compares to objects by first casting them into their expected type
(e.g. Integer for IntegerGene) and then calling the compareTo-method
of the casted type.
Parameters: a_o1 - first object to be compared, always is not null Parameters: a_o2 - second object to be compared, always is not null a negative integer, zero, or a positive integer as this objectis less than, equal to, or greater than the object provided for comparison author: Neil Rostan since: 1.0 |
getLowerBounds | public int getLowerBounds()(Code) | | the lower bounds of the integer gene author: Klaus Meffert since: 2.6 |
getPersistentRepresentation | public String getPersistentRepresentation()(Code) | | 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. This string will be used to represent this
Gene in XML persistence. This is an optional method but, if not
implemented, XML persistence and possibly other features will not be
available. An UnsupportedOperationException should be thrown if no
implementation is provided.
string representation of this Gene's current state author: Neil Rostan since: 1.0 |
getUpperBounds | public int getUpperBounds()(Code) | | the upper bounds of the integer gene author: Klaus Meffert since: 2.6 |
hashCode | public int hashCode()(Code) | | Modified hashCode() function to return different hashcodes for differently
ordered genes in a chromosome.
-1 if no allele set, otherwise value return by BaseGene.hashCode() author: Klaus Meffert since: 2.2 |
intValue | public int intValue()(Code) | | Retrieves the int value of this Gene, which may be more convenient in
some cases than the more general getAllele() method.
the int value of this Gene author: Neil Rostan since: 1.0 |
mapValueToWithinBounds | protected void mapValueToWithinBounds()(Code) | | Maps the value of this IntegerGene to within the bounds specified by
the m_upperBounds and m_lowerBounds instance variables. The value's
relative position within the integer range will be preserved within the
bounds range (in other words, if the value is about halfway between the
integer max and min, then the resulting value will be about halfway
between the upper bounds and lower bounds). If the value is null or
is already within the bounds, it will be left unchanged.
author: Neil Rostan author: Klaus Meffert since: 1.0 |
newGeneInternal | protected Gene newGeneInternal()(Code) | | Provides implementation-independent means for creating new Gene
instances.
a new Gene instance of the same type and with the same setup asthis concrete Gene author: Klaus Meffert since: 2.6 (was newGene since 1.0, moved to BaseGene) |
setToRandomValue | public void setToRandomValue(RandomGenerator a_numberGenerator)(Code) | | Sets the value (allele) of this Gene to a random Integer value between
the lower and upper bounds (if any) of this Gene.
Parameters: a_numberGenerator - the random number generator that should beused to create any random values. It's important to use this generator tomaintain the user's flexibility to configure the genetic engine to use therandom number generator of their choice author: Neil Rostan author: Klaus Meffert since: 1.0 |
setValueFromPersistentRepresentation | public void setValueFromPersistentRepresentation(String a_representation) throws UnsupportedRepresentationException(Code) | | Sets the value and internal state of this Gene from the string
representation returned by a previous invocation of the
getPersistentRepresentation() method. This is an optional method but,
if not implemented, XML persistence and possibly other features will not
be available. An UnsupportedOperationException should be thrown if no
implementation is provided.
Parameters: a_representation - the string representation retrieved from aprior call to the getPersistentRepresentation() method throws: UnsupportedOperationException - to indicate that no implementationis provided for this method throws: UnsupportedRepresentationException - if this Gene implementationdoes not support the given string representation author: Neil Rostan since: 1.0 |
toString | public String toString()(Code) | | string representation of this Gene's value that may be useful fordisplay purposes author: Klaus Meffert since: 2.4 |
|
|