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-2016 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  /// returns statistical information in form of a string.
99  virtual std::string statistics() const = 0;
100 
101  /// Substitute column \p idx with \p subst.
102  /** The change method is used to modify the loaded matrix by substituting
103  column \p idx with the new vector \p subst. One may also pass the
104  optional parameter \p eta to the solution of #solveRight() if
105  readily availabble. This may improve on the performance of the update.
106  */
107  virtual Status change(int idx, const SVector& subst, const SSVector* eta = 0) = 0;
108 
109  /// consistency check.
110  virtual bool isConsistent() const = 0;
111 
112  /// get number of factorizations
113  virtual int getFactorCount() const = 0;
114  //@}
115 
116 
117  /**@name Solving linear systems
118  For solving linear systems with an SLinSolver object, it must
119  have previously been loaded with the matrix to use.
120 
121  Two types of systems can be solved \f$A x = b\f$ and \f$x^T A = b^T\f$.
122  Method names related to the first and second type are solveRight() and
123  solveLeft(), respectively.
124 
125  The methods receive their right hand-side vector \f$b\f$ as a
126  \c const parameter, that will hence be unchanged after termination.
127 
128  Some methods are available with two parameters for right hand-side
129  vectors. Then two system are solved in one method invocation. This
130  should generally be faster than solving two systems seperately.
131 
132  The result vector(s) are allways given as the first parameter(s). Two
133  types of result vectors are supported, Vector and SSVector.
134  */
135  //@{
136  /// Solves \f$Ax=b\f$.
137  virtual void solveRight (Vector& x, const Vector& b) /* const */ = 0;
138  /// Solves \f$Ax=b\f$.
139  virtual void solveRight (SSVector& x, const SVector& b) /* const */ = 0;
140 
141  /** @brief Solves \f$Ax=b\f$.
142  Possibly sets up internal data structures suitable for an optimized
143  subsequent change() call with \f$b\f$ as entering column.
144  */
145  virtual void solveRight4update(SSVector& x, const SVector& b) = 0;
146 
147  /// Solves \f$Ax=b\f$ and \f$Ay=d\f$.
148  virtual void solve2right4update(SSVector& x,
149  Vector& y,
150  const SVector& b,
151  SSVector& d ) = 0;
152  /// sparse version of solving two systems of equations
153  virtual void solve2right4update(SSVector& x,
154  SSVector& y,
155  const SVector& b,
156  SSVector& d ) = 0;
157  /// Solves \f$Ax=b\f$, \f$Ay=d\f$ and \f$Az=e\f$.
158  virtual void solve3right4update(SSVector& x,
159  Vector& y,
160  Vector& z,
161  const SVector& b,
162  SSVector& d,
163  SSVector& e) = 0;
164  /// sparse version of solving three systems of equations
165  virtual void solve3right4update(SSVector& x,
166  SSVector& y,
167  SSVector& z,
168  const SVector& b,
169  SSVector& d,
170  SSVector& e) = 0;
171  /// solves \f$x^TA=b^T\f$.
172  virtual void solveLeft (Vector& x, const Vector& b) /* const */ = 0;
173  /// sparse version of solving one system of equations with transposed basis matrix
174  virtual void solveLeft (SSVector& x, const SVector& b) /* const */ = 0;
175  /// solves \f$x^TA=b^T\f$ and \f$x^TA=rhs2^T\f$ internally using \f$rhs2\f$.
176  virtual void solveLeft (SSVector& x,
177  Vector& two,
178  const SVector& b,
179  SSVector& rhs2) /* const */ = 0;
180  /// sparse version of solving two systems of equations with transposed basis matrix
181  virtual void solveLeft (SSVector& x,
182  SSVector& two,
183  const SVector& b,
184  SSVector& rhs2) /* const */ = 0;
185  /// solves \f$x^TA=b^T\f$, \f$y^TA=d^T\f$ and \f$z^TA=e^T\f$
186  virtual void solveLeft (SSVector& x, Vector& y, Vector& z,
187  const SVector& b, SSVector& d, SSVector& e) = 0;
188  /// sparse version of solving three systems of equations with transposed basis matrix
189  virtual void solveLeft (SSVector& x, SSVector& y, SSVector& z,
190  const SVector& b, SSVector& d, SSVector& e) = 0;
191  //@}
192 
193 
194  //---------------------------------------
195  /**@name Constructors / Destructors */
196  //@{
197  /// default constructor
199  : spxout(0)
200  {}
201  /// destructor
202  virtual ~SLinSolver()
203  {}
204  /// clone function for polymorphism
205  virtual SLinSolver* clone() const = 0;
206  //@}
207 
208  /// message handler
210 
211 
212 };
213 
214 } // namespace soplex
215 #endif // _SLINSOLVER_H_
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:209
virtual void solveRight(Vector &x, const Vector &b)=0
Solves .
Dymnamic index set.
virtual const char * getName() const =0
returns the name of the SLinSolver.
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
double Real
SOPLEX_DEBUG.
Definition: spxdefines.h:200
virtual void solveLeft(Vector &x, const Vector &b)=0
solves .
Dynamic vectors.
virtual Status status() const =0
returns the Status of the SLinSolver.
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
Definition: spxout.h:63
virtual bool isConsistent() const =0
consistency check.
Sparse vectors.
Semi sparse vector.
virtual Real stability() const =0
returns a stability number (0: singularity, 1: perfect stability).
virtual std::string statistics() const =0
returns statistical information in form of a string.
Debugging, floating point type and parameter definitions.
virtual SLinSolver * clone() const =0
clone function for polymorphism
virtual int getFactorCount() const =0
get number of factorizations
Everything should be within this namespace.
An error has occurred.
Definition: slinsolver.h:64
virtual int dim() const =0
returns dimension of loaded matrix.
virtual int memory() const =0
returns current memory consumption.
Dynamic sparse vectors.
virtual ~SLinSolver()
destructor
Definition: slinsolver.h:202
SLinSolver()
default constructor
Definition: slinsolver.h:198
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...