constraint.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 
27 
35 #ifndef ACADO_TOOLKIT_CONSTRAINT_HPP
36 #define ACADO_TOOLKIT_CONSTRAINT_HPP
37 
44 
45 
47 
48 
60 class Constraint : public BoxConstraint{
61 
63  friend class OptimizationAlgorithm;
64  friend class RealTimeAlgorithm;
65  friend class TESTExport;
66  friend class ExportNLPSolver;
67 
68  //
69  // PUBLIC MEMBER FUNCTIONS:
70  //
71  public:
72 
74  Constraint( );
75 
77  Constraint( const Constraint& rhs );
78 
80  virtual ~Constraint( );
81 
84 
85 
93  returnValue init( const Grid& grid_, const int& numberOfStages_ = 1 );
94 
95 
96  // ===========================================================================
97  //
98  // CONTINOUS CONSTRAINTS
99  // --------------------------
100  //
101  //
102  // (general form lb(i) <= h( t,x(i),u(i),p,... ) <= ub(i) for all i)
103  //
104  // ===========================================================================
105 
106 
114  returnValue add( const double lb_, const Expression& arg, const double ub_ );
115 
116 
124  returnValue add( const DVector lb_, const Expression& arg, const double ub_ );
125 
126 
134  returnValue add( const double lb_, const Expression& arg, const DVector ub_ );
135 
136 
144  returnValue add( const DVector lb_, const Expression& arg, const DVector ub_ );
145 
146 
147  // ===========================================================================
148  //
149  // DISCRETE CONSTRAINTS
150  // --------------------------
151  //
152  //
153  // (general form lb(i) <= h( t,x(i),u(i),p,... ) <= ub(i) for a given i)
154  //
155  // ===========================================================================
156 
157 
165  returnValue add( const int index_, const double lb_, const Expression& arg, const double ub_ );
166 
167 
168  // ===========================================================================
169  //
170  // COUPLED BOUNDARY CONSTRAINTS
171  // ----------------------------
172  //
173  //
174  // (general form lb <= h_1( t_0,x(t_0),u(t_0),p,... )
175  // + h_2( t_e,x(t_e),u(t_e),p,... ) <= ub(i) )
176  //
177  // where t_0 is the first and t_e the last time point in the grid.
178  //
179  // ===========================================================================
180 
188  returnValue add( const double lb_, const Expression& arg1,
189  const Expression& arg2, const double ub_ );
190 
191 
192 
193  // ===========================================================================
194  //
195  // GENERAL COUPLED CONSTRAINTS
196  // -------------------------------
197  //
198  //
199  // (general form lb <= sum_i h_i( t_i,x(t_i),u(t_i),p,... ) <= ub(i) )
200  //
201  //
202  // ===========================================================================
203 
211  returnValue add( const double lb_, const Expression *arguments, const double ub_ );
212 
213 
214 
215 
216  // ===========================================================================
217  //
218  // ALGEBRAIC CONSISTENCY CONSTRAINTS
219  // -----------------------------------
220  //
221  // ===========================================================================
222 
234  returnValue add( const uint& endOfStage_ ,
235  const DifferentialEquation& dae );
236 
237 
238 
239 // =======================================================================================
240 //
241 // LOADING ROUTINES
242 //
243 // =======================================================================================
244 
245 
250  returnValue add( const ConstraintComponent& component );
251 
252 
257  returnValue add( const int index_, const ConstraintComponent& component );
258 
259 
260 
261 
262 // =======================================================================================
263 //
264 // DEFINITION OF SEEDS:
265 //
266 // =======================================================================================
267 
268 
274  virtual returnValue setForwardSeed( BlockMatrix *xSeed_ ,
275  BlockMatrix *xaSeed_,
276  BlockMatrix *pSeed_ ,
277  BlockMatrix *uSeed_ ,
278  BlockMatrix *wSeed_ ,
279  int order );
280 
281 
288  virtual returnValue setUnitForwardSeed( );
289 
290 
291 
297  virtual returnValue setBackwardSeed( BlockMatrix *seed,
298  int order );
299 
300 
301 
308  virtual returnValue setUnitBackwardSeed( );
309 
310 
311 
312 // =======================================================================================
313 //
314 // EVALUATION ROUTINES
315 //
316 // =======================================================================================
317 
318 
319 
320  returnValue evaluate( const OCPiterate& iter );
321 
322 
323 
324 
326 
327 
334  returnValue evaluateSensitivities( const BlockMatrix &seed, BlockMatrix &hessian );
335 
336 
337 
338 
339 // =======================================================================================
340 //
341 // RESULTS OF THE EVALUATION
342 //
343 // =======================================================================================
344 
345 
350  virtual returnValue getConstraintResiduum( BlockMatrix &lowerRes,
351  BlockMatrix &upperRes );
352 
353 
358  virtual returnValue getBoundResiduum( BlockMatrix &lowerRes,
359  BlockMatrix &upperRes );
360 
361 
362 
371  int order );
372 
373 
374 
383  int order );
384 
385 
386 
387 
388 
389 // =========================================================================
390 //
391 // MISCELLANEOUS:
392 //
393 // =========================================================================
394 
396  inline Grid& getGrid();
397 
399  inline int getNC();
400 
404  inline int getNX () const;
405 
409  inline int getNXA () const;
410 
414  inline int getNP () const;
415 
419  inline int getNU () const;
420 
424  inline int getNW () const;
425 
426 
428  inline int getNumberOfBlocks() const;
429 
430 
432  inline int getBlockDim( int idx ) const;
433 
435  inline DVector getBlockDims( ) const;
436 
437 
438 
440  inline BooleanType isAffine() const;
441 
443  inline BooleanType isBoxConstraint() const;
444 
450  BooleanType isEmpty() const;
451 
452  returnValue getPathConstraints(Function& function_, DMatrix& lb_, DMatrix& ub_) const;
453 
454  returnValue getPointConstraint(const unsigned index, Function& function_, DMatrix& lb_, DMatrix& ub_) const;
455 
456  //
457  // DATA MEMBERS:
458  //
459  protected:
460 
461 
467 
468 
469  // PROTECTED MEMBER FUNCTIONS:
470  // ---------------------------
471 
472  protected:
473 
477  returnValue add( const int index_, const double lb_, Expression* arg, const double ub_ );
478 
482  returnValue add( const DVector lb_, Expression* arg, const DVector ub_ );
483 
484 
488  virtual returnValue getBounds( const OCPiterate& iter );
489 
491  void deleteAll();
492 
493 };
494 
495 
497 
498 
499 
500 #include <acado/constraint/constraint.ipp>
501 
502 
503 #endif // ACADO_TOOLKIT_CONSTRAINT_HPP
504 
505 /*
506  * end of file
507  */
Data class for storing generic optimization variables.
Definition: ocp_iterate.hpp:57
Implements a very rudimentary block sparse matrix class.
Allows to setup and evaluate a general function based on SymbolicExpressions.
Definition: function_.hpp:59
returnValue getPathConstraints(Function &function_, DMatrix &lb_, DMatrix &ub_) const
virtual returnValue setUnitForwardSeed()
Definition: constraint.cpp:662
virtual returnValue setBackwardSeed(BlockMatrix *seed, int order)
Definition: constraint.cpp:719
User-interface to formulate and solve optimal control problems and static NLPs.
returnValue getPointConstraint(const unsigned index, Function &function_, DMatrix &lb_, DMatrix &ub_) const
Stores and evaluates the constraints of optimal control problems.
Definition: constraint.hpp:60
BoundaryConstraint * boundary_constraint
Definition: constraint.hpp:462
int getNumberOfBlocks() const
Allows to pass back messages to the calling function.
virtual returnValue setUnitBackwardSeed()
Definition: constraint.cpp:725
Stores and evaluates box constraints within optimal control problems.
int getNX() const
BooleanType isAffine() const
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
Allows to conveniently handle (one-dimensional) grids consisting of time points.
Definition: grid.hpp:58
User-interface to formulate and solve model predictive control problems.
Stores and evaluates boundary constraints within optimal control problems.
Stores and evaluates pointwise constraints within optimal control problems.
int getNP() const
#define CLOSE_NAMESPACE_ACADO
int getNW() const
Base class for user-interfaces to formulate and solve optimal control problems and static NLPs...
Stores and evaluates path constraints within optimal control problems.
virtual returnValue setForwardSeed(BlockMatrix *xSeed_, BlockMatrix *xaSeed_, BlockMatrix *pSeed_, BlockMatrix *uSeed_, BlockMatrix *wSeed_, int order)
Definition: constraint.cpp:599
Data class for symbolically formulating constraints within optimal control problems.
virtual returnValue getBoundResiduum(BlockMatrix &lowerRes, BlockMatrix &upperRes)
Definition: constraint.cpp:910
Base class for export of NLP/OCP solvers.
virtual returnValue getBounds(const OCPiterate &iter)
returnValue add(const double lb_, const Expression &arg, const double ub_)
Definition: constraint.cpp:194
Base class for all variables within the symbolic expressions family.
Definition: expression.hpp:56
Deals with algebraic consistency constraints within optimal control problems.
friend class TESTExport
Definition: constraint.hpp:65
int getNU() const
BooleanType isBoxConstraint() const
PathConstraint * path_constraint
Definition: constraint.hpp:464
returnValue evaluate(const OCPiterate &iter)
Definition: constraint.cpp:399
virtual returnValue getForwardSensitivities(BlockMatrix &D, int order)
Definition: constraint.cpp:941
AlgebraicConsistencyConstraint * algebraic_consistency_constraint
Definition: constraint.hpp:465
Constraint & operator=(const Constraint &rhs)
Definition: constraint.cpp:151
Stores and evaluates coupled path constraints within optimal control problems.
BooleanType isEmpty() const
void rhs(const real_t *x, real_t *f)
int getBlockDim(int idx) const
returnValue evaluateSensitivities()
Definition: constraint.cpp:475
Grid & getGrid()
#define BEGIN_NAMESPACE_ACADO
virtual ~Constraint()
Definition: constraint.cpp:95
PointConstraint ** point_constraints
Definition: constraint.hpp:466
CoupledPathConstraint * coupled_path_constraint
Definition: constraint.hpp:463
virtual returnValue getConstraintResiduum(BlockMatrix &lowerRes, BlockMatrix &upperRes)
Definition: constraint.cpp:797
returnValue init(const Grid &grid_, const int &numberOfStages_=1)
Definition: constraint.cpp:129
DVector getBlockDims() const
int getNXA() const
void deleteAll()
Definition: constraint.cpp:101
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
virtual returnValue getBackwardSensitivities(BlockMatrix &D, int order)


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