Skip to content

Commit a2974ce

Browse files
committed
Now reporting whole loop time for race
1 parent 5a1c095 commit a2974ce

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

check/TestMipSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ TEST_CASE("issue-2432", "[highs_test_mip_solver]") {
10371037
}
10381038

10391039
TEST_CASE("mip-race", "[highs_test_mip_solver]") {
1040-
const bool ci_test = true;
1040+
const bool ci_test = false;
10411041
const std::string test_build_model = "fiball";
10421042
const std::string model = ci_test ? "flugpl" : test_build_model;
10431043
// "neos-3381206-awhea";

highs/Highs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,8 @@ class Highs {
17161716
void getHighsFiles();
17171717
HighsStatus mipRaceResults(HighsMipSolverInfo& mip_solver_info,
17181718
const std::vector<HighsMipSolverInfo>& worker_info,
1719-
const std::vector<double>& mip_time);
1719+
const std::vector<double>& mip_time,
1720+
const double& report_mip_time);
17201721
};
17211722

17221723
// Start of deprecated methods not in the Highs class

highs/lp_data/Highs.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4075,6 +4075,9 @@ HighsStatus Highs::callSolveMip() {
40754075
lp, solution_); worker.push_back(&worker_instance);
40764076
*/
40774077
}
4078+
// Time the master outside the parallel loop so that this "real"
4079+
// time is reported
4080+
double loop_mip_time = -timer_.read();
40784081
highs::parallel::for_each(
40794082
0, mip_race_concurrency, [&](HighsInt start, HighsInt end) {
40804083
for (HighsInt instance = start; instance < end; instance++) {
@@ -4101,9 +4104,11 @@ HighsStatus Highs::callSolveMip() {
41014104
}
41024105
}
41034106
});
4107+
loop_mip_time += timer_.read();
41044108
// Determine the winner and report on the solution
41054109
HighsStatus call_status =
4106-
this->mipRaceResults(mip_solver_info, worker_info, mip_time);
4110+
this->mipRaceResults(mip_solver_info, worker_info, mip_time,
4111+
loop_mip_time);
41074112
if (call_status == HighsStatus::kError) {
41084113
const bool undo_mods = true;
41094114
return returnFromOptimizeModel(HighsStatus::kError, undo_mods);

highs/lp_data/HighsInterface.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4264,7 +4264,8 @@ void HighsMipSolverInfo::clear() {
42644264
HighsStatus Highs::mipRaceResults(
42654265
HighsMipSolverInfo& mip_solver_info,
42664266
const std::vector<HighsMipSolverInfo>& worker_info,
4267-
const std::vector<double>& mip_time) {
4267+
const std::vector<double>& mip_time,
4268+
const double& report_mip_time) {
42684269
const HighsInt mip_race_concurrency = this->options_.mip_race_concurrency;
42694270
HighsInt winning_instance = -1;
42704271
HighsModelStatus winning_model_status = HighsModelStatus::kNotset;
@@ -4275,7 +4276,7 @@ HighsStatus Highs::mipRaceResults(
42754276
instance == 0 ? mip_solver_info : worker_info[instance];
42764277
HighsModelStatus instance_model_status = solver_info.modelstatus;
42774278
highsLogUser(options_.log_options, HighsLogType::kInfo,
4278-
" Solver %d has best objective %15.8g, gap %6.2f\% (time "
4279+
" Solver %2d has best objective %15.8g, gap %6.2f\% (time "
42794280
"= %6.2f), and status %s\n",
42804281
int(instance), solver_info.solution_objective,
42814282
1e2 * solver_info.gap, mip_time[instance],
@@ -4348,8 +4349,10 @@ HighsStatus Highs::mipRaceResults(
43484349
highsLogUser(options_.log_options, HighsLogType::kInfo,
43494350
" %.12g (row viol.)\n",
43504351
mip_solver_info.row_violation);
4352+
// Report the solution time for the whole concurrent loop, as that's
4353+
// "real" time
43514354
highsLogUser(options_.log_options, HighsLogType::kInfo,
4352-
" Timing %.2f\n", mip_time[winning_instance]);
4355+
" Timing %.2f\n", report_mip_time);
43534356
highsLogUser(options_.log_options, HighsLogType::kInfo,
43544357
" Max sub-MIP depth %d\n",
43554358
int(mip_solver_info.max_submip_level));

0 commit comments

Comments
 (0)