Class EvolutionListenerLogTopN<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.evolutionlisteners.EvolutionListenerLogTopN<T>
- All Implemented Interfaces:
EvolutionListener<T>
public class EvolutionListenerLogTopN<T extends Comparable<T>>
extends Object
implements EvolutionListener<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator
<T> private final org.apache.logging.log4j.Logger
private final int
private final int
-
Constructor Summary
ConstructorsConstructorDescriptionEvolutionListenerLogTopN
(org.apache.logging.log4j.Logger _logger, int _topN, int _skipN) EvolutionListenerLogTopN
(org.apache.logging.log4j.Logger _logger, int _topN, int _skipN, Comparator<T> _comparator, Function<Genotype, String> _prettyPrinter) -
Method Summary
Modifier and TypeMethodDescriptionvoid
onEvolution
(long generation, List<Genotype> population, List<T> fitness, boolean isDone) Called after each generation to notify about evolution progress.
-
Field Details
-
logger
private final org.apache.logging.log4j.Logger logger -
topN
private final int topN -
skipN
private final int skipN -
comparator
-
prettyPrinter
-
-
Constructor Details
-
EvolutionListenerLogTopN
public EvolutionListenerLogTopN(org.apache.logging.log4j.Logger _logger, int _topN, int _skipN, Comparator<T> _comparator, Function<Genotype, String> _prettyPrinter) -
EvolutionListenerLogTopN
public EvolutionListenerLogTopN(org.apache.logging.log4j.Logger _logger, int _topN, int _skipN)
-
-
Method Details
-
onEvolution
public void onEvolution(long generation, List<Genotype> population, List<T> fitness, boolean isDone) Description copied from interface:EvolutionListener
Called after each generation to notify about evolution progress.This method is invoked by the evolutionary algorithm after each generation has been completed, providing access to the current population state and fitness values. The implementation can use this information for monitoring, logging, or adaptive control.
The method is called with:
- Current generation number (starting from 0)
- Complete population of genotypes for this generation
- Corresponding fitness values for each individual
- Flag indicating whether evolution has completed
Important notes:
- Population and fitness lists are guaranteed to have the same size
- Fitness values correspond to genotypes at the same index
- Data may be shared with the evolution algorithm; avoid modification
- Method should execute quickly to avoid impacting evolution performance
- Specified by:
onEvolution
in interfaceEvolutionListener<T extends Comparable<T>>
- Parameters:
generation
- the current generation number (0-based)population
- the list of genotypes in the current generationfitness
- the list of fitness values corresponding to each genotypeisDone
-true
if the evolution has completed,false
otherwise
-