Skip to content

Commit 2d71109

Browse files
committed
Interface to Numeric back to normal, still ugly
1 parent 131ce3e commit 2d71109

File tree

6 files changed

+18
-20
lines changed

6 files changed

+18
-20
lines changed

highs/ipm/hipo/factorhighs/FactorHiGHS.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,8 @@ Int FHsolver::factorise(Numeric& N, const Symbolic& S,
4545
const std::vector<Int>& rows,
4646
const std::vector<Int>& ptr,
4747
const std::vector<double>& vals) {
48-
if (sn_columns_.empty()) {
49-
sn_columns_.resize(S.sn());
50-
printf("Resizing\n");
51-
}
52-
5348
Factorise fact_obj(S, rows, ptr, vals, regul_, log_, data_, sn_columns_);
5449
return fact_obj.run(N);
5550
}
5651

57-
std::vector<std::vector<double>>& FHsolver::columns() { return sn_columns_; }
58-
5952
} // namespace hipo

highs/ipm/hipo/factorhighs/FactorHiGHS.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ class FHsolver {
9999
// Set values for static regularisation to be added when a pivot is selected.
100100
// If regularisation is already added to the matrix, ignore.
101101
void setRegularisation(double reg_p, double reg_d);
102-
103-
std::vector<std::vector<double>>& columns();
104102
};
105103

106104
/* To do
@@ -123,6 +121,12 @@ class FHsolver {
123121
probably considerably increase the memory usage though and the stack approach
124122
is to be preferred. However, the latter requires a different parallelisation.
125123
124+
125+
- at the moment, I managed to keep the same interface to Numeric, but it's a bit
126+
ugly. Maybe Numeric should be an object that is crested by Factorise, which
127+
only contains pointers to data. Then I can just copy into the general numeric
128+
object within FactorHiGHSSolver and include the pointers to the most up to
129+
date data.
126130
*/
127131

128132
} // namespace hipo

highs/ipm/hipo/factorhighs/Factorise.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ bool Factorise::run(Numeric& num) {
360360

361361
// allocate space for list of generated elements and columns of L
362362
schur_contribution_.resize(S_.sn());
363-
// sn_columns_.resize(S_.sn());
363+
sn_columns_.resize(S_.sn());
364364
swaps_.resize(S_.sn());
365365
pivot_2x2_.resize(S_.sn());
366366

@@ -388,6 +388,7 @@ bool Factorise::run(Numeric& num) {
388388
if (flag_stop_) return true;
389389

390390
// move factorisation to numerical object
391+
num.sn_columns_ = &sn_columns_;
391392
num.total_reg_ = std::move(total_reg_);
392393
num.swaps_ = std::move(swaps_);
393394
num.pivot_2x2_ = std::move(pivot_2x2_);

highs/ipm/hipo/factorhighs/Numeric.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
namespace hipo {
1414

15-
Numeric::Numeric(const Symbolic& S,
16-
std::vector<std::vector<double>>& sn_columns)
17-
: S_{S}, sn_columns_{sn_columns} {
18-
// initialise solve handler
19-
SH_.reset(new HybridSolveHandler(S_, sn_columns_, swaps_, pivot_2x2_));
20-
}
15+
Numeric::Numeric(const Symbolic& S) : S_{S} {}
2116

2217
std::pair<Int, double> Numeric::solve(std::vector<double>& x) const {
2318
// Return the number of solves performed
2419

20+
assert(sn_columns_);
21+
22+
// initialise solve handler
23+
SH_.reset(new HybridSolveHandler(S_, *sn_columns_, swaps_, pivot_2x2_));
24+
2525
SH_->setData(data_);
2626

2727
#if HIPO_TIMING_LEVEL >= 1

highs/ipm/hipo/factorhighs/Numeric.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace hipo {
1313

1414
class Numeric {
1515
// columns of factorisation, stored by supernode
16-
const std::vector<std::vector<double>>& sn_columns_;
16+
const std::vector<std::vector<double>>* sn_columns_ = nullptr;
1717

1818
// swaps of columns for each supernode, ordered locally within a block
1919
std::vector<std::vector<Int>> swaps_{};
@@ -25,7 +25,7 @@ class Numeric {
2525
const Symbolic& S_;
2626

2727
// object to handle solve phase in different formats
28-
std::unique_ptr<SolveHandler> SH_;
28+
mutable std::unique_ptr<SolveHandler> SH_;
2929

3030
// lower triangle of original matrix, permuted
3131
std::vector<Int> rowsA_{};
@@ -43,7 +43,7 @@ class Numeric {
4343
// dynamic regularisation applied to the matrix
4444
std::vector<double> total_reg_{};
4545

46-
Numeric(const Symbolic& S, std::vector<std::vector<double>>& sn_columns);
46+
Numeric(const Symbolic& S);
4747

4848
// Full solve with refinement
4949
// Return pair (number of solves, final residual)

highs/ipm/hipo/ipm/FactorHiGHSSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ FactorHiGHSSolver::FactorHiGHSSolver(Options& options, const Model& model,
1313
IpmData* record, const LogHighs& log)
1414
: FH_(&log, options.block_size),
1515
S_{},
16-
N_(S_, FH_.columns()),
16+
N_(S_),
1717
regul_{regul},
1818
info_{info},
1919
data_{record},

0 commit comments

Comments
 (0)