Skip to content

Commit

Permalink
Enforce a non-empty pool at initialization of an optimization run
Browse files Browse the repository at this point in the history
  • Loading branch information
Azzaare committed Aug 15, 2024
1 parent c28e310 commit 10ddc90
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/configuration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ get_values(c) = c.values
get_value(c, x) = get_values(c)[x]

set_value!(c, val) = c.value = val
# set_value!(c, x, val) = get_values(c)[x] = val
set_values!(c, values) = c.values = values
set_sat!(c, b) = c.solution = b

Expand Down
6 changes: 2 additions & 4 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,11 @@ Add `x` to the constraint `c` list of restricted variables.
"""
add_var_to_cons!(m::_Model, c, x) = _add!(get_constraint(m, c), x)

""" mts = - get_time_stamp(model)
return TimeStamps(mts, mts, mts, mts, mts, mts, mts)
end
"""
add!(m::M, x) where M <: Union{Model, AbstractSolver}
add!(m::M, c) where M <: Union{Model, AbstractSolver}
add!(m::M, o) where M <: Union{Model, AbstractSolver}
Add a variable `x`, a constraint `c`, or an objective `o` to `m`.
"""
function add!(m::_Model, x::Variable)
Expand Down
4 changes: 4 additions & 0 deletions src/pool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ function pool(config::Configuration)
value = get_value(config)
return _Pool(best, configs, status, value)
end
function pool!(s)
has_solution(s) || _draw!(s)
s.pool = pool(s.state.configuration)
end

is_empty(::EmptyPool) = true
is_empty(pool) = isempty(pool.configurations)
Expand Down
4 changes: 3 additions & 1 deletion src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,15 @@ function _init!(s, ::Val{:remote})
end
end

function _init!(s, ::Val{:local}; pool = pool())
function _init!(s, ::Val{:local})
get_option(s, "tabu_time") == 0 && set_option!(s, "tabu_time", length_vars(s) ÷ 2) # 10?
get_option(s, "tabu_local") == 0 &&
set_option!(s, "tabu_local", get_option(s, "tabu_time") ÷ 2)
get_option(s, "tabu_delta") == 0 && set_option!(
s, "tabu_delta", get_option(s, "tabu_time") - get_option(s, "tabu_local")) # 20-30
state!(s)
@warn "Debug" typeof(s) s
pool!(s)
return has_solution(s)
end

Expand Down

0 comments on commit 10ddc90

Please sign in to comment.