Class FitnessEvaluatorSync<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorSync<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
FitnessEvaluator<T>
public class FitnessEvaluatorSync<T extends Comparable<T>>
extends Object
implements FitnessEvaluator<T>
Wrapper around
Fitness
for computing the
fitness of a population
In order to leverage multi-core systems and speed up computations, the
population will be split according to the number of partitions defined in
and processed concurrentlyinvalid reference
net.bmahe.genetics4j.core.EASystemnet.bmahe.genetics4j.core.spec.EAExecutionContext#numberOfPartitions()
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EAConfiguration
<T> private final EAExecutionContext
<T> private final ExecutorService
static final org.apache.logging.log4j.Logger
-
Constructor Summary
ConstructorsConstructorDescriptionFitnessEvaluatorSync
(EAExecutionContext<T> _eaExecutionContext, EAConfiguration<T> _eaConfigurationSync, ExecutorService _executorService) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.bmahe.genetics4j.core.evaluation.FitnessEvaluator
postEvaluation, preEvaluation
-
Field Details
-
logger
public static final org.apache.logging.log4j.Logger logger -
eaExecutionContext
-
eaConfigurationSync
-
executorService
-
-
Constructor Details
-
FitnessEvaluatorSync
public FitnessEvaluatorSync(EAExecutionContext<T> _eaExecutionContext, EAConfiguration<T> _eaConfigurationSync, ExecutorService _executorService)
-
-
Method Details
-
evaluate
Description copied from interface:FitnessEvaluator
Evaluates the fitness of all genotypes in the given population.This is the core method that computes fitness values for an entire population of genotypes. The implementation strategy (synchronous, parallel, asynchronous) is determined by the specific evaluator implementation.
Requirements:
- Return fitness values in the same order as input genotypes
- Return exactly one fitness value per input genotype
- Ensure fitness values are comparable for selection operations
- Handle empty populations gracefully (return empty list)
The generation parameter can be used for:
- Adaptive fitness functions that change over time
- Logging and monitoring evaluation progress
- Implementing generation-specific evaluation strategies
- Debugging and performance analysis
- Specified by:
evaluate
in interfaceFitnessEvaluator<T extends Comparable<T>>
- Parameters:
generation
- the current generation number (0-based)population
- the population of genotypes to evaluate- Returns:
- a list of fitness values corresponding to each genotype
-