From fd655b2291f82e8d1d0098df8e4d71d6252492a8 Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Fri, 7 Jun 2024 12:07:26 -0500 Subject: [PATCH] collect_gmi_dual: Filter out useless cuts --- src/Cuts/tableau/gmi_dual.jl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Cuts/tableau/gmi_dual.jl b/src/Cuts/tableau/gmi_dual.jl index a46b0d8..379f667 100644 --- a/src/Cuts/tableau/gmi_dual.jl +++ b/src/Cuts/tableau/gmi_dual.jl @@ -126,6 +126,8 @@ function collect_gmi_dual( if length(cuts_s.lb) == 0 @info "No cuts generated. Aborting." break + else + @info "Generated $(length(cuts_s.lb)) cuts" end end @@ -153,6 +155,7 @@ function collect_gmi_dual( end @timeit "Add to model" begin + @info "Adding $(length(all_cuts.lb)) constraints to original model" constrs, gmi_exps = add_constraint_set_dual_v2(model, all_cuts) end end @@ -166,16 +169,28 @@ function collect_gmi_dual( push!(stats_obj, obj1) push!(stats_gap, gap(obj1)) sp = [shadow_price(c) for c in constrs] + undo_relax() end - @timeit "Reoptimize with updated obj function" begin + @timeit "Update obj function of original model" begin delete.(model, constrs) set_objective_function( model, obj_original - sum(sp[i] * gmi_exps[i] for (i, c) in enumerate(constrs)), ) end - undo_relax() + + @timeit "Filter out useless cuts" begin + useful = [abs(sp[i]) > 0.001 for (i, _) in enumerate(constrs)] + keep = findall(useful .== true) + @info "Keeping only $(length(keep)) useful cuts" + all_cuts.lhs = all_cuts.lhs[keep, :] + all_cuts.lb = all_cuts.lb[keep] + all_cuts.ub = all_cuts.ub[keep] + all_cuts_bases = all_cuts_bases[keep, :] + all_cuts_rows = all_cuts_rows[keep, :] + push!(stats_ncuts, length(all_cuts_rows)) + end end @timeit "Store cuts in H5 file" begin