From ca1d6f47ed8a30ed78cc2b3beff98c466894f1fe Mon Sep 17 00:00:00 2001 From: Yu Xie Date: Sat, 14 Oct 2023 04:20:19 -0400 Subject: [PATCH] change row bnd rounding rule to tolerance based --- src/MibSBilevel.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/MibSBilevel.cpp b/src/MibSBilevel.cpp index ecf18fbf..acf2ea62 100644 --- a/src/MibSBilevel.cpp +++ b/src/MibSBilevel.cpp @@ -919,8 +919,8 @@ MibSBilevel::setUpModel(OsiSolverInterface * oSolver, bool newOsi, /** Set the row bounds **/ for(i = 0; i < lRows; i++){ index1 = lRowIndices[i]; - rowLb[i] = floor(origRowLb[index1] + 0.5); - rowUb[i] = floor(origRowUb[index1] + 0.5); + rowLb[i] = origRowLb[index1]; + rowUb[i] = origRowUb[index1]; } if (feasCheckSolver == "Cbc"){ @@ -1224,8 +1224,16 @@ MibSBilevel::setUpModel(OsiSolverInterface * oSolver, bool newOsi, /** Correct the row bounds to account for fixed upper-level vars **/ for(i = 0; i < lRows; i++){ - nSolver->setRowLower(i, floor(rowLb[i] - upComp[i] + 0.5)); - nSolver->setRowUpper(i, floor(rowUb[i] - upComp[i] + 0.5)); + if(fabs(rowLb[i] - upComp[i] - floor(rowLb[i] - upComp[i] + 0.5)) < etol){ + nSolver->setRowLower(i, floor(rowLb[i] - upComp[i] + 0.5)); + }else{ + nSolver->setRowLower(i, rowLb[i] - upComp[i]); + } + if(fabs(rowUb[i] - upComp[i] - floor(rowUb[i] - upComp[i] + 0.5)) < etol){ + nSolver->setRowUpper(i, floor(rowUb[i] - upComp[i] + 0.5)); + }else{ + nSolver->setRowUpper(i, rowUb[i] - upComp[i]); + } } delete [] upComp;