Trait genetic_algorithm::strategy::StrategyReporter
source · pub trait StrategyReporter:
Clone
+ Send
+ Sync {
type Allele: Allele;
type State: StrategyState<Self::Allele>;
type Config: StrategyConfig;
// Provided methods
fn on_start(&mut self, _state: &Self::State, _config: &Self::Config) { ... }
fn on_finish(&mut self, _state: &Self::State, _config: &Self::Config) { ... }
fn on_new_generation(
&mut self,
_state: &Self::State,
_config: &Self::Config,
) { ... }
fn on_new_best_chromosome(
&mut self,
_state: &Self::State,
_config: &Self::Config,
) { ... }
fn on_new_best_chromosome_equal_fitness(
&mut self,
_state: &Self::State,
_config: &Self::Config,
) { ... }
}
Expand description
Reporter with event hooks in the Strategy process
As this is a primary API for clients, which are encouraged to implement their own reporters, we want the API to resemble the Fitness API (which is also custom implemented by clients). Therefore we only want to set a associated trait Allele in the API. The error E0658: associated type defaults are unstable blocks this API design. Thus Supertrait StrategyReporter is not used. It is only shadowed, as if it existed as a supertrait for now.
Required Associated Types§
type Allele: Allele
type State: StrategyState<Self::Allele>
type Config: StrategyConfig
Provided Methods§
fn on_start(&mut self, _state: &Self::State, _config: &Self::Config)
fn on_finish(&mut self, _state: &Self::State, _config: &Self::Config)
fn on_new_generation(&mut self, _state: &Self::State, _config: &Self::Config)
fn on_new_best_chromosome( &mut self, _state: &Self::State, _config: &Self::Config, )
fn on_new_best_chromosome_equal_fitness( &mut self, _state: &Self::State, _config: &Self::Config, )
Object Safety§
This trait is not object safe.