SoPlex Doxygen Documentation
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-2012 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>
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 
113 
114  /**@name Solving linear systems
115  For solving linear systems with an SLinSolver object, it must
116  have previously been loaded with the matrix to use.
117 
118  Two types of systems can be solved \f$A x = b\f$ and \f$x^T A = b^T\f$.
119  Method names related to the first and second type are solveRight() and
120  solveLeft(), respectively.
121 
122  The methods receive their right hand-side vector \f$b\f$ as a
123  \c const parameter, that will hence be unchanged after termination.
124 
125  Some methods are available with two parameters for right hand-side
126  vectors. Then two system are solved in one method invocation. This
127  should generally be faster than solving two systems seperately.
128 
129  The result vector(s) are allways given as the first parameter(s). Two
130  types of result vectors are supported, Vector and SSVector.
131  */
132  //@{
133  /// Solves \f$Ax=b\f$.
134  virtual void solveRight (Vector& x, const Vector& b) /* const */ = 0;
135  /// Solves \f$Ax=b\f$.
136  virtual void solveRight (SSVector& x, const SVector& b) /* const */ = 0;
137 
138  /** @brief Solves \f$Ax=b\f$.
139  Possibly sets up internal data structures suitable for an optimized
140  subsequent change() call with \f$b\f$ as entering column.
141  */
142  virtual void solveRight4update(SSVector& x, const SVector& b) = 0;
143 
144  /// Solves \f$Ax=b\f$ and \f$Ay=d\f$.
145  virtual void solve2right4update(SSVector& x,
146  Vector& y,
147  const SVector& b,
148  SSVector& d ) = 0;
149  /// Solves \f$Ax=b\f$, \f$Ay=d\f$ and \f$Az=e\f$.
150  virtual void solve3right4update(SSVector& x,
151  Vector& y,
152  Vector& z,
153  const SVector& b,
154  SSVector& d,
155  SSVector& e) = 0;
156  /// solves \f$x^TA=b^T\f$.
157  virtual void solveLeft (Vector& x, const Vector& b) /* const */ = 0;
158  /// solves \f$x^TA=b^T\f$.
159  virtual void solveLeft (SSVector& x, const SVector& b) /* const */ = 0;
160  /// solves \f$x^TA=b^T\f$ and \f$x^TA=rhs2^T\f$ internally using \f$rhs2\f$.
161  virtual void solveLeft (SSVector& x,
162  Vector& two,
163  const SVector& b,
164  SSVector& rhs2) /* const */ = 0;
165  //@}
166 
167 
168  //---------------------------------------
169  /**@name Constructors / Destructors */
170  //@{
171  /// default constructor
173  {}
174  /// destructor
175  virtual ~SLinSolver()
176  {}
177  /// clone function for polymorphism
178  virtual SLinSolver* clone() const = 0;
179  //@}
180 
181 
182 
183 };
184 
185 } // namespace soplex
186 #endif // _SLINSOLVER_H_
187 
188 //-----------------------------------------------------------------------------
189 //Emacs Local Variables:
190 //Emacs mode:c++
191 //Emacs c-basic-offset:3
192 //Emacs tab-width:8
193 //Emacs indent-tabs-mode:nil
194 //Emacs End:
195 //-----------------------------------------------------------------------------