From 725cdd3e9083393f9b3a32712a32d104751041fa Mon Sep 17 00:00:00 2001 From: tbittar Date: Wed, 22 Nov 2023 16:01:38 +0100 Subject: [PATCH] Fix gap contribution bug (#722) Co-authored-by: Thomas Bittar (cherry picked from commit 9eaff46e3fcc0a662eca15acbf3a032178c6302a) --- src/cpp/benders/benders_by_batch/BendersByBatch.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpp/benders/benders_by_batch/BendersByBatch.cpp b/src/cpp/benders/benders_by_batch/BendersByBatch.cpp index fb2a72826..1ac6cf04b 100644 --- a/src/cpp/benders/benders_by_batch/BendersByBatch.cpp +++ b/src/cpp/benders/benders_by_batch/BendersByBatch.cpp @@ -264,7 +264,8 @@ void BendersByBatch::GetSubproblemCut( subproblem_data.var_name_and_subgradient); // dual pi_s auto subpb_cost_under_approx = GetAlpha_i()[ProblemToId(name)]; *batch_subproblems_costs_contribution_in_gap_per_proc += - subproblem_data.subproblem_cost - subpb_cost_under_approx; + std::max(subproblem_data.subproblem_cost - subpb_cost_under_approx, + static_cast(0)); double cut_value_at_x_cut = subproblem_data.subproblem_cost; for (const auto &[candidate_name, x_cut_candidate_value] : _data.x_cut) { auto subgradient_at_name =