Skip to content

Commit 57196d0

Browse files
committed
More const usage
1 parent cf6b0d3 commit 57196d0

File tree

4 files changed

+35
-32
lines changed

4 files changed

+35
-32
lines changed

highs/simplex/HighsSimplexAnalysis.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {
@@ -1485,12 +1485,10 @@ void HighsSimplexAnalysis::reportRunTime(const bool header,
14851485
}
14861486

14871487
HighsInt HighsSimplexAnalysis::intLog10(const double v) const {
1488-
double log10V = v > 0 ? -2.0 * log(v) / log(10.0) : 99;
1489-
HighsInt intLog10V = log10V;
1490-
return intLog10V;
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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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);
410410
HighsInt intLog10(const double v) const;
411-
bool dualAlgorithm();
411+
bool dualAlgorithm() const;
412412

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

highs/simplex/SimplexTimer.h

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ class SimplexTimer {
217217
clock[UpdateRowEpClock] = timer_pointer->clock_def("UPDATE_ROW_EP");
218218
}
219219

220-
bool reportSimplexClockList(const char* grepStamp,
221-
const std::vector<HighsInt> simplex_clock_list,
222-
const HighsTimerClock& simplex_timer_clock,
223-
const double tolerance_percent_report_ = -1) {
220+
bool reportSimplexClockList(
221+
const char* grepStamp, const std::vector<HighsInt> simplex_clock_list,
222+
const HighsTimerClock& simplex_timer_clock,
223+
const double tolerance_percent_report_ = -1) const {
224224
HighsTimer* timer_pointer = simplex_timer_clock.timer_pointer_;
225225
const std::vector<HighsInt>& clock = simplex_timer_clock.clock_;
226226
HighsInt simplex_clock_list_size = simplex_clock_list.size();
@@ -238,7 +238,7 @@ class SimplexTimer {
238238
};
239239

240240
void reportChuzc4ClockList(const std::vector<HighsInt> simplex_clock_list,
241-
const HighsTimerClock& simplex_timer_clock) {
241+
const HighsTimerClock& simplex_timer_clock) const {
242242
HighsTimer* timer_pointer = simplex_timer_clock.timer_pointer_;
243243
const std::vector<HighsInt>& clock = simplex_timer_clock.clock_;
244244
HighsInt simplex_clock_list_size = simplex_clock_list.size();
@@ -253,13 +253,15 @@ class SimplexTimer {
253253
1e-8);
254254
};
255255

256-
void reportSimplexTotalClock(const HighsTimerClock& simplex_timer_clock) {
256+
void reportSimplexTotalClock(
257+
const HighsTimerClock& simplex_timer_clock) const {
257258
const std::vector<HighsInt> simplex_clock_list{SimplexTotalClock};
258259
reportSimplexClockList("SimplexTotal", simplex_clock_list,
259260
simplex_timer_clock);
260261
};
261262

262-
void reportSimplexPhasesClock(const HighsTimerClock& simplex_timer_clock) {
263+
void reportSimplexPhasesClock(
264+
const HighsTimerClock& simplex_timer_clock) const {
263265
const std::vector<HighsInt> simplex_clock_list{
264266
SimplexIzDseWtClock, SimplexDualPhase1Clock, SimplexDualPhase2Clock,
265267
SimplexPrimalPhase2Clock};
@@ -268,13 +270,14 @@ class SimplexTimer {
268270
};
269271

270272
void reportDualSimplexIterateClock(
271-
const HighsTimerClock& simplex_timer_clock) {
273+
const HighsTimerClock& simplex_timer_clock) const {
272274
const std::vector<HighsInt> simplex_clock_list{IterateClock};
273275
reportSimplexClockList("SimplexIterate", simplex_clock_list,
274276
simplex_timer_clock);
275277
};
276278

277-
void reportDualSimplexOuterClock(const HighsTimerClock& simplex_timer_clock) {
279+
void reportDualSimplexOuterClock(
280+
const HighsTimerClock& simplex_timer_clock) const {
278281
const std::vector<HighsInt> simplex_clock_list{
279282
IterateDualRebuildClock, IterateChuzrClock, IterateChuzcClock,
280283
IterateFtranClock, IterateVerifyClock, IterateDualClock,
@@ -283,8 +286,9 @@ class SimplexTimer {
283286
simplex_timer_clock);
284287
};
285288

286-
bool reportSimplexInnerClock(const HighsTimerClock& simplex_timer_clock,
287-
const double tolerance_percent_report_ = -1) {
289+
bool reportSimplexInnerClock(
290+
const HighsTimerClock& simplex_timer_clock,
291+
const double tolerance_percent_report_ = -1) const {
288292
const std::vector<HighsInt> simplex_clock_list{
289293
initialiseSimplexLpBasisAndFactorClock,
290294
allocateSimplexArraysClock,
@@ -341,15 +345,16 @@ class SimplexTimer {
341345
tolerance_percent_report_);
342346
};
343347

344-
void reportSimplexChuzc4Clock(const HighsTimerClock& simplex_timer_clock) {
348+
void reportSimplexChuzc4Clock(
349+
const HighsTimerClock& simplex_timer_clock) const {
345350
const std::vector<HighsInt> simplex_clock_list{Chuzc4a0Clock, Chuzc4a1Clock,
346351
Chuzc4bClock, Chuzc4cClock,
347352
Chuzc4dClock, Chuzc4eClock};
348353
reportChuzc4ClockList(simplex_clock_list, simplex_timer_clock);
349354
};
350355

351356
void reportSimplexMultiInnerClock(
352-
const HighsTimerClock& simplex_timer_clock) {
357+
const HighsTimerClock& simplex_timer_clock) const {
353358
const std::vector<HighsInt> simplex_clock_list{
354359
ScaleClock,
355360
CrashClock,

highs/util/HighsTimer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class HighsTimer {
216216
* @brief Return whether a clock is running
217217
*/
218218
bool running(const HighsInt i_clock = 0 //!< Index of the clock to be read
219-
) {
219+
) const {
220220
assert(i_clock >= 0);
221221
assert(i_clock < num_clock);
222222
if (i_clock == check_clock) {
@@ -232,7 +232,7 @@ class HighsTimer {
232232
*/
233233
HighsInt numCall(
234234
const HighsInt i_clock = 0 //!< Index of the clock to be read
235-
) {
235+
) const {
236236
assert(i_clock >= 0);
237237
assert(i_clock < num_clock);
238238
return clock_num_call[i_clock];
@@ -245,7 +245,7 @@ class HighsTimer {
245245
//!< output using grep
246246
std::vector<HighsInt>& clock_list, //!< List of indices to report
247247
double ideal_sum_time = 0 //!< Ideal value for times to sum to
248-
) {
248+
) const {
249249
const double tolerance_percent_report = 1.0;
250250
return reportOnTolerance(grep_stamp, clock_list, ideal_sum_time,
251251
tolerance_percent_report);
@@ -259,7 +259,7 @@ class HighsTimer {
259259
double tolerance_percent_report =
260260
0 //!< Lower bound on percentage of total time
261261
//!< before an individual clock is reported
262-
) {
262+
) const {
263263
size_t num_clock_list_entries = clock_list.size();
264264
double current_run_highs_time = read();
265265
bool non_null_report = false;

0 commit comments

Comments
 (0)