diff --git a/src/Cuts/tableau/gmi_dual.jl b/src/Cuts/tableau/gmi_dual.jl index 4795315..ee762e9 100644 --- a/src/Cuts/tableau/gmi_dual.jl +++ b/src/Cuts/tableau/gmi_dual.jl @@ -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