Skip to content

Commit a0898b3

Browse files
committed
info and data interface
1 parent 03ff08d commit a0898b3

File tree

3 files changed

+28
-35
lines changed

3 files changed

+28
-35
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},
@@ -271,7 +271,7 @@ Int FactorHiGHSSolver::factorAS(const HighsSparseMatrix& A,
271271
valLower[next++] = 0.0;
272272
ptrLower[nA + i + 1] = ptrLower[nA + i] + 1;
273273
}
274-
if (info_) info_->matrix_time += clock.stop();
274+
info_.matrix_time += clock.stop();
275275

276276
// set static regularisation, since it may have changed
277277
FH_.setRegularisation(regul_.primal, regul_.dual);
@@ -280,10 +280,8 @@ Int FactorHiGHSSolver::factorAS(const HighsSparseMatrix& A,
280280
clock.start();
281281
if (FH_.factorise(S_, rowsLower, ptrLower, valLower))
282282
return kStatusErrorFactorise;
283-
if (info_) {
284-
info_->factor_time += clock.stop();
285-
info_->factor_number++;
286-
}
283+
info_.factor_time += clock.stop();
284+
info_.factor_number++;
287285

288286
this->valid_ = true;
289287
return kStatusOk;
@@ -298,7 +296,7 @@ Int FactorHiGHSSolver::factorNE(const HighsSparseMatrix& A,
298296

299297
// build matrix
300298
Int status = buildNEvalues(A, scaling);
301-
if (info_) info_->matrix_time += clock.stop();
299+
info_.matrix_time += clock.stop();
302300

303301
// set static regularisation, since it may have changed
304302
FH_.setRegularisation(regul_.primal, regul_.dual);
@@ -310,10 +308,9 @@ Int FactorHiGHSSolver::factorNE(const HighsSparseMatrix& A,
310308
std::vector<Int> ptrNE(ptrNE_);
311309
std::vector<Int> rowsNE(rowsNE_);
312310
if (FH_.factorise(S_, rowsNE, ptrNE, valNE_)) return kStatusErrorFactorise;
313-
if (info_) {
314-
info_->factor_time += clock.stop();
315-
info_->factor_number++;
316-
}
311+
312+
info_.factor_time += clock.stop();
313+
info_.factor_number++;
317314

318315
this->valid_ = true;
319316
return kStatusOk;
@@ -329,13 +326,11 @@ Int FactorHiGHSSolver::solveNE(const std::vector<double>& rhs,
329326

330327
Clock clock;
331328
if (FH_.solve(lhs)) return kStatusErrorSolve;
332-
if (info_) {
333-
info_->solve_time += clock.stop();
334-
info_->solve_number++;
335-
}
336-
if (data_) {
337-
data_->back().num_solves++;
338-
}
329+
330+
info_.solve_time += clock.stop();
331+
info_.solve_number++;
332+
333+
data_.back().num_solves++;
339334

340335
return kStatusOk;
341336
}
@@ -356,13 +351,11 @@ Int FactorHiGHSSolver::solveAS(const std::vector<double>& rhs_x,
356351

357352
Clock clock;
358353
if (FH_.solve(rhs)) return kStatusErrorSolve;
359-
if (info_) {
360-
info_->solve_time += clock.stop();
361-
info_->solve_number++;
362-
}
363-
if (data_) {
364-
data_->back().num_solves++;
365-
}
354+
355+
info_.solve_time += clock.stop();
356+
info_.solve_number++;
357+
358+
data_.back().num_solves++;
366359

367360
// split lhs
368361
lhs_x = std::vector<double>(rhs.begin(), rhs.begin() + n);
@@ -389,7 +382,7 @@ Int FactorHiGHSSolver::analyseAS(Symbolic& S) {
389382
std::vector<Int> rowsLower;
390383
if (Int status = getASstructure(model_.A(), ptrLower, rowsLower))
391384
return status;
392-
if (info_) info_->matrix_structure_time = clock.stop();
385+
info_.matrix_structure_time = clock.stop();
393386

394387
// create vector of signs of pivots
395388
std::vector<Int> pivot_signs(model_.A().num_col_ + model_.A().num_row_, -1);
@@ -400,7 +393,7 @@ Int FactorHiGHSSolver::analyseAS(Symbolic& S) {
400393

401394
clock.start();
402395
Int status = FH_.analyse(S, rowsLower, ptrLower, pivot_signs);
403-
if (info_) info_->analyse_AS_time = clock.stop();
396+
info_.analyse_AS_time = clock.stop();
404397

405398
if (status && log_.debug(2)) {
406399
log_.print("Failed augmented system:");
@@ -430,7 +423,7 @@ Int FactorHiGHSSolver::analyseNE(Symbolic& S, Int64 nz_limit) {
430423

431424
Clock clock;
432425
if (Int status = buildNEstructure(model_.A(), nz_limit)) return status;
433-
if (info_) info_->matrix_structure_time = clock.stop();
426+
info_.matrix_structure_time = clock.stop();
434427

435428
// create vector of signs of pivots
436429
std::vector<Int> pivot_signs(model_.A().num_row_, 1);
@@ -439,7 +432,7 @@ Int FactorHiGHSSolver::analyseNE(Symbolic& S, Int64 nz_limit) {
439432

440433
clock.start();
441434
Int status = FH_.analyse(S, rowsNE_, ptrNE_, pivot_signs);
442-
if (info_) info_->analyse_NE_time = clock.stop();
435+
info_.analyse_NE_time = clock.stop();
443436

444437
if (status && log_.debug(2)) {
445438
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
@@ -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_;
@@ -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/Solver.cpp

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

8383
// initialise linear solver
84-
LS_.reset(new FactorHiGHSSolver(options_, model_, regul_, &info_, &it_->data,
85-
logH_));
84+
LS_.reset(
85+
new FactorHiGHSSolver(options_, model_, regul_, info_, it_->data, logH_));
8686
if (Int status = LS_->setup()) {
8787
info_.status = (Status)status;
8888
return true;

0 commit comments

Comments
 (0)