Class Codons

java.lang.Object
io.jenetics.ext.grammar.Codons
All Implemented Interfaces:
SymbolIndex

public final class Codons extends Object implements SymbolIndex
Represents a mapping of a finite set of integers to symbol indexes. If more indexes are needed, the values are read from the beginning again. You have the possibility to create a Codons object from different chromosome types.
// Create 'classic' codons from a bit-chromosome, where // the genes are split into 8-bit junks and converted // into unsigned int values. final Codons codons = Codons.ofBitGenes(BitChromosome.of(10_000)); // Creating a codons object from an integer chromosome. final var ich = IntegerChromosome.of(IntRange.of(0, 256), 1_000); final var codons = Codons.ofIntegerGenes(ich);
Since:
7.1
Version:
7.1
  • Constructor Details

    • Codons

      public Codons(IntUnaryOperator codons, int length)
      Create a new Codons object from a given codons source and its length.
      Parameters:
      codons - the codon source
      length - the length of the codon source
      Throws:
      NullPointerException - if the codons source is null
      IllegalArgumentException - if the given length is smaller than one
  • Method Details

    • next

      public int next(Cfg.Rule<?> rule, int bound)
      Description copied from interface: SymbolIndex
      Selects an index with the given upper bound, exclusively.
      Specified by:
      next in interface SymbolIndex
      Parameters:
      rule - the rule which requested the index
      bound - the upper bound of the symbol index, exclusively
      Returns:
      the next symbol index
    • ofBitGenes

      public static Codons ofBitGenes(BaseSeq<BitGene> genes)
      Creates a new, classical codons object from the given bit-genes. The genes is split into 8-bit chunks and converted into an unsigned int[] array.
      final Codons codons = Codons.ofBitGenes(BitChromosome.of(10_000));
      Parameters:
      genes - the genes used for creating the codon object
      Returns:
      a new codons object
    • ofIntegerGenes

      public static Codons ofIntegerGenes(BaseSeq<IntegerGene> genes)
      Creates a new codons object from the given int-genes.
      final var chromosome = IntegerChromosome.of(IntRange.of(0, 256), 1_000); final var codons = Codons.ofIntegerGenes(chromosome);
      Parameters:
      genes - the genes used for creating the codon object
      Returns:
      a new codons object