Skip to content

Commit c4fbbb6

Browse files
committed
Fix bugs. Re-enable compiler optimisation
1 parent 00aa78d commit c4fbbb6

8 files changed

Lines changed: 34 additions & 37 deletions

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,6 @@ elseif (DEBUG_MEMORY STREQUAL "Memory")
622622
endif()
623623
endif()
624624

625-
add_compile_options(-O0)
626-
627625
# HiGHS coverage update in progress
628626
if(FAST_BUILD AND HIGHS_COVERAGE)
629627
if(WIN32)

highs/mip/HighsConflictPool.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void HighsConflictPool::addConflictCut(
5353
conflictRanges_[conflictIndex].second = end;
5454
}
5555

56-
ageResetWhileLocked_[conflictIndex] = false;
56+
ageResetWhileLocked_[conflictIndex] = 0;
5757
modification_[conflictIndex] += 1;
5858
ages_[conflictIndex] = 0;
5959
ageDistribution_[ages_[conflictIndex]] += 1;
@@ -127,7 +127,7 @@ void HighsConflictPool::addReconvergenceCut(
127127
conflictRanges_[conflictIndex].second = end;
128128
}
129129

130-
ageResetWhileLocked_[conflictIndex] = false;
130+
ageResetWhileLocked_[conflictIndex] = 0;
131131
modification_[conflictIndex] += 1;
132132
ages_[conflictIndex] = 0;
133133
ageDistribution_[ages_[conflictIndex]] += 1;
@@ -193,11 +193,11 @@ void HighsConflictPool::performAging(const bool thread_safe) {
193193

194194
for (HighsInt i = 0; i != conflictMaxIndex; ++i) {
195195
if (ages_[i] < 0) continue;
196-
if (thread_safe && ageResetWhileLocked_[i]) resetAge(i);
196+
if (thread_safe && ageResetWhileLocked_[i] == 1) resetAge(i);
197197

198198
ageDistribution_[ages_[i]] -= 1;
199199
ages_[i] += 1;
200-
ageResetWhileLocked_[i] = false;
200+
ageResetWhileLocked_[i] = 0;
201201

202202
if (ages_[i] > agelim) {
203203
ages_[i] = -1;
@@ -248,7 +248,7 @@ void HighsConflictPool::addConflictFromOtherPool(
248248
conflictRanges_[conflictIndex].second = end;
249249
}
250250

251-
ageResetWhileLocked_[conflictIndex] = false;
251+
ageResetWhileLocked_[conflictIndex] = 0;
252252
modification_[conflictIndex] += 1;
253253
ages_[conflictIndex] = 0;
254254
ageDistribution_[ages_[conflictIndex]] += 1;

highs/mip/HighsConflictPool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class HighsConflictPool {
2222
std::vector<HighsInt> ageDistribution_;
2323
std::vector<int16_t> ages_;
2424
std::vector<unsigned> modification_;
25-
std::vector<bool> ageResetWhileLocked_;
25+
std::vector<uint8_t> ageResetWhileLocked_;
2626

2727
std::vector<HighsDomainChange> conflictEntries_;
2828
std::vector<std::pair<HighsInt, HighsInt>> conflictRanges_;
@@ -75,7 +75,7 @@ class HighsConflictPool {
7575
void resetAge(HighsInt conflict) {
7676
if (ages_[conflict] > 0) {
7777
if (age_lock_) {
78-
ageResetWhileLocked_[conflict] = true;
78+
ageResetWhileLocked_[conflict] = 1;
7979
return;
8080
}
8181
ageDistribution_[ages_[conflict]] -= 1;

highs/mip/HighsCutPool.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ void HighsCutPool::performAging() {
191191
ages_[i] = 1;
192192
--numLpCuts;
193193
++ageDistribution[1];
194-
} else if (ageResetWhileLocked_[i]) {
194+
} else if (ageResetWhileLocked_[i] == 1) {
195195
resetAge(i);
196196
}
197-
ageResetWhileLocked_[i] = false;
197+
ageResetWhileLocked_[i] = 0;
198198
if (ages_[i] < 0) continue;
199199

200200
bool isPropagated = matrix_.columnsLinked(i);
@@ -290,7 +290,7 @@ void HighsCutPool::separate(const std::vector<double>& sol, HighsDomain& domain,
290290
matrix_.removeRow(i);
291291
ages_[i] = -1;
292292
rhs_[i] = kHighsInf;
293-
ageResetWhileLocked_[i] = false;
293+
ageResetWhileLocked_[i] = 0;
294294
hasSynced_[i] = false;
295295
auto range = hashToCutMap.equal_range(h);
296296

@@ -613,7 +613,7 @@ HighsInt HighsCutPool::addCut(const HighsMipSolver& mipsolver, HighsInt* Rindex,
613613
++ageDistribution[ages_[rowindex]];
614614
rowintegral[rowindex] = integral;
615615
numLps_[rowindex] = 0;
616-
ageResetWhileLocked_[rowindex] = false;
616+
ageResetWhileLocked_[rowindex] = 0;
617617
hasSynced_[rowindex] = false;
618618
if (propagate) propRows.emplace(ages_[rowindex], rowindex);
619619
assert((HighsInt)propRows.size() == numPropRows);

highs/mip/HighsCutPool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class HighsCutPool {
5757
std::vector<double> rhs_;
5858
std::vector<int16_t> ages_;
5959
std::deque<std::atomic<int16_t>> numLps_;
60-
std::vector<bool> ageResetWhileLocked_; // Was the cut propagated?
60+
std::vector<uint8_t> ageResetWhileLocked_; // Was the cut propagated?
6161
std::vector<bool> hasSynced_; // Has the cut been globally synced?
6262
std::vector<double> rownormalization_;
6363
std::vector<double> maxabscoef_;
@@ -105,7 +105,7 @@ class HighsCutPool {
105105
void resetAge(HighsInt cut, bool thread_safe = false) {
106106
if (ages_[cut] > 0) {
107107
if (thread_safe) {
108-
ageResetWhileLocked_[cut] = true;
108+
ageResetWhileLocked_[cut] = 1;
109109
return;
110110
}
111111
if (matrix_.columnsLinked(cut)) {

highs/mip/HighsMipSolver.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -572,23 +572,23 @@ void HighsMipSolver::run() {
572572
HighsInt worker_id = indices[i];
573573
if (search_results[worker_id] == HighsSearch::NodeResult::kSubOptimal) {
574574
analysis_.mipTimerStart(kMipClockCurrentNodeToQueue);
575-
mipdata_->workers[indices[worker_id]].search_ptr_->currentNodeToQueue(
575+
mipdata_->workers[worker_id].search_ptr_->currentNodeToQueue(
576576
mipdata_->nodequeue);
577577
analysis_.mipTimerStop(kMipClockCurrentNodeToQueue);
578578
}
579579
}
580580
};
581581

582582
auto handlePrunedNodes = [&](std::vector<HighsInt>& indices) -> bool {
583-
std::deque<bool> infeasible(num_workers, false);
584-
std::deque<bool> flush(num_workers, false);
585-
std::vector<bool> prune(num_workers, false);
583+
std::vector<uint8_t> infeasible(num_workers, 0);
584+
std::vector<uint8_t> flush(num_workers, 0);
585+
std::vector<uint8_t> prune(num_workers, 0);
586586
bool multiple_workers = num_workers > 1;
587587
auto doHandlePrunedNodes = [&](HighsInt i) {
588588
if (!mipdata_->workers[i].search_ptr_->currentNodePruned()) return;
589589
HighsDomain& globaldom = mipdata_->workers[i].getGlobalDomain();
590590
mipdata_->workers[i].search_ptr_->backtrack();
591-
flush[i] = true;
591+
flush[i] = 1;
592592

593593
globaldom.propagate();
594594
if (!multiple_workers) {
@@ -597,7 +597,7 @@ void HighsMipSolver::run() {
597597
}
598598

599599
if (globaldom.infeasible()) {
600-
infeasible[i] = true;
600+
infeasible[i] = 1;
601601
if (!multiple_workers) {
602602
mipdata_->nodequeue.clear();
603603
mipdata_->pruned_treeweight = 1.0;
@@ -615,7 +615,7 @@ void HighsMipSolver::run() {
615615
return;
616616
}
617617

618-
prune[i] = true;
618+
prune[i] = 1;
619619

620620
if (multiple_workers || mipdata_->checkLimits()) {
621621
return;
@@ -635,25 +635,25 @@ void HighsMipSolver::run() {
635635
analysis_.mipTimerStart(kMipClockNodePrunedLoop);
636636
runTask(doHandlePrunedNodes, tg, true, indices);
637637
// Flush pruned nodes statistics that haven't yet been flushed
638-
for (HighsInt i = 0; i != num_workers; ++i) {
639-
if (flush[i]) {
638+
for (HighsInt i : indices) {
639+
if (flush[i] == 1) {
640640
++mipdata_->num_leaves;
641641
++mipdata_->num_nodes;
642-
mipdata_->workers[indices[i]].search_ptr_->flushStatistics();
642+
mipdata_->workers[i].search_ptr_->flushStatistics();
643643
}
644644
}
645645
// Remove search indices that need a new node
646646
HighsInt num_search_indices = static_cast<HighsInt>(indices.size());
647647
for (HighsInt i = num_search_indices - 1; i >= 0; i--) {
648-
if (prune[i]) {
648+
if (prune[indices[i]] == 1) {
649649
num_search_indices--;
650650
std::swap(indices[i], indices[num_search_indices]);
651651
}
652652
}
653653
indices.resize(num_search_indices);
654654

655-
for (bool status : infeasible) {
656-
if (status) {
655+
for (uint8_t status : infeasible) {
656+
if (status == 1) {
657657
mipdata_->nodequeue.clear();
658658
mipdata_->pruned_treeweight = 1.0;
659659

@@ -805,7 +805,7 @@ void HighsMipSolver::run() {
805805
};
806806

807807
auto runHeuristics = [&](std::vector<HighsInt>& indices) -> void {
808-
std::vector<bool> suboptimal(num_workers, false);
808+
std::vector<uint8_t> suboptimal(num_workers, 0);
809809
auto doRunHeuristics = [&](HighsInt i) -> void {
810810
HighsMipWorker& worker = mipdata_->workers[i];
811811
// analysis_.mipTimerStart(kMipClockDiveEvaluateNode);
@@ -814,7 +814,7 @@ void HighsMipSolver::run() {
814814
// analysis_.mipTimerStop(kMipClockDiveEvaluateNode);
815815

816816
if (evaluate_node_result == HighsSearch::NodeResult::kSubOptimal) {
817-
suboptimal[i] = true;
817+
suboptimal[i] = 1;
818818
return;
819819
}
820820

@@ -845,7 +845,7 @@ void HighsMipSolver::run() {
845845
};
846846
runTask(doRunHeuristics, tg, true, indices);
847847
for (const HighsInt i : indices) {
848-
if (!suboptimal[i]) {
848+
if (suboptimal[i] == 0) {
849849
if (mipdata_->workers[i].search_ptr_->currentNodePruned()) {
850850
++mipdata_->num_leaves;
851851
mipdata_->workers[i].search_ptr_->flushStatistics();
@@ -856,7 +856,7 @@ void HighsMipSolver::run() {
856856
// Remove search indices that have suboptimal status
857857
HighsInt num_search_indices = static_cast<HighsInt>(indices.size());
858858
for (HighsInt i = num_search_indices - 1; i >= 0; i--) {
859-
if (suboptimal[indices[i]]) {
859+
if (suboptimal[indices[i]] == 1) {
860860
num_search_indices--;
861861
std::swap(indices[i], indices[num_search_indices]);
862862
}

highs/mip/HighsPrimalHeuristics.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ double HighsPrimalHeuristics::determineTargetFixingRate(
224224
double highFixingRate = 0.6;
225225

226226
HighsRandom& randgen =
227-
mipsolver.mipdata_->parallelLockActive() ? this->randgen : worker.randgen;
227+
mipsolver.mipdata_->parallelLockActive() ? worker.randgen : this->randgen;
228228

229229
if (getNumInfeasObservations(worker) != 0) {
230230
double infeasRate =
@@ -1081,7 +1081,7 @@ void HighsPrimalHeuristics::randomizedRounding(
10811081

10821082
HighsDomain localdom = worker.getGlobalDomain();
10831083
HighsRandom& randgen =
1084-
mipsolver.mipdata_->parallelLockActive() ? this->randgen : worker.randgen;
1084+
mipsolver.mipdata_->parallelLockActive() ? worker.randgen : this->randgen;
10851085

10861086
for (HighsInt i : intcols) {
10871087
double intval;
@@ -1170,7 +1170,7 @@ void HighsPrimalHeuristics::shifting(HighsMipWorker& worker,
11701170
HighsLpRelaxation lprelax(worker.getLpRelaxation());
11711171
lprelax.setMipWorker(worker);
11721172
HighsRandom& randgen =
1173-
mipsolver.mipdata_->parallelLockActive() ? this->randgen : worker.randgen;
1173+
mipsolver.mipdata_->parallelLockActive() ? worker.randgen : this->randgen;
11741174
std::vector<std::pair<HighsInt, double>> current_fractional_integers =
11751175
lprelax.getFractionalIntegers();
11761176
std::vector<std::tuple<HighsInt, HighsInt, double>> current_infeasible_rows =
@@ -1542,7 +1542,7 @@ void HighsPrimalHeuristics::feasibilityPump(HighsMipWorker& worker) {
15421542
worker.heur_stats.lp_iterations += lprelax.getNumLpIterations();
15431543

15441544
HighsRandom& randgen =
1545-
mipsolver.mipdata_->parallelLockActive() ? this->randgen : worker.randgen;
1545+
mipsolver.mipdata_->parallelLockActive() ? worker.randgen : this->randgen;
15461546

15471547
std::vector<double> fracintcost;
15481548
std::vector<HighsInt> fracintset;

highs/mip/HighsSearch.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,6 @@ HighsSymmetries& HighsSearch::getSymmetries() const {
19411941
bool HighsSearch::addIncumbent(const std::vector<double>& sol, double solobj,
19421942
const int solution_source,
19431943
const bool print_display_line) {
1944-
// if (mipsolver.mipdata_->workers.size() <= 1)
19451944
if (mipsolver.mipdata_->parallelLockActive()) {
19461945
return mipworker.addIncumbent(sol, solobj, solution_source);
19471946
} else {

0 commit comments

Comments
 (0)