Scippy

SoPlex

Sequential object-oriented simPlex

slinsolver_rational.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-2022 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_rational.h
17  * @brief Sparse Linear Solver virtual base class with Rational precision.
18  */
19 #ifndef _SLINSOLVER_RATIONAL_H_
20 #define _SLINSOLVER_RATIONAL_H_
21 
22 
23 #include <assert.h>
24 #include <string.h>
25 
26 #include "soplex/spxdefines.h"
27 #include "soplex/svector.h"
28 #include "soplex/ssvector.h"
29 #include "soplex/dsvector.h"
30 #include "soplex/vector.h"
31 #include "soplex/didxset.h"
32 
33 namespace soplex
34 {
35 /**@brief Sparse Linear Solver virtual base class with Rational precision.
36  @ingroup Algo
37 
38  Class SLinSolverRational 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 #SLinSolverRational object as an array of
41  pointers to the \em column \ref SVectorRational "SVectorsRational" of this matrix.
42 */
44 {
45 public:
46 
47  //---------------------------------------
48  /**@name Types */
49  ///@{
50  /// status flags of the SLinSolverRational class.
51  enum Status
52  {
53  /** The SLinSolverRational 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  /// The time limit has been hit
66  TIME = 16
67  };
68  ///@}
69 
70  //---------------------------------------
71  /**@name Miscellaneous */
72  ///@{
73  /// returns the name of the SLinSolverRational.
74  virtual const char* getName() const = 0;
75 
76  /// returns the Status of the SLinSolverRational.
77  virtual Status status() const = 0;
78 
79  /// unloads any matrix.
80  virtual void clear() = 0;
81 
82  /// returns current memory consumption.
83  virtual int memory() const = 0;
84 
85  /// returns dimension of loaded matrix.
86  virtual int dim() const = 0;
87 
88  /// loads \p dim column vectors \p vec into the solver.
89  /** Initializes SLinSolverRational for the solution of linear systems
90  with the matrix consisting of \p dim column vectors given in \p vec.
91  */
92  virtual Status load(const SVectorRational* vec[], int dim) = 0;
93 
94  /// returns a stability number (0: singularity, 1: perfect stability).
95  /** Returns a stability parameter between 0 and 1, where 0 indicates
96  singularity, while 1 indicates perfect stability.
97  */
98  virtual Rational stability() const = 0;
99 
100  /// returns statistical information in form of a string.
101  virtual std::string statistics() const = 0;
102 
103  /// Substitute column \p idx with \p subst.
104  /** The change method is used to modify the loaded matrix by substituting
105  column \p idx with the new vector \p subst. One may also pass the
106  optional parameter \p eta to the solution of #solveRight() if
107  readily availabble. This may improve on the performance of the update.
108  */
109  virtual Status change(int idx, const SVectorRational& subst, const SSVectorRational* eta = 0) = 0;
110 
111  /// consistency check.
112  virtual bool isConsistent() const = 0;
113 
114  /// get number of factorizations
115  virtual int getFactorCount() const = 0;
116  ///@}
117 
118 
119  /**@name Solving linear systems
120  For solving linear systems with an SLinSolverRational object, it must
121  have previously been loaded with the matrix to use.
122 
123  Two types of systems can be solved \f$A x = b\f$ and \f$x^T A = b^T\f$.
124  Method names related to the first and second type are solveRight() and
125  solveLeft(), respectively.
126 
127  The methods receive their right hand-side vector \f$b\f$ as a
128  \c const parameter, that will hence be unchanged after termination.
129 
130  Some methods are available with two parameters for right hand-side
131  vectors. Then two system are solved in one method invocation. This
132  should generally be faster than solving two systems seperately.
133 
134  The result vector(s) are allways given as the first parameter(s). Two
135  types of result vectors are supported, VectorRational and SSVectorRational.
136  */
137  ///@{
138  /// Solves \f$Ax=b\f$.
139  virtual void solveRight(VectorRational& x, const VectorRational& b) /* const */ = 0;
140  /// Solves \f$Ax=b\f$.
141  virtual void solveRight(SSVectorRational& x, const SVectorRational& b) /* const */ = 0;
142 
143  /** @brief Solves \f$Ax=b\f$.
144  Possibly sets up internal data structures suitable for an optimized
145  subsequent change() call with \f$b\f$ as entering column.
146  */
147  virtual void solveRight4update(SSVectorRational& x, const SVectorRational& b) = 0;
148 
149  /// Solves \f$Ax=b\f$ and \f$Ay=d\f$.
150  virtual void solve2right4update(SSVectorRational& x,
151  VectorRational& y,
152  const SVectorRational& b,
153  SSVectorRational& d) = 0;
154  /// Solves \f$Ax=b\f$, \f$Ay=d\f$ and \f$Az=e\f$.
155  virtual void solve3right4update(SSVectorRational& x,
156  VectorRational& y,
157  VectorRational& z,
158  const SVectorRational& b,
159  SSVectorRational& d,
160  SSVectorRational& e) = 0;
161  /// solves \f$x^TA=b^T\f$.
162  virtual void solveLeft(VectorRational& x, const VectorRational& b) /* const */ = 0;
163  /// solves \f$x^TA=b^T\f$.
164  virtual void solveLeft(SSVectorRational& x, const SVectorRational& b) /* const */ = 0;
165  /// solves \f$x^TA=b^T\f$ and \f$x^TA=rhs2^T\f$ internally using \f$rhs2\f$.
166  virtual void solveLeft(SSVectorRational& x,
167  VectorRational& two,
168  const SVectorRational& b,
169  SSVectorRational& rhs2) /* const */ = 0;
170  /// solves \f$x^TA=b^T\f$, \f$y^TA=d^T\f$ and \f$z^TA=e^T\f$
172  const SVectorRational& b, SSVectorRational& d, SSVectorRational& e) = 0;
173  ///@}
174 
175 
176  //---------------------------------------
177  /**@name Constructors / Destructors */
178  ///@{
179  /// default constructor
181  {}
182  /// destructor
184  {}
185  /// clone function for polymorphism
186  virtual SLinSolverRational* clone() const = 0;
187  ///@}
188 
189 
190 
191 };
192 
193 } // namespace soplex
194 #endif // _SLINSOLVER_RATIONAL_H_
virtual void solve2right4update(SSVectorRational &x, VectorRational &y, const SVectorRational &b, SSVectorRational &d)=0
Solves and .
number< gmp_rational, et_off > Rational
Definition: rational.h:30
No matrix has yet been loaded.
The time limit has been hit.
Dymnamic index set.
The loaded matrix is singular.
virtual Status status() const =0
returns the Status of the SLinSolverRational.
virtual int dim() const =0
returns dimension of loaded matrix.
Dense vector for linear algebra.
virtual Status load(const SVectorRational *vec[], int dim)=0
loads dim column vectors vec into the solver.
virtual const char * getName() const =0
returns the name of the SLinSolverRational.
Sparse Linear Solver virtual base class with Rational precision.Class SLinSolverRational provides a c...
SLinSolverRational()
default constructor
virtual std::string statistics() const =0
returns statistical information in form of a string.
virtual void solveLeft(VectorRational &x, const VectorRational &b)=0
solves .
Sparse vectors.
virtual int getFactorCount() const =0
get number of factorizations
Semi sparse vector.
virtual void solveRight4update(SSVectorRational &x, const SVectorRational &b)=0
Solves . Possibly sets up internal data structures suitable for an optimized subsequent change() call...
virtual SLinSolverRational * clone() const =0
clone function for polymorphism
virtual ~SLinSolverRational()
destructor
Debugging, floating point type and parameter definitions.
Everything should be within this namespace.
virtual void solve3right4update(SSVectorRational &x, VectorRational &y, VectorRational &z, const SVectorRational &b, SSVectorRational &d, SSVectorRational &e)=0
Solves , and .
Dynamic sparse vectors.
virtual Rational stability() const =0
returns a stability number (0: singularity, 1: perfect stability).
virtual int memory() const =0
returns current memory consumption.
virtual void clear()=0
unloads any matrix.
virtual bool isConsistent() const =0
consistency check.
Status
status flags of the SLinSolverRational class.
virtual Status change(int idx, const SVectorRational &subst, const SSVectorRational *eta=0)=0
Substitute column idx with subst.
virtual void solveRight(VectorRational &x, const VectorRational &b)=0
Solves .