![]() |
Ultra 0.9.4
|
#include <evolution_strategy.h>
Public Types | |
| using | evaluator_type = E |
| using | fitness_t = evaluator_fitness_t<E> |
| using | individual_t = evaluator_individual_t<E> |
Public Member Functions | |
| template<Population P> | |
| void | init (P &) const |
| template<Population P> | |
| P * | refinement_subgroup (P &) const noexcept |
| template<Population P> | |
| void | after_generation (P &, const summary< individual_t, fitness_t > &) |
| const problem & | get_problem () const noexcept |
| template<Population P> | |
| std::size_t | max_parallelism (const P &) const noexcept |
| template<LayeredPopulation P> | |
| bool | valid_layer (P &pop, typename P::layer_iter iter) |
| template<Population P> | |
| P * | refinement_subgroup (P &pop) const noexcept |
| template<Population P> | |
| std::size_t | max_parallelism (const P &pop) const noexcept |
| template<Population P> | |
| void | after_generation (P &pop, const summary< individual_t, fitness_t > &sum) |
Static Public Member Functions | |
| static parameters | shape (const parameters &p) |
Protected Member Functions | |
| evolution_strategy (const problem &, E &) | |
Static Protected Member Functions | |
| template<LayeredPopulation P> | |
| static bool | valid_layer (P &, typename P::layer_iter) |
Protected Attributes | |
| E & | eva_ |
| const problem & | prob_ |
Base class for compile-time evolutionary strategies.
An evolution_strategy encapsulates all strategy-dependent aspects of the evolutionary process, while leaving the overall control flow to the evolution driver.
This design uses static polymorphism: concrete strategies derive from evolution_strategy<E> and provide the required operations at compile time. No runtime polymorphism is involved.
The evolution driver owns the main generational loop, termination conditions, concurrency, and logging, while concrete strategies define how one evolutionary step is assembled and how generation-level maintenance is performed.
Strategies are expected to be:
The base class stores shared references to the optimisation problem and evaluator, and provides default no-op hooks where appropriate.
|
protected |
Constructs an evolution strategy.
| [in] | prob | the optimisation problem |
| [in] | eva | the evaluator used to assess individuals |
Stores references to the evaluator and the optimisation problem. These references are shared by all operators composing the strategy (selection, recombination, replacement).
| void ultra::evolution_strategy< E >::after_generation | ( | P & | pop, |
| const summary< individual_t, fitness_t > & | sum ) |
Perform post-generation maintenance.
This hook is called once per generation, after all evolutionary steps have been executed.
Typical responsibilities include:
Performs post-generation bookkeeping.
| P | population type |
| [in,out] | pop | the evolved population |
| [in] | sum | summary statistics of the current generation |
This method is invoked once per generation, after all evolutionary steps have completed.
Responsibilities:
A layer is reset when (and of the points):
| void ultra::evolution_strategy< E >::after_generation | ( | P & | pop, |
| const summary< individual_t, fitness_t > & | sum ) |
Performs post-generation bookkeeping.
| P | population type |
| [in,out] | pop | the evolved population |
| [in] | sum | summary statistics of the current generation |
This method is invoked once per generation, after all evolutionary steps have completed.
Responsibilities:
A layer is reset when (and of the points):
|
inline |
Initialises the strategy before the first generation.
This method is called once, before the evolutionary loop begins. It allows the strategy to:
|
nodiscardnoexcept |
Returns the maximum useful parallelism for this strategy.
| [in] | pop | population being evolved |
The default strategy assumes that the population topology is stable during the run. For layered populations, each layer can be evolved independently, so the useful worker count is the current number of layers. Non-layered populations have a single scheduling unit.
|
noexcept |
Returns the maximum useful parallelism for this strategy.
| [in] | pop | population being evolved |
The default strategy assumes that the population topology is stable during the run. For layered populations, each layer can be evolved independently, so the useful worker count is the current number of layers. Non-layered populations have a single scheduling unit.
|
nodiscardnoexcept |
Returns the population subgroup eligible for refinement.
| [in,out] | pop | population managed by the evolutionary process |
This hook lets an evolutionary strategy restrict refinement to a specific part of the population.
The returned pointer is non-owning and must refer to a population-like object whose lifetime is tied to pop. Returning nullptr means that the strategy currently has no suitable refinement candidates and refinement should be skipped.
The default implementation returns the whole population.
|
noexcept |
Returns the population subgroup eligible for refinement.
| [in,out] | pop | population managed by the evolutionary process |
This hook lets an evolutionary strategy restrict refinement to a specific part of the population.
The returned pointer is non-owning and must refer to a population-like object whose lifetime is tied to pop. Returning nullptr means that the strategy currently has no suitable refinement candidates and refinement should be skipped.
The default implementation returns the whole population.
|
inlinestaticnodiscard |
Sets strategy-specific parameters. The default implementation doesn't change the user-specified parameters. Some evolution strategies force parameters to specific values.