QProblem.hpp
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-2008 by Hans Joachim Ferreau et al. All rights reserved.
00006  *
00007  *      qpOASES is free software; you can redistribute it and/or
00008  *      modify it under the terms of the GNU Lesser General Public
00009  *      License as published by the Free Software Foundation; either
00010  *      version 2.1 of the License, or (at your option) any later version.
00011  *
00012  *      qpOASES is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *      Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with qpOASES; if not, write to the Free Software
00019  *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020  *
00021  */
00022 
00023 
00036 #ifndef QPOASES_QPROBLEM_HPP
00037 #define QPOASES_QPROBLEM_HPP
00038 
00039 
00040 #include <QProblemB.hpp>
00041 #include <Constraints.hpp>
00042 #include <CyclingManager.hpp>
00043 
00044 
00053 class QProblem : public QProblemB
00054 {
00055         /* allow SolutionAnalysis class to access private members */
00056         friend class SolutionAnalysis;
00057         
00058         /*
00059          *      PUBLIC MEMBER FUNCTIONS
00060          */
00061         public:
00063                 QProblem( );
00064 
00066                 QProblem(       int _nV,                                        
00067                                         int _nC                                         
00068                                         );
00069 
00071                 QProblem(       const QProblem& rhs     
00072                                         );
00073 
00075                 ~QProblem( );
00076 
00078                 QProblem& operator=(    const QProblem& rhs             
00079                                                                 );
00080 
00081 
00085                 returnValue reset( );
00086 
00087 
00101                 returnValue init(       const real_t* const _H,                 
00102                                                         const real_t* const _g,                 
00103                                                         const real_t* const _A,                 
00104                                                         const real_t* const _lb,                
00106                                                         const real_t* const _ub,                
00108                                                         const real_t* const _lbA,               
00110                                                         const real_t* const _ubA,               
00112                                                         int& nWSR,                                              
00114                                                         const real_t* const yOpt = 0,   
00115                                                         real_t* const cputime = 0               
00116                                                         );
00117 
00118 
00132                 returnValue init(       const real_t* const _H,                 
00133                                                         const real_t* const _R,                 
00134                                                         const real_t* const _g,                 
00135                                                         const real_t* const _A,                 
00136                                                         const real_t* const _lb,                
00138                                                         const real_t* const _ub,                
00140                                                         const real_t* const _lbA,               
00142                                                         const real_t* const _ubA,               
00144                                                         int& nWSR,                                              
00146                                                         const real_t* const yOpt = 0,   
00147                                                         real_t* const cputime = 0               
00148                                                         );
00149 
00150 
00164                 returnValue hotstart(   const real_t* const g_new,              
00165                                                                 const real_t* const lb_new,             
00167                                                                 const real_t* const ub_new,             
00169                                                                 const real_t* const lbA_new,    
00171                                                                 const real_t* const ubA_new,    
00173                                                                 int& nWSR,                                              
00175                                                                 real_t* const cputime                   
00176                                                                 );
00177 
00178 
00181                 inline returnValue getA(        real_t* const _A        
00182                                                                         ) const;
00183 
00187                 inline returnValue getA(        int number,                     
00188                                                                         real_t* const row       
00189                                                                         ) const;
00190 
00193                 inline returnValue getLBA(      real_t* const _lbA      
00194                                                                         ) const;
00195 
00199                 inline returnValue getLBA(      int number,             
00200                                                                         real_t& value   
00201                                                                         ) const;
00202 
00205                 inline returnValue getUBA(      real_t* const _ubA      
00206                                                                         ) const;
00207 
00211                 inline returnValue getUBA(      int number,             
00212                                                                         real_t& value   
00213                                                                         ) const;
00214 
00215 
00218                 inline returnValue getConstraints(      Constraints* const _constraints 
00219                                                                                         ) const;
00220 
00221 
00224                 inline int getNC( ) const;
00225 
00228                 inline int getNEC( ) const;
00229 
00232                 inline int getNAC( );
00233 
00236                 inline int getNIAC( );
00237 
00240                 int getNZ( );
00241 
00242 
00246                 returnValue getDualSolution(    real_t* const yOpt      
00247                                                                                 ) const;
00248 
00249 
00250         /*
00251          *      PROTECTED MEMBER FUNCTIONS
00252          */
00253         protected:
00257                 returnValue setupSubjectToType( );
00258 
00262                 returnValue setupCholeskyDecompositionProjected( );
00263 
00267                 returnValue setupTQfactorisation( );
00268 
00269 
00281                 returnValue solveInitialQP(     const real_t* const xOpt,                                               
00283                                                                         const real_t* const yOpt,                                               
00285                                                                         const Bounds* const guessedBounds,                              
00287                                                                         const Constraints* const guessedConstraints,    
00289                                                                         int& nWSR,                                                                              
00291                                                                         real_t* const cputime                                                   
00292                                                                         );
00293 
00300                 returnValue obtainAuxiliaryWorkingSet(  const real_t* const xOpt,                                               
00302                                                                                                 const real_t* const yOpt,                                               
00304                                                                                                 const Bounds* const guessedBounds,                              
00305                                                                                                 const Constraints* const guessedConstraints,    
00306                                                                                                 Bounds* auxiliaryBounds,                                                
00308                                                                                                 Constraints* auxiliaryConstraints                               
00310                                                                                                 ) const;
00311 
00320                 returnValue setupAuxiliaryWorkingSet(   const Bounds* const auxiliaryBounds,                    
00321                                                                                                 const Constraints* const auxiliaryConstraints,  
00322                                                                                                 BooleanType setupAfresh                                                 
00324                                                                                                 );
00325 
00328                 returnValue setupAuxiliaryQPsolution(   const real_t* const xOpt,                       
00330                                                                                                 const real_t* const yOpt                        
00332                                                                                                 );
00333 
00338                 returnValue setupAuxiliaryQPgradient( );
00339 
00345                 returnValue setupAuxiliaryQPbounds(     const Bounds* const auxiliaryBounds,                    
00346                                                                                         const Constraints* const auxiliaryConstraints,  
00347                                                                                         BooleanType useRelaxation                                               
00348                                                                                         );
00349 
00350 
00356                 returnValue addConstraint(      int number,                                     
00357                                                                         SubjectToStatus C_status,       
00358                                                                         BooleanType updateCholesky      
00359                                                                         );
00360 
00366                 returnValue addConstraint_checkLI(      int number                      
00367                                                                                         );
00368 
00377                 returnValue addConstraint_ensureLI(     int number,                                     
00378                                                                                         SubjectToStatus C_status        
00379                                                                                         );
00380 
00386                 returnValue addBound(   int number,                                     
00387                                                                 SubjectToStatus B_status,       
00388                                                                 BooleanType updateCholesky      
00389                                                                 );
00390 
00395                 returnValue addBound_checkLI(   int number                      
00396                                                                                 );
00397 
00406                 returnValue addBound_ensureLI(  int number,                                     
00407                                                                                 SubjectToStatus B_status        
00408                                                                                 );
00409 
00415                 returnValue removeConstraint(   int number,                                     
00416                                                                                 BooleanType updateCholesky      
00417                                                                                 );
00418 
00424                 returnValue removeBound(        int number,                                     
00425                                                                         BooleanType updateCholesky      
00426                                                                         );
00427 
00428 
00432                 returnValue backsolveR( const real_t* const b,  
00433                                                                 BooleanType transposed, 
00434                                                                 real_t* const a                 
00435                                                                 );
00436 
00441                 returnValue backsolveR( const real_t* const b,          
00442                                                                 BooleanType transposed,         
00443                                                                 BooleanType removingBound,      
00444                                                                 real_t* const a                         
00445                                                                 );
00446 
00447 
00451                 returnValue backsolveT( const real_t* const b,  
00452                                                                 BooleanType transposed, 
00453                                                                 real_t* const a                 
00454                                                                 );
00455 
00456 
00459                 returnValue hotstart_determineDataShift(const int* const FX_idx,        
00460                                                                                                 const int* const AC_idx,        
00461                                                                                                 const real_t* const g_new,      
00462                                                                                                 const real_t* const lbA_new,
00463                                                                                                 const real_t* const ubA_new,
00464                                                                                                 const real_t* const lb_new,     
00465                                                                                                 const real_t* const ub_new,     
00466                                                                                                 real_t* const delta_g,          
00467                                                                                                 real_t* const delta_lbA,        
00468                                                                                                 real_t* const delta_ubA,        
00469                                                                                                 real_t* const delta_lb,         
00470                                                                                                 real_t* const delta_ub,         
00471                                                                                                 BooleanType& Delta_bC_isZero,
00472                                                                                                 BooleanType& Delta_bB_isZero
00473                                                                                                 );
00474 
00479                 returnValue hotstart_determineStepDirection(const int* const FR_idx,            
00480                                                                                                         const int* const FX_idx,                
00481                                                                                                         const int* const AC_idx,                
00482                                                                                                         const real_t* const delta_g,    
00483                                                                                                         const real_t* const delta_lbA,  
00484                                                                                                         const real_t* const delta_ubA,  
00485                                                                                                         const real_t* const delta_lb,   
00486                                                                                                         const real_t* const delta_ub,   
00487                                                                                                         BooleanType Delta_bC_isZero,    
00488                                                                                                         BooleanType Delta_bB_isZero,    
00489                                                                                                         real_t* const delta_xFX,                
00490                                                                                                         real_t* const delta_xFR,                
00491                                                                                                         real_t* const delta_yAC,                
00492                                                                                                         real_t* const delta_yFX                 
00493                                                                                                         );
00494 
00497                 returnValue hotstart_determineStepLength(       const int* const FR_idx,                        
00498                                                                                                         const int* const FX_idx,                        
00499                                                                                                         const int* const AC_idx,                        
00500                                                                                                         const int* const IAC_idx,                       
00501                                                                                                         const real_t* const delta_lbA,          
00502                                                                                                         const real_t* const delta_ubA,          
00503                                                                                                         const real_t* const delta_lb,           
00504                                                                                                         const real_t* const delta_ub,           
00505                                                                                                         const real_t* const delta_xFX,          
00506                                                                                                         const real_t* const delta_xFR,          
00507                                                                                                         const real_t* const delta_yAC,          
00508                                                                                                         const real_t* const delta_yFX,          
00509                                                                                                         real_t* const delta_Ax,                         
00510                                                                                                         int& BC_idx,                                            
00511                                                                                                         SubjectToStatus& BC_status,                     
00512                                                                                                         BooleanType& BC_isBound                         
00513                                                                                                         );
00514 
00521                 returnValue hotstart_performStep(       const int* const FR_idx,                        
00522                                                                                         const int* const FX_idx,                        
00523                                                                                         const int* const AC_idx,                        
00524                                                                                         const int* const IAC_idx,                       
00525                                                                                         const real_t* const delta_g,            
00526                                                                                         const real_t* const delta_lbA,          
00527                                                                                         const real_t* const delta_ubA,          
00528                                                                                         const real_t* const delta_lb,           
00529                                                                                         const real_t* const delta_ub,           
00530                                                                                         const real_t* const delta_xFX,          
00531                                                                                         const real_t* const delta_xFR,          
00532                                                                                         const real_t* const delta_yAC,          
00533                                                                                         const real_t* const delta_yFX,          
00534                                                                                         const real_t* const delta_Ax,           
00535                                                                                         int BC_idx,                                             
00536                                                                                         SubjectToStatus BC_status,                      
00537                                                                                         BooleanType BC_isBound                          
00538                                                                                         );
00539 
00540 
00545                 BooleanType areBoundsConsistent(        const real_t* const delta_lb,   
00546                                                                                         const real_t* const delta_ub,   
00547                                                                                         const real_t* const delta_lbA,  
00548                                                                                         const real_t* const delta_ubA   
00549                                                                                         ) const;
00550 
00551 
00555                 returnValue setupQPdata(        const real_t* const _H,         
00556                                                                         const real_t* const _R,         
00557                                                                         const real_t* const _g,         
00558                                                                         const real_t* const _A,         
00559                                                                         const real_t* const _lb,        
00561                                                                         const real_t* const _ub,        
00563                                                                         const real_t* const _lbA,       
00565                                                                         const real_t* const _ubA        
00567                                                                         );
00568 
00569 
00570                 #ifdef PC_DEBUG  /* Define print functions only for debugging! */
00571 
00574                 returnValue printIteration(     int iteration,                          
00575                                                                         int BC_idx,                             
00576                                                                         SubjectToStatus BC_status,      
00577                                                                         BooleanType BC_isBound          
00578                                                                         );
00579 
00583                 returnValue printIteration(     int iteration,                          
00584                                                                         int BC_idx,                             
00585                                                                         SubjectToStatus BC_status       
00586                                                                         );
00587 
00588                 #endif  /* PC_DEBUG */
00589 
00590 
00596                 returnValue checkKKTconditions( );
00597 
00598 
00602                 inline returnValue setA(        const real_t* const A_new       
00603                                                                         );
00604 
00609                 inline returnValue setA(        int number,                                     
00610                                                                         const real_t* const value       
00611                                                                         );
00612 
00613 
00616                 inline returnValue setLBA(      const real_t* const lbA_new     
00617                                                                         );
00618 
00622                 inline returnValue setLBA(      int number,             
00623                                                                         real_t value    
00624                                                                         );
00625 
00628                 inline returnValue setUBA(      const real_t* const ubA_new     
00629                                                                         );
00630 
00634                 inline returnValue setUBA(      int number,             
00635                                                                         real_t value    
00636                                                                         );
00637 
00638 
00639         /*
00640          *      PROTECTED MEMBER VARIABLES
00641          */
00642         protected:
00643                 real_t A[NCMAX_ALLOC*NVMAX];            
00644                 real_t lbA[NCMAX_ALLOC];                        
00645                 real_t ubA[NCMAX_ALLOC];                        
00647                 Constraints constraints;                        
00649                 real_t T[NVMAX*NVMAX];                          
00650                 real_t Q[NVMAX*NVMAX];                          
00651                 int sizeT;                                                      
00653                 real_t Ax[NCMAX_ALLOC];                         
00655                 CyclingManager cyclingManager;          
00656 };
00657 
00658 
00659 #include <QProblem.ipp>
00660 
00661 #endif  /* QPOASES_QPROBLEM_HPP */
00662 
00663 
00664 /*
00665  *      end of file
00666  */


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