mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 08:28:52 -06:00
BB: Fix incorrect set_bounds call; add failing tests
This commit is contained in:
@@ -58,6 +58,13 @@ function solve!(
|
||||
sleep(0.1)
|
||||
continue
|
||||
else
|
||||
# Assert node is feasible
|
||||
_set_node_bounds(node)
|
||||
status, _ = solve_relaxation!(mip)
|
||||
@assert status == :Optimal
|
||||
_unset_node_bounds(node)
|
||||
|
||||
# Find branching variable
|
||||
ids = generate_indices(pool, 2)
|
||||
branch_var = find_branching_var(branch_rule, node, pool)
|
||||
|
||||
@@ -136,8 +143,7 @@ function _create_node(
|
||||
fractional_variables = Variable[]
|
||||
fractional_values = Float64[]
|
||||
end
|
||||
n_branch = length(branch_vars)
|
||||
set_bounds!(mip, branch_vars, zeros(n_branch), ones(n_branch))
|
||||
set_bounds!(mip, mip.int_vars, mip.int_vars_lb, mip.int_vars_ub)
|
||||
return Node(
|
||||
mip,
|
||||
index,
|
||||
@@ -197,3 +203,11 @@ function solve!(
|
||||
|
||||
return pool
|
||||
end
|
||||
|
||||
function _set_node_bounds(node::Node)
|
||||
set_bounds!(node.mip, node.branch_vars, node.branch_lb, node.branch_ub)
|
||||
end
|
||||
|
||||
function _unset_node_bounds(node::Node)
|
||||
set_bounds!(node.mip, node.mip.int_vars, node.mip.int_vars_lb, node.mip.int_vars_ub)
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ function find_branching_var(
|
||||
]
|
||||
σ = sortperm(pseudocost_scores, rev = true)
|
||||
sorted_vars = node.fractional_variables[σ]
|
||||
_strong_branch_start(node)
|
||||
_set_node_bounds(node)
|
||||
no_improv_count, n_sb_calls = 0, 0
|
||||
max_score, max_var = pseudocost_scores[σ[1]], sorted_vars[1]
|
||||
for (i, var) in enumerate(sorted_vars)
|
||||
@@ -72,6 +72,6 @@ function find_branching_var(
|
||||
end
|
||||
no_improv_count <= rule.look_ahead || break
|
||||
end
|
||||
_strong_branch_end(node)
|
||||
_unset_node_bounds(node)
|
||||
return max_var
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ function find_branching_var(rule::StrongBranching, node::Node, pool::NodePool)::
|
||||
]
|
||||
σ = sortperm(pseudocost_scores, rev = true)
|
||||
sorted_vars = node.fractional_variables[σ]
|
||||
_strong_branch_start(node)
|
||||
_set_node_bounds(node)
|
||||
no_improv_count, call_count = 0, 0
|
||||
max_score, max_var = (-Inf, -Inf), sorted_vars[1]
|
||||
for (i, var) in enumerate(sorted_vars)
|
||||
@@ -55,7 +55,7 @@ function find_branching_var(rule::StrongBranching, node::Node, pool::NodePool)::
|
||||
no_improv_count <= rule.look_ahead || break
|
||||
call_count <= rule.max_calls || break
|
||||
end
|
||||
_strong_branch_end(node)
|
||||
_unset_node_bounds(node)
|
||||
return max_var
|
||||
end
|
||||
|
||||
@@ -94,11 +94,3 @@ function _strong_branch_score(;
|
||||
end
|
||||
return (obj_change_up * obj_change_down, var.index)
|
||||
end
|
||||
|
||||
function _strong_branch_start(node::Node)
|
||||
set_bounds!(node.mip, node.branch_vars, node.branch_lb, node.branch_ub)
|
||||
end
|
||||
|
||||
function _strong_branch_end(node::Node)
|
||||
set_bounds!(node.mip, node.mip.int_vars, node.mip.int_vars_lb, node.mip.int_vars_ub)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user