Scippy

SoPlex

Sequential object-oriented simPlex

SLUFactor< R > Class Template Reference

Implementation of Sparse Linear Solver. More...

#include <slufactor.h>

Public Types

Types
enum  UpdateType { ETA = 0 , FOREST_TOMLIN }
 Specifies how to perform change method. More...
 
using Status = typename SLinSolver< R >::Status
 for convenience More...
 
- Public Types inherited from SLinSolver< R >
enum  Status {
  OK = 0 , INSTABLE = 1 , SINGULAR = 2 , UNLOADED = 4 ,
  ERROR = 8
}
 status flags of the SLinSolver class. More...
 

Public Member Functions

Update type
UpdateType utype () const
 returns the current update type uptype. More...
 
void setUtype (UpdateType tp)
 sets update type. More...
 
void setMarkowitz (R m)
 sets minimum Markowitz threshold. More...
 
markowitz ()
 returns Markowitz threshold. More...
 
Derived from SLinSolver

See documentation of SLinSolver for a documentation of these methods.

void clear ()
 
int dim () const
 
int memory () const
 
const char * getName () const
 
Status status () const
 
stability () const
 
matrixMetric (int type=0) const
 
std::string statistics () const
 
Status load (const SVectorBase< R > *vec[], int dim)
 
Solve
void solveRight (VectorBase< R > &x, const VectorBase< R > &b)
 Solves \(Ax=b\). More...
 
void solveRight (SSVectorBase< R > &x, const SSVectorBase< R > &b)
 
void solveRight (SSVectorBase< R > &x, const SVectorBase< R > &b)
 Solves \(Ax=b\). More...
 
void solveRight4update (SSVectorBase< R > &x, const SVectorBase< R > &b)
 Solves \(Ax=b\). More...
 
void solve2right4update (SSVectorBase< R > &x, VectorBase< R > &y, const SVectorBase< R > &b, SSVectorBase< R > &d)
 Solves \(Ax=b\) and \(Ay=d\). More...
 
void solve2right4update (SSVectorBase< R > &x, SSVectorBase< R > &y, const SVectorBase< R > &b, SSVectorBase< R > &d)
 Sparse version of solving two systems of equations. More...
 
void solve3right4update (SSVectorBase< R > &x, VectorBase< R > &y, VectorBase< R > &z, const SVectorBase< R > &b, SSVectorBase< R > &d, SSVectorBase< R > &e)
 Solves \(Ax=b\), \(Ay=d\) and \(Az=e\). More...
 
void solve3right4update (SSVectorBase< R > &x, SSVectorBase< R > &y, SSVectorBase< R > &z, const SVectorBase< R > &b, SSVectorBase< R > &d, SSVectorBase< R > &e)
 sparse version of solving three systems of equations More...
 
void solveLeft (VectorBase< R > &x, const VectorBase< R > &b)
 sparse version of solving one system of equations with transposed basis matrix More...
 
void solveLeft (SSVectorBase< R > &x, const SSVectorBase< R > &b)
 
void solveLeft (SSVectorBase< R > &x, const SVectorBase< R > &b)
 Solves \(Ax=b\). More...
 
void solveLeft (SSVectorBase< R > &x, VectorBase< R > &y, const SVectorBase< R > &b, SSVectorBase< R > &d)
 Solves \(Ax=b\) and \(Ay=d\). More...
 
void solveLeft (SSVectorBase< R > &x, SSVectorBase< R > &two, const SVectorBase< R > &b, SSVectorBase< R > &rhs2)
 sparse version of solving two systems of equations with transposed basis matrix More...
 
void solveLeft (SSVectorBase< R > &x, VectorBase< R > &y, VectorBase< R > &z, const SVectorBase< R > &b, SSVectorBase< R > &d, SSVectorBase< R > &e)
 Solves \(Ax=b\), \(Ay=d\) and \(Az=e\). More...
 
