public final class EnumGene<A> extends Object implements Gene<A,EnumGene<A>>, Comparable<EnumGene<A>>
Gene which holds enumerable (countable) genes. Will be used for combinatorial
problems in combination with the PermutationChromosome.
GeneticAlgorithm instance.
final ISeq〈Integer〉 alleles = Array.box(1, 2, 3, 4, 5, 6, 7, 8).toISeq();
final Factory〈Genotype〈EnumGene〈Integer〉〉〉 gtf = Genotype.valueOf(
PermutationChromosome.valueOf(alleles)
);EnumGene.
final ISeq〈Integer〉 alleles = Array.box(1, 2, 3, 4, 5, 6, 7, 8).toISeq();
final EnumGene〈Integer〉 gene = EnumGene.valueOf(alleles, 5);
assert(gene.getAlleleIndex() == 5);
assert(gene.getAllele() == gene.getValidAlleles().get(5));
assert(gene.getValidAlleles() == alleles);PermutationChromosome,
Serialized Form| Modifier and Type | Method and Description |
|---|---|
Factory<EnumGene<A>> |
asFactory()
Deprecated.
No longer needed after adding new factory methods to the
Array class. |
int |
compareTo(EnumGene<A> gene) |
EnumGene<A> |
copy() |
boolean |
equals(Object obj) |
A |
getAllele()
Return the allele of this gene.
|
int |
getAlleleIndex()
Return the index of the allele this gene is representing.
|
ISeq<A> |
getValidAlleles()
Return sequence of the valid alleles where this gene is a part of.
|
int |
hashCode() |
boolean |
isValid()
Check if this object is valid.
|
EnumGene<A> |
newInstance()
Return a new, random gene of the same type than this gene.
|
String |
toString() |
static <G> EnumGene<G> |
valueOf(G[] validAlleles) |
static <G> EnumGene<G> |
valueOf(G[] validAlleles,
int alleleIndex) |
static <G> EnumGene<G> |
valueOf(ISeq<? extends G> validAlleles,
int alleleIndex) |
static <G> EnumGene<G> |
valueOf(ISeq<G> validAlleles) |
public ISeq<A> getValidAlleles()
public int getAlleleIndex()
public A getAllele()
Genepublic boolean isValid()
VerifiableisValid in interface Verifiablepublic EnumGene<A> newInstance()
Genegene.getClass() ==
gene.newInstance().getClass().newInstance in interface Gene<A,EnumGene<A>>newInstance in interface Factory<EnumGene<A>>public int compareTo(EnumGene<A> gene)
compareTo in interface Comparable<EnumGene<A>>@Deprecated public Factory<EnumGene<A>> asFactory()
Array class.© 2007-2013 Franz Wilhelmstötter (2013-12-18 20:17)