taylor_model.hpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00034 #ifndef ACADO_TOOLKIT_TAYLOR_MODEL_HPP
00035 #define ACADO_TOOLKIT_TAYLOR_MODEL_HPP
00036 
00037 #include <acado/utils/acado_utils.hpp>
00038 
00039 
00040 BEGIN_NAMESPACE_ACADO
00041 
00042 template <typename T> class TaylorVariable;
00043 
00051 template <typename T>
00052 class TaylorModel
00054 {
00055 
00056 friend class TaylorVariable<T>;
00057 template <typename U> friend class TaylorModel;
00058 
00059 public:
00060 
00062   TaylorModel
00063     ( const unsigned int nvar_, const unsigned int nord_ )
00064     { _size( nvar_, nord_ ); }
00065 
00067   ~TaylorModel()
00068     { _cleanup(); }
00069 
00071   unsigned int nvar() const
00072     { return _nvar; };
00074   unsigned int nord() const
00075     { return _nord; };
00077   void reset()
00078     { _reset(); };
00079 
00081   class Exceptions
00082   {
00083   public:
00085     enum TYPE{
00086       DIV=1,    
00087       INTER,    
00088       EIGEN,    
00089       SCALING,  
00090       SIZE=-1,  
00091       INIT=-2,  
00092       INCON=-3, 
00093       TMODEL=-4,
00094       UNDEF=-33 
00095     };
00097     Exceptions( TYPE ierr_ ) : _ierr( ierr_ ){}
00099     int ierr(){ return _ierr; }
00100 
00101   private:
00102     TYPE _ierr;
00103   };
00104 
00106   struct Options
00107   {
00109     Options():
00110       BOUNDER_TYPE(LSB), PROPAGATE_BNDT(false), INTER_WITH_BNDT(false),
00111       SCALE_VARIABLES(true), CENTER_REMAINDER(true), REF_MIDPOINT(true)
00112       {}
00114     template <typename U> Options
00115       ( U&_options )
00116       : BOUNDER_TYPE( _options.BOUNDER_TYPE ),
00117         PROPAGATE_BNDT( _options.PROPAGATE_BNDT ),
00118         INTER_WITH_BNDT( _options.INTER_WITH_BNDT ),
00119         SCALE_VARIABLES( _options.SCALE_VARIABLES ),
00120         CENTER_REMAINDER( _options.CENTER_REMAINDER ),
00121         REF_MIDPOINT( _options.REF_MIDPOINT )
00122       {}
00123     template <typename U> Options& operator =
00124       ( U&_options ){
00125         BOUNDER_TYPE = _options.BOUNDER_TYPE;
00126         PROPAGATE_BNDT = _options.PROPAGATE_BNDT;
00127         INTER_WITH_BNDT = _options.INTER_WITH_BNDT;
00128         SCALE_VARIABLES = _options.SCALE_VARIABLES;
00129         CENTER_REMAINDER = _options.CENTER_REMAINDER;
00130         REF_MIDPOINT = _options.REF_MIDPOINT;
00131         return *this;
00132       }
00134     enum BOUNDER{
00135       NAIVE=0,  
00136       LSB,      
00137       EIGEN,    
00138       HYBRID    
00139     };
00141     int BOUNDER_TYPE;
00143     bool PROPAGATE_BNDT;
00145     bool INTER_WITH_BNDT;
00147     bool SCALE_VARIABLES;
00149     bool CENTER_REMAINDER;
00151     bool REF_MIDPOINT;
00152   } options;
00153   
00155   static void pause();
00156     
00157 private:  
00159   unsigned int _nord;
00161   unsigned int _nvar;
00163   unsigned int _nmon;
00165   unsigned int *_posord;
00167   unsigned int *_expmon;
00169   unsigned int **_prodmon;
00171   T *_bndmon;
00173   bool _modvar;
00175   unsigned int *_binom;
00177   T **_bndpow;
00179   double *_refpoint;
00181   double *_scaling; 
00182 
00184   TaylorVariable<T>* _TV;
00185 
00187   void _size
00188     ( const unsigned int nvar, const unsigned int nord );
00189 
00190 //   //! @brief Set the order (nord) and number of variables (nvar)
00191 //   template <typename U> void _copy_data
00192 //     ( const TaylorModel<U>&TM );
00193 
00195   void _set_bndpow
00196     ( const unsigned int ix, const T&X, const double scaling );
00197 
00199   void _set_bndmon();
00200 
00202   void _set_posord();
00203 
00205   void _set_expmon();
00206   
00208   void _next_expmon
00209     ( unsigned int *iexp, const unsigned int iord );
00210 
00212   void _set_prodmon();
00213     
00215   unsigned int _loc_expmon
00216     ( const unsigned int *iexp );
00217     
00219   void _set_binom();
00220 
00222   unsigned int _get_binom
00223     ( const unsigned int n, const unsigned int k ) const;
00224 
00226   void _reset();
00227 
00229   void _cleanup();
00230 
00232   template< typename U > static void _display
00233     ( const unsigned int m, const unsigned int n, U*&a, const unsigned int lda,
00234       const std::string&stra, std::ostream&os );
00235 };
00236 
00237 
00238 CLOSE_NAMESPACE_ACADO
00239 
00240 #include <acado/set_arithmetics/taylor_variable.hpp>
00241 #include <acado/set_arithmetics/taylor_model.ipp>
00242 #include <acado/set_arithmetics/taylor_variable.ipp>
00243 
00244 #endif  // ACADO_TOOLKIT_TAYLOR_MODEL_HPP
00245 


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:39:56