Skip to content

Commit e3f0922

Browse files
committed
Formatted
1 parent e552c59 commit e3f0922

File tree

2 files changed

+100
-86
lines changed

2 files changed

+100
-86
lines changed

src/mip/HighsMipSolver.cpp

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ HighsMipSolver::HighsMipSolver(HighsCallback& callback,
105105
HighsMipSolver::~HighsMipSolver() = default;
106106

107107
void HighsMipSolver::run() {
108-
const bool debug_logging = false;//true;
108+
const bool debug_logging = false; // true;
109109
modelstatus_ = HighsModelStatus::kNotset;
110110

111111
if (submip) {
@@ -234,9 +234,11 @@ void HighsMipSolver::run() {
234234
int64_t num_nodes = mipdata_->nodequeue.numNodes();
235235
if (num_nodes > 1) {
236236
// Should be exactly one node on the queue?
237-
if (debug_logging) printf(
238-
"HighsMipSolver::run() popping node from nodequeue with %d > 1 nodes\n",
239-
HighsInt(num_nodes));
237+
if (debug_logging)
238+
printf(
239+
"HighsMipSolver::run() popping node from nodequeue with %d > 1 "
240+
"nodes\n",
241+
HighsInt(num_nodes));
240242
assert(num_nodes == 1);
241243
}
242244

@@ -275,22 +277,23 @@ void HighsMipSolver::run() {
275277
auto limitReached = [&]() -> bool {
276278
bool limit_reached = false;
277279
for (HighsInt iSearch = 0; iSearch < use_mip_concurrency; iSearch++) {
278-
HighsSearch& search = iSearch == 0 ? master_search : worker_search;
279-
limit_reached = limit_reached || search.limit_reached_;
280+
HighsSearch& search = iSearch == 0 ? master_search : worker_search;
281+
limit_reached = limit_reached || search.limit_reached_;
280282
}
281283
return limit_reached;
282284
};
283285

284286
// Lambda checking whether lopp pass is to be skipped
285-
auto performedDive = [&](const HighsSearch& search, const HighsInt iSearch) -> bool {
287+
auto performedDive = [&](const HighsSearch& search,
288+
const HighsInt iSearch) -> bool {
286289
if (iSearch == 0) {
287-
assert(search.performed_dive_);
290+
assert(search.performed_dive_);
288291
} else {
289-
assert(!search.performed_dive_);
292+
assert(!search.performed_dive_);
290293
}
291294
return search.performed_dive_;
292295
};
293-
296+
294297
// Perform concurrent dives
295298
for (HighsInt iSearch = 0; iSearch < use_mip_concurrency; iSearch++) {
296299
HighsSearch& search = iSearch == 0 ? master_search : worker_search;
@@ -310,7 +313,6 @@ void HighsMipSolver::run() {
310313
analysis_.mipTimerStop(kMipClockOpenNodesToQueue);
311314

312315
search.flushStatistics();
313-
314316
}
315317

316318
for (HighsInt iSearch = 0; iSearch < use_mip_concurrency; iSearch++) {
@@ -329,7 +331,8 @@ void HighsMipSolver::run() {
329331
prev_lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
330332
mipdata_->upper_bound);
331333
mipdata_->printDisplayLine();
332-
if (debug_logging) printf("HighsMipSolver::run() break on limit_reached - 0\n");
334+
if (debug_logging)
335+
printf("HighsMipSolver::run() break on limit_reached - 0\n");
333336
break;
334337
}
335338

@@ -361,7 +364,10 @@ void HighsMipSolver::run() {
361364
prev_lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
362365
mipdata_->upper_bound);
363366
mipdata_->printDisplayLine();
364-
if (debug_logging) printf("HighsMipSolver::run() break on mipdata_->domain.infeasible() - 0\n");
367+
if (debug_logging)
368+
printf(
369+
"HighsMipSolver::run() break on mipdata_->domain.infeasible() - "
370+
"0\n");
365371
break;
366372
}
367373

@@ -376,8 +382,10 @@ void HighsMipSolver::run() {
376382
mipdata_->upper_bound);
377383
mipdata_->printDisplayLine();
378384
if (mipdata_->nodequeue.empty()) {
379-
if (debug_logging) printf("HighsMipSolver::run() break on mipdata_->nodequeue.empty()\n");
380-
break;
385+
if (debug_logging)
386+
printf(
387+
"HighsMipSolver::run() break on mipdata_->nodequeue.empty()\n");
388+
break;
381389
}
382390

383391
// if global propagation found bound changes, we update the local domain
@@ -479,7 +487,6 @@ void HighsMipSolver::run() {
479487
// remove the iteration limit when installing a new node
480488
// mipdata_->lp.setIterationLimit();
481489

482-
483490
/*
484491
} // HighsInt iSearch = 0...use_mip_concurrency
485492
@@ -493,10 +500,6 @@ void HighsMipSolver::run() {
493500
-analysis_.mipTimerRead(kMipClockNodeSearch);
494501
analysis_.mipTimerStart(kMipClockNodeSearch);
495502

496-
497-
498-
499-
500503
while (!mipdata_->nodequeue.empty()) {
501504
assert(!search.hasNode());
502505

@@ -522,7 +525,10 @@ void HighsMipSolver::run() {
522525
numStallNodes >= options_mip_->mip_max_stall_nodes) {
523526
limit_reached = true;
524527
modelstatus_ = HighsModelStatus::kSolutionLimit;
525-
if (debug_logging) printf("HighsMipSolver::run() break on HighsModelStatus::kSolutionLimit\n");
528+
if (debug_logging)
529+
printf(
530+
"HighsMipSolver::run() break on "
531+
"HighsModelStatus::kSolutionLimit\n");
526532
break;
527533
}
528534
} else
@@ -563,13 +569,17 @@ void HighsMipSolver::run() {
563569
mipdata_->updatePrimalDualIntegral(
564570
prev_lower_bound, mipdata_->lower_bound,
565571
mipdata_->upper_bound, mipdata_->upper_bound);
566-
if (debug_logging) printf("HighsMipSolver::run() break on mipdata_->domain.infeasible() - 1\n");
572+
if (debug_logging)
573+
printf(
574+
"HighsMipSolver::run() break on "
575+
"mipdata_->domain.infeasible() - 1\n");
567576
break;
568577
}
569578

570579
if (mipdata_->checkLimits()) {
571580
limit_reached = true;
572-
if (debug_logging) printf("HighsMipSolver::run() break on limit_reached - 1\n");
581+
if (debug_logging)
582+
printf("HighsMipSolver::run() break on limit_reached - 1\n");
573583
break;
574584
}
575585

@@ -622,7 +632,10 @@ void HighsMipSolver::run() {
622632
mipdata_->updatePrimalDualIntegral(
623633
prev_lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
624634
mipdata_->upper_bound);
625-
if (debug_logging) printf("HighsMipSolver::run() break on mipdata_->domain.infeasible() - 2\n");
635+
if (debug_logging)
636+
printf(
637+
"HighsMipSolver::run() break on mipdata_->domain.infeasible() "
638+
"- 2\n");
626639
break;
627640
}
628641

@@ -640,28 +653,29 @@ void HighsMipSolver::run() {
640653
mipdata_->lp.setStoredBasis(basis);
641654
}
642655

643-
if (debug_logging) printf("HighsMipSolver::run() break on completed node search\n");
656+
if (debug_logging)
657+
printf("HighsMipSolver::run() break on completed node search\n");
644658
break;
645659
} // while(!mipdata_->nodequeue.empty())
646660
analysis_.mipTimerStop(kMipClockNodeSearch);
647661
if (analysis_.analyse_mip_time) {
648-
this_node_search_time += analysis_.mipTimerRead(kMipClockNodeSearch);
649-
analysis_.node_search_time.push_back(this_node_search_time);
662+
this_node_search_time += analysis_.mipTimerRead(kMipClockNodeSearch);
663+
analysis_.node_search_time.push_back(this_node_search_time);
650664
}
651-
} // HighsInt iSearch = 0...use_mip_concurrency
652-
665+
} // HighsInt iSearch = 0...use_mip_concurrency
653666

654667
/*
655668
for (HighsInt iSearch = 0; iSearch < use_mip_concurrency; iSearch++) {
656669
HighsSearch& search = iSearch == 0 ? master_search : worker_search;
657670
if (!performedDive(search, iSearch)) continue;
658671
*/
659-
limit_reached = limitReached();
660-
if (limit_reached) {
661-
if (debug_logging) printf("HighsMipSolver::run() break on limit_reached - 2\n");
662-
break;
663-
}
664-
// } // HighsInt iSearch = 0...use_mip_concurrency
672+
limit_reached = limitReached();
673+
if (limit_reached) {
674+
if (debug_logging)
675+
printf("HighsMipSolver::run() break on limit_reached - 2\n");
676+
break;
677+
}
678+
// } // HighsInt iSearch = 0...use_mip_concurrency
665679
} // while(search.hasNode())
666680
analysis_.mipTimerStop(kMipClockSearch);
667681

src/mip/HighsSearch.cpp

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,9 +1965,10 @@ void HighsSearch::dive() {
19651965
// average nodes
19661966

19671967
HighsInt iterlimit = 10 * std::max(mipsolver.mipdata_->lp.getAvgSolveIters(),
1968-
mipsolver.mipdata_->avgrootlpiters);
1969-
iterlimit = std::max({HighsInt{10000}, iterlimit,
1970-
HighsInt((3 * mipsolver.mipdata_->firstrootlpiters) / 2)});
1968+
mipsolver.mipdata_->avgrootlpiters);
1969+
iterlimit =
1970+
std::max({HighsInt{10000}, iterlimit,
1971+
HighsInt((3 * mipsolver.mipdata_->firstrootlpiters) / 2)});
19711972

19721973
mipsolver.mipdata_->lp.setIterationLimit(iterlimit);
19731974

@@ -1979,94 +1980,93 @@ void HighsSearch::dive() {
19791980
// Possibly apply primal heuristics
19801981
if (considerHeuristics && mipsolver.mipdata_->moreHeuristicsAllowed()) {
19811982
analysis_.mipTimerStart(kMipClockEvaluateNode);
1982-
const HighsSearch::NodeResult evaluate_node_result =
1983-
this->evaluateNode();
1983+
const HighsSearch::NodeResult evaluate_node_result = this->evaluateNode();
19841984
analysis_.mipTimerStop(kMipClockEvaluateNode);
1985-
1985+
19861986
if (evaluate_node_result == HighsSearch::NodeResult::kSubOptimal) {
1987-
printf(
1988-
"HighsMipSolver::run() evaluate_node_result == "
1989-
"HighsSearch::NodeResult::kSubOptimal\n");
1990-
assert(345 == 678);
1991-
break;
1987+
printf(
1988+
"HighsMipSolver::run() evaluate_node_result == "
1989+
"HighsSearch::NodeResult::kSubOptimal\n");
1990+
assert(345 == 678);
1991+
break;
19921992
}
1993-
1993+
19941994
if (this->currentNodePruned()) {
1995-
++mipsolver.mipdata_->num_leaves;
1996-
this->flushStatistics();
1995+
++mipsolver.mipdata_->num_leaves;
1996+
this->flushStatistics();
19971997
} else {
1998-
analysis_.mipTimerStart(kMipClockPrimalHeuristics);
1999-
if (mipsolver.mipdata_->incumbent.empty()) {
2000-
analysis_.mipTimerStart(kMipClockRandomizedRounding0);
2001-
mipsolver.mipdata_->heuristics.randomizedRounding(
2002-
mipsolver.mipdata_->lp.getLpSolver().getSolution().col_value);
2003-
analysis_.mipTimerStop(kMipClockRandomizedRounding0);
2004-
}
2005-
2006-
if (mipsolver.mipdata_->incumbent.empty()) {
2007-
analysis_.mipTimerStart(kMipClockRens);
2008-
mipsolver.mipdata_->heuristics.RENS(
2009-
mipsolver.mipdata_->lp.getLpSolver().getSolution().col_value);
2010-
analysis_.mipTimerStop(kMipClockRens);
2011-
} else {
2012-
analysis_.mipTimerStart(kMipClockRins);
2013-
mipsolver.mipdata_->heuristics.RINS(
2014-
mipsolver.mipdata_->lp.getLpSolver().getSolution().col_value);
2015-
analysis_.mipTimerStop(kMipClockRins);
2016-
}
2017-
2018-
mipsolver.mipdata_->heuristics.flushStatistics();
2019-
analysis_.mipTimerStop(kMipClockPrimalHeuristics);
1998+
analysis_.mipTimerStart(kMipClockPrimalHeuristics);
1999+
if (mipsolver.mipdata_->incumbent.empty()) {
2000+
analysis_.mipTimerStart(kMipClockRandomizedRounding0);
2001+
mipsolver.mipdata_->heuristics.randomizedRounding(
2002+
mipsolver.mipdata_->lp.getLpSolver().getSolution().col_value);
2003+
analysis_.mipTimerStop(kMipClockRandomizedRounding0);
2004+
}
2005+
2006+
if (mipsolver.mipdata_->incumbent.empty()) {
2007+
analysis_.mipTimerStart(kMipClockRens);
2008+
mipsolver.mipdata_->heuristics.RENS(
2009+
mipsolver.mipdata_->lp.getLpSolver().getSolution().col_value);
2010+
analysis_.mipTimerStop(kMipClockRens);
2011+
} else {
2012+
analysis_.mipTimerStart(kMipClockRins);
2013+
mipsolver.mipdata_->heuristics.RINS(
2014+
mipsolver.mipdata_->lp.getLpSolver().getSolution().col_value);
2015+
analysis_.mipTimerStop(kMipClockRins);
2016+
}
2017+
2018+
mipsolver.mipdata_->heuristics.flushStatistics();
2019+
analysis_.mipTimerStop(kMipClockPrimalHeuristics);
20202020
}
20212021
}
2022-
2022+
20232023
considerHeuristics = false;
2024-
2024+
20252025
if (mipsolver.mipdata_->domain.infeasible()) break;
2026-
2026+
20272027
if (!this->currentNodePruned()) {
20282028
double this_dive_time = -analysis_.mipTimerRead(kMipClockTheDive);
20292029
analysis_.mipTimerStart(kMipClockTheDive);
20302030
const HighsSearch::NodeResult search_dive_result = this->theDive();
20312031
analysis_.mipTimerStop(kMipClockTheDive);
20322032
if (analysis_.analyse_mip_time) {
2033-
this_dive_time += analysis_.mipTimerRead(kMipClockTheDive);
2034-
analysis_.dive_time.push_back(this_dive_time);
2033+
this_dive_time += analysis_.mipTimerRead(kMipClockTheDive);
2034+
analysis_.dive_time.push_back(this_dive_time);
20352035
}
20362036
if (search_dive_result == HighsSearch::NodeResult::kSubOptimal) break;
2037-
2037+
20382038
++mipsolver.mipdata_->num_leaves;
2039-
2039+
20402040
this->flushStatistics();
20412041
}
2042-
2042+
20432043
if (mipsolver.mipdata_->checkLimits()) {
20442044
limit_reached_ = true;
20452045
break;
20462046
}
20472047

20482048
HighsInt numPlungeNodes = mipsolver.mipdata_->num_nodes - plungestart;
20492049
if (numPlungeNodes >= 100) break;
2050-
2050+
20512051
analysis_.mipTimerStart(kMipClockBacktrackPlunge);
20522052
const bool backtrack_plunge =
2053-
this->backtrackPlunge(mipsolver.mipdata_->nodequeue);
2053+
this->backtrackPlunge(mipsolver.mipdata_->nodequeue);
20542054
analysis_.mipTimerStop(kMipClockBacktrackPlunge);
20552055
if (!backtrack_plunge) break;
2056-
2056+
20572057
assert(this->hasNode());
2058-
2058+
20592059
if (mipsolver.mipdata_->conflictPool.getNumConflicts() >
2060-
options_mip_->mip_pool_soft_limit) {
2060+
options_mip_->mip_pool_soft_limit) {
20612061
analysis_.mipTimerStart(kMipClockPerformAging2);
20622062
mipsolver.mipdata_->conflictPool.performAging();
20632063
analysis_.mipTimerStop(kMipClockPerformAging2);
20642064
}
2065-
2065+
20662066
this->flushStatistics();
20672067
mipsolver.mipdata_->printDisplayLine();
20682068
// printf("continue plunging due to good estimate\n");
2069-
}
2069+
}
20702070
analysis_.mipTimerStop(kMipClockDive);
20712071
}
20722072

0 commit comments

Comments
 (0)