taylor_model.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 
34 #ifndef ACADO_TOOLKIT_TAYLOR_MODEL_HPP
35 #define ACADO_TOOLKIT_TAYLOR_MODEL_HPP
36 
38 
39 
41 
42 template <typename T> class TaylorVariable;
43 
51 template <typename T>
54 {
55 
56 friend class TaylorVariable<T>;
57 template <typename U> friend class TaylorModel;
58 
59 public:
60 
63  ( const unsigned int nvar_, const unsigned int nord_ )
64  { _size( nvar_, nord_ ); }
65 
68  { _cleanup(); }
69 
71  unsigned int nvar() const
72  { return _nvar; };
74  unsigned int nord() const
75  { return _nord; };
77  void reset()
78  { _reset(); };
79 
81  class Exceptions
82  {
83  public:
85  enum TYPE{
86  DIV=1,
90  SIZE=-1,
91  INIT=-2,
92  INCON=-3,
93  TMODEL=-4,
94  UNDEF=-33
95  };
97  Exceptions( TYPE ierr_ ) : _ierr( ierr_ ){}
99  int ierr(){ return _ierr; }
100 
101  private:
103  };
104 
106  struct Options
107  {
110  BOUNDER_TYPE(LSB), PROPAGATE_BNDT(false), INTER_WITH_BNDT(false),
111  SCALE_VARIABLES(true), CENTER_REMAINDER(true), REF_MIDPOINT(true)
112  {}
114  template <typename U> Options
115  ( U&_options )
116  : BOUNDER_TYPE( _options.BOUNDER_TYPE ),
117  PROPAGATE_BNDT( _options.PROPAGATE_BNDT ),
118  INTER_WITH_BNDT( _options.INTER_WITH_BNDT ),
119  SCALE_VARIABLES( _options.SCALE_VARIABLES ),
120  CENTER_REMAINDER( _options.CENTER_REMAINDER ),
121  REF_MIDPOINT( _options.REF_MIDPOINT )
122  {}
123  template <typename U> Options& operator =
124  ( U&_options ){
125  BOUNDER_TYPE = _options.BOUNDER_TYPE;
126  PROPAGATE_BNDT = _options.PROPAGATE_BNDT;
127  INTER_WITH_BNDT = _options.INTER_WITH_BNDT;
128  SCALE_VARIABLES = _options.SCALE_VARIABLES;
129  CENTER_REMAINDER = _options.CENTER_REMAINDER;
130  REF_MIDPOINT = _options.REF_MIDPOINT;
131  return *this;
132  }
134  enum BOUNDER{
135  NAIVE=0,
136  LSB,
138  HYBRID
139  };
152  } options;
153 
155  static void pause();
156 
157 private:
159  unsigned int _nord;
161  unsigned int _nvar;
163  unsigned int _nmon;
165  unsigned int *_posord;
167  unsigned int *_expmon;
169  unsigned int **_prodmon;
173  bool _modvar;
175  unsigned int *_binom;
179  double *_refpoint;
181  double *_scaling;
182 
185 
187  void _size
188  ( const unsigned int nvar, const unsigned int nord );
189 
190 // //! @brief Set the order (nord) and number of variables (nvar)
191 // template <typename U> void _copy_data
192 // ( const TaylorModel<U>&TM );
193 
195  void _set_bndpow
196  ( const unsigned int ix, const T&X, const double scaling );
197 
199  void _set_bndmon();
200 
202  void _set_posord();
203 
205  void _set_expmon();
206 
208  void _next_expmon
209  ( unsigned int *iexp, const unsigned int iord );
210 
212  void _set_prodmon();
213 
215  unsigned int _loc_expmon
216  ( const unsigned int *iexp );
217 
219  void _set_binom();
220 
222  unsigned int _get_binom
223  ( const unsigned int n, const unsigned int k ) const;
224 
226  void _reset();
227 
229  void _cleanup();
230 
232  template< typename U > static void _display
233  ( const unsigned int m, const unsigned int n, U*&a, const unsigned int lda,
234  const std::string&stra, std::ostream&os );
235 };
236 
237 
239 
241 #include <acado/set_arithmetics/taylor_model.ipp>
242 #include <acado/set_arithmetics/taylor_variable.ipp>
243 
244 #endif // ACADO_TOOLKIT_TAYLOR_MODEL_HPP
245 
static void _display(const unsigned int m, const unsigned int n, U *&a, const unsigned int lda, const std::string &stra, std::ostream &os)
Display the elements of a 2D array.
Exceptions(TYPE ierr_)
Constructor for error ierr
Error due to an inconsistent number of variables (zero variables)
USING_NAMESPACE_ACADO typedef TaylorVariable< Interval > T
C++ template class for definition of and operation on variables in a Taylor model.
void _set_prodmon()
Populate array _prodmon w/ exponents resulting from the product of two monomial terms 1...
double * _refpoint
Reference point.
Error due to calling a function/feature not yet implemented.
unsigned int * _posord
Positions of terms of degrees 1,...,_nord.
Eigenvalue decomposition-based bounder.
unsigned int _loc_expmon(const unsigned int *iexp)
Locates position in _posord of monomial term with variable exponents iexp.
unsigned int nvar() const
Get number of variables in the TaylorModel.
unsigned int * _binom
Binomial coefficients.
double * _scaling
Variable scaling.
unsigned int _get_binom(const unsigned int n, const unsigned int k) const
Return binomial coefficient .
Error during calculation of a TaylorVariable for a division term (division by zero) ...
~TaylorModel()
Destructor.
T ** _bndpow
Bounds on the terms for given .
void _set_posord()
Populate array _posord w/ positions of terms of degrees 1,...,nord.
Taylor model options.
void _reset()
Reset the variable bound arrays.
bool REF_MIDPOINT
Flag indicating whether the reference in Taylor expansion of univariate function is taken as the mid-...
T * _bndmon
Bounds on all the monomial terms 1,...,_nmon for given interval vector .
int ierr()
Inline function returning the error flag.
#define CLOSE_NAMESPACE_ACADO
Error due to inconsistency between the Taylor model and T bounders.
struct TaylorModel::Options options
unsigned int _nord
Model order of the model.
bool PROPAGATE_BNDT
Flag indicating whether interval bound are to be propagated in T arithmetic.
Error during eigenvalue decomposition in range bounder.
bool _modvar
Have any of the model variables been modified?
BOUNDER
Taylor model range bounders.
unsigned int _nmon
Number of monomial terms.
void _cleanup()
Clean up the arrays.
bool SCALE_VARIABLES
Flag indicating whether the variables are to be scaled to [-1,1] internally – this requires proper i...
Error due to invalid initialization of a TaylorVariable.
friend class TaylorModel
void _set_binom()
Populate array _binom w/ binomial coefficients.
Error during scaling (degenerate variable range)
unsigned int * _expmon
Variable exponents for monomial terms 1,...,_nmon.
Taylor model exceptions.
void _set_expmon()
Populate array _expmon w/ exponents for monomial terms 1,...,nmon.
unsigned int _nvar
Number of independent variables.
TaylorVariable< T > * _TV
Taylor variable to speed-up computations and reduce dynamic allocation.
TYPE
Enumeration type for TaylorModel exception handling.
Options()
Constructor.
Lin & Stadtherr range bounder.
static void pause()
Pause the program execution and prompt the user.
Error during intersection of two sets of bounds (empty intersection)
unsigned int nord() const
Get order of the TaylorModel.
void _set_bndpow(const unsigned int ix, const T &X, const double scaling)
Populate _bndpow[ix] w/ bounds on the terms .
#define BEGIN_NAMESPACE_ACADO
bool CENTER_REMAINDER
Flag indicating whether the remainder term is to be centered after each operation.
void reset()
Reset the TaylorModel.
Error due to an operation between TaylorVariable linked to different TaylorModel. ...
void _next_expmon(unsigned int *iexp, const unsigned int iord)
Generate exponent configuration for subsequent monomial terms.
bool INTER_WITH_BNDT
Flag indicating whether interval bound for the Taylor model and T arithmetic are to be intersected...
void _set_bndmon()
Populate _bndmon w/ bounds on all possible monomial terms.
unsigned int ** _prodmon
Variable exponents resulting from the product of two monomial terms 1,...,_nmon.
int BOUNDER_TYPE
Flag indicating the Taylor model range bounder.
void _size(const unsigned int nvar, const unsigned int nord)
Set the order (nord) and number of variables (nvar)
C++ class supporting the definition and computation of Taylor models for factorable functions...


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