Skip to content

Commit edc00ef

Browse files
authored
Merge pull request #2437 from fwesselm/makeMoreConst
Make some more methods const
2 parents efdd433 + 57196d0 commit edc00ef

File tree

14 files changed

+67
-63
lines changed

14 files changed

+67
-63
lines changed

highs/simplex/HEkk.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ void HEkk::initialiseEkk() {
15781578
status_.initialised_for_new_lp = true;
15791579
}
15801580

1581-
bool HEkk::isUnconstrainedLp() {
1581+
bool HEkk::isUnconstrainedLp() const {
15821582
bool is_unconstrained_lp = lp_.num_row_ <= 0;
15831583
if (is_unconstrained_lp)
15841584
highsLogDev(
@@ -2796,7 +2796,7 @@ void HEkk::fullBtran(HVector& buffer) {
27962796
void HEkk::choosePriceTechnique(const HighsInt price_strategy,
27972797
const double row_ep_density,
27982798
bool& use_col_price,
2799-
bool& use_row_price_w_switch) {
2799+
bool& use_row_price_w_switch) const {
28002800
// By default switch to column PRICE when pi_p has at least this
28012801
// density
28022802
const double density_for_column_price_switch = 0.75;
@@ -2966,7 +2966,7 @@ void HEkk::computeDual() {
29662966
}
29672967

29682968
double HEkk::computeDualForTableauColumn(const HighsInt iVar,
2969-
const HVector& tableau_column) {
2969+
const HVector& tableau_column) const {
29702970
const vector<double>& workCost = info_.workCost_;
29712971
const vector<HighsInt>& basicIndex = basis_.basicIndex_;
29722972

@@ -3737,7 +3737,7 @@ void HEkk::initialiseAnalysis() {
37373737
analysis_.setup(lp_name_, lp_, *options_, iteration_count_);
37383738
}
37393739

3740-
std::string HEkk::rebuildReason(const HighsInt rebuild_reason) {
3740+
std::string HEkk::rebuildReason(const HighsInt rebuild_reason) const {
37413741
std::string rebuild_reason_string;
37423742
if (rebuild_reason == kRebuildReasonCleanup) {
37433743
rebuild_reason_string = "Perturbation cleanup";
@@ -4219,7 +4219,8 @@ bool HEkk::proofOfPrimalInfeasibility(HVector& row_ep, const HighsInt move_out,
42194219
return proof_of_primal_infeasibility;
42204220
}
42214221

4222-
double HEkk::getValueScale(const HighsInt count, const vector<double>& value) {
4222+
double HEkk::getValueScale(const HighsInt count,
4223+
const vector<double>& value) const {
42234224
if (count <= 0) return 1;
42244225
double max_abs_value = 0;
42254226
for (HighsInt iX = 0; iX < count; iX++)

highs/simplex/HEkk.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class HEkk {
116116
bool proofOfPrimalInfeasibility(HVector& row_ep, const HighsInt move_out,
117117
const HighsInt row_out);
118118

119-
double getValueScale(const HighsInt count, const vector<double>& value);
119+
double getValueScale(const HighsInt count, const vector<double>& value) const;
120120
double getMaxAbsRowValue(HighsInt row);
121121

122122
void unitBtranIterativeRefinement(const HighsInt row_out, HVector& row_ep);
@@ -260,7 +260,7 @@ class HEkk {
260260
HighsSimplexStats simplex_stats_;
261261

262262
private:
263-
bool isUnconstrainedLp();
263+
bool isUnconstrainedLp() const;
264264
void initialiseForSolve();
265265
void setSimplexOptions();
266266
void updateSimplexOptions();
@@ -301,15 +301,15 @@ class HEkk {
301301
void fullBtran(HVector& buffer);
302302
void choosePriceTechnique(const HighsInt price_strategy,
303303
const double row_ep_density, bool& use_col_price,
304-
bool& use_row_price_w_switch);
304+
bool& use_row_price_w_switch) const;
305305
void tableauRowPrice(const bool quad_precision, const HVector& row_ep,
306306
HVector& row_ap,
307307
const HighsInt debug_report = kDebugReportOff);
308308
void fullPrice(const HVector& full_col, HVector& full_row);
309309
void computePrimal();
310310
void computeDual();
311311
double computeDualForTableauColumn(const HighsInt iVar,
312-
const HVector& tableau_column);
312+
const HVector& tableau_column) const;
313313
bool reinvertOnNumericalTrouble(const std::string method_name,
314314
double& numerical_trouble_measure,
315315
const double alpha_from_col,
@@ -347,7 +347,7 @@ class HEkk {
347347
HighsStatus returnFromSolve(const HighsStatus return_status);
348348

349349
void initialiseAnalysis();
350-
std::string rebuildReason(const HighsInt rebuild_reason);
350+
std::string rebuildReason(const HighsInt rebuild_reason) const;
351351

352352
void clearBadBasisChange(
353353
const BadBasisChangeReason reason = BadBasisChangeReason::kAll);
@@ -371,7 +371,7 @@ class HEkk {
371371
void assessDSEWeightError(const double computed_edge_weight,
372372
const double updated_edge_weight);
373373
void updateOperationResultDensity(const double local_density,
374-
double& density);
374+
double& density) const;
375375
bool switchToDevex();
376376

377377
// private debug methods

highs/simplex/HEkkControl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void HEkk::initialiseControl() {
4242
}
4343

4444
void HEkk::updateOperationResultDensity(const double local_density,
45-
double& density) {
45+
double& density) const {
4646
density = (1 - kRunningAverageMultiplier) * density +
4747
kRunningAverageMultiplier * local_density;
4848
}

highs/simplex/HEkkDual.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2731,7 +2731,7 @@ void HEkkDual::reportOnPossibleLpDualInfeasibility() {
27312731
analysis.sum_dual_phase_1_lp_dual_infeasibility);
27322732
}
27332733

2734-
bool HEkkDual::dualInfoOk(const HighsLp& lp) {
2734+
bool HEkkDual::dualInfoOk(const HighsLp& lp) const {
27352735
HighsInt lp_num_col = lp.num_col_;
27362736
HighsInt lp_num_row = lp.num_row_;
27372737
bool dimensions_ok;

highs/simplex/HEkkDual.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ class HEkkDual {
362362
void exitPhase1ResetDuals();
363363
void reportOnPossibleLpDualInfeasibility();
364364

365-
bool checkNonUnitWeightError(std::string message);
366-
bool dualInfoOk(const HighsLp& lp);
365+
bool checkNonUnitWeightError(std::string message) const;
366+
bool dualInfoOk(const HighsLp& lp) const;
367367
bool bailoutOnDualObjective();
368368
HighsDebugStatus debugDualSimplex(const std::string message,
369369
const bool initialise = false);

highs/simplex/HEkkDualMulti.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ void HEkkDual::majorRollback() {
960960
}
961961
}
962962

963-
bool HEkkDual::checkNonUnitWeightError(std::string message) {
963+
bool HEkkDual::checkNonUnitWeightError(std::string message) const {
964964
bool error_found = false;
965965
if (edge_weight_mode == EdgeWeightMode::kDantzig) {
966966
std::vector<double>& edge_weight = ekk_instance_.dual_edge_weight_;

highs/simplex/HEkkDualRow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ void HEkkDualRow::computeDevexWeight(const HighsInt slice) {
633633

634634
HighsInt HEkkDualRow::debugFindInWorkData(
635635
const HighsInt iCol, const HighsInt count,
636-
const std::vector<std::pair<HighsInt, double>>& workData_) {
636+
const std::vector<std::pair<HighsInt, double>>& workData_) const {
637637
for (HighsInt Ix = 0; Ix < count; Ix++)
638638
if (workData_[Ix].first == iCol) return Ix;
639639
return -1;

highs/simplex/HEkkDualRow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class HEkkDualRow {
144144

145145
HighsInt debugFindInWorkData(
146146
const HighsInt iCol, const HighsInt count,
147-
const std::vector<std::pair<HighsInt, double>>& workData_);
147+
const std::vector<std::pair<HighsInt, double>>& workData_) const;
148148
HighsInt debugChooseColumnInfeasibilities() const;
149149
void debugReportBfrtVar(
150150
const HighsInt ix,

highs/simplex/HighsSimplexAnalysis.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ void HighsSimplexAnalysis::dualSteepestEdgeWeightError(
483483

484484
bool HighsSimplexAnalysis::predictEndDensity(const HighsInt tran_stage_type,
485485
const double start_density,
486-
double& end_density) {
486+
double& end_density) const {
487487
return predictFromScatterData(tran_stage[tran_stage_type].rhs_density_,
488488
start_density, end_density);
489489
}
@@ -607,15 +607,15 @@ void HighsSimplexAnalysis::simplexTimerStop(const HighsInt simplex_clock,
607607
}
608608

609609
bool HighsSimplexAnalysis::simplexTimerRunning(const HighsInt simplex_clock,
610-
const HighsInt thread_id) {
610+
const HighsInt thread_id) const {
611611
if (!analyse_simplex_time) return false;
612612
// assert(analyse_simplex_time);
613613
return thread_simplex_clocks[thread_id].timer_pointer_->clock_start
614614
[thread_simplex_clocks[thread_id].clock_[simplex_clock]] < 0;
615615
}
616616

617-
HighsInt HighsSimplexAnalysis::simplexTimerNumCall(const HighsInt simplex_clock,
618-
const HighsInt thread_id) {
617+
HighsInt HighsSimplexAnalysis::simplexTimerNumCall(
618+
const HighsInt simplex_clock, const HighsInt thread_id) const {
619619
if (!analyse_simplex_time) return -1;
620620
// assert(analyse_simplex_time);
621621
return thread_simplex_clocks[thread_id]
@@ -624,7 +624,7 @@ HighsInt HighsSimplexAnalysis::simplexTimerNumCall(const HighsInt simplex_clock,
624624
}
625625

626626
double HighsSimplexAnalysis::simplexTimerRead(const HighsInt simplex_clock,
627-
const HighsInt thread_id) {
627+
const HighsInt thread_id) const {
628628
if (!analyse_simplex_time) return -1.0;
629629
// assert(analyse_simplex_time);
630630
return thread_simplex_clocks[thread_id].timer_pointer_->read(
@@ -1140,10 +1140,10 @@ void HighsSimplexAnalysis::summaryReport() {
11401140
}
11411141
}
11421142

1143-
void HighsSimplexAnalysis::summaryReportFactor() {
1143+
void HighsSimplexAnalysis::summaryReportFactor() const {
11441144
for (HighsInt tran_stage_type = 0; tran_stage_type < NUM_TRAN_STAGE_TYPE;
11451145
tran_stage_type++) {
1146-
TranStageAnalysis& stage = tran_stage[tran_stage_type];
1146+
const TranStageAnalysis& stage = tran_stage[tran_stage_type];
11471147
// printScatterData(stage.name_, stage.rhs_density_);
11481148
printScatterDataRegressionComparison(stage.name_, stage.rhs_density_);
11491149
if (!stage.num_decision_) return;
@@ -1163,7 +1163,7 @@ void HighsSimplexAnalysis::summaryReportFactor() {
11631163
}
11641164
}
11651165

1166-
void HighsSimplexAnalysis::reportSimplexTimer() {
1166+
void HighsSimplexAnalysis::reportSimplexTimer() const {
11671167
assert(analyse_simplex_time);
11681168
SimplexTimer simplex_timer;
11691169
simplex_timer.reportSimplexInnerClock(thread_simplex_clocks[0]);
@@ -1247,7 +1247,7 @@ void HighsSimplexAnalysis::updateInvertFormData(const HFactor& factor) {
12471247
if (report_kernel) printf("\n");
12481248
}
12491249

1250-
void HighsSimplexAnalysis::reportInvertFormData() {
1250+
void HighsSimplexAnalysis::reportInvertFormData() const {
12511251
assert(analyse_factor_data);
12521252
printf("grep_kernel,%s,%s,%" HIGHSINT_FORMAT ",%" HIGHSINT_FORMAT
12531253
",%" HIGHSINT_FORMAT ",",
@@ -1378,7 +1378,7 @@ void HighsSimplexAnalysis::reportOneDensity(const double density) {
13781378
}
13791379
}
13801380

1381-
void HighsSimplexAnalysis::printOneDensity(const double density) {
1381+
void HighsSimplexAnalysis::printOneDensity(const double density) const {
13821382
assert(analyse_simplex_summary_data || analyse_simplex_runtime_data);
13831383
const HighsInt log_10_density = intLog10(density);
13841384
if (log_10_density > -99) {
@@ -1484,13 +1484,11 @@ void HighsSimplexAnalysis::reportRunTime(const bool header,
14841484
#endif
14851485
}
14861486

1487-
HighsInt HighsSimplexAnalysis::intLog10(const double v) {
1488-
double log10V = v > 0 ? -2.0 * log(v) / log(10.0) : 99;
1489-
HighsInt intLog10V = log10V;
1490-
return intLog10V;
1487+
HighsInt HighsSimplexAnalysis::intLog10(const double v) const {
1488+
return static_cast<HighsInt>(v > 0 ? -2.0 * log(v) / log(10.0) : 99);
14911489
}
14921490

1493-
bool HighsSimplexAnalysis::dualAlgorithm() {
1491+
bool HighsSimplexAnalysis::dualAlgorithm() const {
14941492
return (simplex_strategy == kSimplexStrategyDual ||
14951493
simplex_strategy == kSimplexStrategyDualTasks ||
14961494
simplex_strategy == kSimplexStrategyDualMulti);

highs/simplex/HighsSimplexAnalysis.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class HighsSimplexAnalysis {
196196
void userInvertReport(const bool force);
197197
void userInvertReport(const bool header, const bool force);
198198
bool predictEndDensity(const HighsInt tran_stage_id,
199-
const double start_density, double& end_density);
199+
const double start_density, double& end_density) const;
200200
void afterTranStage(const HighsInt tran_stage_id, const double start_density,
201201
const double end_density, const double historical_density,
202202
const double predicted_end_density,
@@ -208,11 +208,11 @@ class HighsSimplexAnalysis {
208208
void simplexTimerStop(const HighsInt simplex_clock,
209209
const HighsInt thread_id = 0);
210210
bool simplexTimerRunning(const HighsInt simplex_clock,
211-
const HighsInt thread_id = 0);
211+
const HighsInt thread_id = 0) const;
212212
HighsInt simplexTimerNumCall(const HighsInt simplex_clock,
213-
const HighsInt thread_id = 0);
213+
const HighsInt thread_id = 0) const;
214214
double simplexTimerRead(const HighsInt simplex_clock,
215-
const HighsInt thread_id = 0);
215+
const HighsInt thread_id = 0) const;
216216

217217
HighsTimerClock* getThreadFactorTimerClockPointer();
218218

@@ -245,12 +245,12 @@ class HighsSimplexAnalysis {
245245
void operationRecordAfter(const HighsInt operation_type,
246246
const HighsInt result_count);
247247
void summaryReport();
248-
void summaryReportFactor();
249-
void reportSimplexTimer();
248+
void summaryReportFactor() const;
249+
void reportSimplexTimer() const;
250250
void reportFactorTimer();
251251
void updateInvertFormData(const HFactor& factor);
252-
void reportInvertFormData();
253-
HighsInt numInvert() { return num_invert; }
252+
void reportInvertFormData() const;
253+
HighsInt numInvert() const { return num_invert; }
254254

255255
// Control methods to be moved to HEkkControl
256256
void dualSteepestEdgeWeightError(const double computed_edge_weight,
@@ -400,15 +400,15 @@ class HighsSimplexAnalysis {
400400
void reportThreads(const bool header);
401401
void reportMulti(const bool header);
402402
void reportOneDensity(const double density);
403-
void printOneDensity(const double density);
403+
void printOneDensity(const double density) const;
404404
void reportDensity(const bool header);
405405
void reportInvert(const bool header);
406406
// void reportCondition(const bool header);
407407
void reportIterationData(const bool header);
408408
void reportRunTime(const bool header, const double run_time);
409409
void reportFreeListSize(const bool header);
410-
HighsInt intLog10(const double v);
411-
bool dualAlgorithm();
410+
HighsInt intLog10(const double v) const;
411+
bool dualAlgorithm() const;
412412

413413
// double AnIterCostlyDseFq; //!< Frequency of iterations when DSE is costly
414414
// double AnIterCostlyDseMeasure;

0 commit comments

Comments
 (0)