clipping_functionality.cpp
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 
35 
36 
37 
39 
40 
41 //
42 // PUBLIC MEMBER FUNCTIONS:
43 //
44 
45 
47 {
48 }
49 
50 
52  uint _nP
53  )
54 {
55  lowerLimitControls.init( _nU );
56  upperLimitControls.init( _nU );
59 
64 }
65 
66 
68 {
71 
74 }
75 
76 
78 {
79 }
80 
81 
83 {
84  if ( this != &rhs )
85  {
88 
91  }
92 
93  return *this;
94 }
95 
96 
97 
99  )
100 {
101  if ( _lowerLimit.getDim( ) != getNumControlLimits( ) )
103 
104  lowerLimitControls = _lowerLimit;
105 
106  return SUCCESSFUL_RETURN;
107 }
108 
109 
111  double _lowerLimit
112  )
113 {
114  if ( idx >= getNumControlLimits( ) )
116 
117  lowerLimitControls( idx ) = _lowerLimit;
118  return SUCCESSFUL_RETURN;
119 }
120 
121 
123  )
124 {
125  if ( _upperLimit.getDim( ) != getNumControlLimits( ) )
127 
128  upperLimitControls = _upperLimit;
129 
130  return SUCCESSFUL_RETURN;
131 }
132 
133 
135  double _upperLimit
136  )
137 {
138  if ( idx >= getNumControlLimits( ) )
140 
141  upperLimitControls( idx ) = _upperLimit;
142  return SUCCESSFUL_RETURN;
143 }
144 
145 
146 
148  )
149 {
150  if ( _lowerLimit.getDim( ) != getNumParameterLimits( ) )
152 
153  lowerLimitParameters = _lowerLimit;
154 
155  return SUCCESSFUL_RETURN;
156 }
157 
158 
160  double _lowerLimit
161  )
162 {
163  if ( idx >= getNumParameterLimits( ) )
165 
166  lowerLimitParameters( idx ) = _lowerLimit;
167  return SUCCESSFUL_RETURN;
168 }
169 
170 
172  )
173 {
174  if ( _upperLimit.getDim( ) != getNumParameterLimits( ) )
176 
177  upperLimitParameters = _upperLimit;
178 
179  return SUCCESSFUL_RETURN;
180 }
181 
182 
184  double _upperLimit
185  )
186 {
187  if ( idx >= getNumParameterLimits( ) )
189 
190  upperLimitParameters( idx ) = _upperLimit;
191  return SUCCESSFUL_RETURN;
192 }
193 
194 
195 
196 //
197 // PROTECTED MEMBER FUNCTIONS:
198 //
199 
200 
201 
203  VariablesGrid& _p
204  )
205 {
206  // consistency checks
207  if ( _u.getNumValues( ) != getNumControlLimits( ) )
209 
210  if ( _p.getNumValues( ) != getNumParameterLimits( ) )
212 
213 
214  // limit controls
215  for( uint i=0; i<getNumControlLimits( ); ++i )
216  {
217  for( uint j=0; j<_u.getNumPoints( ); ++j )
218  {
219  if ( _u( j,i ) < lowerLimitControls( i ) )
220  _u( j,i ) = lowerLimitControls( i );
221 
222  if ( _u( j,i ) > upperLimitControls( i ) )
223  _u( j,i ) = upperLimitControls( i );
224  }
225  }
226 
227 
228  // limit parameters
229  for( uint i=0; i<getNumParameterLimits( ); ++i )
230  {
231  for( uint j=0; j<_p.getNumPoints( ); ++j )
232  {
233  if ( _p( j,i ) < lowerLimitParameters( i ) )
234  _p( j,i ) = lowerLimitParameters( i );
235 
236  if ( _p( j,i ) > upperLimitParameters( i ) )
237  _p( j,i ) = upperLimitParameters( i );
238  }
239  }
240 
241  return SUCCESSFUL_RETURN;
242 }
243 
244 
246  DVector& _p
247  )
248 {
249  // consistency checks
250  if ( _u.getDim( ) != getNumControlLimits( ) )
252 
253  if ( _p.getDim( ) != getNumParameterLimits( ) )
255 
256 
257  // limit controls
258  for( uint i=0; i<getNumControlLimits( ); ++i )
259  {
260  if ( _u( i ) < lowerLimitControls( i ) )
261  _u( i ) = lowerLimitControls( i );
262 
263  if ( _u( i ) > upperLimitControls( i ) )
264  _u( i ) = upperLimitControls( i );
265  }
266 
267 
268  // limit parameters
269  for( uint i=0; i<getNumParameterLimits( ); ++i )
270  {
271  if ( _p( i ) < lowerLimitParameters( i ) )
272  _p( i ) = lowerLimitParameters( i );
273 
274  if ( _p( i ) > upperLimitParameters( i ) )
275  _p( i ) = upperLimitParameters( i );
276  }
277 
278  return SUCCESSFUL_RETURN;
279 }
280 
281 
283 
284 // end of file.
returnValue setParameterLowerLimit(uint idx, double _lowerLimit)
const double INFTY
uint getNumParameterLimits() const
void init(unsigned _dim=0)
Definition: vector.hpp:155
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to pass back messages to the calling function.
ClippingFunctionality & operator=(const ClippingFunctionality &rhs)
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
#define CLOSE_NAMESPACE_ACADO
returnValue setControlLowerLimit(uint idx, double _lowerLimit)
returnValue setParameterUpperLimits(const DVector &_upperLimit)
returnValue setParameterLowerLimits(const DVector &_lowerLimit)
returnValue setControlUpperLimits(const DVector &_upperLimit)
unsigned getDim() const
Definition: vector.hpp:172
returnValue setParameterUpperLimit(uint idx, double _upperLimit)
void rhs(const real_t *x, real_t *f)
uint getNumPoints() const
void setAll(const T &_value)
Definition: vector.hpp:160
Allows to transform the output of the ControlLaw before passing it to the Process.
#define BEGIN_NAMESPACE_ACADO
returnValue setControlUpperLimit(uint idx, double _upperLimit)
uint getNumControlLimits() const
returnValue clipSignals(VariablesGrid &_u, VariablesGrid &_p=emptyVariablesGrid)
returnValue setControlLowerLimits(const DVector &_lowerLimit)
#define ACADOERROR(retval)


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