Skip to content

Commit 12d8ce1

Browse files
committed
Fixed max sub-MIP level, but rename data members for clarity
1 parent 2256aae commit 12d8ce1

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

check/TestMipSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ TEST_CASE("ines", "[highs_test_mip_solver]") {
11301130
lp.a_matrix_.value_ = {1, -2, 3, -6, 7, 4, -6, 7, -4, -1, 2, -3};
11311131
double required_objective_value = 215;
11321132
Highs h;
1133-
// h.setOptionValue("output_flag", dev_run);
1133+
h.setOptionValue("output_flag", dev_run);
11341134
h.setOptionValue("presolve", kHighsOffString);
11351135
REQUIRE(h.passModel(lp) == HighsStatus::kOk);
11361136
REQUIRE(h.run() == HighsStatus::kOk);

highs/mip/HighsMipSolver.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ void HighsMipSolver::run() {
134134
mipdata_->transformNewIntegerFeasibleSolution(std::vector<double>());
135135
mipdata_->saveReportMipSolution();
136136
}
137+
if (!mipdata_->mipIsKnapsack()) {
138+
if (!mipdata_->mipIsInes()) mipdata_->mipIsOther();
139+
}
137140
cleanupSolve();
138141
return;
139142
}
@@ -899,7 +902,7 @@ void HighsMipSolver::cleanupSolve(const bool mip_logging) {
899902
HighsInt num_ines_mip = 0;
900903
size_t sum_ines_num_col = 0;
901904
size_t sum_ines_num_row = 0;
902-
HighsInt lc_max_submip_level = -1;
905+
HighsInt max_global_submip_level = -1;
903906
HighsInt min_submip_sum_dim = kHighsIInf;
904907
HighsInt min_submip_num_col = kHighsIInf;
905908
HighsInt min_submip_num_row = kHighsIInf;
@@ -919,9 +922,8 @@ void HighsMipSolver::cleanupSolve(const bool mip_logging) {
919922
default:
920923
break;
921924
}
922-
HighsInt lc_submip_level = mip_problem_data[iMip].submip_level;
923-
924-
lc_max_submip_level = std::max(lc_submip_level, lc_max_submip_level);
925+
HighsInt global_submip_level = mip_problem_data[iMip].submip_level;
926+
max_global_submip_level = std::max(global_submip_level, max_global_submip_level);
925927
HighsInt submip_num_col = mip_problem_data[iMip].num_continuous +
926928
mip_problem_data[iMip].num_binary +
927929
mip_problem_data[iMip].num_general_integer +
@@ -935,9 +937,9 @@ void HighsMipSolver::cleanupSolve(const bool mip_logging) {
935937
}
936938
if (full_submip_logging)
937939
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
938-
" MIP %3d (level = %2d; %3d conts; %3d bin; "
939-
"%3d gen; %3d impl; cols / rows: %3d / %3d; type %s)\n",
940-
int(iMip), int(lc_submip_level),
940+
" MIP %3d (level = %2d; %6d conts; %6d bin; "
941+
"%6d gen; %6d impl; cols / rows: %6d / %6d; type %s)\n",
942+
int(iMip), int(global_submip_level),
941943
int(mip_problem_data[iMip].num_continuous),
942944
int(mip_problem_data[iMip].num_binary),
943945
int(mip_problem_data[iMip].num_general_integer),
@@ -955,7 +957,8 @@ void HighsMipSolver::cleanupSolve(const bool mip_logging) {
955957

956958
std::stringstream ss;
957959
ss.str(std::string());
958-
ss << highsFormatToString(" Max sub-MIP depth %d", int(max_submip_level));
960+
assert(submip_level + max_submip_level == max_global_submip_level);
961+
ss << highsFormatToString(" Max sub-MIP level %d", int(submip_level + max_submip_level));
959962
if (max_submip_level > 0)
960963
ss << highsFormatToString(" (min cols/rows: %d/%d)\n",
961964
int(min_submip_num_col), int(min_submip_num_row));

highs/mip/HighsPrimalHeuristics.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,15 @@ bool HighsPrimalHeuristics::solveSubMip(
150150
submipsolver.implicinit = &mipsolver.mipdata_->implications;
151151
// Solve the sub-MIP
152152
submipsolver.run();
153+
// Update the local max_submip_level for the MIP solver
153154
mipsolver.max_submip_level =
154-
std::max(submipsolver.max_submip_level + 1, mipsolver.max_submip_level);
155+
std::max(1 + submipsolver.max_submip_level, mipsolver.max_submip_level);
155156

156157
// Append the sub-MIP problem data to this MIP problem data
157-
std::vector<HighsMipProblemData> mipsolver_mip_data =
158-
mipsolver.mipdata_->mip_problem_data_;
159-
std::vector<HighsMipProblemData> submipsolver_mip_data =
160-
submipsolver.mipdata_->mip_problem_data_;
161158
mipsolver.mipdata_->mip_problem_data_.insert(
162159
mipsolver.mipdata_->mip_problem_data_.end(),
163160
submipsolver.mipdata_->mip_problem_data_.begin(),
164161
submipsolver.mipdata_->mip_problem_data_.end());
165-
mipsolver_mip_data = mipsolver.mipdata_->mip_problem_data_;
166162

167163
if (!mipsolver.submip) mipsolver.analysis_.mipTimerStop(kMipClockSubMipSolve);
168164
if (submipsolver.mipdata_) {

0 commit comments

Comments
 (0)