SoPlex Documentation
Loading...
Searching...
No Matches
SLUFactor< R > Class Template Reference

Implementation of Sparse Linear Solver. More...

#include <slufactor.h>

Inheritance diagram for SLUFactor< R >:
SLinSolver< R > CLUFactor< R >

Public Types

Types
enum  UpdateType { ETA = 0 , FOREST_TOMLIN }
 Specifies how to perform change method. More...
 
using Status = typename SLinSolver<R>::Status
 for convenience
 
- 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.
 
void setUtype (UpdateType tp)
 sets update type.
 
void setMarkowitz (R m)
 sets minimum Markowitz threshold.
 
markowitz ()
 returns Markowitz threshold.
 
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\).
 
void solveRight (SSVectorBase< R > &x, const SSVectorBase< R > &b)
 
void solveRight (SSVectorBase< R > &x, const SVectorBase< R > &b)
 Solves \(Ax=b\).
 
void solveRight4update (SSVectorBase< R > &x, const SVectorBase< R > &b)
 Solves \(Ax=b\).
 
void solve2right4update (SSVectorBase< R > &x, VectorBase< R > &y, const SVectorBase< R > &b, SSVectorBase< R > &d)
 Solves \(Ax=b\) and \(Ay=d\).
 
void solve2right4update (SSVectorBase< R > &x, SSVectorBase< R > &y, const SVectorBase< R > &b, SSVectorBase< R > &d)
 Sparse version of solving two systems of equations.
 
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\).
 
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
 
void solveLeft (VectorBase< R > &x, const VectorBase< R > &b)
 sparse version of solving one system of equations with transposed basis matrix
 
void solveLeft (SSVectorBase< R > &x, const SSVectorBase< R > &b)
 
void solveLeft (SSVectorBase< R > &x, const SVectorBase< R > &b)
 Solves \(Ax=b\).
 
void solveLeft (SSVectorBase< R > &x, VectorBase< R > &y, const SVectorBase< R > &b, SSVectorBase< R > &d)
 Solves \(Ax=b\) and \(Ay=d\).
 
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
 
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\).
 
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
 
Status change (int idx, const SVectorBase< R > &subst, const SSVectorBase< R > *eta=0)
 
Miscellaneous
Real getFactorTime () const
 time spent in factorizations
 
void resetFactorTime ()
 reset FactorTime
 
int getFactorCount () const
 number of factorizations performed
 
Real getSolveTime () const
 time spent in solves
 
void resetSolveTime ()
 reset SolveTime
 
int getSolveCount () const
 number of solves performed
 
void resetCounters ()
 reset timers and counters
 
void changeTimer (const Timer::TYPE ttype)
 
void dump () const
 prints the LU factorization to stdout.
 
bool isConsistent () const
 consistency check.
 
virtual void setTolerances (std::shared_ptr< Tolerances > tolerances)
 set tolerances
 
Constructors / Destructors
 SLUFactor ()
 default constructor.
 
SLUFactor< R > & operator= (const SLUFactor< R > &old)
 assignment operator.
 
 SLUFactor (const SLUFactor< R > &old)
 copy constructor.
 
virtual ~SLUFactor ()
 destructor.
 
virtual SLinSolver< R > * clone () const
 clone function for polymorphism
 
- Public Member Functions inherited from SLinSolver< R >
 SLinSolver ()
 default constructor
 
virtual ~SLinSolver ()
 destructor
 

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
 
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
 
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
 
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
 
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
 
const std::shared_ptr< Tolerancestolerances () const
 get tolerances
 

Protected Attributes

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

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

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

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

template<class R >
using Status = typename SLinSolver<R>::Status

for convenience

Definition at line 64 of file slufactor.h.

Member Enumeration Documentation

◆ UpdateType

template<class R >
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]

template<class R >
SLUFactor ( )

default constructor.

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

◆ SLUFactor() [2/2]

template<class R >
SLUFactor ( const SLUFactor< R > & old)

copy constructor.

◆ ~SLUFactor()

template<class R >
virtual ~SLUFactor ( )
virtual

destructor.

Member Function Documentation

◆ assign()

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

used to implement the assignment operator

◆ change()

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

Implements SLinSolver< R >.

◆ changeEta()

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

◆ changeTimer()

template<class R >
void changeTimer ( const Timer::TYPE ttype)

◆ clear()

template<class R >
void clear ( )
virtual

Implements SLinSolver< R >.

◆ clone()

template<class R >
virtual SLinSolver< R > * clone ( ) const
virtual

clone function for polymorphism

Implements SLinSolver< R >.

Definition at line 328 of file slufactor.h.

References SLUFactor< R >::SLUFactor().

◆ dim()