void solveLeft (SSVectorBase< R > &x, SSVectorBase< R > &y, SSVectorBase< R > &z, const SVectorBase< R > &b, SSVectorBase< R > &d, SSVectorBase< R > &e)
 sparse version of solving three systems of equations with transposed basis matrix More...
 
Status change (int idx, const SVectorBase< R > &subst, const SSVectorBase< R > *eta=0)
 
Miscellaneous
Real getFactorTime () const
 time spent in factorizations More...
 
void resetFactorTime ()
 reset FactorTime More...
 
int getFactorCount () const
 number of factorizations performed More...
 
Real getSolveTime () const
 time spent in solves More...
 
void resetSolveTime ()
 reset SolveTime More...
 
int getSolveCount () const
 number of solves performed More...
 
void resetCounters ()
 reset timers and counters More...
 
void changeTimer (const Timer::TYPE ttype)
 
void dump () const
 prints the LU factorization to stdout. More...
 
bool isConsistent () const
 consistency check. More...
 
virtual void setTolerances (std::shared_ptr< Tolerances > tolerances)
 set tolerances More...
 
Constructors / Destructors
 SLUFactor ()
 default constructor. More...
 
SLUFactor< R > & operator= (const SLUFactor< R > &old)
 assignment operator. More...
 
 SLUFactor (const SLUFactor< R > &old)
 copy constructor. More...
 
virtual ~SLUFactor ()
 destructor. More...
 
virtual SLinSolver< R > * clone () const
 clone function for polymorphism More...
 
- Public Member Functions inherited from SLinSolver< R >
 SLinSolver ()
 default constructor More...
 
virtual ~SLinSolver ()
 destructor More...
 

Protected Member Functions

Protected helpers
void freeAll ()
 
void changeEta (int idx, SSVectorBase< R > &eta)
 
- Protected Member Functions inherited from CLUFactor< R >
void solveLright (R *vec)
 
int solveRight4update (R *vec, int *nonz, R eps, R *rhs, R *forest, int *forestNum, int *forestIdx)
 
void solveRight (R *vec, R *rhs)
 
int solveRight2update (R *vec1, R *vec2, R *rhs1, R *rhs2, int *nonz, R eps, R *forest, int *forestNum, int *forestIdx)
 
void solveRight2 (R *vec1, R *vec2, R *rhs1, R *rhs2)
 
void solveLeft (R *vec, R *rhs)
 
int solveLeftEps (R *vec, R *rhs, int *nonz, R eps)
 
int solveLeft2 (R *vec1, int *nonz, R *vec2, R eps, R *rhs1, R *rhs2)
 
int vSolveRight4update (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *forest, int *forestNum, int *forestIdx)
 
int vSolveRight4update2 (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *vec2, R eps2, R *rhs2, int *ridx2, int rn2, R *forest, int *forestNum, int *forestIdx)
 
void vSolveRight4update2sparse (R eps, R *vec, int *idx, R *rhs, int *ridx, int &rn, R eps2, R *vec2, int *idx2, R *rhs2, int *ridx2, int &rn2, R *forest, int *forestNum, int *forestIdx)
 sparse version of above method More...
 
int vSolveRight4update3 (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *vec2, R eps2, R *rhs2, int *ridx2, int rn2, R *vec3, R eps3, R *rhs3, int *ridx3, int rn3, R *forest, int *forestNum, int *forestIdx)
 
void vSolveRight4update3sparse (R eps, R *vec, int *idx, R *rhs, int *ridx, int &rn, R eps2, R *vec2, int *idx2, R *rhs2, int *ridx2, int &rn2, R eps3, R *vec3, int *idx3, R *rhs3, int *ridx3, int &rn3, R *forest, int *forestNum, int *forestIdx)
 sparse version of above method More...
 
void vSolveRightNoNZ (R *vec, R eps, R *rhs, int *ridx, int rn)
 
int vSolveLeft (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn)
 
void vSolveLeftNoNZ (R eps, R *vec, R *rhs, int *ridx, int rn)
 
