Interface Evaluator<G extends Gene<?,G>,C extends Comparable<? super C>>
- Type Parameters:
G- the gene type
C- the fitness result type
- All Known Implementing Classes:
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Evaluator<G extends Gene<?,G>,C extends Comparable<? super C>>This interface allows to define different strategies for evaluating the fitness functions of a given population. Normally, there is no need for overriding the default evaluation strategy, but it might be necessary if you have performance problems and a batched fitness evaluation would solve the problem.
The implementer is free to do the evaluation in place, or create new
Phenotypeinstance and return the newly created one. A simple serial evaluator can easily implemented:
final Function<? super Genotype<G>, ? extends C> fitness = ...; final Evaluator<G, C> evaluator = population -> population .map(pt -> pt.eval(fitness)) .asISeq(); final Engine<G, C> engine = new Engine.Builder(evaluator, genotypeFactory) .build();
- See Also:
- API Note:
- The size of the returned, evaluated, phenotype sequence must be exactly
the size of the input phenotype sequence and all phenotypes must have a
fitness value assigned (
assert population.forAll(Phenotype::isEvaluated);). It is allowed to return the input sequence, after evaluation, as well a newly created one.
evalEvaluates the fitness values of the given
population. The given
populationmight contain already evaluated individuals. It is the responsibility of the implementer to filter out already evaluated individuals, if desired.
population- the population to evaluate
- the evaluated population. Implementers are free to return the the input population or a newly created one.