- Type Parameters:
A
- the Allele type of this gene.
- All Superinterfaces:
Factory<G>
,Self<G>
,Verifiable
- All Known Subinterfaces:
BoundedGene<A,
,G> NumericGene<N,
,G> TreeGene<A,
G>
- All Known Implementing Classes:
AbstractTreeGene
,AnyGene
,BigIntegerGene
,BitGene
,CharacterGene
,DoubleGene
,EnumGene
,IntegerGene
,LongGene
,ProgramGene
Genes are the atoms of the Jenetics library. They contain the actual
information (alleles) of the encoded solution. All implementations of the
interface are final, immutable and can be only created via static
factory methods which have the name
of
. When extending the library
with own Gene
implementations, it is recommended to also implement it
as value objects.-
Method Summary
Modifier and TypeMethodDescriptionallele()
Return the allele of this gene.Return a new, random gene with the same type and with the same constraints as this gene.newInstance
(A value) Create a new gene from the givenvalue
and the gene context.Methods inherited from interface io.jenetics.util.Verifiable
isValid
-
Method Details
-
allele
Return the allele of this gene.- Returns:
- the allele of this gene.
-
newInstance
G newInstance()Return a new, random gene with the same type and with the same constraints as this gene. For all genes returned by this method holdsgene.getClass() == gene.newInstance().getClass()
. Implementations of this method have to use theRandomGenerator
object which can be fetched from theRandomRegistry
.- Specified by:
newInstance
in interfaceFactory<A>
- Returns:
- a new instance of type T
-
newInstance
Create a new gene from the givenvalue
and the gene context.- Parameters:
value
- the value of the new gene.- Returns:
- a new gene with the given value.
- Since:
- 2.0
-