int vSolveLeft2 (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *vec2, R *rhs2, int *ridx2, int rn2)
 
void vSolveLeft2sparse (R eps, R *vec, int *idx, R *rhs, int *ridx, int &rn, R *vec2, int *idx2, R *rhs2, int *ridx2, int &rn2)
 sparse version of solving 2 systems of equations More...
 
int vSolveLeft3 (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *vec2, R *rhs2, int *ridx2, int rn2, R *vec3, R *rhs3, int *ridx3, int rn3)
 
void vSolveLeft3sparse (R eps, R *vec, int *idx, R *rhs, int *ridx, int &rn, R *vec2, int *idx2, R *rhs2, int *ridx2, int &rn2, R *vec3, int *idx3, R *rhs3, int *ridx3, int &rn3)
 sparse version of solving 3 systems of equations More...
 
void forestUpdate (int col, R *work, int num, int *nonz)
 
void update (int p_col, R *p_work, const int *p_idx, int num)
 
void updateNoClear (int p_col, const R *p_work, const int *p_idx, int num)
 
void factor (const SVectorBase< R > **vec, R threshold, R eps)
 
void dump () const
 
bool isConsistent () const
 
void setTolerances (std::shared_ptr< Tolerances > tolerances)
 set tolerances More...
 
const std::shared_ptr< Tolerancestolerances () const
 get tolerances More...
 

Protected Attributes

Protected data
bool usetup
 TRUE iff update vector has been setup. More...
 
UpdateType uptype
 the current UpdateType. More...
 
SSVectorBase< R > eta
 
SSVectorBase< R > forest
 ? Update VectorBase<R> set up by solveRight4update() and solve2right4update() More...
 
lastThreshold
 pivoting threshold of last factorization More...
 
Control Parameters
minThreshold
 minimum threshold to use. More...
 
minStability
 minimum stability to achieve by setting threshold. More...
 
TimersolveTime
 Time spent in solves. More...
 
Timer::TYPE timerType
 
int solveCount
 Number of solves. More...
 
- Protected Attributes inherited from CLUFactor< R >
SLinSolver< R >::Status stat
 Status indicator. More...
 
int thedim
 dimension of factorized matrix More...
 
int nzCnt
 number of nonzeros in U More...
 
initMaxabs
 maximum abs number in initail Matrix More...
 
maxabs
 maximum abs number in L and U More...
 
rowMemMult
 factor of minimum Memory * number of nonzeros More...
 
colMemMult
 factor of minimum Memory * number of nonzeros More...
 
lMemMult
 factor of minimum Memory * number of nonzeros More...
 
Perm row
 row permutation matrices More...
 
Perm col
 column permutation matrices More...
 
L l
 L matrix. More...
 
std::vector< R > diag
 Array of pivot elements. More...
 
U u
 U matrix. More...
 
R * work
 Working array: must always be left as 0! More...
 
TimerfactorTime
 Time spent in factorizations. More...
 
int factorCount
 Number of factorizations. More...
 
int hugeValues
 number of times huge values occurred during solve (only used in debug mode) More...
 
std::shared_ptr< Tolerances_tolerances
 Tolerances for the factorization. More...
 

Private Member Functions

Private helpers
void assign (const SLUFactor< R > &old)
 used to implement the assignment operator More...
 

Private Attributes

Private data
VectorBase< R > vec
 Temporary VectorBase<R> More...
 
SSVectorBase< R > ssvec
 Temporary semi-sparse VectorBase<R> More...
 

Additional Inherited Members

- Public Attributes inherited from SLinSolver< R >
SPxOutspxout
 message handler More...
 

Detailed Description

template<class R>
class soplex::SLUFactor< R >

Implementation of Sparse Linear Solver.

This class implements a SLinSolver interface by using the sparse LU factorization implemented in CLUFactor.

Definition at line 50 of file slufactor.h.

Member Typedef Documentation

◆ Status

using Status = typename SLinSolver<R>::Status

for convenience

