Skip to content

Commit

Permalink
ask for cpu time less often
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhforrest committed Apr 17, 2024
1 parent 73359bf commit cb855c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/CbcHeuristicFPump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ int CbcHeuristicFPump::solutionInternal(double &solutionValue,
if (clpSolver) {
// better to clean up using primal?
ClpSimplex *lp = clpSolver->getModelPtr();
// try and re-use factorization
clpSolver->setSpecialOptions(clpSolver->specialOptions()|8);
int options = lp->specialOptions();
lp->setSpecialOptions(options | 8192);
//lp->setSpecialOptions(options|0x01000000);
Expand Down
6 changes: 3 additions & 3 deletions src/CbcModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6415,7 +6415,7 @@ CbcModel::CbcModel()
numberStrong_(5), numberBeforeTrust_(10), numberPenalties_(20),
stopNumberIterations_(-1), penaltyScaleFactor_(3.0),
numberAnalyzeIterations_(0), analyzeResults_(NULL),
numberInfeasibleNodes_(0), problemType_(0), printFrequency_(1),
numberInfeasibleNodes_(0), problemType_(0), printFrequency_(100),
secsPrintFrequency_(1), lastSecPrintProgress_(0.0),
numberCutGenerators_(0), generator_(NULL), virginGenerator_(NULL),
numberHeuristics_(0), heuristic_(NULL), lastHeuristic_(NULL),
Expand Down Expand Up @@ -6518,7 +6518,7 @@ CbcModel::CbcModel(const OsiSolverInterface &rhs)
presolve_(0), numberStrong_(5), numberBeforeTrust_(10),
numberPenalties_(20), stopNumberIterations_(-1), penaltyScaleFactor_(3.0),
numberAnalyzeIterations_(0), analyzeResults_(NULL),
numberInfeasibleNodes_(0), problemType_(0), printFrequency_(1),
numberInfeasibleNodes_(0), problemType_(0), printFrequency_(100),
secsPrintFrequency_(1), lastSecPrintProgress_(0.0),
numberCutGenerators_(0), generator_(NULL), virginGenerator_(NULL),
numberHeuristics_(0), heuristic_(NULL), lastHeuristic_(NULL),
Expand Down Expand Up @@ -19792,7 +19792,7 @@ bool CbcModel::stoppingCriterionReached() const {
// Return true if maximum time reached
bool CbcModel::maximumSecondsReached() const {
double maxSeconds = getMaximumSeconds();
if (maxSeconds>1.0e10 &&
if (maxSeconds>0.99e8 &&
dblParam_[CbcMaxSecondsNotImproving]>1.0e10)
return false;
double totalTime = getCurrentSeconds();
Expand Down
9 changes: 5 additions & 4 deletions src/CbcNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe
depth_ = 0;
delete branch_;
branch_ = NULL;
double maxTime = model->getDblParam(CbcModel::CbcMaximumSeconds);
OsiSolverInterface *solver = model->solver();
// Mark variables which need to be clean
char *cleanVariables = NULL;
Expand Down Expand Up @@ -929,7 +930,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe
//if (!model->parentModel())
//solver->writeMps("query");
// If we have hit max time don't do strong branching
bool hitMaxTime = (model->getCurrentSeconds() > model->getDblParam(CbcModel::CbcMaximumSeconds));
bool hitMaxTime = maxTime>1.0e18 ? false :(model->getCurrentSeconds() > maxTime);
// also give up if we are looping round too much
if (hitMaxTime || numberPassesLeft <= 0)
numberStrong = 0;
Expand Down Expand Up @@ -1405,7 +1406,7 @@ int CbcNode::chooseBranch(CbcModel *model, CbcNode *lastNode, int numberPassesLe
break;
}
}
bool hitMaxTime = (model->getCurrentSeconds() > model->getDblParam(CbcModel::CbcMaximumSeconds));
bool hitMaxTime = maxTime>1.0e18 ? false :(model->getCurrentSeconds() > maxTime);
if (hitMaxTime) {
numberStrong = i + 1;
break;
Expand Down Expand Up @@ -1657,6 +1658,8 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode,
depth_ = lastNode->depth_ + 1;
else
depth_ = 0;
double maxTime = model->getDblParam(CbcModel::CbcMaximumSeconds);
bool hitMaxTime = maxTime>1.0e18 ? false :(model->getCurrentSeconds() > maxTime);
const double *hotstartSolution = model->hotstartSolution();
const int *hotstartPriorities = model->hotstartPriorities();
// Go to other choose if hot start
Expand Down Expand Up @@ -2830,7 +2833,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode,
if(bestChoice < 0)
bestChoice = 0;
// If we have hit max time don't do strong branching
bool hitMaxTime = (model->getCurrentSeconds() > model->getDblParam(CbcModel::CbcMaximumSeconds));
// also give up if we are looping round too much
if (hitMaxTime || numberPassesLeft <= 0 || useShadow == 2) {
int iObject = whichObject[bestChoice];
Expand Down Expand Up @@ -4421,7 +4423,6 @@ int CbcNode::chooseDynamicBranch(CbcModel *model, CbcNode *lastNode,
}
}
// Check max time
hitMaxTime = (model->getCurrentSeconds() > model->getDblParam(CbcModel::CbcMaximumSeconds));
if (hitMaxTime) {
// make sure rest are fast
for (int jDo = iDo + 1; jDo < numberToDo; jDo++) {
Expand Down

0 comments on commit cb855c7

Please sign in to comment.