Skip to content

Commit 1c5cf45

Browse files
committed
Cleaned up, and first of @mathgeekcoder's suggestions implemented
1 parent d27d46b commit 1c5cf45

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

check/TestMipSolver.cpp

Lines changed: 2 additions & 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 = false;
1040+
const bool ci_test = true;
10411041
const std::string test_build_model = "fiball";
10421042
const std::string model = ci_test ? "flugpl" : test_build_model;
10431043
// "neos-3381206-awhea";
@@ -1048,6 +1048,7 @@ TEST_CASE("mip-race", "[highs_test_mip_solver]") {
10481048
if (ci_test) h.setOptionValue("output_flag", dev_run);
10491049
const HighsInt mip_race_concurrency = ci_test ? 2 : 4;
10501050
h.setOptionValue("mip_race_concurrency", mip_race_concurrency);
1051+
h.setOptionValue("mip_race_read_solutions", true);
10511052
REQUIRE(h.readModel(model_file) == HighsStatus::kOk);
10521053
REQUIRE(h.run() == HighsStatus::kOk);
10531054
REQUIRE(h.getModelStatus() == HighsModelStatus::kOptimal);

highs/mip/HighsMipSolver.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,36 @@ struct MipRaceIncumbent {
3333
std::vector<double>& solution_) const;
3434
};
3535

36+
37+
/*
38+
struct MipRaceIncumbent {
39+
std::atomic<HighsInt> start_write_incumbent = kMipRaceNoSolution;
40+
std::atomic<HighsInt> finish_write_incumbent = kMipRaceNoSolution;
41+
double objective = -kHighsInf;
42+
std::vector<double> solution;
43+
void clear();
44+
void initialise(const HighsInt num_col);
45+
void update(const double objective, const std::vector<double>& solution);
46+
HighsInt read(const HighsInt last_incumbent_read, double& objective_,
47+
std::vector<double>& solution_) const;
48+
49+
MipRaceIncumbent() = default;
50+
51+
MipRaceIncumbent(const MipRaceIncumbent& copy) {
52+
start_write_incumbent = copy.start_write_incumbent.load();
53+
finish_write_incumbent = copy.finish_write_incumbent.load();
54+
objective = copy.objective;
55+
solution = copy.solution;
56+
}
57+
58+
MipRaceIncumbent(MipRaceIncumbent&& moving) {
59+
start_write_incumbent = moving.start_write_incumbent.load();
60+
finish_write_incumbent = moving.finish_write_incumbent.load();
61+
objective = moving.objective;
62+
solution = std::move(moving.solution);
63+
}
64+
};
65+
*/
3666
struct MipRaceRecord {
3767
std::vector<MipRaceIncumbent> incumbent;
3868
void clear();

highs/mip/HighsMipSolverData.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,13 +2923,20 @@ void MipRaceRecord::clear() { this->incumbent.clear(); }
29232923
void MipRaceRecord::initialise(const HighsInt mip_race_concurrency,
29242924
const HighsInt num_col) {
29252925
this->clear();
2926+
this->incumbent.resize(mip_race_concurrency);
2927+
2928+
for (HighsInt instance = 0; instance < mip_race_concurrency; instance++)
2929+
this->incumbent[instance].initialise(num_col);
2930+
2931+
/*
29262932
MipRaceIncumbent incumbent_;
29272933
incumbent_.initialise(num_col);
29282934
// Loop from 1...
29292935
for (HighsInt instance = 1; instance < mip_race_concurrency; instance++)
29302936
this->incumbent.push_back(incumbent_);
29312937
// ... and move incumbent_ to complete the vector of incumbents
29322938
this->incumbent.push_back(std::move(incumbent_));
2939+
*/
29332940
}
29342941

29352942
HighsInt MipRaceRecord::concurrency() const {

0 commit comments

Comments
 (0)