Package io.jenetics
Interface Gene<A,G extends Gene<A,G>>
-
- Type Parameters:
A- the Allele type of this gene.
- All Superinterfaces:
Factory<G>,Verifiable
- All Known Subinterfaces:
BoundedGene<A,G>,NumericGene<N,G>
- All Known Implementing Classes:
AnyGene,BitGene,CharacterGene,DoubleGene,EnumGene,IntegerGene,LongGene
public interface Gene<A,G extends Gene<A,G>> extends Factory<G>, Verifiable
Genes are the atoms of the Jenetics library. They contain the actual information (alleles) of the encoded solution. All implementations of the this interface are final, immutable and can be only created via static factory methods which have the nameof. When extending the library with ownGeneimplementations, it is recommended to also implement it as value objects.- Since:
- 1.0
- Version:
- 6.0
- Author:
- Franz Wilhelmstötter
- See Also:
- Value object,
Chromosome - Implementation Requirements:
- Jenetics requires that the individuals (
GenotypeandPhenotype) are not changed after they have been created. Therefore, all implementations of theGeneinterface must also be immutable.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Aallele()Return the allele of this gene.GnewInstance()Return a new, random gene with the same type and with the same constraints than this gene.GnewInstance(A value)Create a new gene from the givenvalueand the gene context.-
Methods inherited from interface io.jenetics.util.Verifiable
isValid
-
-
-
-
Method Detail
-
newInstance
G newInstance()
Return a new, random gene with the same type and with the same constraints than this gene. For all genes returned by this method holdsgene.getClass() == gene.newInstance().getClass(). Implementations of this method has to use theRandomobject which can be fetched from theRandomRegistry.- Specified by:
newInstancein interfaceFactory<A>- Returns:
- a new instance of type T
-
newInstance
G newInstance(A value)
Create a new gene from the givenvalueand the gene context.- Parameters:
value- the value of the new gene.- Returns:
- a new gene with the given value.
- Since:
- 2.0
-
-