unary_operator.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 
00027 
00035 #ifndef ACADO_TOOLKIT_UNARY_OPERATOR_HPP
00036 #define ACADO_TOOLKIT_UNARY_OPERATOR_HPP
00037 
00038 
00039 #include <acado/symbolic_operator/symbolic_operator_fwd.hpp>
00040 
00041 
00042 BEGIN_NAMESPACE_ACADO
00043 
00044 
00056 class UnaryOperator : public SmoothOperator{
00057 
00058 public:
00059 
00061     UnaryOperator();
00062 
00064     UnaryOperator( Operator *_argument );
00065 
00067     UnaryOperator( const UnaryOperator &arg );
00068 
00070     virtual ~UnaryOperator();
00071 
00073     UnaryOperator& operator=( const UnaryOperator &arg );
00074 
00075 
00082     virtual returnValue evaluate( int     number    ,
00083                                   double *x         ,
00084                                   double *result      );
00085 
00086 
00088     virtual returnValue evaluate( EvaluationBase *x ) = 0;
00089         
00090         
00096     Operator* differentiate( int index   );
00097 
00098 
00104     virtual Operator* AD_forward( int                dim      , 
00105                                   VariableType      *varType  , 
00106                                   int               *component, 
00107                                   Operator         **seed     , 
00108                                   int                &nNewIS  , 
00109                                   TreeProjection  ***newIS       );
00110 
00111 
00117     virtual returnValue AD_backward( int           dim      , 
00118                                      VariableType *varType  , 
00119                                      int          *component, 
00120                                      Operator     *seed     , 
00121                                      Operator    **df       , 
00122                                      int           &nNewIS  , 
00123                                      TreeProjection ***newIS   );
00124 
00125     
00126     
00132      virtual returnValue AD_symmetric( int            dim       , 
00133                                       VariableType  *varType   , 
00134                                       int           *component , 
00135                                       Operator      *l         , 
00136                                       Operator     **S         , 
00137                                       int            dimS      , 
00138                                       Operator     **dfS       , 
00139                                       Operator     **ldf       , 
00140                                       Operator     **H         , 
00141                                       int            &nNewLIS  , 
00142                                       TreeProjection ***newLIS , 
00143                                       int            &nNewSIS  , 
00144                                       TreeProjection ***newSIS , 
00145                                       int            &nNewHIS  , 
00146                                       TreeProjection ***newHIS    );
00147        
00148 
00153     virtual Operator* substitute( int index           ,
00154                                   const Operator *sub   ) = 0;
00155 
00156 
00157 
00164     virtual NeutralElement isOneOrZero() const;
00165 
00166 
00167 
00173     virtual BooleanType isDependingOn( VariableType var ) const;
00174 
00175 
00181     virtual BooleanType isDependingOn( int           dim      ,    
00182                                        VariableType *varType  ,    
00183                                        int          *component,    
00184                                        BooleanType   *implicit_dep  );
00185 
00186 
00194     virtual BooleanType isLinearIn( int           dim      ,    
00195                                     VariableType *varType  ,    
00196                                     int          *component,    
00197                                     BooleanType  *implicit_dep   );
00198 
00199 
00205     virtual BooleanType isPolynomialIn( int           dim      ,    
00206                                         VariableType *varType  ,    
00207                                         int          *component,    
00208                                         BooleanType  *implicit_dep   );
00209 
00210 
00216     virtual BooleanType isRationalIn( int           dim      ,    
00217                                       VariableType *varType  ,    
00218                                       int          *component,    
00219                                       BooleanType  *implicit_dep   );
00220 
00221 
00227     virtual MonotonicityType getMonotonicity( );
00228 
00229 
00236     virtual CurvatureType getCurvature( );
00237 
00238 
00244     virtual returnValue setMonotonicity( MonotonicityType monotonicity_ );
00245 
00246 
00252     virtual returnValue setCurvature( CurvatureType curvature_  );
00253 
00254 
00261     virtual returnValue AD_forward( int     number  ,
00262                                     double *seed    ,
00263                                     double *df        );
00264 
00265 
00273     virtual returnValue AD_forward( int     number  ,
00274                                     double *x       ,
00275                                     double *seed    ,
00276                                     double *f       ,
00277                                     double *df        );
00278 
00279 
00285     virtual returnValue AD_backward( int    number ,
00286                                      double seed   ,
00287                                      double  *df    );
00288 
00289 
00297     virtual returnValue AD_forward2( int    number  ,
00298                                      double *seed1  ,
00299                                      double *seed2  ,
00300                                      double *df     ,
00301                                      double *ddf    );
00302 
00303 
00309     virtual returnValue AD_backward2( int    number ,
00310                                       double seed1  ,
00311                                       double seed2  ,
00312                                       double   *df  ,
00313                                       double  *ddf    );
00314 
00315 
00316 
00320      virtual std::ostream& print( std::ostream &stream ) const;
00321 
00322 
00326     virtual Operator* clone() const = 0;
00327 
00328 
00333     virtual returnValue clearBuffer();
00334 
00335 
00336 
00341     virtual returnValue enumerateVariables( SymbolicIndexList *indexList );
00342 
00343 
00344 
00348     virtual OperatorName getName();
00349 
00350 
00354     virtual BooleanType isVariable( VariableType &varType,
00355                                     int          &component ) const;
00356 
00357 
00376     virtual returnValue loadIndices( SymbolicIndexList *indexList );
00377 
00378 
00384     virtual BooleanType isSymbolic() const;
00385 
00386 
00387 //
00388 //  PROTECTED FUNCTIONS:
00389 //
00390 
00391 protected:
00392 
00393 
00399      Operator* ADforwardProtected( int                dim      , 
00400                                              VariableType      *varType  , 
00401                                              int               *component, 
00402                                              Operator       **seed     , 
00403                                              int                &nNewIS  , 
00404                                              TreeProjection ***newIS     );
00405 
00406 
00407 
00413      returnValue ADbackwardProtected( int            dim      , 
00414                                               VariableType  *varType  , 
00415                                               int           *component, 
00416                                               Operator      *seed     , 
00417                                               Operator     **df       , 
00418                                               int            &nNewIS  , 
00419                                               TreeProjection ***newIS     );
00420 
00421 
00427      returnValue ADsymmetricProtected( int            dim       , 
00428                                                VariableType  *varType   , 
00429                                                int           *component , 
00430                                                Operator      *l         , 
00431                                                Operator     **S         , 
00432                                                int            dimS      , 
00433                                                Operator     **dfS       , 
00434                                                Operator     **ldf       , 
00435                                                Operator     **H         , 
00436                                                int            &nNewLIS  , 
00437                                                TreeProjection ***newLIS , 
00438                                                int            &nNewSIS  , 
00439                                                TreeProjection ***newSIS , 
00440                                                int            &nNewHIS  , 
00441                                                TreeProjection ***newHIS    );
00442 
00443 
00444                                               
00448      virtual returnValue setVariableExportName( const VariableType &_type,
00449                                                                                         const std::vector< std::string >& _name
00450                                                                                         );
00451 
00452 
00453   //  PROTECTED MEMBERS:
00454   // -------------------------
00455   protected:
00456 
00457     Operator  *derivative;              
00458     Operator  *derivative2;             
00460     Operator *argument        ;     
00461     Operator *dargument       ;     
00462     double   *argument_result ;     
00463     double   *dargument_result;     
00464     int       bufferSize      ;     
00466     CurvatureType     curvature   ;
00467     MonotonicityType  monotonicity;
00468     OperatorName      operatorName;
00469     std::string       cName       ;
00470 
00471     double (*fcn)(double);
00472     double (*dfcn)(double);
00473     double (*ddfcn)(double);
00474 };
00475 
00476 
00477 CLOSE_NAMESPACE_ACADO
00478 
00479 
00480 
00481 #endif


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 12:01:27