From 926c50e8648e1d6c0f0a242294f2efc2771ab1d9 Mon Sep 17 00:00:00 2001 From: Henri Lefebvre Date: Mon, 16 Oct 2023 10:36:40 +0200 Subject: [PATCH] take into account the Ctr sense --- lib/src/optimizers/callbacks/SimpleRounding.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/optimizers/callbacks/SimpleRounding.cpp b/lib/src/optimizers/callbacks/SimpleRounding.cpp index 3db39232..e1220ee6 100644 --- a/lib/src/optimizers/callbacks/SimpleRounding.cpp +++ b/lib/src/optimizers/callbacks/SimpleRounding.cpp @@ -28,14 +28,20 @@ void idol::Heuristics::SimpleRounding::Strategy::operator()(CallbackEvent t_even throw Exception("SimpleRounding for quadratic problems is not implemented."); } - std::optional is_trivially_up_roundable = 0; + std::optional is_trivially_up_roundable = 0; // The name assumes <= constraints for (const auto& [ctr, coefficient] : column.linear()) { if (!coefficient.is_numerical()) { throw Exception("A coefficient which is non numerical was found when rounding."); } - bool direction = coefficient.numerical() >= 0.; + const auto type = model.get_ctr_type(ctr); + + if (type == Equal) { + return; + } + + bool direction = (type == LessOrEqual && coefficient.numerical() >= 0.) || (type == GreaterOrEqual && coefficient.numerical() <= 0.); if (!is_trivially_up_roundable.has_value()) { is_trivially_up_roundable = direction;