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 Details

    • logger

      private final org.apache.logging.log4j.Logger logger
    • topN

      private final int topN
    • skipN

      private final int skipN
    • comparator

      private final Comparator<T extends Comparable<T>> comparator
    • prettyPrinter

      private Function<Genotype,String> 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 interface EvolutionListener<T extends Comparable<T>>
      Parameters:
      generation - the current generation number (0-based)
      population - the list of genotypes in the current generation
      fitness - the list of fitness values corresponding to each genotype
      isDone - true if the evolution has completed, false otherwise