Definition at line 64 of file slufactor.h.

Member Enumeration Documentation

◆ UpdateType

enum UpdateType

Specifies how to perform change method.

Enumerator
ETA 
FOREST_TOMLIN 

Definition at line 58 of file slufactor.h.

Constructor & Destructor Documentation

◆ SLUFactor() [1/2]

SLUFactor ( )

default constructor.

◆ SLUFactor() [2/2]

SLUFactor ( const SLUFactor< R > &  old)

copy constructor.

◆ ~SLUFactor()

virtual ~SLUFactor ( )
virtual

destructor.

Member Function Documentation

◆ assign()

void assign ( const SLUFactor< R > &  old)
private

used to implement the assignment operator

◆ change()

Status change ( int  idx,
const SVectorBase< R > &  subst,
const SSVectorBase< R > *  eta = 0 
)
virtual

Implements SLinSolver< R >.

◆ changeEta()

void changeEta ( int  idx,
SSVectorBase< R > &  eta 
)
protected

◆ changeTimer()

void changeTimer ( const Timer::TYPE  ttype)

◆ clear()

void clear ( )
virtual

Implements SLinSolver< R >.

◆ clone()

virtual SLinSolver< R > * clone ( ) const
virtual

clone function for polymorphism

Implements SLinSolver< R >.

Definition at line 328 of file slufactor.h.

◆ dim()

int dim ( ) const
virtual

Implements SLinSolver< R >.

Definition at line 164 of file slufactor.h.

References CLUFactor< R >::thedim.

◆ dump()

void dump ( ) const

prints the LU factorization to stdout.

◆ freeAll()

void freeAll ( )
protected

◆ getFactorCount()

int getFactorCount ( ) const
virtual

number of factorizations performed

Implements SLinSolver< R >.

Definition at line 264 of file slufactor.h.

References CLUFactor< R >::factorCount.

◆ getFactorTime()

Real getFactorTime ( ) const

time spent in factorizations

Definition at line 254 of file slufactor.h.

References CLUFactor< R >::factorTime, and Timer::time().

◆ getName()

const char * getName ( ) const
virtual

Implements SLinSolver< R >.

Definition at line 174 of file slufactor.h.

◆ getSolveCount()

int getSolveCount ( ) const

number of solves performed

Definition at line 280 of file slufactor.h.

References SLUFactor< R >::solveCount.

◆ getSolveTime()

Real getSolveTime ( ) const

time spent in solves

Definition at line 270 of file slufactor.h.

References SLUFactor< R >::solveTime, and Timer::time().

◆ isConsistent()

bool isConsistent ( ) const
virtual

consistency check.

Implements SLinSolver< R >.

◆ load()

Status load ( const SVectorBase< R > *  vec[],
int  dim 
)
virtual

Implements SLinSolver< R >.

◆ markowitz()

R markowitz ( )

returns Markowitz threshold.

Definition at line 149 of file slufactor.h.

References SLUFactor< R >::lastThreshold.

◆ matrixMetric()

R matrixMetric ( int  type = 0) const
virtual

return one of several matrix metrics based on the diagonal of U 0: condition number estimate by ratio of min/max 1: trace (sum of diagonal elements) 2: determinant (product of diagonal elements)

Implements SLinSolver< R >.

◆ memory()

int memory ( ) const
virtual

◆ operator=()

SLUFactor< R > & operator= ( const SLUFactor< R > &  old)

assignment operator.

◆ resetCounters()

void resetCounters ( )

reset timers and counters

Definition at line 285 of file slufactor.h.

References CLUFactor< R >::factorCount, CLUFactor< R >::factorTime, CLUFactor< R >::hugeValues, and Timer::reset().

◆ resetFactorTime()

void resetFactorTime ( )

reset FactorTime

Definition at line 259 of file slufactor.h.

References CLUFactor< R >::factorTime, and Timer::reset().

◆ resetSolveTime()

void resetSolveTime ( )

reset SolveTime

Definition at line 275 of file slufactor.h.

