From 32627eef23dac0ba8fc1d7606bdd0dcd272811a0 Mon Sep 17 00:00:00 2001 From: Hendrych Date: Wed, 11 Sep 2024 17:46:35 +0200 Subject: [PATCH 1/8] Don't create child node if the domain oracle is infeasible. --- src/node.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/node.jl b/src/node.jl index c8af87ac3..8daaed9d5 100644 --- a/src/node.jl +++ b/src/node.jl @@ -161,15 +161,18 @@ function Bonobo.get_branching_nodes_info(tree::Bonobo.BnBTree, node::FrankWolfeN x_right = FrankWolfe.compute_active_set_iterate!(active_set_right) domain_oracle = tree.root.options[:domain_oracle] - nodes = if !prune_left && !prune_right + domain_right = domain_oracle(x_right) + domain_left = domain_oracle(x_left) + + nodes = if !prune_left && !prune_right && domain_right && domain_left [node_info_left, node_info_right] elseif prune_left [node_info_right] elseif prune_right [node_info_left] - elseif domain_oracle(x_right) + elseif domain_right #domain_oracle(x_right) [node_info_right] - elseif domain_oracle(x_left) + elseif domain_left #domain_oracle(x_left) [node_info_left] else warn("No childern nodes can be created.") From 414a3f90bf980b741811e05d1ce690578bac52a5 Mon Sep 17 00:00:00 2001 From: Hendrych Date: Wed, 11 Sep 2024 17:53:39 +0200 Subject: [PATCH 2/8] Set version up after bug fix. --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 710426c03..6e1fb7f06 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Boscia" uuid = "36b166db-dac5-4d05-b36a-e6c4cef071c9" authors = ["ZIB IOL"] -version = "0.1.27" +version = "0.1.28" [deps] Bonobo = "f7b14807-3d4d-461a-888a-05dd4bca8bc3" From c99356238cbac4000e61d6ff1e98f5e5ca0ec22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Besan=C3=A7on?= Date: Fri, 13 Sep 2024 09:33:03 +0200 Subject: [PATCH 3/8] Apply suggestions from code review --- src/node.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node.jl b/src/node.jl index 8daaed9d5..5bb18bcea 100644 --- a/src/node.jl +++ b/src/node.jl @@ -170,9 +170,9 @@ function Bonobo.get_branching_nodes_info(tree::Bonobo.BnBTree, node::FrankWolfeN [node_info_right] elseif prune_right [node_info_left] - elseif domain_right #domain_oracle(x_right) + elseif domain_right # x_right in domain [node_info_right] - elseif domain_left #domain_oracle(x_left) + elseif domain_left # x_left in domain [node_info_left] else warn("No childern nodes can be created.") From 98783d53141d34f239aba73f028dd864265a7960 Mon Sep 17 00:00:00 2001 From: Hendrych Date: Fri, 13 Sep 2024 15:51:39 +0200 Subject: [PATCH 4/8] Print statement in case assert fails. --- src/interface.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/interface.jl b/src/interface.jl index b496a1ea8..74d0f30fe 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -642,7 +642,8 @@ function postsolve(tree, result, time_ref, verbose, max_iteration_post) else @info "primal >= tree.incumbent" @assert primal <= tree.incumbent + 1e-3 || - isapprox(primal, tree.incumbent, atol=1e-6, rtol=1e-2) + isapprox(primal, tree.incumbent, atol=1e-6, rtol=1e-2) "primal <= tree.incumbent + 1e-3 || + isapprox(primal, tree.incumbent, atol=1e-6, rtol=1e-2): primal=$(primal) and tree.incumbent=$(tree.incumbent)" end @info "postsolve did not improve the solution" primal = tree.incumbent_solution.objective = tree.solutions[1].objective From c55223f554d0aa61891dbdbd1627205a7e3e4241 Mon Sep 17 00:00:00 2001 From: Hendrych Date: Mon, 16 Sep 2024 12:11:30 +0200 Subject: [PATCH 5/8] Print logs for better bug hunting. --- test/heuristics.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/heuristics.jl b/test/heuristics.jl index 6005832c3..e06d74ffa 100644 --- a/test/heuristics.jl +++ b/test/heuristics.jl @@ -11,6 +11,11 @@ using Dates const MOI = MathOptInterface const MOIU = MOI.Utilities +seed = rand(UInt64) +seed = 0x61746adc8587896d +@show seed +Random.seed!(seed) + n = 20 x_sol = rand(1:floor(Int, n/4), n) N = sum(x_sol) @@ -159,7 +164,7 @@ diffi = x_sol + 0.3 * dir heu = Boscia.Heuristic(Boscia.probability_rounding, 0.6, :probability_rounding) x, _, result = - Boscia.solve(f, grad!, sblmo, fill(0.0, m), fill(1.0, m), int_vars, n, custom_heuristics=[heu], rounding_prob=0.0) + Boscia.solve(f, grad!, sblmo, fill(0.0, m), fill(1.0, m), int_vars, n, custom_heuristics=[heu], rounding_prob=0.0, verbose=true) @test f(x) ≥ f(x_sol) if isapprox(sum(x_sol), N) From b5e7e240f9a239067604476857a369930ee65373 Mon Sep 17 00:00:00 2001 From: Hendrych Date: Mon, 16 Sep 2024 12:54:50 +0200 Subject: [PATCH 6/8] Another try to reproduce error. --- test/heuristics.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/heuristics.jl b/test/heuristics.jl index e06d74ffa..e3daac936 100644 --- a/test/heuristics.jl +++ b/test/heuristics.jl @@ -164,7 +164,7 @@ diffi = x_sol + 0.3 * dir heu = Boscia.Heuristic(Boscia.probability_rounding, 0.6, :probability_rounding) x, _, result = - Boscia.solve(f, grad!, sblmo, fill(0.0, m), fill(1.0, m), int_vars, n, custom_heuristics=[heu], rounding_prob=0.0, verbose=true) + Boscia.solve(f, grad!, sblmo, fill(0.0, m), fill(1.0, m), int_vars, n, custom_heuristics=[heu], rounding_prob=0.0, verbose=false) @test f(x) ≥ f(x_sol) if isapprox(sum(x_sol), N) From 722cb2d65743d8a13cb87b232fe8bcf789aeeabb Mon Sep 17 00:00:00 2001 From: Hendrych Date: Mon, 16 Sep 2024 13:55:47 +0200 Subject: [PATCH 7/8] Test lower bound against tree.incumbent plus current fw_epsilon. --- src/node.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node.jl b/src/node.jl index 5bb18bcea..170960ebd 100644 --- a/src/node.jl +++ b/src/node.jl @@ -323,7 +323,7 @@ function Bonobo.evaluate_node!(tree::Bonobo.BnBTree, node::FrankWolfeNode) elseif node.id == 1 @debug "Lower bound of root node: $(lower_bound)" @debug "Current incumbent: $(tree.incumbent)" - @assert lower_bound <= tree.incumbent + 1e-5 "lower_bound <= tree.incumbent + 1e-5 : $(lower_bound) <= $(tree.incumbent + 1e-5)" + @assert lower_bound <= tree.incumbent + node.fw_dual_gap_limit "lower_bound <= tree.incumbent + node.fw_dual_gap_limit : $(lower_bound) <= $(tree.incumbent + node.fw_dual_gap_limit)" end # Call heuristic From c6aaf84a9e2a306a04fadaaf59b45154c7401163 Mon Sep 17 00:00:00 2001 From: Hendrych Date: Mon, 16 Sep 2024 14:25:44 +0200 Subject: [PATCH 8/8] Have the same seed as in runtests.jl. --- test/heuristics.jl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/heuristics.jl b/test/heuristics.jl index e3daac936..e2422c402 100644 --- a/test/heuristics.jl +++ b/test/heuristics.jl @@ -11,11 +11,6 @@ using Dates const MOI = MathOptInterface const MOIU = MOI.Utilities -seed = rand(UInt64) -seed = 0x61746adc8587896d -@show seed -Random.seed!(seed) - n = 20 x_sol = rand(1:floor(Int, n/4), n) N = sum(x_sol)