qpOASES  3.2.1
An Implementation of the Online Active Set Strategy
include/qpOASES/SQProblemSchur.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-2014 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 
00038 #ifndef QPOASES_SQPROBLEMSCHUR_HPP
00039 #define QPOASES_SQPROBLEMSCHUR_HPP
00040 
00041 
00042 #include <qpOASES/SQProblem.hpp>
00043 #include <qpOASES/SparseSolver.hpp>
00044 #include <qpOASES/LapackBlasReplacement.hpp>
00045 
00046 
00047 BEGIN_NAMESPACE_QPOASES
00048 
00049 
00061 class SQProblemSchur : public SQProblem
00062 {
00063     /* allow SolutionAnalysis class to access private members */
00064     friend class SolutionAnalysis;
00065 
00066     /*
00067      *  PUBLIC MEMBER FUNCTIONS
00068      */
00069     public:
00071         SQProblemSchur( );
00072 
00078         SQProblemSchur( int_t _nV,                              
00079                         int_t _nC,                              
00080                         HessianType _hessianType = HST_UNKNOWN, 
00081                         int_t maxSchurUpdates = 75              
00082                         );
00083 
00085         SQProblemSchur( const SQProblemSchur& rhs       
00086                         );
00087 
00089         virtual ~SQProblemSchur( );
00090 
00092         virtual SQProblemSchur& operator=(  const SQProblemSchur& rhs   
00093                                             );
00094 
00098         virtual returnValue reset( );
00099 
00102         returnValue resetSchurComplement( BooleanType allowInertiaCorrection );
00103 
00105         inline int_t getNumFactorizations( ) const;
00106 
00107     /*
00108      *  PROTECTED MEMBER FUNCTIONS
00109      */
00110     protected:
00113         returnValue clear( );
00114 
00117         returnValue copy(   const SQProblemSchur& rhs   
00118                             );
00119 
00122         virtual returnValue computeProjectedCholesky( );
00123 
00127         virtual returnValue computeInitialCholesky( );
00128 
00131         virtual returnValue setupTQfactorisation( );
00132 
00142         virtual returnValue setupAuxiliaryQP(   SymmetricMatrix *H_new,     
00144                                                 Matrix *A_new,              
00146                                                 const real_t *lb_new,
00147                                                 const real_t *ub_new,
00148                                                 const real_t *lbA_new,
00149                                                 const real_t *ubA_new
00150                                                 );
00151 
00158         virtual returnValue setupAuxiliaryWorkingSet(   const Bounds* const auxiliaryBounds,
00159                                                         const Constraints* const auxiliaryConstraints,
00160                                                         BooleanType setupAfresh
00161                                                         );
00162 
00163 
00169         virtual returnValue addConstraint(  int_t number,                   
00170                                             SubjectToStatus C_status,       
00171                                             BooleanType updateCholesky,     
00172                                             BooleanType ensureLI = BT_TRUE  
00173                                             );
00174 
00180         virtual returnValue addConstraint_checkLI(  int_t number    
00181                                             );
00182 
00191         virtual returnValue addConstraint_ensureLI( int_t number,               
00192                                                         SubjectToStatus C_status    
00193                                                         );
00194 
00200         virtual returnValue addBound(   int_t number,                   
00201                                         SubjectToStatus B_status,       
00202                                         BooleanType updateCholesky,     
00203                                         BooleanType ensureLI = BT_TRUE  
00204                                         );
00205 
00210         virtual returnValue addBound_checkLI(   int_t number    
00211                                                 );
00212 
00221         virtual returnValue addBound_ensureLI(  int_t number,               
00222                                                 SubjectToStatus B_status    
00223                                                 );
00224 
00230         virtual returnValue removeConstraint(   int_t number,                           
00231                                                 BooleanType updateCholesky,             
00232                                                 BooleanType allowFlipping = BT_FALSE,   
00233                                                 BooleanType ensureNZC = BT_FALSE        
00234                                                 );
00235 
00241         virtual returnValue removeBound(    int_t number,                           
00242                                             BooleanType updateCholesky,             
00243                                             BooleanType allowFlipping = BT_FALSE,   
00244                                             BooleanType ensureNZC = BT_FALSE        
00245                                             );
00246 
00249         virtual returnValue backsolveT(     const real_t* const b,  
00250                                             BooleanType transposed, 
00251                                             real_t* const a         
00252                                             ) const;
00253 
00256         virtual returnValue backsolveR(     const real_t* const b,  
00257                                             BooleanType transposed, 
00258                                             real_t* const a         
00259                                             ) const;
00260 
00263         virtual returnValue backsolveR(     const real_t* const b,      
00264                                             BooleanType transposed,     
00265                                             BooleanType removingBound,  
00266                                             real_t* const a             
00267                                             ) const;
00268 
00269 
00274         virtual returnValue determineStepDirection( const real_t* const delta_g,    
00275                                                         const real_t* const delta_lbA,  
00276                                                         const real_t* const delta_ubA,  
00277                                                         const real_t* const delta_lb,   
00278                                                         const real_t* const delta_ub,   
00279                                                         BooleanType Delta_bC_isZero,    
00280                                                         BooleanType Delta_bB_isZero,    
00281                                                         real_t* const delta_xFX,        
00282                                                         real_t* const delta_xFR,        
00283                                                         real_t* const delta_yAC,        
00284                                                         real_t* const delta_yFX         
00285                                                         );
00286 
00287         virtual returnValue determineStepDirection2(    const real_t* const delta_g,    
00288                                                         const real_t* const delta_lbA,  
00289                                                         const real_t* const delta_ubA,  
00290                                                         const real_t* const delta_lb,   
00291                                                         const real_t* const delta_ub,   
00292                                                         BooleanType Delta_bC_isZero,    
00293                                                         BooleanType Delta_bB_isZero,    
00294                                                         real_t* const delta_xFX,        
00295                                                         real_t* const delta_xFR,        
00296                                                         real_t* const delta_yAC,        
00297                                                         real_t* const delta_yFX         
00298                                                         );
00299 
00300     /*
00301      *  PRIVATE MEMBER FUNCTION
00302      */
00303     private:
00309         returnValue addBound_checkLISchur(  int_t number,           
00310                                             real_t* const xiC,      
00311                                             real_t* const xiX       
00312                                             );
00313 
00319         returnValue addConstraint_checkLISchur( int_t number,       
00320                                                     real_t* const xiC,  
00321                                                     real_t* const xiX   
00322                                                     );
00323 
00326         returnValue computeMTimes( real_t alpha, const real_t* const x, real_t beta, real_t* const y );
00327 
00330         returnValue computeMTransTimes( real_t alpha, const real_t* const x, real_t beta, real_t* const y );
00331 
00333         returnValue addToSchurComplement( int_t number, SchurUpdateType update, int_t numNonzerosM, const sparse_int_t* M_pos, const real_t* const M_vals, int_t numNonzerosN, const sparse_int_t* Npos, const real_t* const Nvals, real_t N_diag );
00334 
00336         returnValue deleteFromSchurComplement( int_t idx, BooleanType allowUndo = BT_FALSE );
00337 
00339         returnValue undoDeleteFromSchurComplement( int_t idx );
00340 
00342         real_t calcDetSchur( int_t idxDel );
00343 
00345         returnValue updateSchurQR( int_t idxDel );
00346 
00348         returnValue backsolveSchurQR( int_t dimS, const real_t* const rhs, int_t dimRhs, real_t* const sol );
00349 
00351         returnValue correctInertia();
00352 
00354         returnValue repairSingularWorkingSet( );
00355 
00356         returnValue stepCalcRhs(    int_t nFR, int_t nFX, int_t nAC, int_t* FR_idx, int_t* FX_idx, int_t* AC_idx, real_t& rhs_max, const real_t* const delta_g,
00357                                     const real_t* const delta_lbA, const real_t* const delta_ubA,
00358                                     const real_t* const delta_lb, const real_t* const delta_ub,
00359                                     BooleanType Delta_bC_isZero, BooleanType Delta_bB_isZero,
00360                                     real_t* const delta_xFX, real_t* const delta_xFR,
00361                                     real_t* const delta_yAC, real_t* const delta_yFX
00362                                     );
00363 
00364         returnValue stepCalcReorder(int_t nFR, int_t nAC, int_t* FR_idx, int_t* AC_idx, int_t nFRStart, int_t nACStart,
00365                                     int_t* FR_idxStart, int_t* AC_idxStart, int_t* FR_iSort, int_t* FR_iSortStart,
00366                                     int_t* AC_iSort, int_t* AC_iSortStart, real_t* rhs
00367                                     );
00368 
00369         returnValue stepCalcBacksolveSchur( int_t nFR, int_t nFX, int_t nAC, int_t* FR_idx, int_t* FX_idx, int_t* AC_idx,
00370                                             int_t dim, real_t* rhs, real_t* sol
00371                                             );
00372 
00373         returnValue stepCalcReorder2(   int_t nFR, int_t nAC, int_t* FR_idx, int_t* AC_idx, int_t nFRStart, int_t nACStart,
00374                                         int_t* FR_idxStart, int_t* AC_idxStart, int_t* FR_iSort, int_t* FR_iSortStart,
00375                                         int_t* AC_iSort, int_t* AC_iSortStart, real_t* sol, real_t* const delta_xFR, real_t* const delta_yAC
00376                                         );
00377 
00378         returnValue stepCalcResid(  int_t nFR, int_t nFX, int_t nAC, int_t* FR_idx, int_t* FX_idx, int_t* AC_idx,
00379                                     BooleanType Delta_bC_isZero, real_t* const delta_xFX, real_t* const delta_xFR,
00380                                     real_t* const delta_yAC, const real_t* const delta_g,
00381                                     const real_t* const delta_lbA, const real_t* const delta_ubA, real_t& rnrm
00382                                     );
00383 
00384         returnValue stepCalcDeltayFx(   int_t nFR, int_t nFX, int_t nAC, int_t* FX_idx, const real_t* const delta_g,
00385                                         real_t* const delta_xFX, real_t* const delta_xFR, real_t* const delta_yAC, real_t* const delta_yFX
00386                                         );
00387 
00388     /*
00389      *  PROTECTED MEMBER VARIABLES
00390      */
00391     protected:
00392         SparseSolver* sparseSolver;         
00394         real_t* S;                          
00395         int_t nS;                           
00396         int_t nSmax;                        
00398         real_t* Q_;                         
00399         real_t* R_;                         
00400         real_t detS;                        
00401         real_t rcondS;                      
00402         int_t numFactorizations;            
00404         int_t* schurUpdateIndex;            
00405         SchurUpdateType* schurUpdate;       
00407         int_t M_physicallength;             
00408         real_t* M_vals;                     
00409         sparse_int_t* M_ir;                 
00410         sparse_int_t* M_jc;                 
00412         Indexlist boundsFreeStart;          
00413         Indexlist constraintsActiveStart;   
00414 };
00415 
00416 
00417 END_NAMESPACE_QPOASES
00418 
00419 #include <qpOASES/SQProblemSchur.ipp>
00420 
00421 #endif  /* QPOASES_QPROBLEMSCHUR_HPP */
00422 
00423 
00424 /*
00425  *  end of file
00426  */