constraint_component.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 
27 
38 
39 
41 
42 
43 
44 // --------------------------------------------------------------------------------------------
45 // --------------------------------------------------------------------------------------------
46 
47 
49 
50  ub.init(1);
51  lb.init(1);
52  ub.setAll(INFTY);
53  lb.setAll(-INFTY);
54 }
55 
57 
58  expression = arg.expression;
59  ub = arg.ub ;
60  lb = arg.lb ;
61  lbGrid = arg.lbGrid ;
62  ubGrid = arg.ubGrid ;
63 }
64 
65 
67 
68 }
69 
70 
72 
73  if( this != &arg ){
74 
75  expression = arg.expression;
76  ub = arg.ub ;
77  lb = arg.lb ;
78  lbGrid = arg.lbGrid ;
79  ubGrid = arg.ubGrid ;
80  }
81  return *this;
82 }
83 
84 
86 
87  expression = arg;
88  ub = ub_;
89  lb = lb_;
90 
91  return SUCCESSFUL_RETURN;
92 }
93 
94 
96 
97  expression = arg;
98  ubGrid = ub_;
99  lbGrid = lb_;
100 
101  return SUCCESSFUL_RETURN;
102 }
103 
104 
105 
106 
108 
109  ASSERT( index < getDim() );
110 
112 
113  tmp.expression = expression(index);
114 
115  if( lbGrid.isEmpty() == BT_TRUE ) tmp.lb(0) = lb (index);
116  else tmp.lbGrid = lbGrid(index);
117 
118  if( ubGrid.isEmpty() == BT_TRUE ) tmp.ub(0) = ub (index);
119  else tmp.ubGrid = ubGrid(index);
120 
121  return tmp;
122 }
123 
124 
125 
127 
128  ConstraintComponent tmp(arg);
129  tmp.setLB( lb_ );
130  return tmp;
131 }
132 
134 
135  ConstraintComponent tmp(arg);
136  tmp.setUB( ub_ );
137  return tmp;
138 }
139 
141 
142  ConstraintComponent tmp(arg);
143  tmp.setLB( lb_ );
144  return tmp;
145 }
146 
148 
149  ConstraintComponent tmp(arg);
150  tmp.setUB( ub_ );
151  return tmp;
152 }
153 
155 
156  ConstraintComponent tmp(arg);
157  tmp.setLB( lb_ );
158  return tmp;
159 }
160 
162 
163  ConstraintComponent tmp(arg);
164  tmp.setUB( ub_ );
165  return tmp;
166 }
167 
168 ConstraintComponent operator<=( const Expression& arg, const double& ub ) {
169 
170  DVector ub_(arg.getDim());
171  ub_.setAll(ub);
172 
173  return operator<=(arg, ub_);
174 }
175 
176 ConstraintComponent operator>=( const Expression& arg, const double& lb ) {
177 
178  DVector lb_(arg.getDim());
179  lb_.setAll(lb);
180 
181  return operator>=(arg, lb_);
182 }
183 
184 ConstraintComponent operator==( const Expression& arg, const double& b ) {
185 
186  DVector b_(arg.getDim());
187  b_.setAll(b);
188 
189  return operator==(arg, b_);
190 }
191 
192 
193 
195 
197 
198  DVector lb = ub;
199  lb.setAll(-INFTY);
200 
201  tmp.initialize( lb, arg, ub );
202 
203  return tmp;
204 }
205 
206 
208 
210 
211  DVector ub = lb;
212  ub.setAll(INFTY);
213 
214  tmp.initialize( lb, arg, ub );
215 
216  return tmp;
217 }
218 
219 
221 
223 
224  tmp.initialize( b, arg, b );
225  return tmp;
226 }
227 
228 
229 
231 
233 
234  VariablesGrid lb = ub;
235  lb.setAll(-INFTY);
236 
237  tmp.initialize( lb, arg, ub );
238 
239  return tmp;
240 }
241 
242 
244 
246 
247  VariablesGrid ub = lb;
248  ub.setAll(INFTY);
249 
250  tmp.initialize( lb, arg, ub );
251 
252  return tmp;
253 }
254 
255 
257 
259 
260  tmp.initialize( b, arg, b );
261  return tmp;
262 }
263 
264 
265 ConstraintComponent operator<=( double lb, const Expression &arg ){ return ( arg >= lb ); }
266 ConstraintComponent operator>=( double ub, const Expression &arg ){ return ( arg <= ub ); }
267 ConstraintComponent operator==( double b, const Expression &arg ){ return ( arg == b ); }
268 
269 ConstraintComponent operator<=( DVector lb, const Expression &arg ){ return ( arg >= lb ); }
270 ConstraintComponent operator>=( DVector ub, const Expression &arg ){ return ( arg <= ub ); }
271 ConstraintComponent operator==( DVector b, const Expression &arg ){ return ( arg == b ); }
272 
273 ConstraintComponent operator<=( VariablesGrid lb, const Expression &arg ){ return ( arg >= lb ); }
274 ConstraintComponent operator>=( VariablesGrid ub, const Expression &arg ){ return ( arg <= ub ); }
275 ConstraintComponent operator==( VariablesGrid b , const Expression &arg ){ return ( arg == b ); }
276 
277 
279 
280 // end of file.
returnValue initialize(const DVector &lb, Expression arg, const DVector &ub)
friend ConstraintComponent operator<=(double lb_, const ConstraintComponent &arg)
ConstraintComponent operator==(const double &b) const
const double INFTY
void init(unsigned _dim=0)
Definition: vector.hpp:155
friend ConstraintComponent operator>=(double ub_, const ConstraintComponent &arg)
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to pass back messages to the calling function.
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
BooleanType isEmpty() const
#define CLOSE_NAMESPACE_ACADO
Data class for symbolically formulating constraints within optimal control problems.
returnValue setAll(double _value)
Base class for all variables within the symbolic expressions family.
Definition: expression.hpp:56
ConstraintComponent & operator=(const ConstraintComponent &arg)
#define ASSERT(x)
returnValue setLB(const double &lb_)
#define BT_TRUE
Definition: acado_types.hpp:47
returnValue setUB(const double &lb_)
void setAll(const T &_value)
Definition: vector.hpp:160
ConstraintComponent operator()(const uint &index) const
uint getDim() const
#define BEGIN_NAMESPACE_ACADO
uint getDim() const


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