Interface Termination<T extends Comparable<T>>

Type Parameters:
T - the type of the fitness values, must be comparable for fitness-based termination
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 Termination<T extends Comparable<T>>
Functional interface for determining when to stop the evolutionary algorithm.

Termination criteria are essential for controlling when an evolutionary algorithm should stop evolving and return its best solutions. The choice of termination criteria significantly affects both the quality of results and computational efficiency.

Termination conditions provide access to various aspects of the evolution state including:

  • Generation count: Number of evolutionary cycles completed
  • Population state: Current genotypes and their fitness values
  • Configuration: Algorithm parameters and settings
  • Evolution progress: Fitness improvements and convergence indicators

Common termination strategies include:

  • Generation limit: Stop after a fixed number of generations
  • Fitness threshold: Stop when best fitness reaches a target value
  • Convergence detection: Stop when population diversity becomes too low
  • Stagnation detection: Stop when fitness stops improving for N generations
  • Time limit: Stop after a specified duration
  • Resource limit: Stop when computational budget is exhausted

Best practices for termination criteria:

  • Multiple criteria: Combine several conditions using logical operators
  • Problem-specific: Adapt criteria to the characteristics of the optimization problem
  • Configurable: Allow users to adjust termination parameters
  • Efficient: Minimize computational overhead of termination checks
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isDone(AbstractEAConfiguration<T> eaConfiguration, long generation, List<Genotype> population, List<T> fitness)
    Determines whether the evolutionary algorithm should terminate.
  • Method Details

    • isDone

      boolean isDone(AbstractEAConfiguration<T> eaConfiguration, long generation, List<Genotype> population, List<T> fitness)
      Determines whether the evolutionary algorithm should terminate.

      This method is called after each generation to check if any termination criteria have been satisfied. The implementation should evaluate the current state of evolution and return true if the algorithm should stop, false otherwise.

      The method has access to:

      • Current generation number (starting from 0)
      • Current population genotypes
      • Current fitness values for all individuals
      • Algorithm configuration and parameters

      Implementations should be efficient as this method is called frequently during evolution. Complex termination logic should cache intermediate results when possible.

      Parameters:
      eaConfiguration - the evolutionary algorithm configuration containing parameters
      generation - the current generation number (0-based)
      population - the list of genotypes in the current population
      fitness - the list of fitness values corresponding to each genotype
      Returns:
      true if the algorithm should terminate, false to continue evolving
      Throws:
      IllegalArgumentException - if any parameter is null or if population and fitness lists have different sizes
      RuntimeException - if termination evaluation fails due to computational errors