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 aPoint2D
allele.- 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 Point2D
allele()
protected boolean
canEqual(Object other)
DiscreteGene
clone()
Clones theDiscreteGene
.double
distance(DiscreteGene other)
Calculate the euclidean distance to anotherDiscreteGene
.boolean
equals(Object o)
float
getDistance()
The genes distance corresponding the the alleles distance.short
getPosition()
The discrete genes position index.short
getPositions()
Configuration providing context for the gene.int
hashCode()
boolean
isValid()
Checks, if a gene is valid.DiscreteGene
newInstance()
DiscreteGene
newInstance(Point2D value)
DiscreteGene
parse(org.dom4j.Element element)
Parse aElement
and return the entity.String
printSmall()
Prints a small gene representation of the form (4, 5.9).org.dom4j.Element
serialize()
Serialize the entity into aElement
.void
setDistance(float distance)
The genes distance corresponding the the alleles distance.void
setPosition(short position)
The discrete genes position index.void
setPositions(short positions)
Configuration providing context for the gene.String
toString()
-
-
-
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:
allele
in interfaceio.jenetics.Gene<Point2D,DiscreteGene>
-
newInstance
public DiscreteGene newInstance()
- Specified by:
newInstance
in interfaceio.jenetics.util.Factory<DiscreteGene>
- Specified by:
newInstance
in interfaceio.jenetics.Gene<Point2D,DiscreteGene>
-
newInstance
public DiscreteGene newInstance(Point2D value)
- Specified by:
newInstance
in 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:
clone
in 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 theConfiguration
and smaller than the positions property.- Specified by:
isValid
in interfaceio.jenetics.util.Verifiable
- Returns:
- whether the discrete gene is valid
-
serialize
public org.dom4j.Element serialize()
Description copied from interface:XmlEntity
Serialize the entity into aElement
.- Specified by:
serialize
in interfaceXmlEntity<DiscreteGene>
- Returns:
- serialized document
-
parse
public DiscreteGene parse(org.dom4j.Element element)
Description copied from interface:XmlEntity
Parse aElement
and return the entity.- Specified by:
parse
in 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)
-
-