Class GenerationalEvolutionEngine<T>

  • Type Parameters:
    T - The type of entity that is to be evolved.
    All Implemented Interfaces:
    EvolutionEngine<T>

    public class GenerationalEvolutionEngine<T>
    extends AbstractEvolutionEngine<T>

    This class implements a general-purpose generational evolutionary algorithm. It supports optional concurrent fitness evaluations to take full advantage of multi-processor, multi-core and hyper-threaded machines.

    If multi-threading is enabled, evolution (mutation, cross-over, etc.) occurs on the request thread but fitness evaluations are delegated to a pool of worker threads. All of the host's available processing units are used (i.e. on a quad-core machine there will be four fitness evaluation worker threads).

    If multi-threading is disabled, all work is performed synchronously on the request thread. This strategy is suitable for restricted/managed environments where it is not permitted for applications to manage their own threads. If there are no restrictions on concurrency, applications should enable multi-threading for improved performance.

    See Also:
    SteadyStateEvolutionEngine, EvolutionStrategyEngine
    • Constructor Detail

      • GenerationalEvolutionEngine

        public GenerationalEvolutionEngine​(CandidateFactory<T> candidateFactory,
                                           EvolutionaryOperator<T> evolutionScheme,
                                           FitnessEvaluator<? super T> fitnessEvaluator,
                                           SelectionStrategy<? super T> selectionStrategy,
                                           Random rng)
        Creates a new evolution engine by specifying the various components required by a generational evolutionary algorithm.
        Parameters:
        candidateFactory - Factory used to create the initial population that is iteratively evolved.
        evolutionScheme - The combination of evolutionary operators used to evolve the population at each generation.
        fitnessEvaluator - A function for assigning fitness scores to candidate solutions.
        selectionStrategy - A strategy for selecting which candidates survive to be evolved.
        rng - The source of randomness used by all stochastic processes (including evolutionary operators and selection strategies).
      • GenerationalEvolutionEngine

        public GenerationalEvolutionEngine​(CandidateFactory<T> candidateFactory,
                                           EvolutionaryOperator<T> evolutionScheme,
                                           InteractiveSelection<T> selectionStrategy,
                                           Random rng)
        Creates a new evolution engine for an interactive evolutionary algorithm. It is not necessary to specify a fitness evaluator for interactive evolution.
        Parameters:
        candidateFactory - Factory used to create the initial population that is iteratively evolved.
        evolutionScheme - The combination of evolutionary operators used to evolve the population at each generation.
        selectionStrategy - Interactive selection strategy configured with appropriate console.
        rng - The source of randomness used by all stochastic processes (including evolutionary operators and selection strategies).
    • Method Detail

      • nextEvolutionStep

        protected List<EvaluatedCandidate<T>> nextEvolutionStep​(List<EvaluatedCandidate<T>> evaluatedPopulation,
                                                                int eliteCount,
                                                                Random rng)
        This method performs a single step/iteration of the evolutionary process.
        Specified by:
        nextEvolutionStep in class AbstractEvolutionEngine<T>
        Parameters:
        evaluatedPopulation - The population at the beginning of the process.
        eliteCount - The number of the fittest individuals that must be preserved.
        rng - A source of randomness.
        Returns:
        The updated population after the evolutionary process has proceeded by one step/iteration.