template<class R >
int dim ( ) const
virtual

Implements SLinSolver< R >.

Definition at line 164 of file slufactor.h.

References CLUFactor< R >::thedim.

◆ dump()

template<class R >
void dump ( ) const

prints the LU factorization to stdout.

◆ freeAll()

template<class R >
void freeAll ( )
protected

◆ getFactorCount()

template<class R >
int getFactorCount ( ) const
virtual

number of factorizations performed

Implements SLinSolver< R >.

Definition at line 264 of file slufactor.h.

References CLUFactor< R >::factorCount.

◆ getFactorTime()

template<class R >
Real getFactorTime ( ) const

time spent in factorizations

Definition at line 254 of file slufactor.h.

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

◆ getName()

template<class R >
const char * getName ( ) const
virtual

Implements SLinSolver< R >.

Definition at line 174 of file slufactor.h.

◆ getSolveCount()

template<class R >
int getSolveCount ( ) const

number of solves performed

Definition at line 280 of file slufactor.h.

References SLUFactor< R >::solveCount.

◆ getSolveTime()

template<class R >
Real getSolveTime ( ) const

time spent in solves

Definition at line 270 of file slufactor.h.

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

◆ isConsistent()

template<class R >
bool isConsistent ( ) const
virtual

consistency check.

Implements SLinSolver< R >.

◆ load()

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

Implements SLinSolver< R >.

◆ markowitz()

template<class R >
R markowitz ( )

returns Markowitz threshold.

Definition at line 149 of file slufactor.h.

References SLUFactor< R >::lastThreshold.

◆ matrixMetric()

template<class R >
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()

template<class R >
int memory ( ) const
virtual

◆ operator=()

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

assignment operator.

◆ resetCounters()

template<class R >
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()

template<class R >
void resetFactorTime ( )

reset FactorTime

Definition at line 259 of file slufactor.h.

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

◆ resetSolveTime()

template<class R >
void resetSolveTime ( )

reset SolveTime

Definition at line 275 of file slufactor.h.

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

◆ setMarkowitz()

template<class R >
void setMarkowitz ( R m)

sets minimum Markowitz threshold.

Definition at line 136 of file slufactor.h.

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

◆ setTolerances()

template<class R >
virtual void setTolerances ( std::shared_ptr< Tolerances > tolerances)
virtual

◆ setUtype()

template<class R >
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]

template<class R >
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]

template<class R >
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]

template<class R >
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]

template<class R >
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]

template<class R >
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]

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

Solves \(Ax=b\).

Implements SLinSolver< R >.

◆ solveLeft() [3/7]

template<class R >
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]

template<class R >
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]

template<class R >
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]

template<class R >
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]

template<class R >
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]

template<class R >
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]

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

Solves \(Ax=b\).

Implements SLinSolver< R >.

◆ solveRight() [3/3]

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

Solves \(Ax=b\).

Implements SLinSolver< R >.

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

◆ solveRight4update()

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

Solves \(Ax=b\).

Implements SLinSolver< R >.

◆ stability()

template<class R >
R stability ( ) const
virtual

Implements SLinSolver< R >.

◆ statistics()

template<class R >
std::string statistics ( ) const
virtual

Implements SLinSolver< R >.

◆ status()

template<class R >
Status status ( ) const
virtual

Implements SLinSolver< R >.

Definition at line 179 of file slufactor.h.

References CLUFactor< R >::stat.

◆ utype()

template<class R >
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

template<class R >
SSVectorBase<R> eta
protected

Definition at line 83 of file slufactor.h.

◆ forest

template<class R >
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

template<class R >
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

template<class R >
R minStability
protected

minimum stability to achieve by setting threshold.

Definition at line 95 of file slufactor.h.

◆ minThreshold

template<class R >
R minThreshold
protected

minimum threshold to use.

Definition at line 93 of file slufactor.h.

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

◆ solveCount

template<class R >
int solveCount
protected

Number of solves.

Definition at line 100 of file slufactor.h.

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

◆ solveTime

template<class R >
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

template<class R >
SSVectorBase<R> ssvec
private

Temporary semi-sparse VectorBase<R>

Definition at line 73 of file slufactor.h.

◆ timerType

template<class R >
Timer::TYPE timerType
protected

Definition at line 98 of file slufactor.h.

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

◆ uptype

template<class R >
UpdateType uptype
protected

the current UpdateType.

Definition at line 82 of file slufactor.h.

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

◆ usetup

template<class R >
bool usetup
protected

TRUE iff update vector has been setup.

Definition at line 81 of file slufactor.h.

◆ vec

template<class R >
VectorBase<R> vec
private

Temporary VectorBase<R>

Definition at line 72 of file slufactor.h.