From 1d6580d4f7a31da4dfb93b5514ae013d11c0de6d Mon Sep 17 00:00:00 2001 From: Azzaare Date: Thu, 15 Aug 2024 08:21:54 +0000 Subject: [PATCH] Fix collecting pools of solution for // computing. Fix termination of remote processes --- src/solver.jl | 1 - src/solvers/lead.jl | 12 ++---------- src/solvers/main.jl | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/solver.jl b/src/solver.jl index c57414f..0dd4925 100644 --- a/src/solver.jl +++ b/src/solver.jl @@ -245,7 +245,6 @@ function _init!(s, ::Val{:local}) 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 diff --git a/src/solvers/lead.jl b/src/solvers/lead.jl index 90e366f..801d702 100644 --- a/src/solvers/lead.jl +++ b/src/solvers/lead.jl @@ -33,14 +33,6 @@ stop_while_loop(s::LeadSolver, ::Atomic{Bool}, ::Int, ::Float64) = isready(s.rc_ function remote_stop!(s::LeadSolver) isready(s.rc_stop) && take!(s.rc_stop) - sat = is_sat(s) - if !sat || !has_solution(s) - while isready(s.rc_report) - wait(s.rc_sol) - t = take!(s.rc_sol) - update_pool!(s, t) - sat && has_solution(t) && break - take!(s.rc_report) - end - end + put!(s.rc_sol, s.pool) + take!(s.rc_report) end diff --git a/src/solvers/main.jl b/src/solvers/main.jl index abe8f30..ff5e08f 100644 --- a/src/solvers/main.jl +++ b/src/solvers/main.jl @@ -116,3 +116,26 @@ function post_process(s::MainSolver) write(path, JSON.json(info)) end end + +function remote_stop!(s::MainSolver) + isready(s.rc_stop) && take!(s.rc_stop) + sat = is_sat(s) + @info "Remote stop: report main pool" best_values(s.pool) has_solution(s) s.rc_report s.rc_sol s.rc_stop length(s.remotes) + if !sat || !has_solution(s) + @warn "debugging remote stop" nworkers() length(s.remotes) + while isready(s.rc_report) || isready(s.rc_sol) + wait(s.rc_sol) + t = take!(s.rc_sol) + @info "Remote stop: report remote pool" best_values(t) length(s.remotes) + update_pool!(s, t) + if sat && has_solution(t) + empty!(s.rc_report) + break + end + @info "mark 1" + isready(s.rc_report) && take!(s.rc_report) + @info "mark 2" + end + end + @info "Remote stop: report best pool" best_values(s.pool) length(s.remotes) +end