Skip to content

Commit 9d021c8

Browse files
authored
Merge pull request #2451 from fwesselm/moreConstAgain
Make some more methods const
2 parents 0d7192e + b7e7ca0 commit 9d021c8

File tree

10 files changed

+42
-36
lines changed

10 files changed

+42
-36
lines changed

highs/mip/HighsDomain.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ void HighsDomain::ObjectivePropagation::propagate() {
12431243
void HighsDomain::computeMinActivity(HighsInt start, HighsInt end,
12441244
const HighsInt* ARindex,
12451245
const double* ARvalue, HighsInt& ninfmin,
1246-
HighsCDouble& activitymin) {
1246+
HighsCDouble& activitymin) const {
12471247
if (infeasible_) {
12481248
activitymin = 0.0;
12491249
ninfmin = 0;
@@ -1288,7 +1288,7 @@ void HighsDomain::computeMinActivity(HighsInt start, HighsInt end,
12881288
void HighsDomain::computeMaxActivity(HighsInt start, HighsInt end,
12891289
const HighsInt* ARindex,
12901290
const double* ARvalue, HighsInt& ninfmax,
1291-
HighsCDouble& activitymax) {
1291+
HighsCDouble& activitymax) const {
12921292
if (infeasible_) {
12931293
activitymax = 0.0;
12941294
ninfmax = 0;
@@ -1398,7 +1398,7 @@ HighsInt HighsDomain::propagateRowUpper(const HighsInt* Rindex,
13981398
double Rupper,
13991399
const HighsCDouble& minactivity,
14001400
HighsInt ninfmin,
1401-
HighsDomainChange* boundchgs) {
1401+
HighsDomainChange* boundchgs) const {
14021402
assert(std::isfinite(double(minactivity)));
14031403
if (ninfmin > 1) return 0;
14041404
HighsInt numchgs = 0;
@@ -1442,7 +1442,7 @@ HighsInt HighsDomain::propagateRowLower(const HighsInt* Rindex,
14421442
double Rlower,
14431443
const HighsCDouble& maxactivity,
14441444
HighsInt ninfmax,
1445-
HighsDomainChange* boundchgs) {
1445+
HighsDomainChange* boundchgs) const {
14461446
assert(std::isfinite(double(maxactivity)));
14471447
if (ninfmax > 1) return 0;
14481448
HighsInt numchgs = 0;
@@ -1481,7 +1481,7 @@ HighsInt HighsDomain::propagateRowLower(const HighsInt* Rindex,
14811481
}
14821482

14831483
void HighsDomain::updateThresholdLbChange(HighsInt col, double newbound,
1484-
double val, double& threshold) {
1484+
double val, double& threshold) const {
14851485
if (newbound != col_upper_[col]) {
14861486
double thresholdNew =
14871487
std::fabs(val) * boundRange(col_upper_[col], newbound,
@@ -1496,7 +1496,7 @@ void HighsDomain::updateThresholdLbChange(HighsInt col, double newbound,
14961496
}
14971497

14981498
void HighsDomain::updateThresholdUbChange(HighsInt col, double newbound,
1499-
double val, double& threshold) {
1499+
double val, double& threshold) const {
15001500
if (newbound != col_lower_[col]) {
15011501
double thresholdNew =
15021502
std::fabs(val) * boundRange(newbound, col_lower_[col],
@@ -3617,9 +3617,11 @@ HighsDomain::ConflictSet::popQueue() {
36173617

36183618
void HighsDomain::ConflictSet::clearQueue() { resolveQueue.clear(); }
36193619

3620-
HighsInt HighsDomain::ConflictSet::queueSize() { return resolveQueue.size(); }
3620+
HighsInt HighsDomain::ConflictSet::queueSize() const {
3621+
return resolveQueue.size();
3622+
}
36213623

3622-
bool HighsDomain::ConflictSet::resolvable(HighsInt domChgPos) {
3624+
bool HighsDomain::ConflictSet::resolvable(HighsInt domChgPos) const {
36233625
assert(domChgPos >= 0);
36243626
assert(domChgPos < (HighsInt)localdom.domchgreason_.size());
36253627
// printf("domchgPos: %d\n", domChgPos);

highs/mip/HighsDomain.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class HighsDomain {
104104
void pushQueue(std::set<LocalDomChg>::iterator domchgPos);
105105
std::set<LocalDomChg>::iterator popQueue();
106106
void clearQueue();
107-
HighsInt queueSize();
108-
bool resolvable(HighsInt domChgPos);
107+
HighsInt queueSize() const;
108+
bool resolvable(HighsInt domChgPos) const;
109109

110110
HighsInt resolveDepth(std::set<LocalDomChg>& frontier, HighsInt depthLevel,
111111
HighsInt stopSize, HighsInt minResolve = 0,
@@ -317,10 +317,10 @@ class HighsDomain {
317317
void updateActivityUbChange(HighsInt col, double oldbound, double newbound);
318318

319319
void updateThresholdLbChange(HighsInt col, double newbound, double val,
320-
double& threshold);
320+
double& threshold) const;
321321

322322
void updateThresholdUbChange(HighsInt col, double newbound, double val,
323-
double& threshold);
323+
double& threshold) const;
324324

325325
void recomputeCapacityThreshold(HighsInt row);
326326

@@ -407,11 +407,11 @@ class HighsDomain {
407407

408408
void computeMinActivity(HighsInt start, HighsInt end, const HighsInt* ARindex,
409409
const double* ARvalue, HighsInt& ninfmin,
410-
HighsCDouble& activitymin);
410+
HighsCDouble& activitymin) const;
411411

412412
void computeMaxActivity(HighsInt start, HighsInt end, const HighsInt* ARindex,
413413
const double* ARvalue, HighsInt& ninfmax,
414-
HighsCDouble& activitymax);
414+
HighsCDouble& activitymax) const;
415415

416416
double adjustedUb(HighsInt col, HighsCDouble boundVal, bool& accept) const;
417417

@@ -420,12 +420,12 @@ class HighsDomain {
420420
HighsInt propagateRowUpper(const HighsInt* Rindex, const double* Rvalue,
421421
HighsInt Rlen, double Rupper,
422422
const HighsCDouble& minactivity, HighsInt ninfmin,
423-
HighsDomainChange* boundchgs);
423+
HighsDomainChange* boundchgs) const;
424424

425425
HighsInt propagateRowLower(const HighsInt* Rindex, const double* Rvalue,
426426
HighsInt Rlen, double Rlower,
427427
const HighsCDouble& maxactivity, HighsInt ninfmax,
428-
HighsDomainChange* boundchgs);
428+
HighsDomainChange* boundchgs) const;
429429

430430
const std::vector<HighsInt>& getChangedCols() const { return changedcols_; }
431431

highs/mip/HighsLpRelaxation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ bool HighsLpRelaxation::checkDualProof() const {
10191019
bool HighsLpRelaxation::computeDualInfProof(const HighsDomain& globaldomain,
10201020
std::vector<HighsInt>& inds,
10211021
std::vector<double>& vals,
1022-
double& rhs) {
1022+
double& rhs) const {
10231023
if (!hasdualproof) return false;
10241024

10251025
assert(std::isfinite(dualproofrhs));

highs/mip/HighsLpRelaxation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ class HighsLpRelaxation {
329329

330330
bool computeDualInfProof(const HighsDomain& globaldomain,
331331
std::vector<HighsInt>& inds,
332-
std::vector<double>& vals, double& rhs);
332+
std::vector<double>& vals, double& rhs) const;
333333

334334
Status resolveLp(HighsDomain* domain = nullptr);
335335

highs/mip/HighsMipSolver.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -895,10 +895,13 @@ void HighsMipSolver::callbackGetCutPool() const {
895895
callback_->user_callback_data);
896896
}
897897

898-
bool HighsMipSolver::solutionFeasible(
899-
const HighsLp* lp, const std::vector<double>& col_value,
900-
const std::vector<double>* pass_row_value, double& bound_violation,
901-
double& row_violation, double& integrality_violation, HighsCDouble& obj) {
898+
bool HighsMipSolver::solutionFeasible(const HighsLp* lp,
899+
const std::vector<double>& col_value,
900+
const std::vector<double>* pass_row_value,
901+
double& bound_violation,
902+
double& row_violation,
903+
double& integrality_violation,
904+
HighsCDouble& obj) const {
902905
bound_violation = 0;
903906
row_violation = 0;
904907
integrality_violation = 0;

highs/mip/HighsMipSolver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class HighsMipSolver {
106106
bool solutionFeasible(const HighsLp* lp, const std::vector<double>& col_value,
107107
const std::vector<double>* pass_row_value,
108108
double& bound_violation, double& row_violation,
109-
double& integrality_violation, HighsCDouble& obj);
109+
double& integrality_violation, HighsCDouble& obj) const;
110110
};
111111

112112
#endif

highs/mip/HighsMipSolverData.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "util/HighsIntegers.h"
2121

2222
std::string HighsMipSolverData::solutionSourceToString(
23-
const int solution_source, const bool code) {
23+
const int solution_source, const bool code) const {
2424
if (solution_source == kSolutionSourceNone) {
2525
if (code) return " ";
2626
return "None";
@@ -1179,9 +1179,10 @@ double HighsMipSolverData::transformNewIntegerFeasibleSolution(
11791179
}
11801180

11811181
double HighsMipSolverData::percentageInactiveIntegers() const {
1182-
return 100.0 * (1.0 - double(integer_cols.size() -
1183-
cliquetable.getSubstitutions().size()) /
1184-
numintegercols);
1182+
return 100.0 *
1183+
(1.0 - static_cast<double>(integer_cols.size() -
1184+
cliquetable.getSubstitutions().size()) /
1185+
numintegercols);
11851186
}
11861187

11871188
void HighsMipSolverData::performRestart() {
@@ -1498,7 +1499,7 @@ static std::array<char, 22> convertToPrintString(double val,
14981499
return printString;
14991500
}
15001501

1501-
void HighsMipSolverData::printSolutionSourceKey() {
1502+
void HighsMipSolverData::printSolutionSourceKey() const {
15021503
std::stringstream ss;
15031504
// Last MipSolutionSource enum is kSolutionSourceCleanup - which is
15041505
// not a solution source, but used to force the last logging line to

highs/mip/HighsMipSolverData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ struct HighsMipSolverData {
277277
const std::vector<double>& getSolution() const;
278278

279279
std::string solutionSourceToString(const int solution_source,
280-
const bool code = true);
281-
void printSolutionSourceKey();
280+
const bool code = true) const;
281+
void printSolutionSourceKey() const;
282282
void printDisplayLine(const int solution_source = kSolutionSourceNone);
283283

284284
void getRow(HighsInt row, HighsInt& rowlen, const HighsInt*& rowinds,

highs/presolve/HighsSymmetry.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ bool HighsSymmetryDetection::partitionRefinement() {
984984
return true;
985985
}
986986

987-
HighsInt HighsSymmetryDetection::selectTargetCell() {
987+
HighsInt HighsSymmetryDetection::selectTargetCell() const {
988988
HighsInt i = 0;
989989
if (nodeStack.size() > 1) i = nodeStack[nodeStack.size() - 2].targetCell;
990990

@@ -997,7 +997,7 @@ HighsInt HighsSymmetryDetection::selectTargetCell() {
997997
return -1;
998998
}
999999

1000-
bool HighsSymmetryDetection::checkStoredAutomorphism(HighsInt vertex) {
1000+
bool HighsSymmetryDetection::checkStoredAutomorphism(HighsInt vertex) const {
10011001
HighsInt numCheck = std::min(numAutomorphisms, (HighsInt)64);
10021002

10031003
for (HighsInt i = 0; i < numCheck; ++i) {
@@ -1363,7 +1363,7 @@ void HighsSymmetryDetection::switchToNextNode(HighsInt backtrackDepth) {
13631363

13641364
bool HighsSymmetryDetection::compareCurrentGraph(
13651365
const HighsHashTable<std::tuple<HighsInt, HighsInt, HighsUInt>>& otherGraph,
1366-
HighsInt& wrongCell) {
1366+
HighsInt& wrongCell) const {
13671367
for (HighsInt i = 0; i < numCol; ++i) {
13681368
HighsInt colCell = vertexToCell[i];
13691369

highs/presolve/HighsSymmetry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class HighsSymmetryDetection {
207207
bool compareCurrentGraph(
208208
const HighsHashTable<std::tuple<HighsInt, HighsInt, HighsUInt>>&
209209
otherGraph,
210-
HighsInt& wrongCell);
210+
HighsInt& wrongCell) const;
211211

212212
void removeFixPoints();
213213
void initializeGroundSet();
@@ -218,9 +218,9 @@ class HighsSymmetryDetection {
218218
void initializeHashValues();
219219
bool isomorphicToFirstLeave();
220220
bool partitionRefinement();
221-
bool checkStoredAutomorphism(HighsInt vertex);
221+
bool checkStoredAutomorphism(HighsInt vertex) const;
222222
u32 getVertexHash(HighsInt vertex);
223-
HighsInt selectTargetCell();
223+
HighsInt selectTargetCell() const;
224224

225225
bool updateCellMembership(HighsInt vertex, HighsInt cell,
226226
bool markForRefinement = true);

0 commit comments

Comments
 (0)