From 88488b234dbb0387a08f690fa6d22db47621efc6 Mon Sep 17 00:00:00 2001 From: Ted Ralphs Date: Fri, 29 Nov 2024 16:38:55 +0100 Subject: [PATCH] Allowing branching on linking variables even when doing fractional branching to accpount for some cases where cut generation fails --- src/MibSBranchStrategyPseudo.cpp | 15 +++++++++++++-- src/MibSCutGenerator.cpp | 14 +++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/MibSBranchStrategyPseudo.cpp b/src/MibSBranchStrategyPseudo.cpp index 4ba5efd3..d6aba9e0 100644 --- a/src/MibSBranchStrategyPseudo.cpp +++ b/src/MibSBranchStrategyPseudo.cpp @@ -158,17 +158,28 @@ MibSBranchStrategyPseudo::createCandBranchObjects(int numPassesLeft, double ub) } } - // Check for fractional lower level variables variables + // Check for fractional lower level variables if(branchPar == MibSBranchingStrategyLower){ for (i = 0; i < numCols; ++i) { if (fabs(floor(solution[i] + 0.5) - solution[i]) > etol && - varType[i] == MibSVarLower){ + varType[i] == MibSVarLower && colType[i] == 'C'){ fractionalLowerVar = true; break; } } } + // Check for fractional variables overall + if(branchPar == MibSBranchingStrategyFractional){ + for (i = 0; i < numCols; ++i) { + if (fabs(floor(solution[i] + 0.5) - solution[i]) > etol && + colType[i] != 'C'){ + branchPar = MibSBranchingStrategyLinking; + break; + } + } + } + for (i = 0; i < numCols; ++i) { if(colType[i] == 'C'){ candidate[i] = false; diff --git a/src/MibSCutGenerator.cpp b/src/MibSCutGenerator.cpp index 35856d2a..314174ee 100644 --- a/src/MibSCutGenerator.cpp +++ b/src/MibSCutGenerator.cpp @@ -1245,7 +1245,7 @@ MibSCutGenerator::solveModelIC(double *uselessIneqs, double *ray, double *rhs, } } - assert(alphaUb >= 0); + //assert(alphaUb >= 0); if(isUnbounded == false){ alpha = alphaUb; @@ -6062,7 +6062,7 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool) if (localModel_->MibSPar_->entry(MibSParams::bilevelFreeSetTypeISIC) == MibSBilevelFreeSetTypeISICWithLLOptSol && haveSecondLevelSol && relaxedObjVal <= localModel_->bS_->objVal_ + localModel_->etol_){ - localModel_->counterFracISICFail_++; + localModel_->counterLIntISICFail_++; }else if ((localModel_->MibSPar_->entry(MibSParams::bilevelFreeSetTypeISIC) == MibSBilevelFreeSetTypeISICWithLLOptSol && haveSecondLevelSol) || localModel_->MibSPar_->entry(MibSParams::bilevelFreeSetTypeISIC) == @@ -6070,9 +6070,9 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool) cutType = MibSIntersectionCutImprovingSolution; returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType); if (returnVal){ - localModel_->counterFracISIC_++; + localModel_->counterLIntISIC_++; }else{ - localModel_->counterFracISICFail_++; + localModel_->counterLIntISICFail_++; } numCuts += returnVal; } @@ -6127,7 +6127,7 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool) if (localModel_->MibSPar_->entry(MibSParams::bilevelFreeSetTypeISIC) == MibSBilevelFreeSetTypeISICWithLLOptSol && haveSecondLevelSol && relaxedObjVal <= localModel_->bS_->objVal_ + localModel_->etol_){ - localModel_->counterFracISICFail_++; + localModel_->counterYIntISICFail_++; }else if ((localModel_->MibSPar_->entry(MibSParams::bilevelFreeSetTypeISIC) == MibSBilevelFreeSetTypeISICWithLLOptSol && haveSecondLevelSol) || localModel_->MibSPar_->entry(MibSParams::bilevelFreeSetTypeISIC) == @@ -6135,9 +6135,9 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool) cutType = MibSIntersectionCutImprovingSolution; returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType); if (returnVal){ - localModel_->counterFracISIC_++; + localModel_->counterYIntISIC_++; }else{ - localModel_->counterFracISICFail_++; + localModel_->counterYIntISICFail_++; } numCuts += returnVal; }