Skip to content

Commit

Permalink
modifications for lazy constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhforrest committed Aug 29, 2023
1 parent d4272be commit 51159cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
41 changes: 25 additions & 16 deletions src/CbcModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,10 +1253,18 @@ void CbcModel::analyzeObjective()
value *= scaleFactor;
// trueIncrement=CoinMax(cutoff,value);;
if (value * 0.999 > cutoff) {
messageHandler()->message(CBC_INTEGERINCREMENT, messages())
if ((moreSpecialOptions2_ & 65536) == 0) {
messageHandler()->message(CBC_INTEGERINCREMENT, messages())
<< value << CoinMessageEol;
setDblParam(CbcModel::CbcCutoffIncrement,
CoinMax(value * 0.999, value - 1.0e-4));
setDblParam(CbcModel::CbcCutoffIncrement,
CoinMax(value * 0.999, value - 1.0e-4));
} else {
// lazy constraints - can't be certain
char temp[100];
sprintf(temp,"May be able to increase cutoff increment to %g - but we have lazy constraints",CoinMax(value*0.999,value-1.0e-4));
messageHandler()->message(CBC_GENERAL, messages())
<< temp << CoinMessageEol;
}
}
}
}
Expand Down Expand Up @@ -2375,9 +2383,10 @@ void CbcModel::branchAndBound(int doStatistics)
#endif
bool feasible;
numberSolves_ = 0;
{
// check
if (!parentModel_) {
int numberOdd = 0;
moreSpecialOptions2_ &= ~65536; // say no lazy constraints
// check
int numberSOS = 0;
for (int i = 0; i < numberObjects_; i++) {
CbcSimpleInteger *obj = dynamic_cast<CbcSimpleInteger *>(object_[i]);
Expand All @@ -2395,18 +2404,18 @@ void CbcModel::branchAndBound(int doStatistics)
#endif
specialOptions_ &= ~(512 | 32768);
}
moreSpecialOptions2_ &= ~65536; // say no lazy constraints
if (!numberOdd && !parentModel_) {
// see if lazy constraints
bool needCuts = false;
for (int i = 0; i < numberCutGenerators_; i++) {
bool generate = generator_[i]->atSolution();
if (generate) {
needCuts = true;
}
// see if lazy constraints
bool needCuts = false;
for (int i = 0; i < numberCutGenerators_; i++) {
bool generate = generator_[i]->atSolution();
if (generate) {
needCuts = true;
}
if (needCuts)
moreSpecialOptions2_ |= 65536; // lazy constraints
}
if (needCuts) {
moreSpecialOptions2_ |= 65536; // lazy constraints
// switch off nauty
moreSpecialOptions2_ &= ~(128|256);
}
}
// If NLP then we assume already solved outside branchAndbound
Expand Down
8 changes: 5 additions & 3 deletions src/CbcSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,7 @@ int CbcMain1(std::deque<std::string> inputQueue, CbcModel &model,
buffer.str("");
buffer << "switching on global root cuts for gomory and "
<< "knapsack" << std::endl;
buffer << "using OSL factorization" << std::endl;
//buffer << "using OSL factorization" << std::endl;
buffer << "extra options - -rens on -extra4 " << extra4
<< " -passc 1000!" << std::endl;
printGeneralMessage(model_, buffer.str());
Expand All @@ -2321,7 +2321,7 @@ int CbcMain1(std::deque<std::string> inputQueue, CbcModel &model,
parameters[CbcParam::KNAPSACKCUTS]->setVal("onGlobal");
knapsackMode = CbcParameters::CGOnGlobal;
clpParameters[ClpParam::FACTORIZATION]->setVal("osl");
lpSolver->factorization()->forceOtherFactorization(3);
//lpSolver->factorization()->forceOtherFactorization(3);
parameters[CbcParam::MAXHOTITS]->setVal(100);
parameters[CbcParam::CUTPASS]->setVal(1000);
cutPass = 1000;
Expand Down Expand Up @@ -6339,9 +6339,11 @@ int CbcMain1(std::deque<std::string> inputQueue, CbcModel &model,
double increment = babModel_->getCutoffIncrement();
;
int *changed = NULL;
if (!miplib && increment == normalIncrement)
#ifdef UNSAFE_FOR_LAZY_CUTS
if (!miplib && increment == normalIncrement)
changed = analyze(osiclp, numberChanged, increment, false,
generalMessageHandler, parameters.noPrinting());
#endif
#elif CBC_OTHER_SOLVER == 1
double increment = babModel_->getCutoffIncrement();
;
Expand Down

0 comments on commit 51159cf

Please sign in to comment.