Skip to content

Commit 273c091

Browse files
committed
Simplify
1 parent cc5b4e1 commit 273c091

File tree

9 files changed

+363
-367
lines changed

9 files changed

+363
-367
lines changed

highs/ipm/hipo/ipm/FactorHiGHSSolver.cpp

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
namespace hipo {
1010

1111
FactorHiGHSSolver::FactorHiGHSSolver(Options& options, const Model& model,
12-
const Regularisation& regul, Info* info,
13-
IpmData* record, const LogHighs& log)
12+
const Regularisation& regul, Info& info,
13+
IpmData& record, const LogHighs& log)
1414
: FH_(&log, options.block_size),
1515
S_{},
1616
regul_{regul},
@@ -256,7 +256,7 @@ Int FactorHiGHSSolver::factorAS(const HighsSparseMatrix& A,
256256
valLower[next++] = 0.0;
257257
ptrLower[nA + i + 1] = ptrLower[nA + i] + 1;
258258
}
259-
if (info_) info_->matrix_time += clock.stop();
259+
info_.matrix_time += clock.stop();
260260

261261
// set static regularisation, since it may have changed
262262
FH_.setRegularisation(regul_.primal, regul_.dual);
@@ -265,10 +265,8 @@ Int FactorHiGHSSolver::factorAS(const HighsSparseMatrix& A,
265265
clock.start();
266266
if (FH_.factorise(S_, rowsLower, ptrLower, valLower))
267267
return kStatusErrorFactorise;
268-
if (info_) {
269-
info_->factor_time += clock.stop();
270-
info_->factor_number++;
271-
}
268+
info_.factor_time += clock.stop();
269+
info_.factor_number++;
272270

273271
this->valid_ = true;
274272
return kStatusOk;
@@ -287,7 +285,7 @@ Int FactorHiGHSSolver::factorNE(const HighsSparseMatrix& A,
287285

288286
// build matrix
289287
Int status = buildNEvalues(A, scaling);
290-
if (info_) info_->matrix_time += clock.stop();
288+
info_.matrix_time += clock.stop();
291289

292290
// set static regularisation, since it may have changed
293291
FH_.setRegularisation(regul_.primal, regul_.dual);
@@ -299,10 +297,9 @@ Int FactorHiGHSSolver::factorNE(const HighsSparseMatrix& A,
299297
std::vector<Int> ptrNE(ptrNE_);
300298
std::vector<Int> rowsNE(rowsNE_);
301299
if (FH_.factorise(S_, rowsNE, ptrNE, valNE_)) return kStatusErrorFactorise;
302-
if (info_) {
303-
info_->factor_time += clock.stop();
304-
info_->factor_number++;
305-
}
300+
301+
info_.factor_time += clock.stop();
302+
info_.factor_number++;
306303

307304
this->valid_ = true;
308305
return kStatusOk;
@@ -318,13 +315,11 @@ Int FactorHiGHSSolver::solveNE(const std::vector<double>& rhs,
318315

319316
Clock clock;
320317
if (FH_.solve(lhs)) return kStatusErrorSolve;
321-
if (info_) {
322-
info_->solve_time += clock.stop();
323-
info_->solve_number++;
324-
}
325-
if (data_) {
326-
data_->back().num_solves++;
327-
}
318+
319+
info_.solve_time += clock.stop();
320+
info_.solve_number++;
321+
322+
data_.back().num_solves++;
328323

329324
return kStatusOk;
330325
}
@@ -345,13 +340,11 @@ Int FactorHiGHSSolver::solveAS(const std::vector<double>& rhs_x,
345340

346341
Clock clock;
347342
if (FH_.solve(rhs)) return kStatusErrorSolve;
348-
if (info_) {
349-
info_->solve_time += clock.stop();
350-
info_->solve_number++;
351-
}
352-
if (data_) {
353-
data_->back().num_solves++;
354-
}
343+
344+
info_.solve_time += clock.stop();
345+
info_.solve_number++;
346+
347+
data_.back().num_solves++;
355348

356349
// split lhs
357350
lhs_x = std::vector<double>(rhs.begin(), rhs.begin() + n);
@@ -377,7 +370,7 @@ Int FactorHiGHSSolver::analyseAS(Symbolic& S) {
377370
std::vector<Int> ptrLower, rowsLower;
378371
if (Int status = getASstructure(model_.A(), ptrLower, rowsLower))
379372
return status;
380-
if (info_) info_->matrix_structure_time = clock.stop();
373+
info_.matrix_structure_time = clock.stop();
381374

382375
// create vector of signs of pivots
383376
std::vector<Int> pivot_signs(model_.A().num_col_ + model_.A().num_row_, -1);
@@ -388,7 +381,7 @@ Int FactorHiGHSSolver::analyseAS(Symbolic& S) {
388381

389382
clock.start();
390383
Int status = FH_.analyse(S, rowsLower, ptrLower, pivot_signs);
391-
if (info_) info_->analyse_AS_time = clock.stop();
384+
info_.analyse_AS_time = clock.stop();
392385

393386
if (status && log_.debug(2)) {
394387
log_.print("Failed augmented system:");
@@ -418,7 +411,7 @@ Int FactorHiGHSSolver::analyseNE(Symbolic& S, int64_t nz_limit) {
418411

419412
Clock clock;
420413
if (Int status = buildNEstructure(model_.A(), nz_limit)) return status;
421-
if (info_) info_->matrix_structure_time = clock.stop();
414+
info_.matrix_structure_time = clock.stop();
422415

423416
// create vector of signs of pivots
424417
std::vector<Int> pivot_signs(model_.A().num_row_, 1);
@@ -427,7 +420,7 @@ Int FactorHiGHSSolver::analyseNE(Symbolic& S, int64_t nz_limit) {
427420

428421
clock.start();
429422
Int status = FH_.analyse(S, rowsNE_, ptrNE_, pivot_signs);
430-
if (info_) info_->analyse_NE_time = clock.stop();
423+
info_.analyse_NE_time = clock.stop();
431424

432425
if (status && log_.debug(2)) {
433426
log_.print("Failed normal equations:");

highs/ipm/hipo/ipm/FactorHiGHSSolver.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class FactorHiGHSSolver : public LinearSolver {
2727

2828
const Regularisation& regul_;
2929

30-
Info* info_ = nullptr;
31-
IpmData* data_ = nullptr;
30+
Info& info_;
31+
IpmData& data_;
3232
const LogHighs& log_;
3333

3434
const Model& model_;
@@ -49,7 +49,7 @@ class FactorHiGHSSolver : public LinearSolver {
4949

5050
public:
5151
FactorHiGHSSolver(Options& options, const Model& model,
52-
const Regularisation& regul, Info* info, IpmData* record,
52+
const Regularisation& regul, Info& info, IpmData& record,
5353
const LogHighs& log);
5454

5555
// Override functions

highs/ipm/hipo/ipm/IpmData.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ namespace hipo {
44

55
void IpmData::append() { record.push_back({}); }
66
IpmIterData& IpmData::back() { return record.back(); }
7+
const IpmIterData& IpmData::readBack() const { return record.back(); }
78

89
} // namespace hipo

highs/ipm/hipo/ipm/IpmData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct IpmData {
3030
std::vector<IpmIterData> record;
3131
void append();
3232
IpmIterData& back();
33+
const IpmIterData& readBack() const;
3334
};
3435

3536
} // namespace hipo

0 commit comments

Comments
 (0)