Skip to content

Commit

Permalink
Better printing of statistics and some bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tkralphs committed Nov 7, 2024
1 parent 3289751 commit 6c1cc80
Show file tree
Hide file tree
Showing 5 changed files with 273 additions and 37 deletions.
124 changes: 95 additions & 29 deletions src/MibSCutGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,13 @@ MibSCutGenerator::feasibilityCuts(BcpsConstraintPool &conPool)
= localModel_->MibSPar_->entry(MibSParams::useValFuncCut);

if(useIntegerNoGoodCut && !useValFuncCut){
return bilevelFeasCut1(conPool) ? true : false;
return bilevelFeasCut1(conPool);
}
else if(!useIntegerNoGoodCut && useValFuncCut){
return bilevelFeasCut2(conPool) ? true : false;
return bilevelFeasCut2(conPool);
}
else if(useIntegerNoGoodCut && useValFuncCut){
return ((bilevelFeasCut1(conPool) ? true : false) ||
(bilevelFeasCut2(conPool) ? true : false));
return (bilevelFeasCut1(conPool) + bilevelFeasCut2(conPool));
}
else{
//std::cout << "No MIBS Cuts generated" << std::endl;
Expand Down Expand Up @@ -5886,6 +5885,8 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool)
(useLinkingSolutionPool != PARAM_ON &&
bS->isLowerSolved_ != false &&
bS->isProvenOptimal_ != false));

int returnVal(0);

if ((useBoundCut) && (localModel_->boundingPass_ <= 1)){

Expand Down Expand Up @@ -5951,27 +5952,43 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool)
int bendersInterdictionCutType =
localModel_->MibSPar_->entry(MibSParams::bendersInterdictionCutType);
if(bendersInterdictionCutType == MibSBendersInterdictionCutTypeJustOneCut){
numCuts += bendersInterdictionOneCut(conPool,
returnVal = bendersInterdictionOneCut(conPool,
bS->optLowerSolutionOrd_);
}
else{
numCuts += bendersInterdictionMultipleCuts(conPool);
}
returnVal = bendersInterdictionMultipleCuts(conPool);
}
numCuts += returnVal;
localModel_->counterBendersInterdict_ += returnVal;
}

if (useImprovingSolutionIC == PARAM_ON){
cutType = MibSIntersectionCutImprovingSolution;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
if (returnVal){
localModel_->counterXYIntISIC_++;
}else{
localModel_->counterXYIntISICFail_++;
}
numCuts += returnVal;
}

if (useImprovingDirectionIC == PARAM_ON){
cutType = MibSIntersectionCutImprovingDirection;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
if (returnVal){
localModel_->counterXYIntIDIC_++;
}else{
localModel_->counterXYIntIDICFail_++;
}
numCuts += returnVal;
}

if (useHypercubeIC == PARAM_ON){
cutType = MibSIntersectionCutHypercube;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
localModel_->counterHypercubeIC_ += returnVal;
numCuts += returnVal;
}

if (useTenderIC == PARAM_ON){
Expand All @@ -5985,15 +6002,21 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool)
}

if (useGeneralizedNoGoodCut == PARAM_ON){
numCuts += generalizedNoGoodCut(conPool);
returnVal = generalizedNoGoodCut(conPool);
localModel_->counterGeneralizedNoGood_ += returnVal;
numCuts += returnVal;
}

if (useBendersBinaryCut == PARAM_ON &&
relaxedObjVal > localModel_->bS_->objVal_ + localModel_->etol_){
numCuts += bendersBinaryCut(conPool);
returnVal = bendersBinaryCut(conPool);
localModel_->counterBendersBinary_ += returnVal;
numCuts += returnVal;
}

numCuts += feasibilityCuts(conPool) ? true : false;
returnVal = feasibilityCuts(conPool);
localModel_->counterBendersInterdict_ += returnVal;
numCuts += returnVal;

