java.lang.Object
io.jenetics.ext.grammar.Codons
- All Implemented Interfaces:
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 Summary
ConstructorDescriptionCodons
(IntUnaryOperator codons, int length) Create a newCodons
object from a givencodons
source and itslength
. -
Method Summary
Modifier and TypeMethodDescriptionint
Selects an index with the given upperbound
, exclusively.static Codons
ofBitGenes
(BaseSeq<BitGene> genes) Creates a new, classical codons object from the given bit-genes.static Codons
ofIntegerGenes
(BaseSeq<IntegerGene> genes) Creates a new codons object from the given int-genes.
-
Constructor Details
-
Codons
Create a newCodons
object from a givencodons
source and itslength
.- Parameters:
codons
- the codon sourcelength
- the length of the codon source- Throws:
NullPointerException
- if thecodons
source isnull
IllegalArgumentException
- if the givenlength
is smaller than one
-
-
Method Details
-
next
Description copied from interface:SymbolIndex
Selects an index with the given upperbound
, exclusively.- Specified by:
next
in interfaceSymbolIndex
- Parameters:
rule
- the rule which requested the indexbound
- the upper bound of the symbol index, exclusively- Returns:
- the next symbol index
-
ofBitGenes
Creates a new, classical codons object from the given bit-genes. The genes is split into 8-bit chunks and converted into an unsignedint[]
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
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
-