metaheuristic_designer.survivor_selection.survivor_selection module#
Survivor selection registry and factory.
- class SurvivorSelectionDef(selection_fn, params=<factory>, forced_params=<factory>, preserves_order=False)[source]#
Bases:
objectWrapper that turns a raw survivor-selection function into a callable.
- Parameters:
- selection_fncallable
Function
(parent_fitness, offspring_fitness, rng, **kwargs) -> indices.- paramsdict, optional
Default keyword arguments merged with user-supplied ones.
- forced_paramsdict, optional
Keyword arguments that always override user-supplied ones.
- preserves_orderbool, optional
If
True, the selection method keeps individuals in the same order. DefaultFalse.
- Parameters:
selection_fn (callable)
params (dict)
forced_params (dict)
preserves_order (bool)
Methods
__call__(population, offspring[, rng])Call self as a function.
-
selection_fn:
callable#
-
params:
dict#
-
forced_params:
dict#
-
preserves_order:
bool= False#
- create_survivor_selection(method, name=None, rng=None, **kwargs)[source]#
Create a survivor selection method by name.
- Parameters:
- methodstr
Key into
surv_method_map, or a null alias.- namestr, optional
Display name for the selection method.
- rngRNGLike, optional
Random number generator.
- **kwargs
Additional parameters forwarded to the selection function.
- Returns:
- SurvivorSelectionFromLambda or NullSurvivorSelection
The wrapped selection method.
- Parameters:
method (str)
name (str | None)
rng (int | Generator | None)
- add_survivor_selection_entry(selection_fn, selection_method_name, preserves_order=False)[source]#
Register a new survivor selection method.
- Parameters:
- selection_fncallable
A function with the survivor selection signature.
- selection_method_namestr
Name under which to register the method. If it already exists, a warning is logged.
- preserves_orderbool, optional
Whether the method preserves the order of individuals.
- Parameters:
selection_fn (callable)
selection_method_name (str)
preserves_order (bool)