References Timer::reset(), and SLUFactor< R >::solveTime.

◆ setMarkowitz()

void setMarkowitz ( m)

sets minimum Markowitz threshold.

Definition at line 136 of file slufactor.h.

References SLUFactor< R >::lastThreshold, and SLUFactor< R >::minThreshold.

◆ setTolerances()

virtual void setTolerances ( std::shared_ptr< Tolerances tolerances)
virtual

◆ setUtype()

void setUtype ( UpdateType  tp)

sets update type.

The new UpdateType becomes valid only after the next call to method load().

Definition at line 130 of file slufactor.h.

References SLUFactor< R >::uptype.

◆ solve2right4update() [1/2]

void solve2right4update ( SSVectorBase< R > &  x,
SSVectorBase< R > &  y,
const SVectorBase< R > &  b,
SSVectorBase< R > &  d 
)
virtual

Sparse version of solving two systems of equations.

Implements SLinSolver< R >.

◆ solve2right4update() [2/2]

void solve2right4update ( SSVectorBase< R > &  x,
VectorBase< R > &  y,
const SVectorBase< R > &  b,
SSVectorBase< R > &  d 
)
virtual

Solves \(Ax=b\) and \(Ay=d\).

Implements SLinSolver< R >.

◆ solve3right4update() [1/2]

void solve3right4update ( SSVectorBase< R > &  x,
SSVectorBase< R > &  y,
SSVectorBase< R > &  z,
const SVectorBase< R > &  b,
SSVectorBase< R > &  d,
SSVectorBase< R > &  e 
)
virtual

sparse version of solving three systems of equations

Implements SLinSolver< R >.

◆ solve3right4update() [2/2]

void solve3right4update ( SSVectorBase< R > &  x,
VectorBase< R > &  y,
VectorBase< R > &  z,
const SVectorBase< R > &  b,
SSVectorBase< R > &  d,
SSVectorBase< R > &  e 
)
virtual

Solves \(Ax=b\), \(Ay=d\) and \(Az=e\).

Implements SLinSolver< R >.

◆ solveLeft() [1/7]

void solveLeft ( SSVectorBase< R > &  x,
const SSVectorBase< R > &  b 
)
virtual

Implements SLinSolver< R >.

Definition at line 227 of file slufactor.h.

References SLUFactor< R >::solveLeft(), and SSVectorBase< R >::unSetup().

◆ solveLeft() [2/7]

void solveLeft ( SSVectorBase< R > &  x,
const SVectorBase< R > &  b 
)
virtual

Solves \(Ax=b\).

Implements SLinSolver< R >.

◆ solveLeft() [3/7]

void solveLeft ( SSVectorBase< R > &  x,
SSVectorBase< R > &  two,
const SVectorBase< R > &  b,
SSVectorBase< R > &  rhs2 
)
virtual

sparse version of solving two systems of equations with transposed basis matrix

Implements SLinSolver< R >.

◆ solveLeft() [4/7]

void solveLeft ( SSVectorBase< R > &  x,
SSVectorBase< R > &  y,
SSVectorBase< R > &  z,
const SVectorBase< R > &  b,
SSVectorBase< R > &  d,
SSVectorBase< R > &  e 
)
virtual

sparse version of solving three systems of equations with transposed basis matrix

Implements SLinSolver< R >.

◆ solveLeft() [5/7]

void solveLeft ( SSVectorBase< R > &  x,
VectorBase< R > &  y,
const SVectorBase< R > &  b,
SSVectorBase< R > &  d 
)
virtual

Solves \(Ax=b\) and \(Ay=d\).

Implements SLinSolver< R >.

◆ solveLeft() [6/7]

void solveLeft ( SSVectorBase< R > &  x,
VectorBase< R > &  y,
VectorBase< R > &  z,
const SVectorBase< R > &  b,
SSVectorBase< R > &  d,
SSVectorBase< R > &  e 
)
virtual

Solves \(Ax=b\), \(Ay=d\) and \(Az=e\).

