public final class Genotype<G extends Gene<?,G>> extends Object implements Factory<Genotype<G>>, Iterable<Chromosome<G>>, Verifiable, XMLSerializable, Realtime, Immutable
Genotype
. It is the
structural representative of an individual. This class is the encoded problem
solution with one to many Chromosome
.
final Genotype〈DoubleGene〉 genotype = Genotype.of(
DoubleChromosome.of(0.0, 1.0, 8),
DoubleChromosome.of(1.0, 2.0, 10),
DoubleChromosome.of(0.0, 10.0, 9),
DoubleChromosome.of(0.1, 0.9, 5)
);
DoubleGene
has been chosen as
gene type.Constructor and Description |
---|
Genotype(ISeq<? extends Chromosome<G>> chromosomes)
Create a new Genotype from a given sequence of
Chromosomes . |
Modifier and Type | Method and Description |
---|---|
static <T extends Gene<?,T>> |
Chromosome()
Return a converter which access the first chromosome of this genotype.
|
static <T extends Gene<?,T>> |
Chromosome(int index)
Return a converter which access the chromosome with the given index of
this genotype.
|
static <T extends Gene<?,T>> |
Chromosomes()
Return a converter which access the chromosome array of this genotype.
|
boolean |
equals(Object o) |
Chromosome<G> |
getChromosome()
Return the first chromosome.
|
Chromosome<G> |
getChromosome(int index)
Return the chromosome at the given index.
|
G |
getGene()
|
int |
getNumberOfGenes()
Return the number of genes this genotype consists of.
|
int |
hashCode() |
boolean |
isValid()
Test if this genotype is valid.
|
Iterator<Chromosome<G>> |
iterator() |
int |
length()
Getting the number of chromosomes of this genotype.
|
Genotype<G> |
newInstance()
Return a new, random genotype by creating new, random chromosomes (calling
the
Factory.newInstance() method) from the chromosomes of this
genotype. |
static <G extends Gene<?,G>> |
of(Chromosome<G>... chromosomes)
Create a new Genotype from a given array of
Chromosomes . |
ISeq<Chromosome<G>> |
toSeq() |
String |
toString() |
Text |
toText() |
static <G extends Gene<?,G>> |
valueOf(Chromosome<G>... chromosomes)
Deprecated.
Use
of(Chromosome[]) instead. |
static <G extends Gene<?,G>> |
valueOf(ISeq<? extends Chromosome<G>> chromosomes)
Deprecated.
Use
Genotype(org.jenetics.util.ISeq) instead. |
public Genotype(ISeq<? extends Chromosome<G>> chromosomes)
Chromosomes
.chromosomes
- The Chromosome
array the Genotype
consists of.NullPointerException
- if chromosomes
is null or one of its
element.IllegalArgumentException
- if chromosome.length == 0
.public Chromosome<G> getChromosome(int index)
index
- Chromosome index.IndexOutOfBoundsException
- if (index < 0 || index >= _length).public Chromosome<G> getChromosome()
final Genotype〈DoubleGene〉 gt = ...
final Chromosome〈DoubleGene〉 chromosome = gt.getChromosome(0);
public G getGene()
Gene
of the first Chromosome
of this
Genotype
. This is a shortcut for
final Genotype〈DoubleGene〉 gt = ...
final DoubleGene gene = gt.getChromosome(0).getGene(0);
Gene
of the first Chromosome
of this
Genotype
.public ISeq<Chromosome<G>> toSeq()
public Iterator<Chromosome<G>> iterator()
public int length()
public int getNumberOfGenes()
public boolean isValid()
Chromosome
s are valid.isValid
in interface Verifiable
public Genotype<G> newInstance()
Factory.newInstance()
method) from the chromosomes of this
genotype.public static <T extends Gene<?,T>> Function<Genotype<T>,ISeq<Chromosome<T>>> Chromosomes()
public static <T extends Gene<?,T>> Function<Genotype<T>,Chromosome<T>> Chromosome(int index)
public static <T extends Gene<?,T>> Function<Genotype<T>,Chromosome<T>> Chromosome()
@Deprecated public static <G extends Gene<?,G>> Genotype<G> valueOf(ISeq<? extends Chromosome<G>> chromosomes)
Genotype(org.jenetics.util.ISeq)
instead.@Deprecated @SafeVarargs public static <G extends Gene<?,G>> Genotype<G> valueOf(Chromosome<G>... chromosomes)
of(Chromosome[])
instead.@SafeVarargs public static <G extends Gene<?,G>> Genotype<G> of(Chromosome<G>... chromosomes)
Chromosomes
.chromosomes
- The Chromosome
array the Genotype
consists of.NullPointerException
- if chromosomes
is null or one of its
element.IllegalArgumentException
- if chromosome.length == 0
.© 2007-2014 Franz Wilhelmstötter (2014-03-07 19:35)