Package io.jenetics

Interface NumericGene<N extends Number & Comparable<? super N>,G extends NumericGene<N,G>>

All Superinterfaces:
BoundedGene<N,G>, Comparable<G>, Factory<G>, Gene<N,G>, Self<G>, Verifiable
All Known Implementing Classes:
BigIntegerGene, DoubleGene, IntegerGene, LongGene

public interface NumericGene<N extends Number & Comparable<? super N>,G extends NumericGene<N,G>> extends BoundedGene<N,G>
Base interface for numeric genes.
Since:
1.6
Version:
3.0
See Also:
Implementation Requirements:
Jenetics requires that the individuals (Genotype and Phenotype) are not changed after they have been created. Therefore, all implementations of the NumericGene interface must also be immutable.
  • Method Summary

    Modifier and Type
    Method
    Description
    default byte
    Returns the value of the specified gene as a byte.
    default double
    Returns the value of the specified gene as a double.
    default float
    Returns the value of the specified gene as a float.
    default int
    Returns the value of the specified gene as an int.
    default long
    Returns the value of the specified gene as a long.
    Create a new gene from the given value and the current bounds.
    default short
    Returns the value of the specified gene as a short.

    Methods inherited from interface io.jenetics.BoundedGene

    compareTo, isValid, max, max, min, min

    Methods inherited from interface io.jenetics.util.Factory

    instances

    Methods inherited from interface io.jenetics.Gene

    allele, newInstance

    Methods inherited from interface io.jenetics.util.Self

    self
  • Method Details

    • byteValue

      default byte byteValue()
      Returns the value of the specified gene as a byte. This may involve rounding or truncation.
      Returns:
      the numeric value represented by this object after conversion to type byte.
    • shortValue

      default short shortValue()
      Returns the value of the specified gene as a short. This may involve rounding or truncation.
      Returns:
      the numeric value represented by this object after conversion to type short.
    • intValue

      default int intValue()
      Returns the value of the specified gene as an int. This may involve rounding or truncation.
      Returns:
      the numeric value represented by this object after conversion to type int.
    • longValue

      default long longValue()
      Returns the value of the specified gene as a long. This may involve rounding or truncation.
      Returns:
      the numeric value represented by this object after conversion to type long.
    • floatValue

      default float floatValue()
      Returns the value of the specified gene as a float. This may involve rounding or truncation.
      Returns:
      the numeric value represented by this object after conversion to type float.
    • doubleValue

      default double doubleValue()
      Returns the value of the specified gene as a double. This may involve rounding or truncation.
      Returns:
      the numeric value represented by this object after conversion to type double.
    • newInstance

      G newInstance(Number number)
      Description copied from interface: BoundedGene
      Create a new gene from the given value and the current bounds.
      Specified by:
      newInstance in interface BoundedGene<N extends Number & Comparable<? super N>,G extends NumericGene<N,G>>
      Specified by:
      newInstance in interface Gene<N extends Number & Comparable<? super N>,G extends NumericGene<N,G>>
      Parameters:
      number - the value of the new gene.
      Returns:
      a new gene with the given value.