//This return value indicates whether the relaxation needs to be re-solved
//and should always be false (see BlisTreeNode.cpp)
Expand All @@ -6005,45 +6028,64 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool)
int bendersInterdictionCutType =
localModel_->MibSPar_->entry(MibSParams::bendersInterdictionCutType);
if(bendersInterdictionCutType == MibSBendersInterdictionCutTypeJustOneCut){
numCuts += bendersInterdictionOneCut(conPool,
bS->optLowerSolutionOrd_);
returnVal = bendersInterdictionOneCut(conPool,
bS->optLowerSolutionOrd_);
}else{
returnVal = bendersInterdictionMultipleCuts(conPool);
}
else{
numCuts += bendersInterdictionMultipleCuts(conPool);
}
localModel_->counterBendersInterdict_ += returnVal;
numCuts += returnVal;
}
if (useImprovingDirectionIC == PARAM_ON &&
(IDICGenStrategy == MibSIDICGenStrategyLInt ||
IDICGenStrategy == MibSIDICGenStrategyAlways ||
(IDICGenStrategy == MibSIDICGenStrategyAlwaysRoot &&
localModel_->activeNode_->getDepth() == 0))){
cutType = MibSIntersectionCutImprovingDirection;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
if (returnVal){
localModel_->counterLIntIDIC_++;
}else{
localModel_->counterLIntIDICFail_++;
}
numCuts += returnVal;
}
if (useImprovingSolutionIC == PARAM_ON &&
((haveSecondLevelSol &&
relaxedObjVal > localModel_->bS_->objVal_ + localModel_->etol_) ||
(localModel_->MibSPar_->entry(MibSParams::bilevelFreeSetTypeISIC) ==
MibSBilevelFreeSetTypeISICWithNewLLSol &&
MibSBilevelFreeSetTypeISICWithNewLLSol)) &&
(ISICGenStrategy == MibSISICGenStrategyLInt ||
ISICGenStrategy == MibSISICGenStrategyAlways ||
(ISICGenStrategy == MibSISICGenStrategyAlwaysRoot &&
localModel_->activeNode_->getDepth() == 0))))){
localModel_->activeNode_->getDepth() == 0))){
cutType = MibSIntersectionCutImprovingSolution;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
if (returnVal){
localModel_->counterLIntISIC_++;
}else{
localModel_->counterLIntISICFail_++;
}
numCuts += returnVal;
}
if (useHypercubeIC == PARAM_ON && haveSecondLevelSol){
cutType = MibSIntersectionCutHypercube;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
localModel_->counterHypercubeIC_ += returnVal;
numCuts += returnVal;
}
if (localModel_->allUpperBin_){
//problem with binary UL variables and integer LL variables
if (useGeneralizedNoGoodCut == PARAM_ON){
numCuts += generalizedNoGoodCut(conPool);
returnVal = generalizedNoGoodCut(conPool);
localModel_->counterGeneralizedNoGood_ += returnVal;
numCuts += returnVal;
}
if (useBendersBinaryCut == PARAM_ON &&
relaxedObjVal > localModel_->bS_->objVal_ + localModel_->etol_){
numCuts += bendersBinaryCut(conPool);
returnVal = bendersBinaryCut(conPool);
localModel_->counterBendersBinary_ += returnVal;
numCuts += returnVal;
}
}

Expand All @@ -6058,7 +6100,13 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool)
(IDICGenStrategy == MibSIDICGenStrategyAlwaysRoot &&
localModel_->activeNode_->getDepth() == 0))){
cutType = MibSIntersectionCutImprovingDirection;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
if (returnVal){
localModel_->counterYIntIDIC_++;
}else{
localModel_->counterYIntIDICFail_++;
}
numCuts += returnVal;
}
if (useImprovingSolutionIC == PARAM_ON &&
((haveSecondLevelSol &&
Expand All @@ -6070,15 +6118,27 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool)
(ISICGenStrategy == MibSISICGenStrategyAlwaysRoot &&
localModel_->activeNode_->getDepth() == 0))))){
cutType = MibSIntersectionCutImprovingSolution;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
if (returnVal){
localModel_->counterYIntISIC_++;
}else{
localModel_->counterYIntISICFail_++;
}
numCuts += returnVal;
}
}else{
if (useImprovingDirectionIC == PARAM_ON &&
(IDICGenStrategy == MibSIDICGenStrategyAlways ||
(IDICGenStrategy == MibSIDICGenStrategyAlwaysRoot &&
localModel_->activeNode_->getDepth() == 0))){
cutType = MibSIntersectionCutImprovingDirection;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
if (returnVal){
localModel_->counterFracIDIC_++;
}else{
localModel_->counterFracIDICFail_++;
}
numCuts += returnVal;
}
if (useImprovingSolutionIC == PARAM_ON &&
((haveSecondLevelSol &&
Expand All @@ -6089,7 +6149,13 @@ MibSCutGenerator::generateConstraints(BcpsConstraintPool &conPool)
(ISICGenStrategy == MibSIDICGenStrategyAlwaysRoot &&
localModel_->activeNode_->getDepth() == 0))))){
cutType = MibSIntersectionCutImprovingSolution;
numCuts += intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
returnVal = intersectionCuts(conPool, bS->optLowerSolutionOrd_, cutType);
if (returnVal){
localModel_->counterFracISIC_++;
}else{
localModel_->counterFracISICFail_++;
}
numCuts += returnVal;
}
}

