Package evo.search.ga

Class DiscreteGene

    • Constructor Detail

      • DiscreteGene

        public DiscreteGene​(int positions,
                            int position,
                            double distance)
        Convenience constructor.
        Parameters:
        positions - amount of rays
        position - index of ray
        distance - distance from origin
      • DiscreteGene

        public DiscreteGene​(short positions,
                            short position,
                            float distance)
    • Method Detail

      • distance

        public double distance​(DiscreteGene other)
        Calculate the euclidean distance to another DiscreteGene.
        Parameters:
        other - other discrete point
        Returns:
        The euclidean distance to another 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 the Configuration and smaller than the positions property.
        Specified by:
        isValid in interface io.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 a Element.
        Specified by:
        serialize in interface XmlEntity<DiscreteGene>
        Returns:
        serialized document
      • parse

        public DiscreteGene parse​(org.dom4j.Element element)
        Description copied from interface: XmlEntity
        Parse a Element and return the entity.
        Specified by:
        parse in interface XmlEntity<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.
        See Also:
        allele(), positions
      • 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.
        See Also:
        allele(), positions
      • 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)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object