nonsmooth_operator.cpp
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 #include <acado/utils/acado_utils.hpp>
00036 #include <acado/symbolic_operator/symbolic_operator.hpp>
00037 #include <acado/symbolic_expression/symbolic_expression.hpp>
00038 #include <acado/symbolic_expression/constraint_component.hpp>
00039 
00040 
00041 BEGIN_NAMESPACE_ACADO
00042 
00043 
00044 NonsmoothOperator::NonsmoothOperator() : Operator( )
00045 {
00046 }
00047 
00048 NonsmoothOperator::~NonsmoothOperator()
00049 {
00050 }
00051 
00052 
00053 Operator& NonsmoothOperator::operator=( const double &arg ){
00054 
00055     ACADOERROR( RET_UNKNOWN_BUG );
00056     ASSERT( 1 == 0 );
00057     return emptyTreeProjection;
00058 }
00059 
00060 Operator& NonsmoothOperator::operator=( const DVector &arg ){
00061 
00062     ACADOERROR( RET_UNKNOWN_BUG );
00063     ASSERT( 1 == 0 );
00064     return emptyTreeProjection;
00065 }
00066 
00067 Operator& NonsmoothOperator::operator=( const DMatrix &arg ){
00068 
00069     ACADOERROR( RET_UNKNOWN_BUG );
00070     ASSERT( 1 == 0 );
00071     return emptyTreeProjection;
00072 }
00073 
00074 Operator& NonsmoothOperator::operator=( const Expression &arg ){
00075 
00076     ACADOERROR( RET_UNKNOWN_BUG );
00077     ASSERT( 1 == 0 );
00078     return emptyTreeProjection;
00079 }
00080 
00081 Operator& NonsmoothOperator::operator=( const Operator &arg ){
00082 
00083     ACADOERROR( RET_UNKNOWN_BUG );
00084     ASSERT( 1 == 0 );
00085     return emptyTreeProjection;
00086 }
00087 
00088 
00089 TreeProjection* NonsmoothOperator::cloneTreeProjection() const{
00090 
00091     // if this routine is ever called something went
00092     // really wrong ....
00093 
00094     ACADOERROR( RET_UNKNOWN_BUG );
00095     ASSERT( 1 == 0 );
00096     return new TreeProjection();
00097 }
00098 
00099 
00100 Operator& NonsmoothOperator::operator+=( const double    & arg ){ return operator=( this->operator+(arg) ); }
00101 Operator& NonsmoothOperator::operator+=( const DVector    & arg ){ return operator=( this->operator+(arg) ); }
00102 Operator& NonsmoothOperator::operator+=( const DMatrix    & arg ){ return operator=( this->operator+(arg) ); }
00103 Operator& NonsmoothOperator::operator+=( const Expression& arg ){ return operator=( this->operator+(arg) ); }
00104 
00105 Operator& NonsmoothOperator::operator-=( const double      & arg ){ return operator=( this->operator-(arg) ); }
00106 Operator& NonsmoothOperator::operator-=( const DVector      & arg ){ return operator=( this->operator-(arg) ); }
00107 Operator& NonsmoothOperator::operator-=( const DMatrix      & arg ){ return operator=( this->operator-(arg) ); }
00108 Operator& NonsmoothOperator::operator-=( const Expression  & arg ){ return operator=( this->operator-(arg) ); }
00109 
00110 Operator& NonsmoothOperator::operator*=( const double      & arg ){ return operator=( this->operator*(arg) ); }
00111 Operator& NonsmoothOperator::operator*=( const DVector      & arg ){ return operator=( this->operator*(arg) ); }
00112 Operator& NonsmoothOperator::operator*=( const DMatrix      & arg ){ return operator=( this->operator*(arg) ); }
00113 Operator& NonsmoothOperator::operator*=( const Expression  & arg ){ return operator=( this->operator*(arg) ); }
00114 
00115 Operator& NonsmoothOperator::operator/=( const double      & arg ){ return operator=( this->operator/(arg) ); }
00116 Operator& NonsmoothOperator::operator/=( const Expression  & arg ){ return operator=( this->operator/(arg) ); }
00117 
00118 
00119 
00120 
00121 Expression NonsmoothOperator::operator+( const double        & arg ) const{ return Expression(*this)+arg; }
00122 Expression NonsmoothOperator::operator+( const DVector        & arg ) const{ return Expression(*this)+arg; }
00123 Expression NonsmoothOperator::operator+( const DMatrix        & arg ) const{ return Expression(*this)+arg; }
00124 Expression NonsmoothOperator::operator+( const Operator& arg ) const{ return Expression(*this)+arg; }
00125 Expression NonsmoothOperator::operator+( const Expression    & arg ) const{ return Expression(*this)+arg; }
00126 
00127 Expression NonsmoothOperator::operator-( const double        & arg ) const{ return Expression(*this)-arg; }
00128 Expression NonsmoothOperator::operator-( const DVector        & arg ) const{ return Expression(*this)-arg; }
00129 Expression NonsmoothOperator::operator-( const DMatrix        & arg ) const{ return Expression(*this)-arg; }
00130 Expression NonsmoothOperator::operator-( const Operator& arg ) const{ return Expression(*this)-arg; }
00131 Expression NonsmoothOperator::operator-( const Expression    & arg ) const{ return Expression(*this)-arg; }
00132 
00133 Expression NonsmoothOperator::operator-( ) const{ return -Expression(*this); }
00134 
00135 Expression NonsmoothOperator::operator*( const double        & arg ) const{ return Expression(*this)*arg; }
00136 Expression NonsmoothOperator::operator*( const DVector        & arg ) const{ return Expression(*this)*arg; }
00137 Expression NonsmoothOperator::operator*( const DMatrix        & arg ) const{ return Expression(*this)*arg; }
00138 
00139 
00140 Expression NonsmoothOperator::operator*( const Operator& arg ) const{
00141 
00142     Expression tmp2(arg);
00143 
00144 
00145     Expression tmp1(*this);
00146 
00147 
00148     return tmp1*tmp2;
00149 }
00150 
00151 
00152 Expression NonsmoothOperator::operator*( const Expression    & arg ) const{ return Expression(*this)*arg; }
00153 
00154 Expression NonsmoothOperator::operator/( const double        & arg ) const{ return Expression(*this)/arg; }
00155 Expression NonsmoothOperator::operator/( const Operator& arg ) const{ return Expression(*this)/arg; }
00156 Expression NonsmoothOperator::operator/( const Expression    & arg ) const{ return Expression(*this)/arg; }
00157 
00158 
00159 ConstraintComponent NonsmoothOperator::operator<=( const double& ub ) const{ return Expression(*this) <= ub; }
00160 ConstraintComponent NonsmoothOperator::operator>=( const double& lb ) const{ return Expression(*this) >= lb; }
00161 ConstraintComponent NonsmoothOperator::operator==( const double&  b ) const{ return Expression(*this) ==  b; }
00162 
00163 ConstraintComponent NonsmoothOperator::operator<=( const DVector& ub ) const{ return Expression(*this) <= ub; }
00164 ConstraintComponent NonsmoothOperator::operator>=( const DVector& lb ) const{ return Expression(*this) >= lb; }
00165 ConstraintComponent NonsmoothOperator::operator==( const DVector&  b ) const{ return Expression(*this) ==  b; }
00166 
00167 ConstraintComponent NonsmoothOperator::operator<=( const VariablesGrid& ub ) const{ return Expression(*this) <= ub; }
00168 ConstraintComponent NonsmoothOperator::operator>=( const VariablesGrid& lb ) const{ return Expression(*this) >= lb; }
00169 ConstraintComponent NonsmoothOperator::operator==( const VariablesGrid&  b ) const{ return Expression(*this) ==  b; }
00170 
00171 
00172 
00173 
00174 returnValue NonsmoothOperator::evaluate( int number, double *x, double *result ){
00175 
00176     //result[0] = value;
00177     return SUCCESSFUL_RETURN;
00178 }
00179 
00180 
00181 returnValue NonsmoothOperator::evaluate( EvaluationBase *x ){
00182 
00183     return SUCCESSFUL_RETURN;
00184 }
00185 
00186 
00187 
00188 Operator* NonsmoothOperator::differentiate( int index ){
00189 
00190   return new NonsmoothOperator();
00191 }
00192 
00193 
00194 Operator* NonsmoothOperator::AD_forward( int dim,
00195                                         VariableType *varType,
00196                                         int *component,
00197                                         Operator **seed,
00198                                         int &nNewIS,
00199                                         TreeProjection ***newIS ){
00200 
00201     return new NonsmoothOperator();
00202 }
00203 
00204 
00205 
00206 returnValue NonsmoothOperator::AD_backward( int           dim      , 
00207                                         VariableType *varType  , 
00208                                         int          *component, 
00209                                         Operator     *seed     , 
00210                                         Operator    **df       , 
00211                                         int           &nNewIS  , 
00212                                         TreeProjection ***newIS   ){
00213 
00214     delete seed;
00215     return SUCCESSFUL_RETURN;
00216 }
00217 
00218 
00219 
00220 returnValue NonsmoothOperator::AD_symmetric( int            dim       , 
00221                                         VariableType  *varType   , 
00222                                         int           *component , 
00223                                         Operator      *l         , 
00224                                         Operator     **S         , 
00225                                         int            dimS      , 
00226                                         Operator     **dfS       , 
00227                                         Operator     **ldf       , 
00228                                         Operator     **H         , 
00229                                       int            &nNewLIS  , 
00230                                       TreeProjection ***newLIS , 
00231                                       int            &nNewSIS  , 
00232                                       TreeProjection ***newSIS , 
00233                                       int            &nNewHIS  , 
00234                                       TreeProjection ***newHIS    ){
00235 
00236     delete l;
00237     return SUCCESSFUL_RETURN; 
00238 }
00239 
00240 
00241 
00242 Operator* NonsmoothOperator::substitute( int index, const Operator *sub ){
00243 
00244     return clone();
00245 }
00246 
00247 
00248 
00249 NeutralElement NonsmoothOperator::isOneOrZero() const{
00250 
00251     return NE_NEITHER_ONE_NOR_ZERO;
00252 }
00253 
00254 
00255 BooleanType NonsmoothOperator::isDependingOn( VariableType var ) const{
00256 
00257     return BT_FALSE;
00258 }
00259 
00260 
00261 BooleanType NonsmoothOperator::isDependingOn( int dim,
00262                                              VariableType *varType,
00263                                              int *component,
00264                                              BooleanType   *implicit_dep ){
00265 
00266     return BT_FALSE;
00267 }
00268 
00269 
00270 BooleanType NonsmoothOperator::isLinearIn( int dim,
00271                                           VariableType *varType,
00272                                           int *component,
00273                                           BooleanType   *implicit_dep ){
00274 
00275     return BT_TRUE;
00276 }
00277 
00278 
00279 BooleanType NonsmoothOperator::isPolynomialIn( int dim,
00280                                               VariableType *varType,
00281                                               int *component,
00282                                               BooleanType   *implicit_dep ){
00283 
00284     return BT_TRUE;
00285 }
00286 
00287 
00288 BooleanType NonsmoothOperator::isRationalIn( int dim,
00289                                             VariableType *varType,
00290                                             int *component,
00291                                             BooleanType   *implicit_dep ){
00292 
00293     return BT_TRUE;
00294 }
00295 
00296 
00297 BooleanType NonsmoothOperator::isSmooth( ) const
00298 {
00299     return BT_FALSE;
00300 }
00301 
00302 
00303 MonotonicityType NonsmoothOperator::getMonotonicity( ){
00304 
00305     return MT_CONSTANT;
00306 }
00307 
00308 
00309 CurvatureType NonsmoothOperator::getCurvature( ){
00310 
00311     return CT_CONSTANT;
00312 }
00313 
00314 
00315 returnValue NonsmoothOperator::setMonotonicity( MonotonicityType monotonicity_ ){
00316 
00317     return SUCCESSFUL_RETURN;
00318 }
00319 
00320 
00321 returnValue NonsmoothOperator::setCurvature( CurvatureType curvature_ ){
00322 
00323     return SUCCESSFUL_RETURN;
00324 }
00325 
00326 
00327 returnValue NonsmoothOperator::AD_forward( int number, double *x, double *seed,
00328                                         double *f, double *df ){
00329 
00330       f[0] =  0.0;//value;
00331      df[0] =  0.0;
00332 
00333      return SUCCESSFUL_RETURN;
00334 }
00335 
00336 
00337 
00338 returnValue NonsmoothOperator::AD_forward( int number, double *seed, double *df ){
00339 
00340      df[0] =  0.0;
00341      return SUCCESSFUL_RETURN;
00342 }
00343 
00344 
00345 returnValue NonsmoothOperator::AD_backward( int number, double seed, double *df ){
00346 
00347      return SUCCESSFUL_RETURN;
00348 }
00349 
00350 
00351 returnValue NonsmoothOperator::AD_forward2( int number, double *seed, double *dseed,
00352                                          double *df, double *ddf ){
00353 
00354      df[0] = 0.0;
00355     ddf[0] = 0.0;
00356 
00357     return SUCCESSFUL_RETURN;
00358 }
00359 
00360 
00361 returnValue NonsmoothOperator::AD_backward2( int number, double seed1, double seed2,
00362                                           double *df, double *ddf ){
00363 
00364     return SUCCESSFUL_RETURN;
00365 }
00366 
00367 
00368 std::ostream& NonsmoothOperator::print( std::ostream &stream ) const
00369 {
00370     return stream; // << value;
00371 }
00372 
00373 
00374 Operator* NonsmoothOperator::clone() const{
00375 
00376     return new NonsmoothOperator(*this);
00377 }
00378 
00379 
00380 returnValue NonsmoothOperator::clearBuffer(){
00381 
00382     return SUCCESSFUL_RETURN;
00383 }
00384 
00385 
00386 returnValue NonsmoothOperator::enumerateVariables( SymbolicIndexList *indexList ){
00387 
00388     return SUCCESSFUL_RETURN;
00389 }
00390 
00391 //
00392 // PROTECTED MEMBER FUNCTIONS:
00393 // ---------------------------
00394 
00395 OperatorName NonsmoothOperator::getName(){
00396 
00397     return ON_DOUBLE_CONSTANT;
00398 }
00399 
00400 BooleanType NonsmoothOperator::isVariable( VariableType &varType, int &component ) const
00401 {
00402     return BT_FALSE;
00403 }
00404 
00405 
00406 returnValue NonsmoothOperator::loadIndices( SymbolicIndexList *indexList ){
00407 
00408     return SUCCESSFUL_RETURN;
00409 }
00410 
00411 
00412 BooleanType NonsmoothOperator::isSymbolic() const{
00413 
00414     return BT_TRUE;
00415 }
00416 
00417 
00418 
00419 double NonsmoothOperator::getValue() const{ return INFTY; }
00420 
00421 int NonsmoothOperator::getGlobalIndex( ) const{
00422 
00423         ACADOERROR( RET_UNKNOWN_BUG );
00424     return -1;
00425 }
00426 
00427 
00428 Operator* NonsmoothOperator::passArgument() const{
00429 
00430     return 0;
00431 }
00432 
00433 
00434 
00435 CLOSE_NAMESPACE_ACADO
00436 
00437 
00438 // end of file.


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:59:22