qpOASES  3.2.1
An Implementation of the Online Active Set Strategy
SparseSolver.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
35 #ifndef QPOASES_SPARSESOLVER_HPP
36 #define QPOASES_SPARSESOLVER_HPP
37 
38 #include <qpOASES/Utils.hpp>
39 
40 
42 
43 
53 {
54  /*
55  * PUBLIC MEMBER FUNCTIONS
56  */
57  public:
59  SparseSolver( );
60 
62  SparseSolver( const SparseSolver& rhs
63  );
64 
66  virtual ~SparseSolver( );
67 
69  virtual SparseSolver& operator=( const SparseSolver& rhs
70  );
71 
75  virtual returnValue setMatrixData( int_t dim,
76  int_t numNonzeros,
77  const int_t* const airn,
78  const int_t* const acjn,
79  const real_t* const avals
80  ) = 0;
81 
83  virtual returnValue factorize( ) = 0;
84 
86  virtual returnValue solve( int_t dim,
87  const real_t* const rhs,
88  real_t* const sol
89  ) = 0;
90 
92  virtual returnValue reset( );
93 
95  virtual int_t getNegativeEigenvalues( );
96 
98  virtual int_t getRank( );
99 
101  virtual returnValue getZeroPivots( int_t *&zeroPivots );
102 
103  /*
104  * PROTECTED MEMBER FUNCTIONS
105  */
106  protected:
109  returnValue clear( );
110 
113  returnValue copy( const SparseSolver& rhs
114  );
115 
116  /*
117  * PROTECTED MEMBER VARIABLES
118  */
119  protected:
120 };
121 
122 
123 #ifdef SOLVER_MA27
124 
132 class Ma27SparseSolver: public SparseSolver
133 {
134  /*
135  * PUBLIC MEMBER FUNCTIONS
136  */
137  public:
139  Ma27SparseSolver( );
140 
142  Ma27SparseSolver( const Ma27SparseSolver& rhs
143  );
144 
146  virtual ~Ma27SparseSolver( );
147 
149  virtual Ma27SparseSolver& operator=( const SparseSolver& rhs
150  );
151 
155  virtual returnValue setMatrixData( int_t dim,
156  int_t numNonzeros,
157  const int_t* const airn,
158  const int_t* const acjn,
159  const real_t* const avals
160  );
161 
163  virtual returnValue factorize( );
164 
166  virtual returnValue solve( int_t dim,
167  const real_t* const rhs,
168  real_t* const sol
169  );
170 
172  virtual returnValue reset( );
173 
175  virtual int_t getNegativeEigenvalues( );
176 
178  virtual int getRank( );
179 
180  /*
181  * PROTECTED MEMBER FUNCTIONS
182  */
183  protected:
186  returnValue clear( );
187 
190  returnValue copy( const Ma27SparseSolver& rhs
191  );
192 
193  /*
194  * PRIVATE MEMBER FUNCTIONS
195  */
196  private:
197  /*
198  * PRIVATE MEMBER VARIABLES
199  */
200  private:
201  fint_t dim;
203  fint_t numNonzeros;
205  fint_t la_ma27;
207  double* a_ma27;
209  fint_t* irn_ma27;
211  fint_t* jcn_ma27;
213  fint_t icntl_ma27[30];
215  double cntl_ma27[5];
217  fint_t liw_ma27;
219  fint_t* iw_ma27;
221  fint_t* ikeep_ma27;
223  fint_t nsteps_ma27;
225  fint_t maxfrt_ma27;
227  bool have_factorization;
229  fint_t neig;
231  fint_t rank;
232 };
233 
234 #endif /* SOLVER_MA27 */
235 
236 
237 #ifdef SOLVER_MA57
238 
246 class Ma57SparseSolver: public SparseSolver
247 {
248  /*
249  * PUBLIC MEMBER FUNCTIONS
250  */
251  public:
253  Ma57SparseSolver( );
254 
256  Ma57SparseSolver( const Ma57SparseSolver& rhs
257  );
258 
260  virtual ~Ma57SparseSolver( );
261 
263  virtual Ma57SparseSolver& operator=( const SparseSolver& rhs
264  );
265 
269  virtual returnValue setMatrixData( int_t dim,
270  int_t numNonzeros,
271  const int_t* const airn,
272  const int_t* const acjn,
273  const real_t* const avals
274  );
275 
277  virtual returnValue factorize( );
278 
280  virtual returnValue solve( int_t dim,
281  const real_t* const rhs,
282  real_t* const sol
283  );
284 
286  virtual returnValue reset( );
287 
289  virtual int_t getNegativeEigenvalues( );
290 
292  virtual int_t getRank( );
293 
295  virtual returnValue getZeroPivots( int_t* &zeroPivots
296  );
297  /*
298  * PROTECTED MEMBER FUNCTIONS
299  */
300  protected:
303  returnValue clear( );
304 
307  returnValue copy( const Ma57SparseSolver& rhs
308  );
309 
310  /*
311  * PRIVATE MEMBER FUNCTIONS
312  */
313  private:
314  /*
315  * PRIVATE MEMBER VARIABLES
316  */
317  private:
318  fint_t dim;
320  fint_t numNonzeros;
322  double* a_ma57;
324  fint_t* irn_ma57;
326  fint_t* jcn_ma57;
328  fint_t icntl_ma57[30];
330  double cntl_ma57[5];
332  double* fact_ma57;
334  fint_t lfact_ma57;
336  fint_t* ifact_ma57;
338  fint_t lifact_ma57;
340  bool have_factorization;
342  fint_t neig;
344  fint_t rank;
346  fint_t* pivots;
347 };
348 
349 #endif /* SOLVER_MA57 */
350 
351 
352 #ifdef SOLVER_NONE
353 
361 class DummySparseSolver: public SparseSolver
362 {
363  /*
364  * PUBLIC MEMBER FUNCTIONS
365  */
366  public:
370  virtual returnValue setMatrixData( int_t dim,
371  int_t numNonzeros,
372  const int_t* const airn,
373  const int_t* const acjn,
374  const real_t* const avals
375  );
376 
378  virtual returnValue factorize( );
379 
381  virtual returnValue solve( int_t dim,
382  const real_t* const rhs,
383  real_t* const sol
384  );
385 };
386 
387 #endif /* SOLVER_NONE */
388 
389 
391 
392 #endif /* QPOASES_SPARSESOLVER_HPP */
393 
394 /*
395  * end of file
396  */
Bounds::getNFV
int_t getNFV() const
Definition: Bounds.ipp:55
QProblemB::lb
real_t * lb
Definition: QProblemB.hpp:975
QProblemB::applyGivens
void applyGivens(real_t c, real_t s, real_t nu, real_t xold, real_t yold, real_t &xnew, real_t &ynew) const
Definition: QProblemB.ipp:447
real_t
BEGIN_NAMESPACE_QPOASES typedef double real_t
Definition: Types.hpp:171
RET_INDEX_OUT_OF_BOUNDS
@ RET_INDEX_OUT_OF_BOUNDS
Definition: MessageHandling.hpp:70
SymmetricMatrix
Abstract base class for interfacing matrix-vector operations tailored to symmetric matrices.
Definition: Matrices.hpp:292
Bounds::getNFX
int_t getNFX() const
Definition: Bounds.ipp:91
Options
Manages all user-specified options for solving QPs.
Definition: Options.hpp:56
QProblemB::getStatus
QProblemStatus getStatus() const
Definition: QProblemB.ipp:100
END_NAMESPACE_QPOASES
#define END_NAMESPACE_QPOASES
Definition: Types.hpp:110
QProblemB::isBlocking
BooleanType isBlocking(real_t num, real_t den, real_t epsNum, real_t epsDen, real_t &t) const
Definition: QProblemB.ipp:474
BooleanType
BooleanType
Definition: Types.hpp:203
SparseSolver::copy
returnValue copy(const SparseSolver &rhs)
Definition: SparseSolver.cpp:143
SparseSolver::getRank
virtual int_t getRank()
Definition: SparseSolver.cpp:111
SparseSolver::getZeroPivots
virtual returnValue getZeroPivots(int_t *&zeroPivots)
Definition: SparseSolver.cpp:119
QProblemB::bounds
Bounds bounds
Definition: QProblemB.hpp:978
ZERO
const real_t ZERO
Definition: Constants.hpp:57
QProblemB::getOptions
Options getOptions() const
Definition: QProblemB.ipp:182
QProblemStatus
QProblemStatus
Definition: Types.hpp:233
HessianType
HessianType
Definition: Types.hpp:248
BEGIN_NAMESPACE_QPOASES
#define BEGIN_NAMESPACE_QPOASES
Definition: Types.hpp:107
Bounds
Manages working sets of bounds (i.e. box constraints).
Definition: Bounds.hpp:56
SparseSolver::factorize
virtual returnValue factorize()=0
QProblemB::freeHessian
BooleanType freeHessian
Definition: QProblemB.hpp:971
BT_TRUE
@ BT_TRUE
Definition: Types.hpp:206
QProblemB::isSolved
BooleanType isSolved() const
Definition: QProblemB.ipp:121
QProblemB::isUnbounded
BooleanType isUnbounded() const
Definition: QProblemB.ipp:142
getSqrt
real_t getSqrt(real_t x)
Definition: Utils.ipp:157
QProblemB::count
uint_t count
Definition: QProblemB.hpp:996
SparseSolver::getNegativeEigenvalues
virtual int_t getNegativeEigenvalues()
Definition: SparseSolver.cpp:103
Options::ensureConsistency
returnValue ensureConsistency()
Definition: Options.cpp:234
QProblemB::ub
real_t * ub
Definition: QProblemB.hpp:976
isZero
BooleanType isZero(real_t x, real_t TOL=ZERO)
Definition: Utils.ipp:60
QProblemB::H
SymmetricMatrix * H
Definition: QProblemB.hpp:972
QProblemB::computeGivens
void computeGivens(real_t xold, real_t yold, real_t &xnew, real_t &ynew, real_t &c, real_t &s) const
Definition: QProblemB.ipp:409
SparseSolver::operator=
virtual SparseSolver & operator=(const SparseSolver &rhs)
Definition: SparseSolver.cpp:81
QProblemB::getBounds
returnValue getBounds(Bounds &_bounds) const
Definition: QProblemB.ipp:48
QPS_NOTINITIALISED
@ QPS_NOTINITIALISED
Definition: Types.hpp:235
INFTY
const real_t INFTY
Definition: Constants.hpp:61
BT_FALSE
@ BT_FALSE
Definition: Types.hpp:205
QProblemB::setHessianType
returnValue setHessianType(HessianType _hessianType)
Definition: QProblemB.ipp:160
Options::printLevel
PrintLevel printLevel
Definition: Options.hpp:122
fint_t
int fint_t
Definition: Types.hpp:189
QProblemB::status
QProblemStatus status
Definition: QProblemB.hpp:988
QProblemB::setUB
returnValue setUB(const real_t *const ub_new)
Definition: QProblemB.ipp:360
QProblemB::getCount
uint_t getCount() const
Definition: QProblemB.ipp:216
QProblemB::g
real_t * g
Definition: QProblemB.hpp:974
QProblemB::getPrintLevel
PrintLevel getPrintLevel() const
Definition: QProblemB.ipp:206
returnValue
returnValue
Defines all symbols for global return values.
Definition: MessageHandling.hpp:64
SparseSolver
Base class for linear solvers that are used in a Schur-complement implementation in qpOASES.
Definition: SparseSolver.hpp:52
Utils.hpp
QProblemB::unbounded
BooleanType unbounded
Definition: QProblemB.hpp:991
RET_INVALID_ARGUMENTS
@ RET_INVALID_ARGUMENTS
Definition: MessageHandling.hpp:71
QProblemB::setOptions
returnValue setOptions(const Options &_options)
Definition: QProblemB.ipp:191
QProblemB::isInfeasible
BooleanType isInfeasible() const
Definition: QProblemB.ipp:133
QPS_SOLVED
@ QPS_SOLVED
Definition: Types.hpp:243
SparseSolver::~SparseSolver
virtual ~SparseSolver()
Definition: SparseSolver.cpp:72
QProblemB::getHessianType
HessianType getHessianType() const
Definition: QProblemB.ipp:151
SparseSolver::reset
virtual returnValue reset()
Definition: SparseSolver.cpp:95
SUCCESSFUL_RETURN
@ SUCCESSFUL_RETURN
Definition: MessageHandling.hpp:68
QProblemB::getNV
int_t getNV() const
Definition: QProblemB.ipp:64
THROWERROR
#define THROWERROR(retval)
Definition: MessageHandling.hpp:456
Bounds::getNV
int_t getNV() const
Definition: Bounds.ipp:46
QProblemB::usingRegularisation
BooleanType usingRegularisation() const
Definition: QProblemB.ipp:170
QProblemB::setPrintLevel
returnValue setPrintLevel(PrintLevel _printlevel)
Definition: QProblemB.cpp:824
QProblemB::setLB
returnValue setLB(const real_t *const lb_new)
Definition: QProblemB.ipp:312
QProblemB::hessianType
HessianType hessianType
Definition: QProblemB.hpp:993
HST_ZERO
@ HST_ZERO
Definition: Types.hpp:250
QProblemB::infeasible
BooleanType infeasible
Definition: QProblemB.hpp:990
QProblemB::regVal
real_t regVal
Definition: QProblemB.hpp:994
HST_IDENTITY
@ HST_IDENTITY
Definition: Types.hpp:251
SparseSolver::SparseSolver
SparseSolver()
Definition: SparseSolver.cpp:55
QProblemB::resetCounter
returnValue resetCounter()
Definition: QProblemB.ipp:225
QProblemB::getNFX
int_t getNFX() const
Definition: QProblemB.ipp:82
QProblemB::options
Options options
Definition: QProblemB.hpp:1004
QProblemB::isInitialised
BooleanType isInitialised() const
Definition: QProblemB.ipp:109
RET_QPOBJECT_NOT_SETUP
@ RET_QPOBJECT_NOT_SETUP
Definition: MessageHandling.hpp:100
getAbs
real_t getAbs(real_t x)
Definition: Utils.ipp:143
SparseSolver::solve
virtual returnValue solve(int_t dim, const real_t *const rhs, real_t *const sol)=0
QProblemB::getNFV
int_t getNFV() const
Definition: QProblemB.ipp:91
PrintLevel
PrintLevel
Definition: Types.hpp:212
Bounds::getNFR
int_t getNFR() const
Definition: Bounds.ipp:82
SparseSolver::setMatrixData
virtual returnValue setMatrixData(int_t dim, int_t numNonzeros, const int_t *const airn, const int_t *const acjn, const real_t *const avals)=0
QProblemB::setG
returnValue setG(const real_t *const g_new)
Definition: QProblemB.ipp:293
SparseSolver::clear
returnValue clear()
Definition: SparseSolver.cpp:134
SymDenseMat
Interfaces matrix-vector operations tailored to symmetric dense matrices.
Definition: Matrices.hpp:511
QProblemB::getNFR
int_t getNFR() const
Definition: QProblemB.ipp:73
int_t
int int_t
Definition: Types.hpp:180
QProblemB::setH
returnValue setH(SymmetricMatrix *H_new)
Definition: QProblemB.ipp:239