constraint.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_CONSTRAINT_HPP
00036 #define ACADO_TOOLKIT_CONSTRAINT_HPP
00037 
00038 #include <acado/constraint/box_constraint.hpp>
00039 #include <acado/constraint/boundary_constraint.hpp>
00040 #include <acado/constraint/coupled_path_constraint.hpp>
00041 #include <acado/constraint/path_constraint.hpp>
00042 #include <acado/constraint/algebraic_consistency_constraint.hpp>
00043 #include <acado/constraint/point_constraint.hpp>
00044 
00045 
00046 BEGIN_NAMESPACE_ACADO
00047 
00048 
00060 class Constraint : public BoxConstraint{
00061 
00062         friend class OptimizationAlgorithmBase;
00063         friend class OptimizationAlgorithm;
00064         friend class RealTimeAlgorithm;
00065         friend class TESTExport;
00066         friend class ExportNLPSolver;
00067 
00068     //
00069     // PUBLIC MEMBER FUNCTIONS:
00070     //
00071     public:
00072 
00074         Constraint( );
00075 
00077         Constraint( const Constraint& rhs );
00078 
00080         virtual ~Constraint( );
00081 
00083         Constraint& operator=( const Constraint& rhs );
00084 
00085 
00093         returnValue init( const Grid& grid_, const int& numberOfStages_ = 1 );
00094 
00095 
00096         // ===========================================================================
00097         //
00098         //                          CONTINOUS CONSTRAINTS
00099         //                       --------------------------
00100         //
00101         //
00102         //     (general form  lb(i) <= h( t,x(i),u(i),p,... ) <= ub(i)  for all i)
00103         //
00104         // ===========================================================================
00105 
00106 
00114         returnValue add( const double lb_, const Expression& arg, const double ub_  );
00115 
00116 
00124         returnValue add( const DVector lb_, const Expression& arg, const double ub_  );
00125 
00126 
00134         returnValue add( const double lb_, const Expression& arg, const DVector ub_  );
00135 
00136 
00144         returnValue add( const DVector lb_, const Expression& arg, const DVector ub_  );
00145 
00146 
00147         // ===========================================================================
00148         //
00149         //                           DISCRETE CONSTRAINTS
00150         //                       --------------------------
00151         //
00152         //
00153         //   (general form  lb(i) <= h( t,x(i),u(i),p,... ) <= ub(i)  for a given i)
00154         //
00155         // ===========================================================================
00156 
00157 
00165         returnValue add( const int index_, const double lb_, const Expression& arg, const double ub_  );
00166 
00167 
00168         // ===========================================================================
00169         //
00170         //                       COUPLED BOUNDARY CONSTRAINTS
00171         //                       ----------------------------
00172         //
00173         //
00174         //   (general form  lb <=   h_1( t_0,x(t_0),u(t_0),p,... )
00175         //                        + h_2( t_e,x(t_e),u(t_e),p,... ) <= ub(i)  )
00176         //
00177         //    where t_0 is the first and t_e the last time point in the grid.
00178         //
00179         // ===========================================================================
00180 
00188         returnValue add( const double lb_, const Expression& arg1,
00189                                 const Expression& arg2, const double ub_ );
00190 
00191 
00192 
00193         // ===========================================================================
00194         //
00195         //                         GENERAL COUPLED CONSTRAINTS
00196         //                       -------------------------------
00197         //
00198         //
00199         //   (general form  lb <= sum_i  h_i( t_i,x(t_i),u(t_i),p,... ) <= ub(i)  )
00200         //
00201         //
00202         // ===========================================================================
00203 
00211         returnValue add( const double lb_, const Expression *arguments, const double ub_ );
00212 
00213 
00214 
00215 
00216         // ===========================================================================
00217         //
00218         //                        ALGEBRAIC CONSISTENCY CONSTRAINTS
00219         //                       -----------------------------------
00220         //
00221         // ===========================================================================
00222 
00234         returnValue add( const uint&                 endOfStage_  ,  
00235                                 const DifferentialEquation& dae              );
00236 
00237 
00238 
00239 // =======================================================================================
00240 //
00241 //                                   LOADING ROUTINES
00242 //
00243 // =======================================================================================
00244 
00245 
00250         returnValue add( const ConstraintComponent& component );
00251 
00252 
00257         returnValue add( const int index_, const ConstraintComponent& component );
00258 
00259 
00260 
00261 
00262 // =======================================================================================
00263 //
00264 //                                  DEFINITION OF SEEDS:
00265 //
00266 // =======================================================================================
00267 
00268 
00274     virtual returnValue setForwardSeed( BlockMatrix *xSeed_ ,   
00275                                         BlockMatrix *xaSeed_,   
00276                                         BlockMatrix *pSeed_ ,   
00277                                         BlockMatrix *uSeed_ ,   
00278                                         BlockMatrix *wSeed_ ,   
00279                                         int          order       );
00280 
00281 
00288     virtual returnValue setUnitForwardSeed( );
00289 
00290 
00291 
00297     virtual returnValue setBackwardSeed( BlockMatrix *seed,    
00298                                          int          order      );
00299 
00300 
00301 
00308     virtual returnValue setUnitBackwardSeed( );
00309 
00310 
00311 
00312 // =======================================================================================
00313 //
00314 //                                   EVALUATION ROUTINES
00315 //
00316 // =======================================================================================
00317 
00318 
00319 
00320         returnValue evaluate( const OCPiterate& iter );
00321 
00322 
00323 
00324 
00325         returnValue evaluateSensitivities();
00326 
00327 
00334         returnValue evaluateSensitivities( const BlockMatrix &seed, BlockMatrix &hessian );
00335 
00336 
00337 
00338 
00339 // =======================================================================================
00340 //
00341 //                               RESULTS OF THE EVALUATION
00342 //
00343 // =======================================================================================
00344 
00345 
00350     virtual returnValue getConstraintResiduum( BlockMatrix &lowerRes, 
00351                                                BlockMatrix &upperRes   );
00352 
00353 
00358     virtual returnValue getBoundResiduum( BlockMatrix &lowerRes, 
00359                                           BlockMatrix &upperRes   );
00360 
00361 
00362 
00368     virtual returnValue getForwardSensitivities( BlockMatrix &D  ,
00371                                                  int order         );
00372 
00373 
00374 
00380     virtual returnValue getBackwardSensitivities( BlockMatrix &D  ,
00383                                                   int order         );
00384 
00385 
00386 
00387 
00388 
00389 //  =========================================================================
00390 //
00391 //                               MISCELLANEOUS:
00392 //
00393 //  =========================================================================
00394 
00396         inline Grid& getGrid();
00397 
00399         inline int getNC();
00400 
00404         inline int getNX    () const;
00405 
00409         inline int getNXA   () const;
00410 
00414         inline int getNP   () const;
00415 
00419         inline int getNU   () const;
00420 
00424         inline int getNW  () const;
00425 
00426 
00428         inline int getNumberOfBlocks() const;
00429 
00430 
00432         inline int getBlockDim( int idx ) const;
00433 
00435         inline DVector getBlockDims( ) const;
00436 
00437 
00438 
00440         inline BooleanType isAffine() const;
00441 
00443                 inline BooleanType isBoxConstraint() const;
00444 
00450         BooleanType isEmpty() const;
00451 
00452         returnValue getPathConstraints(Function& function_, DMatrix& lb_, DMatrix& ub_) const;
00453 
00454         returnValue getPointConstraint(const unsigned index, Function& function_, DMatrix& lb_, DMatrix& ub_) const;
00455 
00456     //
00457     // DATA MEMBERS:
00458     //
00459     protected:
00460 
00461 
00462         BoundaryConstraint              *boundary_constraint             ;
00463         CoupledPathConstraint           *coupled_path_constraint         ;
00464         PathConstraint                  *path_constraint                 ;
00465         AlgebraicConsistencyConstraint  *algebraic_consistency_constraint;
00466         PointConstraint                **point_constraints               ;
00467 
00468 
00469     // PROTECTED MEMBER FUNCTIONS:
00470     // ---------------------------
00471 
00472     protected:
00473 
00477         returnValue add( const int index_, const double lb_, Expression* arg, const double ub_  );
00478                 
00482         returnValue add( const DVector lb_, Expression* arg, const DVector ub_  );
00483 
00484 
00488         virtual returnValue getBounds( const OCPiterate& iter );
00489 
00491         void deleteAll();
00492 
00493 };
00494 
00495 
00496 CLOSE_NAMESPACE_ACADO
00497 
00498 
00499 
00500 #include <acado/constraint/constraint.ipp>
00501 
00502 
00503 #endif  // ACADO_TOOLKIT_CONSTRAINT_HPP
00504 
00505 /*
00506  *    end of file
00507  */


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