Skip to content

Commit

Permalink
Merge pull request #2139 from ERGO-Code/parallel-MIP
Browse files Browse the repository at this point in the history
Fixed error in analyseVectorValues MIP profiling, and now analysing spectrum of times for node search and dive.
  • Loading branch information
jajhall authored Jan 17, 2025
2 parents 876c828 + 1d36028 commit 4f102c8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/mip/HighsMipAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <cmath>

#include "mip/MipTimer.h"
#include "util/HighsUtils.h"

const HighsInt check_mip_clock = -4;

Expand Down Expand Up @@ -153,4 +154,8 @@ void HighsMipAnalysis::reportMipTimer() {
reportMipSolveLpClock(true);
mip_timer.csvMipClock(this->model_name, mip_clocks, false, false);
reportMipSolveLpClock(false);
analyseVectorValues(nullptr, "Node search time",
HighsInt(node_search_time.size()), node_search_time);
analyseVectorValues(nullptr, "Dive time", HighsInt(dive_time.size()),
dive_time);
}
2 changes: 2 additions & 0 deletions src/mip/HighsMipAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class HighsMipAnalysis {
std::string model_name;
HighsTimerClock mip_clocks;
bool analyse_mip_time;
std::vector<double> dive_time;
std::vector<double> node_search_time;
};

#endif /* MIP_HIGHSMIPANALYSIS_H_ */
12 changes: 10 additions & 2 deletions src/mip/HighsMipSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,14 @@ void HighsMipSolver::run() {
if (mipdata_->domain.infeasible()) break;

if (!search.currentNodePruned()) {
double this_dive_time = -analysis_.mipTimerRead(kMipClockTheDive);
analysis_.mipTimerStart(kMipClockTheDive);
const HighsSearch::NodeResult search_dive_result = search.dive();
analysis_.mipTimerStop(kMipClockTheDive);

if (analysis_.analyse_mip_time) {
this_dive_time += analysis_.mipTimerRead(kMipClockNodeSearch);
analysis_.dive_time.push_back(this_dive_time);
}
if (search_dive_result == HighsSearch::NodeResult::kSubOptimal) break;

++mipdata_->num_leaves;
Expand Down Expand Up @@ -507,6 +511,7 @@ void HighsMipSolver::run() {
// mipdata_->lp.setIterationLimit();

// loop to install the next node for the search
double this_node_search_time = -analysis_.mipTimerRead(kMipClockNodeSearch);
analysis_.mipTimerStart(kMipClockNodeSearch);

while (!mipdata_->nodequeue.empty()) {
Expand Down Expand Up @@ -651,7 +656,10 @@ void HighsMipSolver::run() {
break;
} // while(!mipdata_->nodequeue.empty())
analysis_.mipTimerStop(kMipClockNodeSearch);

if (analysis_.analyse_mip_time) {
this_node_search_time += analysis_.mipTimerRead(kMipClockNodeSearch);
analysis_.node_search_time.push_back(this_node_search_time);
}
if (limit_reached) break;
} // while(search.hasNode())
analysis_.mipTimerStop(kMipClockSearch);
Expand Down
2 changes: 1 addition & 1 deletion src/mip/MipTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class MipTimer {
const bool end_line) {
const std::vector<HighsInt> mip_clock_list{
kMipClockRunPresolve, kMipClockEvaluateRootNode,
kMipClockPrimalHeuristics, kMipClockTheDive};
kMipClockPrimalHeuristics, kMipClockTheDive, kMipClockNodeSearch};
csvMipClockList(model_name, mip_clock_list, mip_timer_clock, kMipClockTotal,
header, end_line);
};
Expand Down
4 changes: 2 additions & 2 deletions src/util/HighsUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void analyseVectorValues(const HighsLogOptions* log_options,
highsFormatToString("%12" HIGHSINT_FORMAT
" values satisfy 10^(%3" HIGHSINT_FORMAT
") <= v < 10^(%3" HIGHSINT_FORMAT ")\n",
vK, k, k + 1));
vK, k - 1, k));
}
for (HighsInt k = 1; k <= nVK; k++) {
HighsInt vK = negVK[k];
Expand All @@ -445,7 +445,7 @@ void analyseVectorValues(const HighsLogOptions* log_options,
highsFormatToString("%12" HIGHSINT_FORMAT
" values satisfy 10^(%3" HIGHSINT_FORMAT
") <= v < 10^(%3" HIGHSINT_FORMAT ")\n",
vK, -k, 1 - k));
vK, -k - 1, -k));
}
vK = vecDim - nNz;
if (vK > 0)
Expand Down

0 comments on commit 4f102c8

Please sign in to comment.