diff --git a/src/callbacks.jl b/src/callbacks.jl index 27d013166..38b266346 100644 --- a/src/callbacks.jl +++ b/src/callbacks.jl @@ -5,6 +5,8 @@ function build_FW_callback( 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 @@ -13,10 +15,12 @@ function build_FW_callback( @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 + 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) + end end push!(fw_iterations, state.t) @@ -108,6 +112,11 @@ function build_FW_callback( 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 diff --git a/src/interface.jl b/src/interface.jl index 8b121128b..a1f36361c 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -273,7 +273,7 @@ function solve( 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 diff --git a/src/node.jl b/src/node.jl index 9df2b3c1b..9de63b69e 100644 --- a/src/node.jl +++ b/src/node.jl @@ -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,