Options.cpp
Go to the documentation of this file.
00001 /*
00002  *      This file is part of qpOASES.
00003  *
00004  *      qpOASES -- An Implementation of the Online Active Set Strategy.
00005  *      Copyright (C) 2007-2011 by Hans Joachim Ferreau, Andreas Potschka,
00006  *      Christian Kirches et al. All rights reserved.
00007  *
00008  *      qpOASES is free software; you can redistribute it and/or
00009  *      modify it under the terms of the GNU Lesser General Public
00010  *      License as published by the Free Software Foundation; either
00011  *      version 2.1 of the License, or (at your option) any later version.
00012  *
00013  *      qpOASES is distributed in the hope that it will be useful,
00014  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  *      See the GNU Lesser General Public License for more details.
00017  *
00018  *      You should have received a copy of the GNU Lesser General Public
00019  *      License along with qpOASES; if not, write to the Free Software
00020  *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021  *
00022  */
00023 
00024 
00036 #include <qpOASES/Options.hpp>
00037 
00038 
00039 BEGIN_NAMESPACE_QPOASES
00040 
00041 
00042 /*****************************************************************************
00043  *  P U B L I C                                                              *
00044  *****************************************************************************/
00045 
00046 
00047 /*
00048  *      O p t i o n s
00049  */
00050 Options::Options( )
00051 {
00052         setToDefault( );
00053 }
00054 
00055 
00056 /*
00057  *      O p t i o n s
00058  */
00059 Options::Options( const Options& rhs )
00060 {
00061         copy( rhs );
00062 }
00063 
00064 
00065 /*
00066  *      ~ O p t i o n s
00067  */
00068 Options::~Options( )
00069 {
00070 }
00071 
00072 
00073 /*
00074  *      o p e r a t o r =
00075  */
00076 Options& Options::operator=( const Options& rhs )
00077 {
00078         if ( this != &rhs )
00079         {
00080                 copy( rhs );
00081         }
00082 
00083         return *this;
00084 }
00085 
00086 
00087 
00088 /*
00089  *      s e t T o D e f a u l t
00090  */
00091 returnValue Options::setToDefault( )
00092 {
00093         printLevel = PL_MEDIUM;
00094         #ifdef __DEBUG__
00095         printLevel = PL_HIGH;
00096         #endif
00097         #ifdef __XPCTARGET__
00098         printLevel = PL_NONE;
00099         #endif
00100 
00101         enableRamping                 =  BT_TRUE;
00102         enableFarBounds               =  BT_TRUE;
00103         enableFlippingBounds          =  BT_TRUE;
00104         enableRegularisation          =  BT_FALSE;
00105         enableFullLITests             =  BT_FALSE;
00106         enableNZCTests                =  BT_TRUE;
00107         enableDriftCorrection         =  1;
00108         enableCholeskyRefactorisation =  0;
00109         enableEqualities              =  BT_FALSE;
00110 
00111         terminationTolerance          =  1.0e7 * EPS;
00112         boundTolerance                =  1.0e6 * EPS;
00113         boundRelaxation               =  1.0e4;
00114         epsNum                        = -1.0e3 * EPS;
00115         epsDen                        =  1.0e3 * EPS;
00116         maxPrimalJump                 =  1.0e8;
00117         maxDualJump                   =  1.0e8;
00118 
00119         initialRamping                =  0.5;
00120         finalRamping                  =  1.0;
00121         initialFarBounds              =  1.0e4;
00122         growFarBounds                 =  1.0e3;
00123         initialStatusBounds           =  ST_LOWER;
00124         epsFlipping                   =  1.0e4 * EPS;
00125         numRegularisationSteps        =  0;
00126         epsRegularisation             =  5.0e3 * EPS;
00127         numRefinementSteps            =  1;
00128         epsIterRef                    =  1.0e2 * EPS;
00129         epsLITests                    =  1.0e5 * EPS;
00130         epsNZCTests                   =  1.0e5 * EPS;
00131 
00132         return SUCCESSFUL_RETURN;
00133 }
00134 
00135 
00136 /*
00137  *      s e t T o R e l i a b l e
00138  */
00139 returnValue Options::setToReliable( )
00140 {
00141         setToDefault( );
00142 
00143         enableFullLITests             =  BT_TRUE;
00144         enableCholeskyRefactorisation =  1;
00145 
00146         numRefinementSteps            =  2;
00147 
00148         return SUCCESSFUL_RETURN;
00149 }
00150 
00151 
00152 /*
00153  *      s e t T o F a s t
00154  */
00155 returnValue Options::setToFast( )
00156 {
00157         setToDefault( );
00158 
00159         enableRamping                 =  BT_FALSE;
00160         enableFarBounds               =  BT_TRUE;
00161         enableFlippingBounds          =  BT_FALSE;
00162         enableRegularisation          =  BT_TRUE;
00163         enableNZCTests                =  BT_FALSE;
00164         enableDriftCorrection         =  0;
00165         enableEqualities              =  BT_TRUE;
00166 
00167         terminationTolerance          =  1.0e9 * EPS;
00168         
00169         initialStatusBounds           =  ST_INACTIVE;
00170         numRegularisationSteps        =  2;
00171         numRefinementSteps            =  0;
00172 
00173         return SUCCESSFUL_RETURN;
00174 }
00175 
00176 
00177 
00178 /*
00179  *      e n s u r e C o n s i s t e n c y
00180  */
00181 returnValue Options::ensureConsistency( )
00182 {
00183         /* flipping bounds require far bounds */
00184         if( enableFlippingBounds == BT_TRUE )
00185                 enableFarBounds = BT_TRUE;
00186         
00187         if( enableDriftCorrection < 0 )
00188                 enableDriftCorrection = 0;
00189         
00190         if( enableCholeskyRefactorisation < 0 )
00191                 enableCholeskyRefactorisation = 0;
00192 
00193 
00194         if ( terminationTolerance <= 0.0 )
00195                 terminationTolerance = EPS;
00196 
00197         if ( epsIterRef <= 0.0 )
00198                 epsIterRef = EPS;
00199 
00200         if ( epsRegularisation <= 0.0 )
00201                 epsRegularisation = EPS;
00202 
00203         if ( boundTolerance <= 0.0 )
00204                 boundTolerance = EPS;
00205 
00206         if ( boundRelaxation <= 0.0 )
00207                 boundRelaxation = EPS;
00208         
00209         if ( maxPrimalJump <= 0.0 )
00210                 maxPrimalJump = EPS;
00211 
00212         if ( maxDualJump <= 0.0 )
00213                 maxDualJump = EPS;
00214 
00215 
00216         if ( initialRamping < 0.0 )
00217                 initialRamping = 0.0;
00218 
00219         if ( finalRamping < 0.0 )
00220                 finalRamping = 0.0;
00221 
00222         if ( initialFarBounds <= boundRelaxation )
00223                 initialFarBounds = boundRelaxation+EPS;
00224         
00225         if ( growFarBounds < 1.1 )
00226                 growFarBounds = 1.1;
00227 
00228         if ( epsFlipping <= 0.0 )
00229                 epsFlipping = EPS;
00230 
00231         if ( numRegularisationSteps < 0 )
00232                 numRegularisationSteps = 0;
00233 
00234         if ( epsRegularisation < 0.0 )
00235                 epsRegularisation = EPS;
00236 
00237         if ( numRefinementSteps < 0 )
00238                 numRefinementSteps = 0;
00239 
00240         if ( epsIterRef < 0.0 )
00241                 epsIterRef = EPS;
00242 
00243         if ( epsLITests < 0.0 )
00244                 epsLITests = EPS;
00245 
00246         if ( epsNZCTests < 0.0 )
00247                 epsNZCTests = EPS;
00248 
00249         return SUCCESSFUL_RETURN;
00250 }
00251 
00252 
00253 /*
00254  *      p r i n t
00255  */
00256 returnValue Options::print( ) const
00257 {
00258         #ifndef __XPCTARGET__
00259         #ifndef __DSPACE__
00260         char myPrintfString[160];
00261         char info[20];
00262 
00263         myPrintf( "\n###################   qpOASES  --  QP OPTIONS   ##################\n" );
00264         myPrintf( "\n" );
00265 
00266         convertPrintLevelToString( printLevel,info );
00267         snprintf( myPrintfString,80,"printLevel                     =  %s\n",info );
00268         myPrintf( myPrintfString );
00269 
00270         myPrintf( "\n" );
00271 
00272         convertBooleanTypeToString( enableRamping,info );
00273         snprintf( myPrintfString,80,"enableRamping                  =  %s\n",info );
00274         myPrintf( myPrintfString );
00275 
00276         convertBooleanTypeToString( enableFarBounds,info );
00277         snprintf( myPrintfString,80,"enableFarBounds                =  %s\n",info );
00278         myPrintf( myPrintfString );
00279 
00280         convertBooleanTypeToString( enableFlippingBounds,info );
00281         snprintf( myPrintfString,80,"enableFlippingBounds           =  %s\n",info );
00282         myPrintf( myPrintfString );
00283 
00284         convertBooleanTypeToString( enableRegularisation,info );
00285         snprintf( myPrintfString,80,"enableRegularisation           =  %s\n",info );
00286         myPrintf( myPrintfString );
00287 
00288         convertBooleanTypeToString( enableFullLITests,info );
00289         snprintf( myPrintfString,80,"enableFullLITests              =  %s\n",info );
00290         myPrintf( myPrintfString );
00291         
00292         convertBooleanTypeToString( enableNZCTests,info );
00293         snprintf( myPrintfString,80,"enableNZCTests                 =  %s\n",info );
00294         myPrintf( myPrintfString );
00295 
00296         snprintf( myPrintfString,80,"enableDriftCorrection          =  %d\n",enableDriftCorrection );
00297         myPrintf( myPrintfString );
00298         
00299         snprintf( myPrintfString,80,"enableCholeskyRefactorisation  =  %d\n",enableCholeskyRefactorisation );
00300         myPrintf( myPrintfString );
00301 
00302         convertBooleanTypeToString( enableEqualities,info );
00303         snprintf( myPrintfString,80,"enableEqualities               =  %s\n",info );
00304         myPrintf( myPrintfString );
00305 
00306         myPrintf( "\n" );
00307 
00308         snprintf( myPrintfString,80,"terminationTolerance           =  %e\n",terminationTolerance );
00309         myPrintf( myPrintfString );
00310 
00311         snprintf( myPrintfString,80,"boundTolerance                 =  %e\n",boundTolerance );
00312         myPrintf( myPrintfString );
00313 
00314         snprintf( myPrintfString,80,"boundRelaxation                =  %e\n",boundRelaxation );
00315         myPrintf( myPrintfString );
00316 
00317         snprintf( myPrintfString,80,"epsNum                         =  %e\n",epsNum );
00318         myPrintf( myPrintfString );
00319 
00320         snprintf( myPrintfString,80,"epsDen                         =  %e\n",epsDen );
00321         myPrintf( myPrintfString );
00322 
00323         snprintf( myPrintfString,80,"maxPrimalJump                  =  %e\n",maxPrimalJump );
00324         myPrintf( myPrintfString );
00325 
00326         snprintf( myPrintfString,80,"maxDualJump                    =  %e\n",maxDualJump );
00327         myPrintf( myPrintfString );
00328 
00329         myPrintf( "\n" );
00330 
00331         snprintf( myPrintfString,80,"initialRamping                 =  %e\n",initialRamping );
00332         myPrintf( myPrintfString );
00333 
00334         snprintf( myPrintfString,80,"finalRamping                   =  %e\n",finalRamping );
00335         myPrintf( myPrintfString );
00336 
00337         snprintf( myPrintfString,80,"initialFarBounds               =  %e\n",initialFarBounds );
00338         myPrintf( myPrintfString );
00339 
00340         snprintf( myPrintfString,80,"growFarBounds                  =  %e\n",growFarBounds );
00341         myPrintf( myPrintfString );
00342 
00343         convertSubjectToStatusToString( initialStatusBounds,info );
00344         snprintf( myPrintfString,80,"initialStatusBounds            =  %s\n",info );
00345         myPrintf( myPrintfString );
00346 
00347         snprintf( myPrintfString,80,"epsFlipping                    =  %e\n",epsFlipping );
00348         myPrintf( myPrintfString );
00349 
00350         snprintf( myPrintfString,80,"numRegularisationSteps         =  %d\n",numRegularisationSteps );
00351         myPrintf( myPrintfString );
00352 
00353         snprintf( myPrintfString,80,"epsRegularisation              =  %e\n",epsRegularisation );
00354         myPrintf( myPrintfString );
00355 
00356         snprintf( myPrintfString,80,"numRefinementSteps             =  %d\n",numRefinementSteps );
00357         myPrintf( myPrintfString );
00358 
00359         snprintf( myPrintfString,80,"epsIterRef                     =  %e\n",epsIterRef );
00360         myPrintf( myPrintfString );
00361         
00362         snprintf( myPrintfString,80,"epsLITests                     =  %e\n",epsLITests );
00363         myPrintf( myPrintfString );
00364         
00365         snprintf( myPrintfString,80,"epsNZCTests                    =  %e\n",epsNZCTests );
00366         myPrintf( myPrintfString );
00367 
00368         myPrintf( "\n\n" );
00369         #endif
00370         #endif
00371 
00372         return SUCCESSFUL_RETURN;
00373 }
00374 
00375 
00376 
00377 /*****************************************************************************
00378  *  P R O T E C T E D                                                        *
00379  *****************************************************************************/
00380 
00381 /*
00382  *      c o p y
00383  */
00384 returnValue Options::copy(      const Options& rhs
00385                                                         )
00386 {
00387         printLevel             = rhs.printLevel;
00388 
00389         enableRamping                 =  rhs.enableRamping;
00390         enableFarBounds               =  rhs.enableFarBounds;
00391         enableFlippingBounds          =  rhs.enableFlippingBounds;
00392         enableRegularisation          =  rhs.enableRegularisation;
00393         enableFullLITests             =  rhs.enableFullLITests;
00394         enableNZCTests                =  rhs.enableNZCTests;
00395         enableDriftCorrection         =  rhs.enableDriftCorrection;
00396         enableCholeskyRefactorisation =  rhs.enableCholeskyRefactorisation;
00397         enableEqualities              =  rhs.enableEqualities;
00398 
00399         terminationTolerance          =  rhs.terminationTolerance;
00400         boundTolerance                =  rhs.boundTolerance;
00401         boundRelaxation               =  rhs.boundRelaxation;
00402         epsNum                        =  rhs.epsNum;
00403         epsDen                        =  rhs.epsDen;
00404         maxPrimalJump                 =  rhs.maxPrimalJump;
00405         maxDualJump                   =  rhs.maxDualJump;
00406 
00407         initialRamping                =  rhs.initialRamping;
00408         finalRamping                  =  rhs.finalRamping;
00409         initialFarBounds              =  rhs.initialFarBounds;
00410         growFarBounds                 =  rhs.growFarBounds;
00411         initialStatusBounds           =  rhs.initialStatusBounds;
00412         epsFlipping                   =  rhs.epsFlipping;
00413         numRegularisationSteps        =  rhs.numRegularisationSteps;
00414         epsRegularisation             =  rhs.epsRegularisation;
00415         numRefinementSteps            =  rhs.numRefinementSteps;
00416         epsIterRef                    =  rhs.epsIterRef;
00417         epsLITests                    =  rhs.epsLITests;
00418         epsNZCTests                   =  rhs.epsNZCTests;
00419 
00420         return SUCCESSFUL_RETURN;
00421 }
00422 
00423 
00424 END_NAMESPACE_QPOASES
00425 
00426 
00427 /*
00428  *      end of file
00429  */


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