conjugate_gradient_method.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
33 #ifndef ACADO_TOOLKIT_CONJUGATE_GRADIENT_MEHTOD_HPP
34 #define ACADO_TOOLKIT_CONJUGATE_GRADIENT_MEHTOD_HPP
35 
36 
38 
39 
41 
42 
58 
59 
60  //
61  // PUBLIC MEMBER FUNCTIONS:
62  //
63  public:
64 
67 
70 
72  virtual ~ConjugateGradientMethod( );
73 
75  virtual SparseSolver* clone() const = 0;
76 
77 
82  virtual returnValue setDimension( const int &n );
83 
84 
90  virtual returnValue setNumberOfEntries( const int &nDense_ );
91 
92 
93 
97  virtual returnValue setIndices( const int *rowIdx_,
98  const int *colIdx_ ) = 0;
99 
100 
101 
106  virtual returnValue setMatrix( double *A_ );
107 
108 
109 
115  virtual returnValue solve( double *b );
116 
117 
118 
123  virtual returnValue getX( double *x_ );
124 
125 
126 
137  virtual returnValue setTolerance( double TOL_ );
138 
139 
144  virtual returnValue setPrintLevel( PrintLevel printLevel_ );
145 
146 
147 
148  //
149  // PROTECTED MEMBER FUNCTIONS:
150  //
151  protected:
152 
153 
155  double scalarProduct( double *aa, double *bb );
156 
158  virtual void multiply( double *xx , double *result ) = 0;
159 
161  virtual returnValue applyPreconditioner( double *b ) = 0;
162 
164  virtual returnValue applyInversePreconditioner( double *x_ ) = 0;
165 
167  virtual returnValue computePreconditioner( double* A_ ) = 0;
168 
169 
170  //
171  // DATA MEMBERS:
172  //
173  protected:
174 
175 
176  // DIMENSIONS:
177  // --------------------
178  int dim; // dimension of the matrix A
179  int nDense; // number of non-zero entries in A
180 
181  // DATA:
182  // --------------------
183  double *A; // The (sparse) matrix A
184  double *x; // The result vector x
185 
186 
187  // AUXILIARY VARIABLES:
188  // --------------------
189  double *norm2; // Auxiliary variables
190  double **p; // conjugate basis vectors
191  double *r; // the actual residuum
192  int pCounter; // a counter for the iterates
193  double *condScale; // scaling factors to improve
194  // the conditioning of the system
195 
196  double TOL; // The required tolerance. (default 10^(-10))
197  PrintLevel printLevel; // The PrintLevel.
198 };
199 
200 
202 
203 
204 
205 #include <acado/sparse_solver/conjugate_gradient_method.ipp>
206 
207 
208 #endif // ACADO_TOOLKIT_CONJUGATE_GRADIENT_METHOD_HPP
209 
210 /*
211  * end of file
212  */
213 
virtual returnValue setNumberOfEntries(const int &nDense_)
virtual returnValue getX(double *x_)
Allows to pass back messages to the calling function.
virtual SparseSolver * clone() const =0
virtual returnValue setMatrix(double *A_)
double scalarProduct(double *aa, double *bb)
virtual returnValue setIndices(const int *rowIdx_, const int *colIdx_)=0
#define CLOSE_NAMESPACE_ACADO
virtual void multiply(double *xx, double *result)=0
virtual returnValue setDimension(const int &n)
virtual returnValue applyPreconditioner(double *b)=0
virtual returnValue solve(double *b)
virtual returnValue setPrintLevel(PrintLevel printLevel_)
Implements a conjugate gradient method as sparse linear algebra solver.
PrintLevel
Generic interface for sparse solvers to be coupled with ACADO Toolkit.
#define BEGIN_NAMESPACE_ACADO
virtual returnValue setTolerance(double TOL_)
virtual returnValue applyInversePreconditioner(double *x_)=0
virtual returnValue computePreconditioner(double *A_)=0


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:31