Skip to content

Commit f79b79c

Browse files
committed
Create lambda for evaluating nodes
1 parent 4d322af commit f79b79c

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

highs/mip/HighsMipSolver.cpp

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,36 @@ void HighsMipSolver::run() {
507507
}
508508
};
509509

510+
auto evaluateNodes = [&](std::vector<HighsInt>& search_indices) -> void {
511+
std::vector<HighsSearch::NodeResult> search_results(search_indices.size());
512+
analysis_.mipTimerStart(kMipClockEvaluateNode1);
513+
for (HighsInt i = 0; i != search_indices.size(); i++) {
514+
// TODO MT: Remove this dummy if statement
515+
if (i != 0) continue;
516+
if (mipdata_->parallelLockActive()) {
517+
tg.spawn([&, i]() {
518+
search_results[i] =
519+
mipdata_->workers[search_indices[i]].search_ptr_->evaluateNode();
520+
});
521+
} else {
522+
search_results[i] =
523+
mipdata_->workers[search_indices[i]].search_ptr_->evaluateNode();
524+
}
525+
}
526+
if (mipdata_->parallelLockActive()) tg.taskWait();
527+
analysis_.mipTimerStop(kMipClockEvaluateNode1);
528+
for (HighsInt i = 0; i != search_indices.size(); i++) {
529+
// TODO MT: Remove this dummy if statement
530+
if (i != 0) continue;
531+
if (search_results[i] == HighsSearch::NodeResult::kSubOptimal) {
532+
analysis_.mipTimerStart(kMipClockCurrentNodeToQueue);
533+
mipdata_->workers[search_indices[i]].search_ptr_->currentNodeToQueue(
534+
mipdata_->nodequeue);
535+
analysis_.mipTimerStop(kMipClockCurrentNodeToQueue);
536+
}
537+
}
538+
};
539+
510540
auto diveAllSearches = [&]() -> bool {
511541
std::vector<double> dive_times(mip_search_concurrency,
512542
-analysis_.mipTimerRead(kMipClockTheDive));
@@ -860,15 +890,7 @@ void HighsMipSolver::run() {
860890
// we evaluate the node directly here instead of performing a dive
861891
// because we first want to check if the node is not fathomed due to
862892
// new global information before we perform separation rounds for the node
863-
analysis_.mipTimerStart(kMipClockEvaluateNode1);
864-
const HighsSearch::NodeResult evaluate_node_result =
865-
search.evaluateNode();
866-
analysis_.mipTimerStop(kMipClockEvaluateNode1);
867-
if (evaluate_node_result == HighsSearch::NodeResult::kSubOptimal) {
868-
analysis_.mipTimerStart(kMipClockCurrentNodeToQueue);
869-
search.currentNodeToQueue(mipdata_->nodequeue);
870-
analysis_.mipTimerStop(kMipClockCurrentNodeToQueue);
871-
}
893+
evaluateNodes(search_indices);
872894

873895
// if the node was pruned we remove it from the search and install the
874896
// next node from the queue

0 commit comments

Comments
 (0)