metaheuristic_designer.strategies.classic.SA#
- class SA(initializer, operator, name='SA', iterations=100, temperature_init=100, alpha=0.99, rng=None, **kwargs)[source]#
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:
paramsAccess parameter values by attribute-style lookup.
population_sizeGets the amount of individuals in the population.
- temperature
- Parameters:
initializer (Initializer)
operator (Operator)
name (str)
iterations (int | SchedulableParameter)
temperature_init (float | SchedulableParameter)
alpha (float | SchedulableParameter)
rng (Optional[RNGLike])
Methods
reset
- __init__(initializer, operator, name='SA', iterations=100, temperature_init=100, alpha=0.99, rng=None, **kwargs)[source]#
- Parameters:
initializer (Initializer)
operator (Operator)
name (str)
iterations (int | SchedulableParameter)
temperature_init (float | SchedulableParameter)
alpha (float | SchedulableParameter)
rng (int | Generator | None)
Methods
__init__(initializer, operator[, name, ...])extra_report()Hook called at the end of the optimization (intended for subclasses).
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.
reset(objfunc)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.