Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout from callback #173

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
check_rounding_value::Bool,
fw_iterations,
min_fw_iterations,
time_ref,
time_limit,
)
vars = get_variables_pointers(tree.root.problem.tlmo.blmo, tree)
# variable to only fetch heuristics when the counter increases
Expand All @@ -13,10 +15,12 @@
@assert isapprox(sum(active_set.weights), 1.0)
@assert sum(active_set.weights .< 0) == 0
# TODO deal with vertices becoming infeasible with conflicts
if !is_linear_feasible(tree.root.problem.tlmo, state.v)
@info "$(state.v)"
check_infeasible_vertex(tree.root.problem.tlmo.blmo, tree)
@assert is_linear_feasible(tree.root.problem.tlmo, state.v)
@debug begin
dhendryc marked this conversation as resolved.
Show resolved Hide resolved
if !is_linear_feasible(tree.root.problem.tlmo, state.v)
@info "$(state.v)"
check_infeasible_vertex(tree.root.problem.tlmo.blmo, tree)
@assert is_linear_feasible(tree.root.problem.tlmo, state.v)

Check warning on line 22 in src/callbacks.jl

View check run for this annotation

Codecov / codecov/patch

src/callbacks.jl#L19-L22

Added lines #L19 - L22 were not covered by tests
end
end
push!(fw_iterations, state.t)

Expand Down Expand Up @@ -108,6 +112,11 @@
end
end

# check for time limit
if isfinite(time_limit) && Dates.now() >= time_ref + Dates.Second(time_limit)
return false
end

return true
end
end
2 changes: 1 addition & 1 deletion src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
else
@assert FrankWolfe.active_set_validate(active_set)
for a in active_set.atoms
@assert is_linear_feasible(blmo, a)

Check warning on line 137 in src/interface.jl

View check run for this annotation

Codecov / codecov/patch

src/interface.jl#L137

Added line #L137 was not covered by tests
end
v = active_set.atoms[1]
end
Expand Down Expand Up @@ -273,7 +273,7 @@
num_int,
)

fw_callback = build_FW_callback(tree, min_number_lower, true, fw_iterations, min_fw_iterations)
fw_callback = build_FW_callback(tree, min_number_lower, true, fw_iterations, min_fw_iterations, time_ref, tree.root.options[:time_limit])

tree.root.options[:callback] = fw_callback
tree.root.current_node_id[] = Bonobo.get_next_node(tree, tree.options.traverse_strategy).id
Expand Down
1 change: 0 additions & 1 deletion src/node.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ function Bonobo.evaluate_node!(tree::Bonobo.BnBTree, node::FrankWolfeNode)
line_search=tree.root.options[:lineSearch],
lazy=tree.root.options[:lazy],
lazy_tolerance=tree.root.options[:lazy_tolerance],
timeout=tree.root.options[:time_limit],
add_dropped_vertices=tree.root.options[:use_shadow_set],
use_extra_vertex_storage=tree.root.options[:use_shadow_set],
extra_vertex_storage=node.discarded_vertices,
Expand Down
Loading