Scippy

SoPlex

Sequential object-oriented simPlex

SLUFactor< R > Class Template Reference

Implementation of Sparse Linear Solver.This class implements a SLinSolver interface by using the sparse LU factorization implemented in CLUFactor. 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...
 
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)
 epsilon for zero detection More...
 
void dump () const
 
bool isConsistent () const
 

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...
 
epsilon
 |x| < epsililon is considered to be 0. 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...
 

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 41 of file slufactor.h.

Member Typedef Documentation

◆ Status

using Status = typename SLinSolver<R>::Status

for convenience

Definition at line 55 of file slufactor.h.

Member Enumeration Documentation

◆ UpdateType

enum UpdateType

Specifies how to perform change method.

Enumerator
ETA 
FOREST_TOMLIN 

Definition at line 49 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

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

◆ change()

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

Implements SLinSolver< R >.

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

◆ changeEta()

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

◆ changeTimer()

◆ clear()

void clear ( )
virtual

Implements SLinSolver< R >.

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

◆ clone()

virtual SLinSolver<R>* clone ( ) const
virtual

clone function for polymorphism

Implements SLinSolver< R >.

Definition at line 311 of file slufactor.h.

References SLUFactor< R >::assign().

◆ dim()

int dim ( ) const
virtual

Implements SLinSolver< R >.

Definition at line 157 of file slufactor.h.

References CLUFactor< R >::thedim.

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

◆ dump()

void dump ( ) const

prints the LU factorization to stdout.

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

◆ freeAll()

void freeAll ( )
protected

◆ getFactorCount()

int getFactorCount ( ) const
virtual

number of factorizations performed

Implements SLinSolver< R >.

Definition at line 257 of file slufactor.h.

References CLUFactor< R >::factorCount.

◆ getFactorTime()

Real getFactorTime ( ) const

time spent in factorizations

Definition at line 247 of file slufactor.h.

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

◆ getName()

const char* getName ( ) const
virtual

Implements SLinSolver< R >.

Definition at line 167 of file slufactor.h.

◆ getSolveCount()

int getSolveCount ( ) const

number of solves performed

Definition at line 273 of file slufactor.h.

References SLUFactor< R >::solveCount.

◆ getSolveTime()

Real getSolveTime ( ) const

time spent in solves

Definition at line 263 of file slufactor.h.

References Timer::time().

◆ isConsistent()

bool isConsistent ( ) const
virtual

consistency check.

Implements SLinSolver< R >.

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

◆ load()

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

Implements SLinSolver< R >.

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

◆ markowitz()

R markowitz ( )

returns Markowitz threshold.

Definition at line 142 of file slufactor.h.

References SLUFactor< R >::clear(), and 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 >.

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

◆ memory()

int memory ( ) const
virtual

◆ operator=()

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

assignment operator.

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

◆ resetCounters()

void resetCounters ( )

reset timers and counters

Definition at line 278 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 252 of file slufactor.h.

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

◆ resetSolveTime()

void resetSolveTime ( )

reset SolveTime

Definition at line 268 of file slufactor.h.

References Timer::reset().

◆ setMarkowitz()

void setMarkowitz ( m)

sets minimum Markowitz threshold.

Definition at line 129 of file slufactor.h.

◆ setUtype()

void setUtype ( UpdateType  tp)

sets update type.

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

Definition at line 123 of file slufactor.h.

◆ solve2right4update() [1/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 >.

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

◆ solve2right4update() [2/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 >.

◆ solve3right4update() [1/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 >.

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

◆ solve3right4update() [2/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 >.

◆ solveLeft() [1/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(), and SLUFactor< R >::solveRight().

◆ solveLeft() [2/7]

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

◆ solveLeft() [3/7]

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

Solves \(Ax=b\).

Implements SLinSolver< R >.

◆ solveLeft() [4/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() [5/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() [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 ( 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 >.

◆ solveRight() [1/3]

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

Solves \(Ax=b\).

Implements SLinSolver< R >.

Referenced by SLUFactor< R >::solveRight(), and SLUFactor< R >::status().

◆ solveRight() [2/3]

◆ solveRight() [3/3]

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

Solves \(Ax=b\).

Implements SLinSolver< R >.

◆ solveRight4update()

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

Solves \(Ax=b\).

Implements SLinSolver< R >.

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

◆ stability()

R stability ( ) const
virtual

Implements SLinSolver< R >.

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

◆ statistics()

std::string statistics ( ) const
virtual

Implements SLinSolver< R >.

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

◆ status()

◆ utype()

UpdateType utype ( ) const

returns the current update type uptype.

Definition at line 114 of file slufactor.h.

References SLUFactor< R >::uptype.

Member Data Documentation

◆ epsilon

R epsilon
protected

|x| < epsililon is considered to be 0.

Definition at line 88 of file slufactor.h.

◆ eta

SSVectorBase<R> eta
protected

Definition at line 74 of file slufactor.h.

◆ forest

SSVectorBase<R> forest
protected

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

Definition at line 76 of file slufactor.h.

◆ lastThreshold

R lastThreshold
protected

pivoting threshold of last factorization

Definition at line 77 of file slufactor.h.

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

◆ minStability

R minStability
protected

minimum stability to achieve by setting threshold.

Definition at line 86 of file slufactor.h.

◆ minThreshold

R minThreshold
protected

minimum threshold to use.

Definition at line 84 of file slufactor.h.

◆ solveCount

int solveCount
protected

Number of solves.

Definition at line 93 of file slufactor.h.

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

◆ solveTime

Timer* solveTime
protected

Time spent in solves.

Definition at line 90 of file slufactor.h.

◆ ssvec

SSVectorBase<R> ssvec
private

Temporary semi-sparse VectorBase<R>

Definition at line 64 of file slufactor.h.

◆ timerType

Timer::TYPE timerType
protected

Definition at line 91 of file slufactor.h.

◆ uptype

UpdateType uptype
protected

the current UpdateType.

Definition at line 73 of file slufactor.h.

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

◆ usetup

bool usetup
protected

TRUE iff update vector has been setup.

Definition at line 72 of file slufactor.h.

◆ vec

VectorBase<R> vec
private

Temporary VectorBase<R>

Definition at line 63 of file slufactor.h.