Skip to content

Commit 6e65dbe

Browse files
committed
Reading HiGHS solution; different random_seed; all logging still to file for last worker; LastIncumbentRead not being set
1 parent 14e2a97 commit 6e65dbe

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

highs/lp_data/Highs.cpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4043,12 +4043,31 @@ HighsStatus Highs::callSolveMip() {
40434043
// Don't allow callbacks for workers
40444044
HighsCallback worker_callback = callback_;
40454045
worker_callback.clear();
4046-
HighsOptions worker_options = options_;
4047-
// No workers log to console
4048-
worker_options.log_to_console = false;
4049-
worker_options.setLogOptions();
40504046
// Race the MIP solver!
4047+
highsLogUser(options_.log_options, HighsLogType::kInfo,
4048+
"Starting MIP race with %d instances: performance is non-deterministic!\n", int(mip_race_concurrency));
4049+
// Define the HighsMipSolverInfo record for each worker
40514050
std::vector<HighsMipSolverInfo> worker_info(mip_race_concurrency);
4051+
// Set up the vector of options settings for workers
4052+
std::vector<HighsOptions> worker_options;
4053+
// std::vector<HighsMipSolver*> worker;
4054+
for (HighsInt instance = 0; instance < mip_race_concurrency; instance++) {
4055+
HighsOptions instance_options = options_;
4056+
// No workers log to console
4057+
instance_options.log_to_console = false;
4058+
instance_options.setLogOptions();
4059+
// Use the instance ID as an offset to the random seed
4060+
instance_options.random_seed = options_.random_seed + instance;
4061+
std::string worker_log_file =
4062+
"mip_worker" + std::to_string(instance) + ".log";
4063+
highsOpenLogFile(instance_options, worker_log_file);
4064+
worker_options.push_back(instance_options);
4065+
/*
4066+
HighsMipSolver worker_instance(worker_callback, worker_options[instance], lp,
4067+
solution_);
4068+
worker.push_back(&worker_instance);
4069+
*/
4070+
}
40524071
highs::parallel::for_each(
40534072
0, mip_race_concurrency, [&](HighsInt start, HighsInt end) {
40544073
for (HighsInt instance = start; instance < end; instance++) {
@@ -4059,16 +4078,11 @@ HighsStatus Highs::callSolveMip() {
40594078
solver.run();
40604079
mip_solver_info = getMipSolverInfo(solver);
40614080
} else {
4062-
// Use the instance ID as an offset to the random seed
4063-
worker_options.random_seed = options_.random_seed + instance;
4064-
std::string worker_log_file =
4065-
"mip_worker" + std::to_string(instance) + ".log";
4066-
highsOpenLogFile(worker_options, worker_log_file);
4067-
HighsMipSolver worker(worker_callback, worker_options, lp,
4081+
HighsMipSolver worker(worker_callback, worker_options[instance], lp,
40684082
solution_);
40694083
worker.mip_race_.initialise(mip_race_concurrency, instance,
40704084
&mip_race_record,
4071-
worker_options.log_options);
4085+
worker_options[instance].log_options);
40724086
worker.run();
40734087
worker_info[instance] = getMipSolverInfo(worker);
40744088
}

highs/mip/HighsMipSolver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ HighsMipSolver::HighsMipSolver(HighsCallback& callback,
6767
HighsMipSolver::~HighsMipSolver() = default;
6868

6969
void HighsMipSolver::run() {
70+
if (!submip) printf("HighsMipSolver::run() with random_seed = %d\n", int(options_mip_->random_seed));
7071
modelstatus_ = HighsModelStatus::kNotset;
7172

7273
if (submip) {

highs/mip/HighsMipSolverData.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,22 +2922,22 @@ void MipRaceRecord::report(const HighsLogOptions log_options) const {
29222922
HighsInt mip_race_concurrency = this->concurrency();
29232923
highsLogUser(log_options, HighsLogType::kInfo, "\nMipRaceRecord: ");
29242924
for (HighsInt instance = 0; instance < mip_race_concurrency; instance++)
2925-
highsLogUser(log_options, HighsLogType::kInfo, " %16d", int(instance));
2925+
highsLogUser(log_options, HighsLogType::kInfo, " %20d", int(instance));
29262926
highsLogUser(log_options, HighsLogType::kInfo, "\nTerminated: ");
29272927
for (HighsInt instance = 0; instance < mip_race_concurrency; instance++)
2928-
highsLogUser(log_options, HighsLogType::kInfo, " %16s",
2928+
highsLogUser(log_options, HighsLogType::kInfo, " %20s",
29292929
this->terminated[instance] ? "T" : "F");
29302930
highsLogUser(log_options, HighsLogType::kInfo, "\nStartWrite: ");
29312931
for (HighsInt instance = 0; instance < mip_race_concurrency; instance++)
2932-
highsLogUser(log_options, HighsLogType::kInfo, " %16d",
2932+
highsLogUser(log_options, HighsLogType::kInfo, " %20d",
29332933
this->incumbent[instance].start_write_incumbent);
29342934
highsLogUser(log_options, HighsLogType::kInfo, "\nObjective: ");
29352935
for (HighsInt instance = 0; instance < mip_race_concurrency; instance++)
2936-
highsLogUser(log_options, HighsLogType::kInfo, " %16.8g",
2936+
highsLogUser(log_options, HighsLogType::kInfo, " %20.12g",
29372937
this->incumbent[instance].objective);
29382938
highsLogUser(log_options, HighsLogType::kInfo, "\nFinishWrite: ");
29392939
for (HighsInt instance = 0; instance < mip_race_concurrency; instance++)
2940-
highsLogUser(log_options, HighsLogType::kInfo, " %16d",
2940+
highsLogUser(log_options, HighsLogType::kInfo, " %20d",
29412941
this->incumbent[instance].finish_write_incumbent);
29422942
highsLogUser(log_options, HighsLogType::kInfo, "\n");
29432943
}
@@ -2994,7 +2994,7 @@ void MipRace::report() const {
29942994
this->record->report(this->log_options);
29952995
highsLogUser(this->log_options, HighsLogType::kInfo, "LastIncumbentRead: ");
29962996
for (HighsInt instance = 0; instance < this->concurrency(); instance++)
2997-
highsLogUser(this->log_options, HighsLogType::kInfo, " %16d",
2997+
highsLogUser(this->log_options, HighsLogType::kInfo, " %20d",
29982998
this->last_incumbent_read[instance]);
29992999
highsLogUser(this->log_options, HighsLogType::kInfo, "\n\n");
30003000
}

0 commit comments

Comments
 (0)