Skip to content

Commit 0306739

Browse files
committed
dont evaluate node if valid branch. add limits
1 parent d308ab0 commit 0306739

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

highs/mip/HighsMipSolverData.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,12 +2227,16 @@ void HighsMipSolverData::evaluateRootNode() {
22272227
if (rootlpsol.empty()) break;
22282228
if (upper_limit != kHighsInf && !moreHeuristicsAllowed()) break;
22292229

2230-
if (mipsolver.options_mip_->mip_heuristic_run_fix_and_propagate) {
2230+
// TODO: Find a way to make sure this is only called once
2231+
if (mipsolver.options_mip_->mip_heuristic_run_fix_and_propagate &&
2232+
numRestarts <= 0 && !mipsolver.submip) {
22312233
analysis.mipTimerStart(kMipClockRootHeuristicsFixAndPropagate);
22322234
heuristics.fixAndPropagate();
22332235
analysis.mipTimerStop(kMipClockRootHeuristicsFixAndPropagate);
22342236
heuristics.flushStatistics();
2235-
}
2237+
}
2238+
2239+
if (checkLimits()) return clockOff(analysis);
22362240

22372241
if (mipsolver.options_mip_->mip_heuristic_run_root_reduced_cost) {
22382242
analysis.mipTimerStart(kMipClockRootHeuristicsReducedCost);

highs/mip/HighsPrimalHeuristics.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ void HighsPrimalHeuristics::RENS(const std::vector<double>& tmp) {
421421
heur.branchDownwards(i, upval, upval + 0.5);
422422
localdom.propagate();
423423
if (localdom.infeasible()) {
424+
// TODO: Is this needed? Won't evaluateNode catch the conflict analysis?
424425
localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
425426
break;
426427
}
@@ -1594,24 +1595,28 @@ void HighsPrimalHeuristics::fixAndPropagate() {
15941595
HighsInt numpropagationcalls = 0;
15951596
const HighsInt kMaxPropagationCalls = std::max(
15961597
1000, 2 * static_cast<int>(intcols.size()));
1598+
bool evaluatenode = true;
15971599

15981600
// Continue branching and propagating until either (a) limit is hit,
15991601
// (b) backtracked to root, or (c) reached a potentially feasible leaf
16001602
while (true) {
1601-
heur.evaluateNode();
1602-
// printf("done evaluating node\n");
1603-
if (heur.currentNodePruned()) {
1604-
if (mipsolver.mipdata_->domain.infeasible()) {
1605-
lp_iterations += heur.getLocalLpIterations();
1606-
return;
1607-
}
1603+
if (evaluatenode) {
1604+
heur.evaluateNode();
1605+
// printf("done evaluating node\n");
1606+
if (heur.currentNodePruned()) {
1607+
if (mipsolver.mipdata_->domain.infeasible()) {
1608+
lp_iterations += heur.getLocalLpIterations();
1609+
return;
1610+
}
16081611

1609-
// TODO: Is this case only reached when the root is infeasible?
1610-
if (!heur.backtrack()) {
1611-
lp_iterations += heur.getLocalLpIterations();
1612-
return;
1612+
// TODO: Is this case only reached when the root is infeasible?
1613+
if (!heur.backtrack()) {
1614+
lp_iterations += heur.getLocalLpIterations();
1615+
return;
1616+
}
16131617
}
16141618
}
1619+
evaluatenode = false;
16151620
bool branched = false;
16161621
for (HighsInt col : diveperm) {
16171622
if (numpropagationcalls > kMaxPropagationCalls) {
@@ -1670,6 +1675,7 @@ void HighsPrimalHeuristics::fixAndPropagate() {
16701675
++numpropagationcalls;
16711676
if (localdom.infeasible()) {
16721677
localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
1678+
evaluatenode = true;
16731679
break;
16741680
}
16751681
}

0 commit comments

Comments
 (0)