metaheuristic_designer.strategies.hybrid.memetic module#

Hybrid search strategy based on memetic theory from biology.

class MemeticStrategy(main_strategy, local_search_heuristic, local_search_depth=1, local_search_frequency=1, keep_improved_solutions=True, improvement_selection=None, rng=None)[source]#

Bases: SearchStrategy

Strategy that combines a main search strategy with a local search procedure that improves solutions after they are evolved.

Parameters:
main_strategySearchStrategy

Main search strategy used in the optimization algorithm.

local_search_heuristicSearchStrategy

Local search procedure used to improve solutions after evolution.

local_search_depthint, optional

Number of times to repeat the local search procedure per iteration, by default 1

keep_improved_solutionsstr, optional

Whether to keep the improved solutions for the next iteration (Lamarkian memetic algorithms) or to just update the fitness keeping the original solution values (Baldwinian memetic algorithms), by default True

improvement_selectionParentSelection, optional

Selection method with which to pick the solutions that will be improved with local search, by default None

rngOperator[RNGLike], optional

Random number generator, by default None

Attributes:
params

Access parameter values by attribute-style lookup.

population_size

Gets the amount of individuals in the population.

Parameters:
  • main_strategy (SearchStrategy)

  • local_search_heuristic (SearchStrategy)

  • local_search_depth (int)

  • local_search_frequency (int)

  • keep_improved_solutions (bool)

  • improvement_selection (ParentSelection)

  • rng (int | Generator | None)

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

update(progress)[source]#

Advances the state of the search by one iteration.

Parameters:
progressfloat

Current progress of the algorithm (0-1).

Parameters:

progress (float)

step(prev_population, objfunc)[source]#

Performs a single iteration of the algorithm on a given population.

Return type:

Population

Parameters:
populationPopulation

Population of solutions in which to perform the operators.

Returns:
Population

Next population after performing all the steps in the iteration.

Parameters:
get_state()[source]#

Gets the current state of the search strategy as a dictionary.

Return type:

dict

Parameters:
show_population: bool, optional

Save the state of the current population.

Returns:
state: dict

The complete state of the search strategy.