Scippy

SoPlex

Sequential object-oriented simPlex

slinsolver.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2017 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file slinsolver.h
17  * @brief Sparse Linear Solver virtual base class.
18  */
19 #ifndef _SLINSOLVER_H_
20 #define _SLINSOLVER_H_
21 
22 
23 #include <assert.h>
24 #include <string.h>
25 
26 #include "spxdefines.h"
27 #include "svector.h"
28 #include "ssvector.h"
29 #include "dsvector.h"
30 #include "dvector.h"
31 #include "didxset.h"
32 
33 namespace soplex
34 {
35 /**@brief Sparse Linear Solver virtual base class.
36  @ingroup Algo
37 
38  Class SLinSolver provides a class for solving sparse linear systems with
39  a matrix \f$A\f$ and arbitrary right-hand side vectors. For doing so, the
40  matrix must be first #load%ed to an #SLinSolver object as an array of
41  pointers to the \em column \ref SVector "SVectors" of this matrix.
42 */
44 {
45 public:
46 
47  //---------------------------------------
48  /**@name Types */
49  //@{
50  /// status flags of the SLinSolver class.
51  enum Status
52  {
53  /** The SLinSolver is ready for solving linear systems with the
54  loaded matrix */
55  OK = 0,
56  /** The loaded matrix allows only for instable solutions to be
57  computed */
58  INSTABLE = 1,
59  /// The loaded matrix is singular.
60  SINGULAR = 2,
61  /// No matrix has yet been loaded.
62  UNLOADED = 4,
63  /// An error has occurred.
64  ERROR = 8
65  };
66  //@}
67 
68  //---------------------------------------
69  /**@name Miscellaneous */
70  //@{
71  /// returns the name of the SLinSolver.
72  virtual const char* getName() const = 0;
73 
74  /// returns the Status of the SLinSolver.
75  virtual Status status() const = 0;
76 
77  /// unloads any matrix.
78  virtual void clear() = 0;
79 
80  /// returns current memory consumption.
81  virtual int memory() const = 0;
82 
83  /// returns dimension of loaded matrix.
84  virtual int dim() const = 0;
85 
86  /// loads \p dim column vectors \p vec into the solver.
87  /** Initializes SLinSolver for the solution of linear systems
88  with the matrix consisting of \p dim column vectors given in \p vec.
89  */
90  virtual Status load(const SVector* vec[], int dim) = 0;
91 
92  /// returns a stability number (0: singularity, 1: perfect stability).
93  /** Returns a stability parameter between 0 and 1, where 0 indicates
94  singularity, while 1 indicates perfect stability.
95  */
96  virtual Real stability() const = 0;
97 
98  /// return estimate for the condition number based on the diagonal of U
99  virtual Real conditionEstimate(int type = 0) const = 0;
100 
101  /// returns statistical information in form of a string.
102  virtual std::string statistics() const = 0;
103 
104  /// Substitute column \p idx with \p subst.
105  /** The change method is used to modify the loaded matrix by substituting
106  column \p idx with the new vector \p subst. One may also pass the
107  optional parameter \p eta to the solution of #solveRight() if
108  readily availabble. This may improve on the performance of the update.
109  */
110  virtual Status change(int idx, const SVector& subst, const SSVector* eta = 0) = 0;
111 
112  /// consistency check.
113  virtual bool isConsistent() const = 0;
114 
115  /// get number of factorizations
116  virtual int getFactorCount() const = 0;
117  //@}
118 
119 
120  /**@name Solving linear systems
121  For solving linear systems with an SLinSolver object, it must
122  have previously been loaded with the matrix to use.
123 
124  Two types of systems can be solved \f$A x = b\f$ and \f$x^T A = b^T\f$.
125  Method names related to the first and second type are solveRight() and
126  solveLeft(), respectively.
127 
128  The methods receive their right hand-side vector \f$b\f$ as a
129  \c const parameter, that will hence be unchanged after termination.
130 
131  Some methods are available with two parameters for right hand-side
132  vectors. Then two system are solved in one method invocation. This
133  should generally be faster than solving two systems seperately.
134 
135  The result vector(s) are allways given as the first parameter(s). Two
136  types of result vectors are supported, Vector and SSVector.
137  */
138  //@{
139  /// Solves \f$Ax=b\f$.
140  virtual void solveRight (Vector& x, const Vector& b) /* const */ = 0;
141  /// Solves \f$Ax=b\f$.
142  virtual void solveRight (SSVector& x, const SSVector& b) /* const */ = 0;
143  virtual void solveRight (SSVector& x, const SVector& b) /* const */ = 0;
144 
145  /** @brief Solves \f$Ax=b\f$.
146  Possibly sets up internal data structures suitable for an optimized
147  subsequent change() call with \f$b\f$ as entering column.
148  */
149  virtual void solveRight4update(SSVector& x, const SVector& b) = 0;
150 
151  /// Solves \f$Ax=b\f$ and \f$Ay=d\f$.
152  virtual void solve2right4update(SSVector& x,
153  Vector& y,
154  const SVector& b,
155  SSVector& d ) = 0;
156  /// sparse version of solving two systems of equations
157  virtual void solve2right4update(SSVector& x,
158  SSVector& y,
159  const SVector& b,
160  SSVector& d ) = 0;
161  /// Solves \f$Ax=b\f$, \f$Ay=d\f$ and \f$Az=e\f$.
162  virtual void solve3right4update(SSVector& x,
163  Vector& y,
164  Vector& z,
165  const SVector& b,
166  SSVector& d,
167  SSVector& e) = 0;
168  /// sparse version of solving three systems of equations
169  virtual void solve3right4update(SSVector& x,
170  SSVector& y,
171  SSVector& z,
172  const SVector& b,
173  SSVector& d,
174  SSVector& e) = 0;
175  /// solves \f$x^TA=b^T\f$.
176  virtual void solveLeft (Vector& x, const Vector& b) /* const */ = 0;
177  virtual void solveLeft (SSVector& x, const SSVector& b) /* const */ = 0;
178  /// sparse version of solving one system of equations with transposed basis matrix
179  virtual void solveLeft (SSVector& x, const SVector& b) /* const */ = 0;
180  /// solves \f$x^TA=b^T\f$ and \f$x^TA=rhs2^T\f$ internally using \f$rhs2\f$.
181  virtual void solveLeft (SSVector& x,
182  Vector& two,
183  const SVector& b,
184  SSVector& rhs2) /* const */ = 0;
185  /// sparse version of solving two systems of equations with transposed basis matrix
186  virtual void solveLeft (SSVector& x,
187  SSVector& two,
188  const SVector& b,
189  SSVector& rhs2) /* const */ = 0;
190  /// solves \f$x^TA=b^T\f$, \f$y^TA=d^T\f$ and \f$z^TA=e^T\f$
191  virtual void solveLeft (SSVector& x, Vector& y, Vector& z,
192  const SVector& b, SSVector& d, SSVector& e) = 0;
193  /// sparse version of solving three systems of equations with transposed basis matrix
194  virtual void solveLeft (SSVector& x, SSVector& y, SSVector& z,
195  const SVector& b, SSVector& d, SSVector& e) = 0;
196  //@}
197 
198 
199  //---------------------------------------
200  /**@name Constructors / Destructors */
201  //@{
202  /// default constructor
204  : spxout(0)
205  {}
206  /// destructor
207  virtual ~SLinSolver()
208  {}
209  /// clone function for polymorphism
210  virtual SLinSolver* clone() const = 0;
211  //@}
212 
213  /// message handler
215 
216 
217 };
218 
219 } // namespace soplex
220 #endif // _SLINSOLVER_H_
virtual Real conditionEstimate(int type=0) const =0
return estimate for the condition number based on the diagonal of U
virtual Status change(int idx, const SVector &subst, const SSVector *eta=0)=0
Substitute column idx with subst.
virtual Status load(const SVector *vec[], int dim)=0
loads dim column vectors vec into the solver.
virtual void clear()=0
unloads any matrix.
SPxOut * spxout
message handler
Definition: slinsolver.h:214
virtual std::string statistics() const =0
returns statistical information in form of a string.
virtual void solveRight(Vector &x, const Vector &b)=0
Solves .
virtual int dim() const =0
returns dimension of loaded matrix.
Dymnamic index set.
virtual void solve3right4update(SSVector &x, Vector &y, Vector &z, const SVector &b, SSVector &d, SSVector &e)=0
Solves , and .
Sparse Linear Solver virtual base class.Class SLinSolver provides a class for solving sparse linear s...
Definition: slinsolver.h:43
virtual int getFactorCount() const =0
get number of factorizations
virtual Real stability() const =0
returns a stability number (0: singularity, 1: perfect stability).
virtual Status status() const =0
returns the Status of the SLinSolver.
double Real
Definition: spxdefines.h:218
virtual SLinSolver * clone() const =0
clone function for polymorphism
virtual void solveLeft(Vector &x, const Vector &b)=0
solves .
Dynamic vectors.
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
Definition: spxout.h:63
Sparse vectors.
Semi sparse vector.
virtual bool isConsistent() const =0
consistency check.
Debugging, floating point type and parameter definitions.
Everything should be within this namespace.
virtual int memory() const =0
returns current memory consumption.
An error has occurred.
Definition: slinsolver.h:64
virtual const char * getName() const =0
returns the name of the SLinSolver.
Dynamic sparse vectors.
virtual ~SLinSolver()
destructor
Definition: slinsolver.h:207
SLinSolver()
default constructor
Definition: slinsolver.h:203
The loaded matrix is singular.
Definition: slinsolver.h:60
virtual void solve2right4update(SSVector &x, Vector &y, const SVector &b, SSVector &d)=0
Solves and .
Status
status flags of the SLinSolver class.
Definition: slinsolver.h:51
No matrix has yet been loaded.
Definition: slinsolver.h:62
virtual void solveRight4update(SSVector &x, const SVector &b)=0
Solves . Possibly sets up internal data structures suitable for an optimized subsequent change() call...