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 necessary, 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
ConstructorsConstructorDescriptionCodons(IntUnaryOperator codons, int length) Create a newCodonsobject from a givencodonssource and itslength. -
Method Summary
Modifier and TypeMethodDescriptionintSelects an index with the given upperbound, exclusively.static CodonsofBitGenes(BaseSeq<BitGene> genes) Creates a new, classical codons object from the given bit-genes.static CodonsofIntegerGenes(BaseSeq<IntegerGene> genes) Creates a new codons object from the given int-genes.
-
Constructor Details
-
Codons
Create a newCodonsobject from a givencodonssource and itslength.- Parameters:
codons- the codon sourcelength- the length of the codon source- Throws:
NullPointerException- if thecodonssource isnullIllegalArgumentException- if the givenlengthis smaller than one
-
-
Method Details
-
next
Description copied from interface:SymbolIndexSelects an index with the given upperbound, exclusively.- Specified by:
nextin 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
-