Skip to content

Commit

Permalink
Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Nov 11, 2024
1 parent d8ada72 commit 3f6a72b
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 57 deletions.
8 changes: 4 additions & 4 deletions check/TestMipSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,16 +679,16 @@ TEST_CASE("IP-infeasible-unbounded", "[highs_test_mip_solver]") {
highs.run();
HighsModelStatus required_model_status;
if (k == 0) {
// Presolve off
// Presolve off
if (l == 0) {
// MIP solver proves infeasiblilty
// MIP solver proves infeasiblilty
required_model_status = HighsModelStatus::kInfeasible;
} else {
// Relaxation is unbounded, but origin is feasible
// Relaxation is unbounded, but origin is feasible
required_model_status = HighsModelStatus::kUnbounded;
}
} else {
// Presolve on, and identifies primal infeasible or unbounded
// Presolve on, and identifies primal infeasible or unbounded
required_model_status = HighsModelStatus::kUnboundedOrInfeasible;
}
REQUIRE(highs.getModelStatus() == required_model_status);
Expand Down
3 changes: 2 additions & 1 deletion src/lp_data/HighsOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,8 @@ class HighsOptions : public HighsOptionsStruct {

record_int = new OptionRecordInt(
"highs_analysis_level", "Analysis level in HiGHS", now_advanced,
&highs_analysis_level, kHighsAnalysisLevelMin, kHighsAnalysisLevelMipTime, //kHighsAnalysisLevelMin,
&highs_analysis_level, kHighsAnalysisLevelMin,
kHighsAnalysisLevelMipTime, // kHighsAnalysisLevelMin,
kHighsAnalysisLevelMax);
records.push_back(record_int);

Expand Down
6 changes: 3 additions & 3 deletions src/mip/HighsMipAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ void HighsMipAnalysis::reportMipTimer() {
mip_timer.reportMipLevel1Clock(mip_clocks);
// mip_timer.reportMipSolveLpClock(mip_clocks);
// mip_timer.reportMipPresolveClock(mip_clocks);
mip_timer.reportMipSearchClock(mip_clocks);
mip_timer.reportMipDiveClock(mip_clocks);
mip_timer.reportMipNodeSearchClock(mip_clocks);
mip_timer.reportMipSearchClock(mip_clocks);
mip_timer.reportMipDiveClock(mip_clocks);
mip_timer.reportMipNodeSearchClock(mip_clocks);
// mip_timer.reportMipPrimalHeuristicsClock(mip_clocks);
// mip_timer.reportMipEvaluateRootNodeClock(mip_clocks);
// mip_timer.reportMipSeparationClock(mip_clocks);
Expand Down
62 changes: 33 additions & 29 deletions src/mip/HighsMipSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void HighsMipSolver::run() {

// Pops the node corresponding to lowerMin onto the search stack
search.installNode(mipdata_->nodequeue.popBestBoundNode());

int64_t numStallNodes = 0;
int64_t lastLbLeave = 0;
int64_t numQueueLeaves = 0;
Expand All @@ -263,7 +263,8 @@ void HighsMipSolver::run() {
while (search.hasNode()) {
if (!submip) {
if (search_logging) {
printf("\nHighsMipSolver::run() Number of active nodes %d\n", int(mipdata_->nodequeue.numActiveNodes()));
printf("\nHighsMipSolver::run() Number of active nodes %d\n",
int(mipdata_->nodequeue.numActiveNodes()));
}
}
analysis_.mipTimerStart(kMipClockPerformAging1);
Expand Down Expand Up @@ -335,11 +336,12 @@ void HighsMipSolver::run() {

++mipdata_->num_leaves;

if (!submip) {
if (search_logging) {
// printf("HighsMipSolver::run() Dive nodes %5d; ", int(search.getNnodes()));
}
}
if (!submip) {
if (search_logging) {
// printf("HighsMipSolver::run() Dive nodes %5d; ",
//int(search.getNnodes()));
}
}
search.flushStatistics();
}

Expand All @@ -350,10 +352,11 @@ void HighsMipSolver::run() {

HighsInt numPlungeNodes = mipdata_->num_nodes - plungestart;
if (!submip) {
if (search_logging) {
const bool plunge_break = numPlungeNodes >= 100;
printf("plunge nodes%3d: break = %s\n", int(numPlungeNodes), highsBoolToString(plunge_break).c_str());
}
if (search_logging) {
const bool plunge_break = numPlungeNodes >= 100;
printf("plunge nodes%3d: break = %s\n", int(numPlungeNodes),
highsBoolToString(plunge_break).c_str());
}
}
if (numPlungeNodes >= 100) break;

Expand Down Expand Up @@ -549,12 +552,13 @@ void HighsMipSolver::run() {
assert(!search.hasNode());

if (!submip) {
if (search_logging) {
printf("HighsMipSolver::run() NodeSearch nodes %5d; numQueueLeaves %5d; "
"lastLbLeave %d; numQueueLeaves - lastLbLeave %d\n",
int(search.getNnodes()), int(numQueueLeaves),
int(lastLbLeave), int(numQueueLeaves-lastLbLeave));
}
if (search_logging) {
printf(
"HighsMipSolver::run() NodeSearch nodes %5d; numQueueLeaves %5d; "
"lastLbLeave %d; numQueueLeaves - lastLbLeave %d\n",
int(search.getNnodes()), int(numQueueLeaves), int(lastLbLeave),
int(numQueueLeaves - lastLbLeave));
}
}
if (numQueueLeaves - lastLbLeave >= 10) {
search.installNode(mipdata_->nodequeue.popBestBoundNode());
Expand Down Expand Up @@ -590,21 +594,21 @@ void HighsMipSolver::run() {
// new global information before we perform separation rounds for the node
analysis_.mipTimerStart(kMipClockEvaluateNode1);
const HighsSearch::NodeResult evaluate_node_result =
search.evaluateNode();
search.evaluateNode();
analysis_.mipTimerStop(kMipClockEvaluateNode1);
if (evaluate_node_result == HighsSearch::NodeResult::kSubOptimal) {
analysis_.mipTimerStart(kMipClockCurrentNodeToQueue);
analysis_.mipTimerStart(kMipClockCurrentNodeToQueue);
search.currentNodeToQueue(mipdata_->nodequeue);
analysis_.mipTimerStop(kMipClockCurrentNodeToQueue);
analysis_.mipTimerStop(kMipClockCurrentNodeToQueue);
}

// if the node was pruned we remove it from the search and install the
// next node from the queue
analysis_.mipTimerStart(kMipClockNodePrunedLoop);
if (search.currentNodePruned()) {
analysis_.mipTimerStart(kMipClockSearchBacktrack);
analysis_.mipTimerStart(kMipClockSearchBacktrack);
search.backtrack();
analysis_.mipTimerStop(kMipClockSearchBacktrack);
analysis_.mipTimerStop(kMipClockSearchBacktrack);
++mipdata_->num_leaves;
++mipdata_->num_nodes;
search.flushStatistics();
Expand All @@ -626,7 +630,7 @@ void HighsMipSolver::run() {
mipdata_->updatePrimalDualIntegral(
prev_lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
mipdata_->upper_bound);
analysis_.mipTimerStop(kMipClockNodePrunedLoop);
analysis_.mipTimerStop(kMipClockNodePrunedLoop);
break;
}

Expand All @@ -635,7 +639,7 @@ void HighsMipSolver::run() {
break;
}

analysis_.mipTimerStart(kMipClockStoreBasis);
analysis_.mipTimerStart(kMipClockStoreBasis);
double prev_lower_bound = mipdata_->lower_bound;

mipdata_->lower_bound = std::min(
Expand Down Expand Up @@ -663,9 +667,9 @@ void HighsMipSolver::run() {
mipdata_->domain.clearChangedCols();
mipdata_->removeFixedIndices();
}
analysis_.mipTimerStop(kMipClockStoreBasis);
analysis_.mipTimerStop(kMipClockStoreBasis);

analysis_.mipTimerStop(kMipClockNodePrunedLoop);
analysis_.mipTimerStop(kMipClockNodePrunedLoop);
continue;
}
analysis_.mipTimerStop(kMipClockNodePrunedLoop);
Expand All @@ -677,9 +681,9 @@ void HighsMipSolver::run() {

if (mipdata_->domain.infeasible()) {
search.cutoffNode();
analysis_.mipTimerStart(kMipClockOpenNodesToQueue1);
analysis_.mipTimerStart(kMipClockOpenNodesToQueue1);
search.openNodesToQueue(mipdata_->nodequeue);
analysis_.mipTimerStop(kMipClockOpenNodesToQueue1);
analysis_.mipTimerStop(kMipClockOpenNodesToQueue1);
mipdata_->nodequeue.clear();
mipdata_->pruned_treeweight = 1.0;

Expand Down
4 changes: 3 additions & 1 deletion src/mip/HighsSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ class HighsSearch {

void solveDepthFirst(int64_t maxbacktracks = 1);

HighsInt getNnodes() const { return nnodes; } // For parallel-tree-search study
HighsInt getNnodes() const {
return nnodes;
} // For parallel-tree-search study
};

#endif
40 changes: 21 additions & 19 deletions src/mip/MipTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ enum iClockMip {
kMipClockNodeSearchSeparation,
kMipClockStoreBasis,
// kMipClock@,

// Separation
kMipClockSeparationRootSeparationRound,
kMipClockSeparationFinishAnalyticCentreComputation,
Expand Down Expand Up @@ -181,12 +181,17 @@ class MipTimer {
timer_pointer->clock_def("Evaluate root LP - s.");

// Node search
clock[kMipClockCurrentNodeToQueue] = timer_pointer->clock_def("Current node to queue");
clock[kMipClockSearchBacktrack] = timer_pointer->clock_def("Search backtrack");
clock[kMipClockNodePrunedLoop] = timer_pointer->clock_def("Pruned loop search");
clock[kMipClockOpenNodesToQueue1] = timer_pointer->clock_def("Open nodes to queue 1");
clock[kMipClockCurrentNodeToQueue] =
timer_pointer->clock_def("Current node to queue");
clock[kMipClockSearchBacktrack] =
timer_pointer->clock_def("Search backtrack");
clock[kMipClockNodePrunedLoop] =
timer_pointer->clock_def("Pruned loop search");
clock[kMipClockOpenNodesToQueue1] =
timer_pointer->clock_def("Open nodes to queue 1");
clock[kMipClockEvaluateNode1] = timer_pointer->clock_def("Evaluate node 1");
clock[kMipClockNodeSearchSeparation] = timer_pointer->clock_def("Node search separation");
clock[kMipClockNodeSearchSeparation] =
timer_pointer->clock_def("Node search separation");
clock[kMipClockStoreBasis] = timer_pointer->clock_def("Store basis");
// clock[] = timer_pointer->clock_def("");

Expand Down Expand Up @@ -227,7 +232,7 @@ class MipTimer {
const double tolerance_percent_report =
tolerance_percent_report_ >= 0 ? tolerance_percent_report_ : 1e-8;
return timer_pointer->reportOnTolerance(
grepStamp, clockList, ideal_sum_time, 0);//tolerance_percent_report);
grepStamp, clockList, ideal_sum_time, 0); // tolerance_percent_report);
};

void csvMipClockList(const std::string model_name,
Expand Down Expand Up @@ -301,7 +306,7 @@ class MipTimer {
void reportMipSearchClock(const HighsTimerClock& mip_timer_clock) {
const std::vector<HighsInt> mip_clock_list{
kMipClockPerformAging1, kMipClockDive,
kMipClockOpenNodesToQueue0, kMipClockDomainPropgate,
kMipClockOpenNodesToQueue0, kMipClockDomainPropgate,
kMipClockPruneInfeasibleNodes, kMipClockUpdateLocalDomain,
kMipClockNodeSearch,
// kMipClock@
Expand All @@ -312,10 +317,10 @@ class MipTimer {

void reportMipDiveClock(const HighsTimerClock& mip_timer_clock) {
const std::vector<HighsInt> mip_clock_list{
kMipClockEvaluateNode0,
kMipClockRandomizedRounding0, kMipClockRens, kMipClockRins,
kMipClockTheDive,
kMipClockBacktrackPlunge, kMipClockPerformAging2};
kMipClockEvaluateNode0, kMipClockRandomizedRounding0,
kMipClockRens, kMipClockRins,
kMipClockTheDive, kMipClockBacktrackPlunge,
kMipClockPerformAging2};
reportMipClockList("MipDive_", mip_clock_list, mip_timer_clock,
kMipClockDive, tolerance_percent_report);
};
Expand Down Expand Up @@ -356,13 +361,10 @@ class MipTimer {

void reportMipNodeSearchClock(const HighsTimerClock& mip_timer_clock) {
const std::vector<HighsInt> mip_clock_list{
kMipClockCurrentNodeToQueue,
kMipClockNodePrunedLoop,
// kMipClockSearchBacktrack,
kMipClockOpenNodesToQueue1,
kMipClockEvaluateNode1,
kMipClockNodeSearchSeparation,
kMipClockStoreBasis};
kMipClockCurrentNodeToQueue, kMipClockNodePrunedLoop,
// kMipClockSearchBacktrack,
kMipClockOpenNodesToQueue1, kMipClockEvaluateNode1,
kMipClockNodeSearchSeparation, kMipClockStoreBasis};
reportMipClockList("MipNodeSearch", mip_clock_list, mip_timer_clock,
kMipClockNodeSearch); //, tolerance_percent_report);
};
Expand Down

0 comments on commit 3f6a72b

Please sign in to comment.