metaheuristic_designer.strategies.classic.SA module#

Simulated Annealing strategy.

class SA(initializer, operator, name='SA', iterations=100, temperature_init=100, alpha=0.99, rng=None, **kwargs)[source]#

Bases: SingleSolutionStrategy

Simulated Annealing algorithm.

A single solution is perturbed each iteration. The new solution is accepted if it is better, or probabilistically if it is worse, according to an exponentially decaying temperature schedule.

Parameters:
initializerInitializer

Population initializer (usually creates a single individual).

operatorOperator

Perturbation operator.

namestr, optional

Display name (default "SA").

iterationsint or SchedulableParameter, optional

Number of iterations at constant temperature (default 100).

temperature_initfloat or SchedulableParameter, optional

Starting temperature (default 100).

alphafloat or SchedulableParameter, optional

Cooling factor (default 0.99).

rngRNGLike, optional

Random number generator.

**kwargs

Forwarded to HillClimb.

Attributes:
params

Access parameter values by attribute-style lookup.

population_size

Gets the amount of individuals in the population.

temperature
Parameters:

Methods

extra_report()

Hook called at the end of the optimization (intended for subclasses).

extra_step_info()

Displays temperature values and acceptance probability.

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

extra_step_info()[source]#

Displays temperature values and acceptance probability.