Skip to content

Commit

Permalink
Do not create child node if the start point is not domain feasible. (#…
Browse files Browse the repository at this point in the history
…199)

* Don't create child node if the domain oracle is infeasible.

* Set version up after bug fix.

* Apply suggestions from code review

* Print statement in case assert fails.

* Print logs for better bug hunting.

* Another try to reproduce error.

* Test lower bound against tree.incumbent plus current fw_epsilon.

* Have the same seed as in runtests.jl.

---------

Co-authored-by: Hendrych <[email protected]>
Co-authored-by: Mathieu Besançon <[email protected]>
  • Loading branch information
3 people authored Sep 17, 2024
1 parent ad30f4e commit 02a376e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions src/node.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 # x_right in domain
[node_info_right]
elseif domain_oracle(x_left)
elseif domain_left # x_left in domain
[node_info_left]
else
warn("No childern nodes can be created.")
Expand Down Expand Up @@ -320,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
Expand Down
2 changes: 1 addition & 1 deletion test/heuristics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,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=false)

@test f(x) f(x_sol)
if isapprox(sum(x_sol), N)
Expand Down

2 comments on commit 02a376e

@dhendryc
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/115409

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.28 -m "<description of version>" 02a376e4cce40c1436f6f9196e4446af25acf61a
git push origin v0.1.28

Please sign in to comment.