object
tabu_search(Problem,RandomAlgorithm)
Problem- Problem object implementingtabu_search_protocol.RandomAlgorithm- Random number generator algorithm for thefast_randomlibrary (e.g.xoshiro128pp,xoshiro256ss,well512a, …).
Tabu search optimization algorithm. Parameterized by a problem object implementing the tabu_search_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 stop conditions, delta-energy neighbor generation, full neighborhood enumeration, progress reporting, and restarts can be defined by the problem object or configured via options; suitable defaults are used otherwise.
logtalk_load(tabu_search(loader))static, context_switching_calls
Algorithm: Tabu search is a metaheuristic that guides a local search procedure using a short-term memory structure (the tabu list) to avoid cycling and to escape local minima. At each iteration a set of candidate neighbors is examined and the best admissible (non-tabu or aspiration-allowed) neighbor is selected.
Tabu list: A list of recently visited states paired with expiration steps. With fixed tenure the list behaves as a FIFO of maximum length
tabu_tenure. Withtabu_tenure_range(Min, Max)each accepted move is assigned a random tenure drawn uniformly from the inclusive range.Aspiration criterion: A tabu candidate is accepted when its energy is strictly better than the best energy found so far. This is the classic “best-so-far” aspiration criterion.
Candidate generation: By default the algorithm samples
candidates(N)neighbors usingneighbor_state/2(orneighbor_state/3when defined). If the problem definesneighbors/2, that complete list is used instead (or a random sample of it when larger than the candidate limit).Delta-energy optimization: If the problem object defines
neighbor_state/3, the algorithm uses the returned delta energy directly instead of callingstate_energy/2on the neighbor. This is useful when computing the energy change is cheaper than recomputing the full energy.Progress reporting: If the problem object defines
progress/5, it is called periodically with the current step, best energy, current energy, acceptance rate, and improvement rate. The reporting interval is controlled by theupdates(N)option. A final report is always produced when the loop terminates.Best state tracking: The algorithm tracks the best state found across all iterations and across all restart cycles, not just the final state.
Seed control: The
seed(S)option initializes the random number generator for reproducible runs.Restarts: The
restarts(N)option runs N additional tabu search cycles after the first. Each restart begins from the best state found so far with a cleared tabu list, allowing the search to escape deep local minima. Statistics accumulate across all cycles.
Public predicates
run/2
Runs the tabu search algorithm using default options and returns the best state found and its energy.
staticrun(BestState,BestEnergy)run(-nonvar,-number) - onerun/3
Runs the tabu search algorithm using the given options and returns the best state found and its energy.
staticrun(BestState,BestEnergy,Options)run(-nonvar,-number,+list(compound)) - one
max_steps(N)option: Maximum number of iterations per cycle (default:10000).
tabu_tenure(T)option: Fixed tabu tenure: maximum lifetime (in steps) of each tabu entry (default:7). Ignored whentabu_tenure_range/2is also present.
tabu_tenure_range(Min, Max)option: Random tabu tenure: on each accepted move a tenure is drawn uniformly from the inclusive integer rangeMin..Max. Overridestabu_tenure/1when present.
candidates(N)option: Number of candidate neighbors examined per iteration (default:20).
updates(N)option: Number of progress reports during the run. Set to0to disable. Progress is reported by callingprogress/5on 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 tabu search cycles after the first. Each restart begins from the best state found so far with a cleared tabu list (default:0).
run/4
Runs the tabu search algorithm using the given options, returns the best state found and its energy, and returns run statistics.
staticrun(BestState,BestEnergy,Statistics,Options)run(-nonvar,-number,-list(compound),+list(compound)) - one
Statistics list: A list of
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, andfinal_tabu_size(S)is the number of non-expired tabu entries at termination.
Protected predicates
(no local declarations; see entity ancestors if any)
Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)