T
- the (native) argument type of the problem fitness functionG
- the gene type the evolution engine is working withC
- the result type of the fitness functionpublic interface Problem<T,G extends Gene<?,G>,C extends Comparable<? super C>>
Engine
. It connects the actual fitness()
function
and the needed codec()
.
final Problem<ISeq<BitGene>, BitGene, Integer> counting = Problem.of(
// Native fitness function
genes -> (int)genes.stream()
.filter(BitGene::getBit)
.count(),
// Problem encoding
Codec.of(
Genotype.of(BitChromosome.of(100)),
gt -> gt.getChromosome().toSeq()
)
);
Codec
,
Engine
Modifier and Type | Method and Description |
---|---|
Codec<T,G> |
codec()
Return the codec, which translates the types of the problem domain into
types, which can be understand by the evolution
Engine . |
default T |
decode(Genotype<G> genotype)
Converts the given
Genotype to the target type T . |
Function<T,C> |
fitness()
Return the fitness function of the problem in the native
problem domain.
|
default C |
fitness(Genotype<G> genotype)
Returns the fitness value for the given argument.
|
default C |
fitness(T arg)
Returns the fitness value for the given argument.
|
static <T,G extends Gene<?,G>,C extends Comparable<? super C>> |
of(Function<T,C> fitness,
Codec<T,G> codec)
Return a new optimization problem with the given parameters.
|
Function<T,C> fitness()
Codec<T,G> codec()
Engine
.default T decode(Genotype<G> genotype)
Genotype
to the target type T
. This is
a shortcut for
final Problem<SomeObject, DoubleGene, Double> problem = ...
final Genotype<DoubleGene> gt = problem.codec().encoding().newInstance();
final SomeObject arg = problem.decode(gt);
genotype
- the genotype to be convertedNullPointerException
- if the given genotype
is null
Codec.decode(Genotype)
default C fitness(T arg)
arg
- the argument of the fitness functiondefault C fitness(Genotype<G> genotype)
genotype
- the argument of the fitness functionstatic <T,G extends Gene<?,G>,C extends Comparable<? super C>> Problem<T,G,C> of(Function<T,C> fitness, Codec<T,G> codec)
T
- the (native) argument type of the problem fitness functionG
- the gene type the evolution engine is working withC
- the result type of the fitness functionfitness
- the problem fitness functioncodec
- the evolution engine codecNullPointerException
- if one of the arguments is null
© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)