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-2024 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file slinsolver_rational.h
26 * @brief Sparse Linear Solver virtual base class with Rational precision.
27 */
28#ifndef _SLINSOLVER_RATIONAL_H_
29#define _SLINSOLVER_RATIONAL_H_
30
31
32#include <assert.h>
33#include <string.h>
34
35#include "soplex/spxdefines.h"
36#include "soplex/svector.h"
37#include "soplex/ssvector.h"
38#include "soplex/dsvector.h"
39#include "soplex/vector.h"
40#include "soplex/didxset.h"
41
42namespace soplex
43{
44/**@brief Sparse Linear Solver virtual base class with Rational precision.
45 @ingroup Algo
46
47 Class SLinSolverRational provides a class for solving sparse linear systems with
48 a matrix \f$A\f$ and arbitrary right-hand side vectors. For doing so, the
49 matrix must be first #load%ed to an #SLinSolverRational object as an array of
50 pointers to the \em column \ref SVectorRational "SVectorsRational" of this matrix.
51*/
53{
54public:
55
56 //---------------------------------------
57 /**@name Types */
58 ///@{
59 /// status flags of the SLinSolverRational class.
60 enum Status
61 {
62 /** The SLinSolverRational is ready for solving linear systems with the
63 loaded matrix */
64 OK = 0,
65 /** The loaded matrix allows only for instable solutions to be
66 computed */
68 /// The loaded matrix is singular.
70 /// No matrix has yet been loaded.
72 /// An error has occurred.
73 ERROR = 8,
74 /// The time limit has been hit
75 TIME = 16
76 };
77 ///@}
78
79 //---------------------------------------
80 /**@name Miscellaneous */
81 ///@{
82 /// returns the name of the SLinSolverRational.
83 virtual const char* getName() const = 0;
84
85 /// returns the Status of the SLinSolverRational.
86 virtual Status status() const = 0;
87
88 /// unloads any matrix.
89 virtual void clear() = 0;
90
91 /// returns current memory consumption.
92 virtual int memory() const = 0;
93
94 /// returns dimension of loaded matrix.
95 virtual int dim() const = 0;
96
97 /// loads \p dim column vectors \p vec into the solver.
98 /** Initializes SLinSolverRational for the solution of linear systems
99 with the matrix consisting of \p dim column vectors given in \p vec.
100 */
101 virtual Status load(const SVectorRational* vec[], int dim) = 0;
102
103 /// returns a stability number (0: singularity, 1: perfect stability).
104 /** Returns a stability parameter between 0 and 1, where 0 indicates
105 singularity, while 1 indicates perfect stability.
106 */
107 virtual Rational stability() const = 0;
108
109 /// returns statistical information in form of a string.
110 virtual std::string statistics() const = 0;
111
112 /// Substitute column \p idx with \p subst.
113 /** The change method is used to modify the loaded matrix by substituting
114 column \p idx with the new vector \p subst. One may also pass the
115 optional parameter \p eta to the solution of #solveRight() if
116 readily availabble. This may improve on the performance of the update.
117 */
118 virtual Status change(int idx, const SVectorRational& subst,
119 const SSVectorRational* eta = nullptr) = 0;
120
121 /// consistency check.
122 virtual bool isConsistent() const = 0;
123
124 /// get number of factorizations
125 virtual int getFactorCount() const = 0;
126 ///@}
127
128
129 /**@name Solving linear systems
130 For solving linear systems with an SLinSolverRational object, it must
131 have previously been loaded with the matrix to use.
132
133 Two types of systems can be solved \f$A x = b\f$ and \f$x^T A = b^T\f$.
134 Method names related to the first and second type are solveRight() and
135 solveLeft(), respectively.
136
137 The methods receive their right hand-side vector \f$b\f$ as a
138 \c const parameter, that will hence be unchanged after termination.
139
140 Some methods are available with two parameters for right hand-side
141 vectors. Then two system are solved in one method invocation. This
142 should generally be faster than solving two systems seperately.
143
144 The result vector(s) are allways given as the first parameter(s). Two
145 types of result vectors are supported, VectorRational and SSVectorRational.
146 */
147 ///@{
148 /// Solves \f$Ax=b\f$.
149 virtual void solveRight(VectorRational& x, const VectorRational& b) /* const */ = 0;
150 /// Solves \f$Ax=b\f$.
151 virtual void solveRight(SSVectorRational& x, const SVectorRational& b) /* const */ = 0;
152
153 /** @brief Solves \f$Ax=b\f$.
154 Possibly sets up internal data structures suitable for an optimized
155 subsequent change() call with \f$b\f$ as entering column.
156 */
157 virtual void solveRight4update(SSVectorRational& x, const SVectorRational& b) = 0;
158
159 /// Solves \f$Ax=b\f$ and \f$Ay=d\f$.
162 const SVectorRational& b,
163 SSVectorRational& d) = 0;
164 /// Solves \f$Ax=b\f$, \f$Ay=d\f$ and \f$Az=e\f$.
168 const SVectorRational& b,
170 SSVectorRational& e) = 0;
171 /// solves \f$x^TA=b^T\f$.
172 virtual void solveLeft(VectorRational& x, const VectorRational& b) /* const */ = 0;
173 /// solves \f$x^TA=b^T\f$.
174 virtual void solveLeft(SSVectorRational& x, const SVectorRational& b) /* const */ = 0;
175 /// solves \f$x^TA=b^T\f$ and \f$x^TA=rhs2^T\f$ internally using \f$rhs2\f$.
177 VectorRational& two,
178 const SVectorRational& b,
179 SSVectorRational& rhs2) /* const */ = 0;
180 /// solves \f$x^TA=b^T\f$, \f$y^TA=d^T\f$ and \f$z^TA=e^T\f$
183 ///@}
184
185
186 //---------------------------------------
187 /**@name Constructors / Destructors */
188 ///@{
189 /// default constructor
191 {}
192 /// destructor
194 {}
195 /// clone function for polymorphism
196 virtual SLinSolverRational* clone() const = 0;
197 ///@}
198
199
200
201};
202
203} // namespace soplex
204#endif // _SLINSOLVER_RATIONAL_H_
Sparse Linear Solver virtual base class with Rational precision.
virtual int getFactorCount() const =0
get number of factorizations
virtual void solveLeft(SSVectorRational &x, const SVectorRational &b)=0
solves .
virtual void solveRight4update(SSVectorRational &x, const SVectorRational &b)=0
Solves . Possibly sets up internal data structures suitable for an optimized subsequent change() call...
SLinSolverRational()
default constructor
virtual int dim() const =0
returns dimension of loaded matrix.
virtual const char * getName() const =0
returns the name of the SLinSolverRational.
virtual bool isConsistent() const =0
consistency check.
virtual void solveRight(SSVectorRational &x, const SVectorRational &b)=0
Solves .
virtual void clear()=0
unloads any matrix.
virtual Status change(int idx, const SVectorRational &subst, const SSVectorRational *eta=nullptr)=0
Substitute column idx with subst.
Status
status flags of the SLinSolverRational class.
@ ERROR
An error has occurred.
@ UNLOADED
No matrix has yet been loaded.
@ TIME
The time limit has been hit.
@ SINGULAR
The loaded matrix is singular.
virtual void solve2right4update(SSVectorRational &x, VectorRational &y, const SVectorRational &b, SSVectorRational &d)=0
Solves and .
virtual void solveLeft(VectorRational &x, const VectorRational &b)=0
solves .
virtual ~SLinSolverRational()
destructor
virtual void solveRight(VectorRational &x, const VectorRational &b)=0
Solves .
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 solveLeft(SSVectorRational &x, VectorRational &two, const SVectorRational &b, SSVectorRational &rhs2)=0
solves and internally using .
virtual void solve3right4update(SSVectorRational &x, VectorRational &y, VectorRational &z, const SVectorRational &b, SSVectorRational &d, SSVectorRational &e)=0
Solves , and .
virtual Status status() const =0
returns the Status of the SLinSolverRational.
virtual SLinSolverRational * clone() const =0
clone function for polymorphism
virtual std::string statistics() const =0
returns statistical information in form of a string.
virtual Status load(const SVectorRational *vec[], int dim)=0
loads dim column vectors vec into the solver.
virtual void solveLeft(SSVectorRational &x, VectorRational &y, VectorRational &z, const SVectorRational &b, SSVectorRational &d, SSVectorRational &e)=0
solves , and
Dymnamic index set.
Dynamic sparse vectors.
Everything should be within this namespace.
number< gmp_rational, et_off > Rational
Definition: rational.h:29
Debugging, floating point type and parameter definitions.
Semi sparse vector.
Sparse vectors.
Dense vector for linear algebra.