mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 08:28:52 -06:00
FisSal2011: Large LP: Add cuts in small batches
This commit is contained in:
@@ -608,7 +608,7 @@ function collect_gmi_FisSal2011(
|
||||
end
|
||||
|
||||
@timeit "Computing cut violations" begin
|
||||
violations = (pool.lb' - (sol_frac' * pool.lhs))'
|
||||
violations = pool.lb - pool.lhs' * sol_frac
|
||||
end
|
||||
|
||||
@timeit "Sorting cut violations" begin
|
||||
@@ -619,23 +619,29 @@ function collect_gmi_FisSal2011(
|
||||
break
|
||||
end
|
||||
|
||||
@timeit "Add constraint to the model" begin
|
||||
push!(selected_idx, σ[1])
|
||||
cut_lhs = pool.lhs[:, σ[1]]
|
||||
cut_lhs_value = 0.0
|
||||
cut_lb = pool.lb[σ[1]]
|
||||
cut_expr = AffExpr()
|
||||
for offset in 1:nnz(cut_lhs)
|
||||
var_idx = cut_lhs.nzind[offset]
|
||||
add_to_expression!(
|
||||
cut_expr,
|
||||
vars_s[var_idx],
|
||||
cut_lhs.nzval[offset],
|
||||
)
|
||||
cut_lhs_value += sol_frac[var_idx] * cut_lhs.nzval[offset]
|
||||
@timeit "Add constraints to the model" begin
|
||||
ncuts = min(max(1, sum(violations .> 1e-6) ÷ 10), length(σ))
|
||||
for i in 1:ncuts
|
||||
if violations[σ[i]] <= 1e-6
|
||||
break
|
||||
end
|
||||
cut_lhs = pool.lhs[:, σ[i]]
|
||||
cut_lhs_value = 0.0
|
||||
cut_lb = pool.lb[σ[i]]
|
||||
cut_expr = AffExpr()
|
||||
for offset in 1:nnz(cut_lhs)
|
||||
var_idx = cut_lhs.nzind[offset]
|
||||
add_to_expression!(
|
||||
cut_expr,
|
||||
vars_s[var_idx],
|
||||
cut_lhs.nzval[offset],
|
||||
)
|
||||
cut_lhs_value += sol_frac[var_idx] * cut_lhs.nzval[offset]
|
||||
end
|
||||
cut_constr = @constraint(model_s, cut_expr >= cut_lb)
|
||||
push!(selected_idx, σ[i])
|
||||
push!(selected_contrs, cut_constr)
|
||||
end
|
||||
cut_constr = @constraint(model_s, cut_expr >= cut_lb)
|
||||
push!(selected_contrs, cut_constr)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user