metaheuristic_designer.strategies.classic.GA module#
Genetic Algorithm strategy.
- class GA(initializer, mutation_op, crossover_op, parent_sel, survivor_sel, name='GA', mutation_prob=0.1, crossover_prob=0.9, rng=None, **kwargs)[source]#
Bases:
PopulationBasedStrategyGenetic Algorithm.
Combines crossover (applied with probability crossover_prob) and mutation (applied per individual with probability mutation_prob) via a
BranchOperator. The population size is constant.- Parameters:
- initializerInitializer
Population initializer.
- mutation_opOperator
Mutation operator (will be applied probabilistically).
- crossover_opOperator
Crossover operator (applied pairwise).
- parent_selParentSelection
Parent selection method.
- survivor_selSurvivorSelection
Survivor selection method.
- namestr, optional
Display name (default
"GA").- mutation_probfloat or SchedulableParameter, optional
Individual-level probability of mutation (default 0.1).
- crossover_probfloat or SchedulableParameter, optional
Pair-level probability of crossover (default 0.9). If the crossover operator supports it, this value is injected via
update_kwargs.- rngRNGLike, optional
Random number generator.
- **kwargs
Forwarded to
StaticPopulation.
- Attributes:
paramsAccess parameter values by attribute-style lookup.
population_sizeGets the amount of individuals in the population.
- Parameters:
initializer (Initializer)
mutation_op (Operator)
crossover_op (Operator)
parent_sel (ParentSelection)
survivor_sel (SurvivorSelection)
name (str)
mutation_prob (float | SchedulableParameter)
crossover_prob (float | SchedulableParameter)
rng (Optional[RNGLike])
Methods
extra_report()Hook called at the end of the optimization (intended for subclasses).
extra_step_info()Hook called after each generation (intended for subclasses).
gather_parameters()Collect the current parameters from all sub-components.
get_params()Return a copy of the current parameter dictionary.
get_state()Gets the current state of the search strategy as a dictionary.
initialize(objfunc)Initializes the optimization search strategy.
step(prev_population, objfunc)Performs a single iteration of the algorithm on a given population.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Advances the state of the search by one iteration.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
reset