object

tabu_search(Problem,Random)

  • Problem - Problem object implementing tabu_search_problem_protocol.

  • Random - Random number generator object providing between/3, randomize/1, permutation/2, and sample/4 predicates.

Tabu search optimization algorithm. Parameterized by a problem object implementing the tabu_search_problem_protocol protocol and by a random number generator algorithm for the fast_random library. Minimizes energy with optional problem-defined tabu keys, tenure, aspiration, restart states, neighbor generation, stopping, and progress reporting.

Availability:
logtalk_load(tabu_search(loader))
Author: Paulo Moura
Version: 2:0:0
Date: 2026-11-19
Compilation flags:
static, context_switching_calls
Imports:
public options
Uses:
Remarks:
(none)

Public predicates

run/2

Runs the tabu search 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(-nonvar,-number) - one
Exceptions:
An implemented output hook fails or returns an invalid value:
domain_error(tabu_hook_result,Result)

run/3

Runs the tabu search 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(-nonvar,-number,+list(compound)) - one
Exceptions:
An option is invalid:
domain_error(option,Option)
Exhaustive mode requires implemented enumeration:
existence_error(procedure,Problem::neighbors/2)
An implemented output hook fails or returns an invalid value:
domain_error(tabu_hook_result,Result)
Remarks:
  • max_steps(N) option: Maximum number of iterations per cycle (default: 10000).

  • tabu_tenure(T) option: Fixed lifetime in selection steps (default: 7). Ignored when a range or a problem tabu_tenure/4 implementation is present.

  • tabu_tenure_range(Min, Max) option: Uniform random tenure in the inclusive integer range. Overrides fixed tenure; ignored when the problem implements tabu_tenure/4.

  • candidates(N) option: Number of candidate neighbors examined per iteration (default: 20).

  • exhaustive(Boolean) option: Evaluates the full neighbors/2 list in source order when true, ignoring the candidate limit (default: false). Requires implemented enumeration.

  • 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 cycles (default: 0). Clears memory and uses restart_state/2 when implemented, otherwise the global best state.


run/4

Runs the tabu search 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(-nonvar,-number,-list(compound),+list(compound)) - one
Exceptions:
An option is invalid:
domain_error(option,Option)
Exhaustive mode requires implemented enumeration:
existence_error(procedure,Problem::neighbors/2)
An implemented output hook fails or returns an invalid value:
domain_error(tabu_hook_result,Result)
Remarks:
  • 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, and final_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

select_candidate/10

Selects the best admissible candidate using the cached run policy.

Compilation flags:
static
Template:
select_candidate(Policy,State,Energy,BestEnergy,Tabu,Step,Candidates,Neighbor,NeighborEnergy,Accepted)
Mode and number of proofs:
select_candidate(+compound,+nonvar,+number,+number,+list,+non_negative_integer,+positive_integer,-nonvar,-number,-boolean) - one
Exceptions:
Enumeration fails in exhaustive mode:
domain_error(tabu_hook_result,neighbors/2)
A key hook returns an invalid result:
domain_error(tabu_hook_result,Result)

require_neighborhood/2

Checks the implementation required for exhaustive evaluation.

Compilation flags:
static
Template:
require_neighborhood(Exhaustive,Problem)
Mode and number of proofs:
require_neighborhood(+boolean,+object_identifier) - one
Exceptions:
Enumeration is not implemented:
existence_error(procedure,Problem::neighbors/2)

restart_candidate/7

Resolves a restart state and updates the global best independently.

Compilation flags:
static
Template:
restart_candidate(Policy,Best,BestEnergy,State,Energy,NewBest,NewBestEnergy)
Mode and number of proofs:
restart_candidate(+compound,+nonvar,+number,-nonvar,-number,-nonvar,-number) - one
Exceptions:
The restart hook fails or returns an invalid state:
domain_error(tabu_hook_result,Result)

state_key/3

Resolves an optional tabu key without copying the state.

Compilation flags:
static
Template:
state_key(KeyHook,State,Key)
Mode and number of proofs:
state_key(+boolean,+nonvar,-nonvar) - one
Exceptions:
The key hook fails or returns an unbound key:
domain_error(tabu_hook_result,Result)

resolve_tenure/6

Resolves tenure with hook, range, then fixed-option precedence.

Compilation flags:
static
Template:
resolve_tenure(TenureHook,Specification,Step,BestEnergy,CurrentEnergy,Tenure)
Mode and number of proofs:
resolve_tenure(+boolean,+compound,+non_negative_integer,+number,+number,-non_negative_integer) - one
Exceptions:
The tenure hook fails or returns an invalid value:
domain_error(tabu_hook_result,Result)

Operators

(none)