Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00037 #include <acado/symbolic_expression/constraint_component.hpp>
00038
00039
00040 BEGIN_NAMESPACE_ACADO
00041
00042
00043
00044
00045
00046
00047
00048 ConstraintComponent::ConstraintComponent(){
00049
00050 ub.init(1);
00051 lb.init(1);
00052 ub.setAll(INFTY);
00053 lb.setAll(-INFTY);
00054 }
00055
00056 ConstraintComponent::ConstraintComponent( const ConstraintComponent &arg ){
00057
00058 expression = arg.expression;
00059 ub = arg.ub ;
00060 lb = arg.lb ;
00061 lbGrid = arg.lbGrid ;
00062 ubGrid = arg.ubGrid ;
00063 }
00064
00065
00066 ConstraintComponent::~ConstraintComponent(){
00067
00068 }
00069
00070
00071 ConstraintComponent& ConstraintComponent::operator=( const ConstraintComponent &arg ){
00072
00073 if( this != &arg ){
00074
00075 expression = arg.expression;
00076 ub = arg.ub ;
00077 lb = arg.lb ;
00078 lbGrid = arg.lbGrid ;
00079 ubGrid = arg.ubGrid ;
00080 }
00081 return *this;
00082 }
00083
00084
00085 returnValue ConstraintComponent::initialize( const DVector& lb_, Expression arg, const DVector& ub_ ){
00086
00087 expression = arg;
00088 ub = ub_;
00089 lb = lb_;
00090
00091 return SUCCESSFUL_RETURN;
00092 }
00093
00094
00095 returnValue ConstraintComponent::initialize( const VariablesGrid& lb_, Expression arg, const VariablesGrid& ub_ ){
00096
00097 expression = arg;
00098 ubGrid = ub_;
00099 lbGrid = lb_;
00100
00101 return SUCCESSFUL_RETURN;
00102 }
00103
00104
00105
00106
00107 ConstraintComponent ConstraintComponent::operator()( const uint &index ) const{
00108
00109 ASSERT( index < getDim() );
00110
00111 ConstraintComponent tmp;
00112
00113 tmp.expression = expression(index);
00114
00115 if( lbGrid.isEmpty() == BT_TRUE ) tmp.lb(0) = lb (index);
00116 else tmp.lbGrid = lbGrid(index);
00117
00118 if( ubGrid.isEmpty() == BT_TRUE ) tmp.ub(0) = ub (index);
00119 else tmp.ubGrid = ubGrid(index);
00120
00121 return tmp;
00122 }
00123
00124
00125
00126 ConstraintComponent operator<=( double lb_, const ConstraintComponent &arg ){
00127
00128 ConstraintComponent tmp(arg);
00129 tmp.setLB( lb_ );
00130 return tmp;
00131 }
00132
00133 ConstraintComponent operator>=( double ub_, const ConstraintComponent &arg ){
00134
00135 ConstraintComponent tmp(arg);
00136 tmp.setUB( ub_ );
00137 return tmp;
00138 }
00139
00140 ConstraintComponent operator<=( DVector lb_, const ConstraintComponent &arg ){
00141
00142 ConstraintComponent tmp(arg);
00143 tmp.setLB( lb_ );
00144 return tmp;
00145 }
00146
00147 ConstraintComponent operator>=( DVector ub_, const ConstraintComponent &arg ){
00148
00149 ConstraintComponent tmp(arg);
00150 tmp.setUB( ub_ );
00151 return tmp;
00152 }
00153
00154 ConstraintComponent operator<=( VariablesGrid lb_, const ConstraintComponent &arg ){
00155
00156 ConstraintComponent tmp(arg);
00157 tmp.setLB( lb_ );
00158 return tmp;
00159 }
00160
00161 ConstraintComponent operator>=( VariablesGrid ub_, const ConstraintComponent &arg ){
00162
00163 ConstraintComponent tmp(arg);
00164 tmp.setUB( ub_ );
00165 return tmp;
00166 }
00167
00168 ConstraintComponent operator<=( const Expression& arg, const double& ub ) {
00169
00170 DVector ub_(arg.getDim());
00171 ub_.setAll(ub);
00172
00173 return operator<=(arg, ub_);
00174 }
00175
00176 ConstraintComponent operator>=( const Expression& arg, const double& lb ) {
00177
00178 DVector lb_(arg.getDim());
00179 lb_.setAll(lb);
00180
00181 return operator>=(arg, lb_);
00182 }
00183
00184 ConstraintComponent operator==( const Expression& arg, const double& b ) {
00185
00186 DVector b_(arg.getDim());
00187 b_.setAll(b);
00188
00189 return operator==(arg, b_);
00190 }
00191
00192
00193
00194 ConstraintComponent operator<=( const Expression& arg, const DVector& ub ) {
00195
00196 ConstraintComponent tmp;
00197
00198 DVector lb = ub;
00199 lb.setAll(-INFTY);
00200
00201 tmp.initialize( lb, arg, ub );
00202
00203 return tmp;
00204 }
00205
00206
00207 ConstraintComponent operator>=( const Expression& arg, const DVector& lb ) {
00208
00209 ConstraintComponent tmp;
00210
00211 DVector ub = lb;
00212 ub.setAll(INFTY);
00213
00214 tmp.initialize( lb, arg, ub );
00215
00216 return tmp;
00217 }
00218
00219
00220 ConstraintComponent operator==( const Expression& arg, const DVector& b ) {
00221
00222 ConstraintComponent tmp;
00223
00224 tmp.initialize( b, arg, b );
00225 return tmp;
00226 }
00227
00228
00229
00230 ConstraintComponent operator<=( const Expression& arg, const VariablesGrid& ub ) {
00231
00232 ConstraintComponent tmp;
00233
00234 VariablesGrid lb = ub;
00235 lb.setAll(-INFTY);
00236
00237 tmp.initialize( lb, arg, ub );
00238
00239 return tmp;
00240 }
00241
00242
00243 ConstraintComponent operator>=( const Expression& arg, const VariablesGrid& lb ) {
00244
00245 ConstraintComponent tmp;
00246
00247 VariablesGrid ub = lb;
00248 ub.setAll(INFTY);
00249
00250 tmp.initialize( lb, arg, ub );
00251
00252 return tmp;
00253 }
00254
00255
00256 ConstraintComponent operator==( const Expression& arg, const VariablesGrid& b ) {
00257
00258 ConstraintComponent tmp;
00259
00260 tmp.initialize( b, arg, b );
00261 return tmp;
00262 }
00263
00264
00265 ConstraintComponent operator<=( double lb, const Expression &arg ){ return ( arg >= lb ); }
00266 ConstraintComponent operator>=( double ub, const Expression &arg ){ return ( arg <= ub ); }
00267 ConstraintComponent operator==( double b, const Expression &arg ){ return ( arg == b ); }
00268
00269 ConstraintComponent operator<=( DVector lb, const Expression &arg ){ return ( arg >= lb ); }
00270 ConstraintComponent operator>=( DVector ub, const Expression &arg ){ return ( arg <= ub ); }
00271 ConstraintComponent operator==( DVector b, const Expression &arg ){ return ( arg == b ); }
00272
00273 ConstraintComponent operator<=( VariablesGrid lb, const Expression &arg ){ return ( arg >= lb ); }
00274 ConstraintComponent operator>=( VariablesGrid ub, const Expression &arg ){ return ( arg <= ub ); }
00275 ConstraintComponent operator==( VariablesGrid b , const Expression &arg ){ return ( arg == b ); }
00276
00277
00278 CLOSE_NAMESPACE_ACADO
00279
00280