Package evo.search.ga
Class DiscreteGene
- java.lang.Object
-
- evo.search.ga.DiscreteGene
-
- All Implemented Interfaces:
XmlEntity<DiscreteGene>,io.jenetics.Gene<Point2D,DiscreteGene>,io.jenetics.util.Factory<DiscreteGene>,io.jenetics.util.Verifiable,Serializable,Cloneable
public class DiscreteGene extends Object implements io.jenetics.Gene<Point2D,DiscreteGene>, Serializable, Cloneable, XmlEntity<DiscreteGene>
Discrete genome carrying aPoint2Dallele.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DiscreteGene(int positions, int position, double distance)Convenience constructor.DiscreteGene(short positions, short position, float distance)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Point2Dallele()protected booleancanEqual(Object other)DiscreteGeneclone()Clones theDiscreteGene.doubledistance(DiscreteGene other)Calculate the euclidean distance to anotherDiscreteGene.booleanequals(Object o)floatgetDistance()The genes distance corresponding the the alleles distance.shortgetPosition()The discrete genes position index.shortgetPositions()Configuration providing context for the gene.inthashCode()booleanisValid()Checks, if a gene is valid.DiscreteGenenewInstance()DiscreteGenenewInstance(Point2D value)DiscreteGeneparse(org.dom4j.Element element)Parse aElementand return the entity.StringprintSmall()Prints a small gene representation of the form (4, 5.9).org.dom4j.Elementserialize()Serialize the entity into aElement.voidsetDistance(float distance)The genes distance corresponding the the alleles distance.voidsetPosition(short position)The discrete genes position index.voidsetPositions(short positions)Configuration providing context for the gene.StringtoString()
-
-
-
Constructor Detail
-
DiscreteGene
public DiscreteGene(int positions, int position, double distance)Convenience constructor.- Parameters:
positions- amount of raysposition- index of raydistance- distance from origin
-
DiscreteGene
public DiscreteGene(short positions, short position, float distance)
-
-
Method Detail
-
allele
public Point2D allele()
- Specified by:
allelein interfaceio.jenetics.Gene<Point2D,DiscreteGene>
-
newInstance
public DiscreteGene newInstance()
- Specified by:
newInstancein interfaceio.jenetics.util.Factory<DiscreteGene>- Specified by:
newInstancein interfaceio.jenetics.Gene<Point2D,DiscreteGene>
-
newInstance
public DiscreteGene newInstance(Point2D value)
- Specified by:
newInstancein interfaceio.jenetics.Gene<Point2D,DiscreteGene>
-
distance
public double distance(DiscreteGene other)
Calculate the euclidean distance to anotherDiscreteGene.- Parameters:
other- other discrete point- Returns:
- The euclidean distance to another
DiscreteGene.
-
clone
public DiscreteGene clone()
Clones theDiscreteGene.- Overrides:
clonein classObject- Returns:
- A new instance of the
DiscreteGene.
-
printSmall
public String printSmall()
Prints a small gene representation of the form (4, 5.9).- Returns:
- small string representation of the gene
-
isValid
public boolean isValid()
Checks, if a gene is valid. That means, that the allele's distance is one of these in theConfigurationand smaller than the positions property.- Specified by:
isValidin interfaceio.jenetics.util.Verifiable- Returns:
- whether the discrete gene is valid
-
serialize
public org.dom4j.Element serialize()
Description copied from interface:XmlEntitySerialize the entity into aElement.- Specified by:
serializein interfaceXmlEntity<DiscreteGene>- Returns:
- serialized document
-
parse
public DiscreteGene parse(org.dom4j.Element element)
Description copied from interface:XmlEntityParse aElementand return the entity.- Specified by:
parsein interfaceXmlEntity<DiscreteGene>- Parameters:
element- element to parse- Returns:
- parsed entity
-
getPositions
public short getPositions()
Configuration providing context for the gene. Mainly used to calculate the allele.
-
getPosition
public short getPosition()
The discrete genes position index. This is the index of the ray the gene's allele will be sitting on.- See Also:
position
-
getDistance
public float getDistance()
The genes distance corresponding the the alleles distance.- See Also:
distance
-
setPositions
public void setPositions(short positions)
Configuration providing context for the gene. Mainly used to calculate the allele.
-
setPosition
public void setPosition(short position)
The discrete genes position index. This is the index of the ray the gene's allele will be sitting on.- See Also:
position
-
setDistance
public void setDistance(float distance)
The genes distance corresponding the the alleles distance.- See Also:
distance
-
canEqual
protected boolean canEqual(Object other)
-
-