From 6f017c664581d90b7394a80a7ed998023bce8313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Mon, 2 Dec 2024 20:34:15 +0100 Subject: [PATCH] Fix variable bounds for 1st week in the year (#2517) See function `ORTOOLS_CorrigerLesBornes`. --- src/solver/optimisation/LegacyFiller.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/solver/optimisation/LegacyFiller.cpp b/src/solver/optimisation/LegacyFiller.cpp index 7cbcaff820..c1f2f7edcb 100644 --- a/src/solver/optimisation/LegacyFiller.cpp +++ b/src/solver/optimisation/LegacyFiller.cpp @@ -46,9 +46,18 @@ void LegacyFiller::CopyMatrix(ILinearProblem& pb) const void LegacyFiller::CreateVariable(unsigned idxVar, ILinearProblem& pb) const { - double min_l = problemeSimplexe_->Xmin[idxVar]; - double max_l = problemeSimplexe_->Xmax[idxVar]; - bool isIntegerVariable = problemeSimplexe_->IntegerVariable(idxVar); + const double bMin = problemeSimplexe_->Xmin[idxVar]; + const double bMax = problemeSimplexe_->Xmax[idxVar]; + const int typeVar = problemeSimplexe_->TypeDeVariable[idxVar]; + + double min_l = (typeVar == VARIABLE_NON_BORNEE || typeVar == VARIABLE_BORNEE_SUPERIEUREMENT) + ? -pb.infinity() + : bMin; + double max_l = (typeVar == VARIABLE_NON_BORNEE || typeVar == VARIABLE_BORNEE_INFERIEUREMENT) + ? pb.infinity() + : bMax; + const bool isIntegerVariable = problemeSimplexe_->IntegerVariable(idxVar); + auto* var = pb.addVariable(min_l, max_l, isIntegerVariable, GetVariableName(idxVar)); pb.setObjectiveCoefficient(var, problemeSimplexe_->CoutLineaire[idxVar]); }