| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.98.0/docs/apis/_sources/simulated_annealing_2.rst.txt |
.. index:: single: simulated_annealing(Problem,RandomAlgorithm)
.. _simulated_annealing/2:
.. rst-class:: right
object
simulated_annealing(Problem,RandomAlgorithm)Problem - Problem object implementing simulated_annealing_protocol.RandomAlgorithm - Random number generator algorithm for the fast_random library (e.g. xoshiro128pp, xoshiro256ss, well512a, ...).
Simulated annealing optimization algorithm. Parameterized by a problem object implementing the simulated_annealing_protocol protocol and by a random number generator algorithm for the fast_random library. The algorithm minimizes the energy (cost) function defined by the problem. Custom cooling schedules, stop conditions, delta-energy neighbor generation, progress reporting, and reheating restarts can be defined by the problem object or configured via options; suitable defaults are used otherwise.
| Availability:
| logtalk_load(simulated_annealing(loader))
| Author: Paulo Moura | Version: 1:0:0 | Date: 2026-02-23
| Compilation flags:
| static, context_switching_calls
| Imports:
| public :ref:`options <options/0>`
| Uses:
| :ref:`fast_random(Algorithm) <fast_random/1>`
| :ref:`type <type/0>`
| Remarks:
exp(-DeltaE / Temperature).NewTemp is Temp * 0.995. Override by defining cooling_schedule/3 in the problem object.updates(N) option. A final report is always produced when the loop terminates.seed(S) option initializes the random number generator for reproducible runs.restarts(N) option runs N additional SA cycles after the first. Each restart reheats the temperature to the initial value and begins from the best state found so far, allowing the search to escape local minima. Statistics accumulate across all cycles.estimate_temperature/1-2 predicates sample random neighbor transitions and compute an initial temperature that would produce a target acceptance rate. This avoids manual tuning of the initial temperature.| Inherited public predicates: | Â :ref:`options_protocol/0::check_option/1` Â :ref:`options_protocol/0::check_options/1` Â :ref:`options_protocol/0::default_option/1` Â :ref:`options_protocol/0::default_options/1` Â :ref:`options_protocol/0::option/2` Â :ref:`options_protocol/0::option/3` Â :ref:`options_protocol/0::valid_option/1` Â :ref:`options_protocol/0::valid_options/1` Â
.. contents:: :local: :backlinks: top
.. index:: estimate_temperature/1 .. _simulated_annealing/2::estimate_temperature/1:
estimate_temperature/1 ^^^^^^^^^^^^^^^^^^^^^^^^^^
Estimates an initial temperature for the problem using default options (200 samples, 80% target acceptance rate).
| Compilation flags:
| static
| Template:
| estimate_temperature(Temperature)
| Mode and number of proofs:
| estimate_temperature(-float) - one
.. index:: estimate_temperature/2 .. _simulated_annealing/2::estimate_temperature/2:
estimate_temperature/2 ^^^^^^^^^^^^^^^^^^^^^^^^^^
Estimates an initial temperature by sampling random neighbor transitions. The temperature is computed so that the Boltzmann acceptance probability for the average uphill move equals the target acceptance rate. Sampling starts from the problem initial state and follows a random walk.
| Compilation flags:
| static
| Template:
| estimate_temperature(Temperature,Options)
| Mode and number of proofs:
| estimate_temperature(-float,+list(compound)) - one
| Remarks:
samples(N) option: Number of random neighbor transitions to sample (default: 200).acceptance_rate(P) option: Target initial acceptance rate as an integer percentage between 1 and 99 (default: 80)... index:: run/2 .. _simulated_annealing/2::run/2:
run/2 ^^^^^^^^^
Runs the simulated annealing algorithm using default options and returns the best state found and its energy.
| Compilation flags:
| static
| Template:
| run(BestState,BestEnergy)
| Mode and number of proofs:
| run(-term,-number) - one
.. index:: run/3 .. _simulated_annealing/2::run/3:
run/3 ^^^^^^^^^
Runs the simulated annealing algorithm using the given options and returns the best state found and its energy.
| Compilation flags:
| static
| Template:
| run(BestState,BestEnergy,Options)
| Mode and number of proofs:
| run(-term,-number,+list(compound)) - one
| Remarks:
max_steps(N) option: Maximum number of iterations per cycle (default: 10000).min_temperature(T) option: Minimum temperature floor; search stops when temperature drops below this value (default: 0.001).updates(N) option: Number of progress reports during the run. Set to 0 to disable. Progress is reported by calling progress/5 on the problem object (default: 0).seed(S) option: Positive integer seed for the random number generator, enabling reproducible runs (default: none).restarts(N) option: Number of additional SA cycles after the first. Each restart reheats the temperature and begins from the best state found so far (default: 0)... index:: run/4 .. _simulated_annealing/2::run/4:
run/4 ^^^^^^^^^
Runs the simulated annealing algorithm using the given options, returns the best state found and its energy, and returns run statistics.
| Compilation flags:
| static
| Template:
| run(BestState,BestEnergy,Statistics,Options)
| Mode and number of proofs:
| run(-term,-number,-list(compound),+list(compound)) - one
| Remarks:
Key(Value) pairs: steps(N) is the number of steps executed, acceptances(A) is the number of accepted moves, improvements(I) is the number of moves that improved the best energy, and final_temperature(T) is the temperature at termination.(no local declarations; see entity ancestors if any)
(no local declarations; see entity ancestors if any)
(none)
.. seealso::
:ref:`simulated_annealing(Problem) <simulated_annealing/1>`, :ref:`simulated_annealing_protocol <simulated_annealing_protocol/0>`