@@ -61,12 +61,12 @@ pub enum EvolveVariant {
6161/// * setup
6262/// * [reporter](crate::strategy::reporter) on_start hook
6363/// * loop while not finished
64- /// * increment age & filter by age
64+ /// * (before selection) increment generation & filter by age
6565/// * [select](crate::select)
66- /// * update population cardinality
66+ /// * (after selection) update population cardinality
6767/// * [reporter](crate::strategy::reporter) on_selection_complete hook
6868/// * [extension](crate::extension) after_selection_complete hook
69- /// * increment age
69+ /// * (before crossover) increment age
7070/// * [crossover](crate::crossover)
7171/// * [reporter](crate::strategy::reporter) on_crossover_complete hook
7272/// * [extension](crate::extension) after_crossover_complete hook
@@ -276,18 +276,16 @@ impl<
276276 . on_start ( & self . genotype , & self . state , & self . config ) ;
277277 while !self . is_finished ( ) {
278278 self . state . increment_generation ( ) ;
279- self . state
280- . population_filter_age ( & self . genotype , & self . config ) ;
281279
280+ self . state . before_selection ( & self . genotype , & self . config ) ;
282281 self . plugins . select . call (
283282 & self . genotype ,
284283 & mut self . state ,
285284 & self . config ,
286285 & mut self . reporter ,
287286 & mut self . rng ,
288287 ) ;
289- self . state
290- . update_population_cardinality ( & self . genotype , & self . config ) ;
288+ self . state . after_selection ( & self . genotype , & self . config ) ;
291289 self . reporter
292290 . on_selection_complete ( & self . genotype , & self . state , & self . config ) ;
293291 self . plugins . extension . after_selection_complete (
@@ -298,7 +296,7 @@ impl<
298296 & mut self . rng ,
299297 ) ;
300298
301- self . state . population . increment_age ( ) ;
299+ self . state . before_crossover ( & self . genotype , & self . config ) ;
302300 self . plugins . crossover . call (
303301 & self . genotype ,
304302 & mut self . state ,
@@ -608,6 +606,17 @@ impl<G: EvolveGenotype> StrategyState<G> for EvolveState<G> {
608606}
609607
610608impl < G : EvolveGenotype > EvolveState < G > {
609+ fn before_selection ( & mut self , genotype : & G , config : & EvolveConfig ) {
610+ self . population_filter_age ( genotype, config) ;
611+ }
612+
613+ fn after_selection ( & mut self , genotype : & G , config : & EvolveConfig ) {
614+ self . update_population_cardinality ( genotype, config) ;
615+ }
616+
617+ fn before_crossover ( & mut self , _genotype : & G , _config : & EvolveConfig ) {
618+ self . population . increment_age ( ) ;
619+ }
611620 fn update_best_chromosome_and_report < SR : StrategyReporter < Genotype = G > > (
612621 & mut self ,
613622 genotype : & G ,
0 commit comments