Internal
LocalSearchSolvers.AbstractSolver
— TypeAbstractSolver
Abstract type to encapsulate the different solver types such as Solver
or _SubSolver
.
LocalSearchSolvers.Constraint
— TypeConstraint{F <: Function}
Structure to store an error function and the variables it constrains.
LocalSearchSolvers.LeadSolver
— TypeLeadSolver <: MetaSolver
Solver managed remotely by a MainSolver. Can manage its own set of local sub solvers.
LocalSearchSolvers.MainSolver
— TypeMainSolver <: AbstractSolver
Main solver. Handle the solving of a model, and optional multithreaded and/or distributed subsolvers.
Arguments:
model::Model
: A formal description of the targeted problemstate::_State
: An internal state to store the info necessary to a solving runoptions::Options
: User options for this solversubs::Vector{_SubSolver}
: Optional subsolvers
LocalSearchSolvers.MetaSolver
— TypeAbstract type to encapsulate all solver types that manages other solvers.
LocalSearchSolvers.Objective
— TypeObjective{F <: Function}
A structure to handle objectives in a solver. struct Objective{F <: Function} name::String f::F end
`
LocalSearchSolvers.Objective
— MethodObjective(F, o::Objective{F2}) where {F2 <: Function}
Constructor used in specializing a solver. Should never be called externally.
LocalSearchSolvers.Variable
— TypeVariable{D <: AbstractDomain}
A structure containing the necessary information for a solver's variables: name
, domain
, and constraints
it belongs.
struct Variable{D <: AbstractDomain}
domain::D
constraints::Indices{Int}
end
LocalSearchSolvers._Model
— Type_Model{V <: Variable{<:AbstractDomain},C <: Constraint{<:Function},O <: Objective{<:Function}}
A struct to model a problem as a set of variables, domains, constraints, and objectives.
struct _Model{V <: Variable{<:AbstractDomain},C <: Constraint{<:Function},O <: Objective{<:Function}}
variables::Dictionary{Int,V}
constraints::Dictionary{Int,C}
objectives::Dictionary{Int,O}
# counter to add new variables: vars, cons, objs
max_vars::Ref{Int}
max_cons::Ref{Int}
max_objs::Ref{Int}
# Bool to indicate if the _Model instance has been specialized (relatively to types)
specialized::Ref{Bool}
# Symbol to indicate the kind of model for specialized methods such as pretty printing
kind::Symbol
end
LocalSearchSolvers._State
— TypeGeneralState{T <: Number}
A mutable structure to store the general state of a solver. All methods applied to GeneralState
are forwarded to S <: AbstractSolver
.
mutable struct GeneralState{T <: Number} <: AbstractState
configuration::Configuration{T}
cons_costs::Dictionary{Int, Float64}
last_improvement::Int
tabu::Dictionary{Int, Int}
vars_costs::Dictionary{Int, Float64}
end
LocalSearchSolvers._SubSolver
— Type_SubSolver <: AbstractSolver
An internal solver type called by MetaSolver when multithreading is enabled.
Arguments:
id::Int
: subsolver id for debuggingmodel::Model
: a ref to the model of the main solverstate::_State
: adeepcopy
of the main solver that evolves independentlyoptions::Options
: a ref to the options of the main solver
Base.empty!
— Methodempty!(s::Solver)
Base.empty!
— Methodempty!(m::Model)
DOCSTRING
Base.in
— Methodvar::Int ∈ c::Constraint
Base.in
— Methodx::Variable ∈ constraint
value ∈ x::Variable
Check if a variable x
is restricted by a constraint::Int
, or if a value
belongs to the domain of x
.
LocalSearchSolvers._add!
— Method_add!(c::Constraint, x)
Add the variable of indice x
to c
.
LocalSearchSolvers._add_to_constraint!
— Method_add_to_constraint!(x::Variable, id)
Add a constraint id
to the list of contraints of x
.
LocalSearchSolvers._check_restart
— Method_check_restart(s)
Check if a restart of s
is necessary. If s
has subsolvers, this check is independent for all of them.
LocalSearchSolvers._check_subs
— Method_check_subs(s)
Check if any subsolver of a main solver s
, for
- Satisfaction, has a solution, then return it, resume the run otherwise
- Optimization, has a better solution, then assign it to its internal state
LocalSearchSolvers._compute!
— Method_compute!(s; o::Int = 1, cons_lst = Indices{Int}())
Compute the objective o
's value if s
is satisfied and return the current error
.
Arguments:
s
: a solvero
: targeted objectivecons_lst
: list of targeted constraints, if empty compute for the whole set
LocalSearchSolvers._compute_cost!
— Method_compute_cost!(s, ind, c)
Compute the cost of constraint c
with index ind
.
LocalSearchSolvers._compute_costs!
— Method_compute_costs!(s; cons_lst::Indices{Int} = Indices{Int}())
Compute the cost of constraints c
in cons_lst
. If cons_lst
is empty, compute the cost for all the constraints in s
.
LocalSearchSolvers._compute_objective!
— Method_compute_objective!(s, o::Objective)
_compute_objective!(s, o = 1)
Compute the objective o
's value.
LocalSearchSolvers._cons_cost!
— Method_cons_cost!(s::S, c, cost) where S <: Union{_State, AbstractSolver}
Set the cost
of constraint c
.
LocalSearchSolvers._cons_cost
— Method_cons_cost(s::S, c) where S <: Union{_State, AbstractSolver}
Return the cost of constraint c
.
LocalSearchSolvers._cons_costs!
— Method_cons_costs!(s::S, costs) where S <: Union{_State, AbstractSolver}
Set the constraints costs.
LocalSearchSolvers._cons_costs
— Method_cons_costs(s::S) where S <: Union{_State, AbstractSolver}
Access the constraints costs.
LocalSearchSolvers._constriction
— Method_constriction(x::Variable)
Return the cosntriction
of x
, i.e. the number of constraints restricting x
.
LocalSearchSolvers._delete!
— Method_delete!(c::Constraint, x::Int)
Delete x
from c
.
LocalSearchSolvers._delete_from_constraint!
— Method_delete_from_constraint!(x::Variable, id)
Delete a constraint id
from the list of contraints of x
.
LocalSearchSolvers._draw!
— Method_draw!(s)
Draw a random (re-)starting configuration.
LocalSearchSolvers._dynamic!
— Method_dynamic!(options, dynamic) = begin
DOCSTRING
LocalSearchSolvers._dynamic
— Method_dynamic(options) = begin
DOCSTRING
LocalSearchSolvers._find_rand_argmax
— Method_find_rand_argmax(d::DictionaryView)
Compute argmax
of d
and select one element randomly.
LocalSearchSolvers._get_constraints
— Method_get_constraints(x::Variable)
Access the list of constraints
of x
.
LocalSearchSolvers._get_vars
— Method_get_vars(c::Constraint)
Returns the variables constrained by c
.
LocalSearchSolvers._inc_cons!
— Method_inc_vars!(m::M) where M <: Union{Model, AbstractSolver}
Increment the maximum constraint id that has been attributed to m
.
LocalSearchSolvers._inc_objs!
— Method_inc_vars!(m::M) where M <: Union{Model, AbstractSolver}
Increment the maximum objective id that has been attributed to m
.
LocalSearchSolvers._inc_vars!
— Method_inc_vars!(m::M) where M <: Union{Model, AbstractSolver}
Increment the maximum variable id that has been attributed to m
.
LocalSearchSolvers._info_path!
— Method_info_path!(options, iterations) = begin
DOCSTRING
LocalSearchSolvers._info_path
— Method_info_path(options, path)
DOCSTRING
LocalSearchSolvers._is_empty
— Method_is_empty(m::Model)
DOCSTRING
LocalSearchSolvers._iteration!
— Method_iteration!(options, iterations) = begin
DOCSTRING
LocalSearchSolvers._iteration
— Method_iteration(options) = begin
DOCSTRING
LocalSearchSolvers._length
— Method_length(c::Constraint)
Return the number of constrained variables by c
.
LocalSearchSolvers._max_cons
— Method_max_cons(m::M) where M <: Union{Model, AbstractSolver}
Access the maximum constraint id that has been attributed to m
.
LocalSearchSolvers._max_objs
— Method_max_objs(m::M) where M <: Union{Model, AbstractSolver}
Access the maximum objective id that has been attributed to m
.
LocalSearchSolvers._max_vars
— Method_max_vars(m::M) where M <: Union{Model, AbstractSolver}
Access the maximum variable id that has been attributed to m
.
LocalSearchSolvers._move!
— Function_move!(s, x::Int, dim::Int = 0)
Perform an improving move in x
neighbourhood if possible.
Arguments:
s
: a solver of type S <: AbstractSolverx
: selected variable iddim
: describe the dimension of the considered neighbourhood
LocalSearchSolvers._neighbours
— Function_neighbours(s, x, dim = 0)
DOCSTRING
Arguments:
s
: DESCRIPTIONx
: DESCRIPTIONdim
: DESCRIPTION
LocalSearchSolvers._optimizing!
— Method_optimizing!(s::S) where S <: Union{_State, AbstractSolver}
Set the solver optimizing
status to true
.
LocalSearchSolvers._optimizing
— Method_optimizing(s::S) where S <: Union{_State, AbstractSolver}
Check if s
is in an optimizing state.
LocalSearchSolvers._print_level!
— Method_print_level!(options, level) = begin
DOCSTRING
LocalSearchSolvers._print_level
— Method_print_level(options) = begin
DOCSTRING
LocalSearchSolvers._restart!
— Function_restart!(s, k = 10)
Restart a solver.
LocalSearchSolvers._satisfying!
— Method_satisfying!(s::S) where S <: Union{_State, AbstractSolver}
Set the solver optimizing
status to false
.
LocalSearchSolvers._select_worse
— Method_select_worse(s::S) where S <: Union{_State, AbstractSolver}
Within the non-tabu variables, select the one with the worse error .
LocalSearchSolvers._set!
— Method_set!(s::S, x, val) where S <: Union{_State, AbstractSolver}
Set the value of variable x
to val
.
LocalSearchSolvers._solutions!
— Method_solutions!(options, solutions) = begin
DOCSTRING
LocalSearchSolvers._solutions
— Method_solutions(options) = begin
DOCSTRING
LocalSearchSolvers._specialize!
— Method_specialize!(options, specialize) = begin
DOCSTRING
LocalSearchSolvers._specialize
— Method_specialize(options) = begin
DOCSTRING
LocalSearchSolvers._step!
— Method_step!(s)
Iterate a step of the solver run.
LocalSearchSolvers._swap_value!
— Method_set!(s::S, x, y) where S <: Union{_State, AbstractSolver}
Swap the values of variables x
and y
.
LocalSearchSolvers._tabu_delta!
— Method_tabu_delta!(options, time) = begin
DOCSTRING
LocalSearchSolvers._tabu_delta
— Method_tabu_delta(options) = begin
DOCSTRING
LocalSearchSolvers._tabu_local!
— Method_tabu_local!(options, time) = begin
DOCSTRING
LocalSearchSolvers._tabu_local
— Method_tabu_local(options) = begin
DOCSTRING
LocalSearchSolvers._tabu_time!
— Method_tabu_time!(options, time) = begin
DOCSTRING
LocalSearchSolvers._tabu_time
— Method_tabu_time(options) = begin
DOCSTRING
LocalSearchSolvers._threads!
— Method_threads!(options, threads) = begin
DOCSTRING
LocalSearchSolvers._threads
— Method_threads(options) = begin
DOCSTRING
LocalSearchSolvers._time_limit!
— Method_time_limit!(options, time::Time) = begin
DOCSTRING
LocalSearchSolvers._time_limit
— Method_time_limit(options) = begin
DOCSTRING
LocalSearchSolvers._to_union
— Method_to_union(datatype)
Make a minimal Union
type from a collection of data types.
LocalSearchSolvers._value!
— Method_value!(s::S, x, val) where S <: Union{_State, AbstractSolver}
Set the value of variable x
to val
.
LocalSearchSolvers._value
— Method_value(s::S, x) where S <: Union{_State, AbstractSolver}
Return the value of variable x
.
LocalSearchSolvers._values!
— Method_values!(s::S, values) where S <: Union{_State, AbstractSolver}
Set the variables values.
LocalSearchSolvers._values
— Method_vars_costs(s::S) where S <: Union{_State, AbstractSolver}
Access the variables costs.
LocalSearchSolvers._var_cost!
— Method_var_cost!(s::S, x, cost) where S <: Union{_State, AbstractSolver}
Set the cost
of variable x
.
LocalSearchSolvers._var_cost
— Method_var_cost(s::S, x) where S <: Union{_State, AbstractSolver}
Return the cost of variable x
.
LocalSearchSolvers._vars_costs!
— Method_vars_costs!(s::S, costs) where S <: Union{_State, AbstractSolver}
Set the variables costs.
LocalSearchSolvers._vars_costs
— Method_vars_costs(s::S) where S <: Union{_State, AbstractSolver}
Access the variables costs.
LocalSearchSolvers._verbose
— Method_verbose(settings, str)
Temporary logging function. #TODO: use better log instead (LoggingExtra.jl)
LocalSearchSolvers.decay_tabu!
— Method_decay_tabu!(s::S) where S <: Union{_State, AbstractSolver}
Decay the tabu list.
LocalSearchSolvers.decrease_tabu!
— Method_decrease_tabu!(s::S, x) where S <: Union{_State, AbstractSolver}
Decrement the tabu value of variable x
.
LocalSearchSolvers.delete_tabu!
— Method_delete_tabu!(s::S, x) where S <: Union{_State, AbstractSolver}
Delete the tabu entry of variable x
.
LocalSearchSolvers.domain_size
— Methoddomain_size(m::Model, x) = begin
DOCSTRING
LocalSearchSolvers.empty_tabu!
— Method_empty_tabu!(s::S) where S <: Union{_State, AbstractSolver}
Empty the tabu list.
LocalSearchSolvers.get_kind
— Methodget_kind(m::M) where M <: Union{Model, AbstractSolver}
Access the kind of m
, such as :sudoku
or :generic
(default).
LocalSearchSolvers.get_time_stamp
— Methodget_time_stamp(m::M) where M <: Union{Model, AbstractSolver}
Access the time (since epoch) when the model was created. This time stamp is for internal performance measurement.
LocalSearchSolvers.insert_tabu!
— Method_insert_tabu!(s::S, x, tabu_time) where S <: Union{_State, AbstractSolver}
Insert the bariable x
as tabu for tabu_time
.
LocalSearchSolvers.is_specialized
— Methodis_specialized(m::M) where M <: Union{Model, AbstractSolver}
Return true
if the model is already specialized.
LocalSearchSolvers.length_objs
— Methodlength_objs(m::M) where M <: Union{Model, AbstractSolver}
Return the number of objectives in m
.
LocalSearchSolvers.length_tabu
— Method_length_tabu!(s::S) where S <: Union{_State, AbstractSolver}
Return the length of the tabu list.
LocalSearchSolvers.length_vars
— Methodlength_vars(m::M) where M <: Union{Model, AbstractSolver}
Return the number of variables in m
.
LocalSearchSolvers.post_process
— Methodpost_process(s::MainSolver)
Launch a serie of tasks to round-up a solving run, for instance, export a run's info.
LocalSearchSolvers.remote_dispatch!
— Methodremote_dispatch!(solver)
Starts the LeadSolver
s attached to the MainSolver
.
LocalSearchSolvers.remote_stop!
— Methodremote_stop!!(solver)
Fetch the pool of solutions from LeadSolvers
and merge it into the MainSolver
.
LocalSearchSolvers.solve_for_loop!
— Methodsolve_for_loop!(solver, stop, sat, iter)
First loop in the solving process that starts LeadSolver
s from the MainSolver
, and _SubSolver
s from each MetaSolver
.
LocalSearchSolvers.solve_while_loop!
— Methodsolve_while_loop!(s, )
Search the space of configurations.
LocalSearchSolvers.stop_while_loop
— Methodstop_while_loop()
Check the stop conditions of the solve!
while inner loop.
LocalSearchSolvers.tabu_list
— Method_tabu(s::S) where S <: Union{_State, AbstractSolver}
Access the list of tabu variables.
LocalSearchSolvers.tabu_value
— Method_tabu(s::S, x) where S <: Union{_State, AbstractSolver}
Return the tabu value of variable x
.