Skip to content

Commit 6c4dd19

Browse files
committed
info and data interface
1 parent 3784e7b commit 6c4dd19

File tree

3 files changed

+26
-33
lines changed

3 files changed

+26
-33
lines changed

highs/ipm/hipo/ipm/FactorHiGHSSolver.cpp

Lines changed: 21 additions & 28 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},
@@ -264,7 +264,7 @@ Int FactorHiGHSSolver::factorAS(const HighsSparseMatrix& A,
264264
valLower[next++] = 0.0;
265265
ptrLower[nA + i + 1] = ptrLower[nA + i] + 1;
266266
}
267-
if (info_) info_->matrix_time += clock.stop();
267+
info_.matrix_time += clock.stop();
268268

269269
// set static regularisation, since it may have changed
270270
FH_.setRegularisation(regul_.primal, regul_.dual);
@@ -273,10 +273,8 @@ Int FactorHiGHSSolver::factorAS(const HighsSparseMatrix& A,
273273
clock.start();
274274
if (FH_.factorise(S_, rowsLower, ptrLower, valLower))
275275
return kStatusErrorFactorise;
276-
if (info_) {
277-
info_->factor_time += clock.stop();
278-
info_->factor_number++;
279-
}
276+
info_.factor_time += clock.stop();
277+
info_.factor_number++;
280278

281279
this->valid_ = true;
282280
return kStatusOk;
@@ -291,7 +289,7 @@ Int FactorHiGHSSolver::factorNE(const HighsSparseMatrix& A,
291289

292290
// build matrix
293291
Int status = buildNEvalues(A, scaling);
294-
if (info_) info_->matrix_time += clock.stop();
292+
info_.matrix_time += clock.stop();
295293

296294
// set static regularisation, since it may have changed
297295
FH_.setRegularisation(regul_.primal, regul_.dual);
@@ -303,10 +301,9 @@ Int FactorHiGHSSolver::factorNE(const HighsSparseMatrix& A,
303301
std::vector<Int> ptrNE(ptrNE_);
304302
std::vector<Int> rowsNE(rowsNE_);
305303
if (FH_.factorise(S_, rowsNE, ptrNE, valNE_)) return kStatusErrorFactorise;
306-
if (info_) {
307-
info_->factor_time += clock.stop();
308-
info_->factor_number++;
309-
}
304+
305+
info_.factor_time += clock.stop();
306+
info_.factor_number++;
310307

311308
this->valid_ = true;
312309
return kStatusOk;
@@ -322,13 +319,11 @@ Int FactorHiGHSSolver::solveNE(const std::vector<double>& rhs,
322319

323320
Clock clock;
324321
if (FH_.solve(lhs)) return kStatusErrorSolve;
325-
if (info_) {
326-
info_->solve_time += clock.stop();
327-
info_->solve_number++;
328-
}
329-
if (data_) {
330-
data_->back().num_solves++;
331-
}
322+
323+
info_.solve_time += clock.stop();
324+
info_.solve_number++;
325+
326+
data_.back().num_solves++;
332327

333328
return kStatusOk;
334329
}
@@ -349,13 +344,11 @@ Int FactorHiGHSSolver::solveAS(const std::vector<double>& rhs_x,
349344

350345
Clock clock;
351346
if (FH_.solve(rhs)) return kStatusErrorSolve;
352-
if (info_) {
353-
info_->solve_time += clock.stop();
354-
info_->solve_number++;
355-
}
356-
if (data_) {
357-
data_->back().num_solves++;
358-
}
347+
348+
info_.solve_time += clock.stop();
349+
info_.solve_number++;
350+
351+
data_.back().num_solves++;
359352

360353
// split lhs
361354
lhs_x = std::vector<double>(rhs.begin(), rhs.begin() + n);
@@ -477,7 +470,7 @@ Int FactorHiGHSSolver::analyseAS(Symbolic& S) {
477470
std::vector<Int> rowsLower;
478471
if (Int status = getASstructure(model_.A(), ptrLower, rowsLower))
479472
return status;
480-
if (info_) info_->matrix_structure_time = clock.stop();
473+
info_.matrix_structure_time = clock.stop();
481474

482475
// create vector of signs of pivots
483476
std::vector<Int> pivot_signs(model_.A().num_col_ + model_.A().num_row_, -1);
@@ -509,7 +502,7 @@ Int FactorHiGHSSolver::analyseNE(Symbolic& S, Int64 nz_limit) {
509502

510503
Clock clock;
511504
if (Int status = buildNEstructure(model_.A(), nz_limit)) return status;
512-
if (info_) info_->matrix_structure_time = clock.stop();
505+
info_.matrix_structure_time = clock.stop();
513506

514507
// create vector of signs of pivots
515508
std::vector<Int> pivot_signs(model_.A().num_row_, 1);

highs/ipm/hipo/ipm/FactorHiGHSSolver.h

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

2929
const Regularisation& regul_;
3030

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

3535
const Model& model_;
@@ -51,7 +51,7 @@ class FactorHiGHSSolver : public LinearSolver {
5151

5252
public:
5353
FactorHiGHSSolver(Options& options, const Model& model,
54-
const Regularisation& regul, Info* info, IpmData* record,
54+
const Regularisation& regul, Info& info, IpmData& record,
5555
const LogHighs& log);
5656

5757
// Override functions

highs/ipm/hipo/ipm/Solver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ bool Solver::initialise() {
7979
start_time_ = control_.elapsed();
8080

8181
// initialise linear solver
82-
LS_.reset(new FactorHiGHSSolver(options_, model_, regul_, &info_, &it_->data,
83-
logH_));
82+
LS_.reset(
83+
new FactorHiGHSSolver(options_, model_, regul_, info_, it_->data, logH_));
8484
if (Int status = LS_->setup()) {
8585
info_.status = (Status)status;
8686
return true;

0 commit comments

Comments
 (0)