Implements SLinSolver< R >.

◆ solveLeft() [7/7]

void solveLeft ( VectorBase< R > &  x,
const VectorBase< R > &  b 
)
virtual

sparse version of solving one system of equations with transposed basis matrix

Implements SLinSolver< R >.

Referenced by SLUFactor< R >::solveLeft().

◆ solveRight() [1/3]

void solveRight ( SSVectorBase< R > &  x,
const SSVectorBase< R > &  b 
)
virtual

Implements SLinSolver< R >.

Definition at line 204 of file slufactor.h.

References SLUFactor< R >::solveRight(), and SSVectorBase< R >::unSetup().

◆ solveRight() [2/3]

void solveRight ( SSVectorBase< R > &  x,
const SVectorBase< R > &  b 
)
virtual

Solves \(Ax=b\).

Implements SLinSolver< R >.

◆ solveRight() [3/3]

void solveRight ( VectorBase< R > &  x,
const VectorBase< R > &  b 
)
virtual

Solves \(Ax=b\).

Implements SLinSolver< R >.

Referenced by SLUFactor< R >::solveRight().

◆ solveRight4update()

void solveRight4update ( SSVectorBase< R > &  x,
const SVectorBase< R > &  b 
)
virtual

Solves \(Ax=b\).

Implements SLinSolver< R >.

◆ stability()

R stability ( ) const
virtual

Implements SLinSolver< R >.

◆ statistics()

std::string statistics ( ) const
virtual

Implements SLinSolver< R >.

◆ status()

Status status ( ) const
virtual

Implements SLinSolver< R >.

Definition at line 179 of file slufactor.h.

References CLUFactor< R >::stat.

◆ utype()

UpdateType utype ( ) const

returns the current update type uptype.

Definition at line 121 of file slufactor.h.

References SLUFactor< R >::uptype.

Member Data Documentation

◆ eta

SSVectorBase<R> eta
protected

Definition at line 83 of file slufactor.h.

◆ forest

SSVectorBase<R> forest
protected

? Update VectorBase<R> set up by solveRight4update() and solve2right4update()

Definition at line 85 of file slufactor.h.

Referenced by SLUFactor< R >::setTolerances().

◆ lastThreshold

R lastThreshold
protected

pivoting threshold of last factorization

Definition at line 86 of file slufactor.h.

Referenced by SLUFactor< R >::markowitz(), and SLUFactor< R >::setMarkowitz().

◆ minStability

R minStability
protected

minimum stability to achieve by setting threshold.

Definition at line 95 of file slufactor.h.

◆ minThreshold

R minThreshold
protected

minimum threshold to use.

Definition at line 93 of file slufactor.h.

Referenced by SLUFactor< R >::setMarkowitz().

◆ solveCount

int solveCount
protected

Number of solves.

Definition at line 100 of file slufactor.h.

Referenced by SLUFactor< R >::getSolveCount().

◆ solveTime

Timer* solveTime
protected

Time spent in solves.

Definition at line 97 of file slufactor.h.

Referenced by SLUFactor< R >::changeTimer(), SLUFactor< R >::getSolveTime(), and SLUFactor< R >::resetSolveTime().

◆ ssvec

SSVectorBase<R> ssvec
private

Temporary semi-sparse VectorBase<R>

Definition at line 73 of file slufactor.h.

◆ timerType

Timer::TYPE timerType
protected

Definition at line 98 of file slufactor.h.

Referenced by SLUFactor< R >::changeTimer().

◆ uptype

UpdateType uptype
protected

the current UpdateType.

Definition at line 82 of file slufactor.h.

Referenced by SLUFactor< R >::setUtype(), and SLUFactor< R >::utype().

◆ usetup

bool usetup
protected

TRUE iff update vector has been setup.

Definition at line 81 of file slufactor.h.

◆ vec

VectorBase<R> vec
private

Temporary VectorBase<R>

Definition at line 72 of file slufactor.h.