Expand Down
32 changes: 29 additions & 3 deletions src/MibSModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,27 @@ MibSModel::initialize()
objAlignment_ = 0;
counterVF_ = 0;
counterUB_ = 0;
counterXYIntIDIC_ = 0;
counterLIntIDIC_ = 0;
counterYIntIDIC_ = 0;
counterFracIDIC_ = 0;
counterXYIntIDICFail_ = 0;
counterLIntIDICFail_ = 0;
counterYIntIDICFail_ = 0;
counterFracIDICFail_ = 0;
counterXYIntISIC_ = 0;
counterLIntISIC_ = 0;
counterYIntISIC_ = 0;
counterFracISIC_ = 0;
counterXYIntISICFail_ = 0;
counterLIntISICFail_ = 0;
counterYIntISICFail_ = 0;
counterFracISICFail_ = 0;
counterBendersInterdict_ = 0;
counterHypercubeIC_ = 0;
counterGeneralizedNoGood_ = 0;
counterBendersBinary_ = 0;
counterIntegerNoGood_ = 0;
timerVF_ = 0.0;
timerUB_ = 0.0;
countIteration_ = 0;
Expand Down Expand Up @@ -3934,8 +3955,10 @@ MibSModel::adjustParameters()
}
if (MibSPar_->entry(MibSParams::useImprovingDirectionIC) == PARAM_ON){
defaultCutIsOn = true;
if (MibSPar_->entry(MibSParams::IDICGenStrategy) == MibSIDICGenStrategyNotSet){
MibSPar()->setEntry(MibSParams::IDICGenStrategy, MibSIDICGenStrategyXYInt);
if (MibSPar_->entry(MibSParams::IDICGenStrategy) ==
MibSIDICGenStrategyNotSet){
MibSPar()->setEntry(MibSParams::IDICGenStrategy,
MibSIDICGenStrategyAlways);
}
}

Expand All @@ -3948,7 +3971,10 @@ MibSModel::adjustParameters()
paramValue = MibSPar_->entry(MibSParams::useImprovingSolutionIC);

if (paramValue == PARAM_NOTSET){
if (lowerRowSignsConsistent_ == false || upperRowSignsConsistent_ == false){
if (lowerRowSignsConsistent_ == false || upperRowSignsConsistent_ == false ||
isPureInteger_ == false || isLowerCoeffInt_ == false ||
(MibSPar_->entry(MibSParams::bilevelFreeSetTypeISIC) ==
MibSBilevelFreeSetTypeISICWithNewLLSol && isLowerObjInt_ == false)){
MibSPar()->setEntry(MibSParams::useImprovingSolutionIC, PARAM_OFF);
}else{
MibSPar()->setEntry(MibSParams::useImprovingSolutionIC, PARAM_ON);
Expand Down
63 changes: 63 additions & 0 deletions src/MibSModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,69 @@ class MibSModel : public BlisModel {
/** Number of (UB) solved **/
int counterUB_;

/** Number of IDICs generated when solution is fully integer **/
int counterXYIntIDIC_;

/** Number of IDICs generated when linking variables are integer **/
int counterLIntIDIC_;

/** Number of IDICs generated when lower-level is integer **/
int counterYIntIDIC_;

/** Number of IDICs generated when solutions is fractional **/
int counterFracIDIC_;

/** Number of IDIC fails when solution is fully integer **/
int counterXYIntIDICFail_;

/** Number of IDIC fails when linking variables are integer **/
int counterLIntIDICFail_;

/** Number of IDIC fails when lower-level is integer **/
int counterYIntIDICFail_;

/** Number of IDIC fails when solutions is fractional **/
int counterFracIDICFail_;

/** Number of ISICs generated when solution is fully integer **/
int counterXYIntISIC_;

/** Number of ISICs generated when linking variables are integer **/
int counterLIntISIC_;

/** Number of ISICs generated when lower-level is integer **/
int counterYIntISIC_;

/** Number of ISICs generated when solutions is fractional **/
int counterFracISIC_;

/** Number of ISIC fails when solution is fully integer **/
int counterXYIntISICFail_;

/** Number of ISIC fails when linking variables are integer **/
int counterLIntISICFail_;

/** Number of ISIC fails when lower-level is integer **/
int counterYIntISICFail_;

/** Number of ISIC fails when solutions is fractional**/
int counterFracISICFail_;

/** Number of Benders Interdiction cuts generated **/
int counterBendersInterdict_;

/** Number of Hypercube Intersection cuts generated **/
int counterHypercubeIC_;

/** Number of Generalized No Good cuts generated **/
int counterGeneralizedNoGood_;

/** Number of Benders Binary cuts generated **/
int counterBendersBinary_;

/** Number of Integer No Good cuts generated **/
int counterIntegerNoGood_;

/** Time for solving (VF) **/
double timerVF_;

Expand Down
4 changes: 4 additions & 0 deletions src/MibSParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,12 @@ MibSParams::setDefaultEntries() {

setEntry(useImprovingSolutionIC, PARAM_NOTSET);

setEntry(ISICGenStrategy, MibSISICGenStrategyNotSet);

setEntry(useImprovingDirectionIC, PARAM_NOTSET);

setEntry(IDICGenStrategy, MibSIDICGenStrategyNotSet);

setEntry(useHypercubeIC, PARAM_NOTSET);

setEntry(useTenderIC, PARAM_NOTSET);
Expand Down
Loading

0 comments on commit 6c1cc80

Please sign in to comment.