00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00038 #ifndef QPOASES_QPROBLEMB_HPP
00039 #define QPOASES_QPROBLEMB_HPP
00040
00041
00042 #include <qpOASES/Flipper.hpp>
00043 #include <qpOASES/Options.hpp>
00044 #include <qpOASES/Matrices.hpp>
00045
00046
00047 BEGIN_NAMESPACE_QPOASES
00048
00049
00050 class SolutionAnalysis;
00051
00063 class QProblemB
00064 {
00065
00066 friend class SolutionAnalysis;
00067
00068
00069
00070
00071 public:
00073 QProblemB( );
00074
00080 QProblemB( int _nV,
00081 HessianType _hessianType = HST_UNKNOWN
00082 );
00083
00085 QProblemB( const QProblemB& rhs
00086 );
00087
00089 virtual ~QProblemB( );
00090
00092 QProblemB& operator=( const QProblemB& rhs
00093 );
00094
00095
00099 virtual returnValue reset( );
00100
00101
00113 returnValue init( SymmetricMatrix *_H,
00114 const real_t* const _g,
00115 const real_t* const _lb,
00117 const real_t* const _ub,
00119 int& nWSR,
00121 real_t* const cputime
00123 );
00124
00136 returnValue init( const real_t* const _H,
00138 const real_t* const _g,
00139 const real_t* const _lb,
00141 const real_t* const _ub,
00143 int& nWSR,
00145 real_t* const cputime
00147 );
00148
00160 returnValue init( const char* const H_file,
00162 const char* const g_file,
00163 const char* const lb_file,
00165 const char* const ub_file,
00167 int& nWSR,
00169 real_t* const cputime
00171 );
00172
00191 returnValue init( SymmetricMatrix *_H,
00192 const real_t* const _g,
00193 const real_t* const _lb,
00195 const real_t* const _ub,
00197 int& nWSR,
00199 real_t* const cputime,
00201 const real_t* const xOpt,
00203 const real_t* const yOpt,
00205 const Bounds* const guessedBounds
00207 );
00208
00227 returnValue init( const real_t* const _H,
00229 const real_t* const _g,
00230 const real_t* const _lb,
00232 const real_t* const _ub,
00234 int& nWSR,
00236 real_t* const cputime,
00238 const real_t* const xOpt,
00240 const real_t* const yOpt,
00242 const Bounds* const guessedBounds
00244 );
00245
00264 returnValue init( const char* const H_file,
00266 const char* const g_file,
00267 const char* const lb_file,
00269 const char* const ub_file,
00271 int& nWSR,
00273 real_t* const cputime,
00275 const real_t* const xOpt,
00277 const real_t* const yOpt,
00279 const Bounds* const guessedBounds
00281 );
00282
00283
00297 returnValue hotstart( const real_t* const g_new,
00298 const real_t* const lb_new,
00300 const real_t* const ub_new,
00302 int& nWSR,
00304 real_t* const cputime
00306 );
00307
00324 returnValue hotstart( const char* const g_file,
00325 const char* const lb_file,
00327 const char* const ub_file,
00329 int& nWSR,
00331 real_t* const cputime
00333 );
00334
00349 returnValue hotstart( const real_t* const g_new,
00350 const real_t* const lb_new,
00352 const real_t* const ub_new,
00354 int& nWSR,
00356 real_t* const cputime,
00358 const Bounds* const guessedBounds
00360 );
00361
00379 returnValue hotstart( const char* const g_file,
00380 const char* const lb_file,
00382 const char* const ub_file,
00384 int& nWSR,
00386 real_t* const cputime,
00388 const Bounds* const guessedBounds
00390 );
00391
00392
00396 inline returnValue getBounds( Bounds& _bounds
00397 ) const;
00398
00399
00402 inline int getNV( ) const;
00403
00406 inline int getNFR( ) const;
00407
00410 inline int getNFX( ) const;
00411
00414 inline int getNFV( ) const;
00415
00418 virtual int getNZ( ) const;
00419
00420
00424 real_t getObjVal( ) const;
00425
00428 real_t getObjVal( const real_t* const _x
00429 ) const;
00430
00434 returnValue getPrimalSolution( real_t* const xOpt
00435 ) const;
00436
00440 virtual returnValue getDualSolution( real_t* const yOpt
00441 ) const;
00442
00443
00446 inline QProblemStatus getStatus( ) const;
00447
00448
00452 inline BooleanType isInitialised( ) const;
00453
00457 inline BooleanType isSolved( ) const;
00458
00462 inline BooleanType isInfeasible( ) const;
00463
00467 inline BooleanType isUnbounded( ) const;
00468
00469
00472 inline HessianType getHessianType( ) const;
00473
00476 inline returnValue setHessianType( HessianType _hessianType
00477 );
00478
00482 inline BooleanType usingRegularisation( ) const;
00483
00486 inline Options getOptions( ) const;
00487
00490 inline returnValue setOptions( const Options& _options
00491 );
00492
00495 inline PrintLevel getPrintLevel( ) const;
00496
00499 returnValue setPrintLevel( PrintLevel _printlevel
00500 );
00501
00502
00505 virtual returnValue printProperties( );
00506
00509 returnValue printOptions( ) const;
00510
00511
00512
00513
00514
00515 protected:
00518 returnValue clear( );
00519
00522 returnValue copy( const QProblemB& rhs
00523 );
00524
00530 returnValue determineHessianType( );
00531
00535 virtual returnValue setupSubjectToType( );
00536
00540 virtual returnValue setupSubjectToType( const real_t* const lb_new,
00541 const real_t* const ub_new
00542 );
00543
00552 returnValue setupCholeskyDecomposition( );
00553
00554
00560 returnValue obtainAuxiliaryWorkingSet( const real_t* const xOpt,
00562 const real_t* const yOpt,
00564 const Bounds* const guessedBounds,
00565 Bounds* auxiliaryBounds
00567 ) const;
00568
00569
00573 returnValue backsolveR( const real_t* const b,
00574 BooleanType transposed,
00575 real_t* const a
00576 ) const;
00577
00582 returnValue backsolveR( const real_t* const b,
00583 BooleanType transposed,
00584 BooleanType removingBound,
00585 real_t* const a
00586 ) const;
00587
00588
00591 returnValue determineDataShift( const real_t* const g_new,
00592 const real_t* const lb_new,
00593 const real_t* const ub_new,
00594 real_t* const delta_g,
00595 real_t* const delta_lb,
00596 real_t* const delta_ub,
00597 BooleanType& Delta_bB_isZero
00598 );
00599
00600
00604 returnValue setupQPdata( SymmetricMatrix *_H,
00605 const real_t* const _g,
00606 const real_t* const _lb,
00608 const real_t* const _ub
00610 );
00611
00618 returnValue setupQPdata( const real_t* const _H,
00620 const real_t* const _g,
00621 const real_t* const _lb,
00623 const real_t* const _ub
00625 );
00626
00635 returnValue setupQPdataFromFile( const char* const H_file,
00637 const char* const g_file,
00638 const char* const lb_file,
00640 const char* const ub_file
00642 );
00643
00649 returnValue loadQPvectorsFromFile( const char* const g_file,
00650 const char* const lb_file,
00652 const char* const ub_file,
00654 real_t* const g_new,
00655 real_t* const lb_new,
00656 real_t* const ub_new
00657 ) const;
00658
00659
00665 returnValue setInfeasibilityFlag( returnValue returnvalue
00666 );
00667
00668
00672 BooleanType isCPUtimeLimitExceeded( const real_t* const cputime,
00673 real_t starttime,
00674 int nWSR
00675 ) const;
00676
00677
00681 returnValue regulariseHessian( );
00682
00683
00686 inline returnValue setH( SymmetricMatrix* H_new
00687 );
00688
00694 inline returnValue setH( const real_t* const H_new
00695 );
00696
00700 inline returnValue setG( const real_t* const g_new
00701 );
00702
00706 inline returnValue setLB( const real_t* const lb_new
00707 );
00708
00712 inline returnValue setLB( int number,
00713 real_t value
00714 );
00715
00719 inline returnValue setUB( const real_t* const ub_new
00720 );
00721
00725 inline returnValue setUB( int number,
00726 real_t value
00727 );
00728
00729
00732 inline void computeGivens( real_t xold,
00733 real_t yold,
00734 real_t& xnew,
00735 real_t& ynew,
00736 real_t& c,
00737 real_t& s
00738 ) const;
00739
00742 inline void applyGivens( real_t c,
00743 real_t s,
00744 real_t nu,
00745 real_t xold,
00747 real_t yold,
00749 real_t& xnew,
00751 real_t& ynew
00753 ) const;
00754
00755
00756
00760 real_t relativeHomotopyLength( const real_t* const g_new,
00761 const real_t* const lb_new,
00762 const real_t* const ub_new
00763 );
00764
00768 virtual returnValue performRamping( );
00769
00770
00774 returnValue performRatioTest( int nIdx,
00775 const int* const idxList,
00776 const SubjectTo* const subjectTo,
00777 const real_t* const num,
00778 const real_t* const den,
00779 real_t epsNum,
00780 real_t epsDen,
00781 real_t& t,
00782 int& BC_idx
00783 ) const;
00784
00788 inline BooleanType isBlocking( real_t num,
00789 real_t den,
00790 real_t epsNum,
00791 real_t epsDen,
00792 real_t& t
00794 ) const;
00795
00796
00797
00798
00799
00800 private:
00812 returnValue solveInitialQP( const real_t* const xOpt,
00814 const real_t* const yOpt,
00816 const Bounds* const guessedBounds,
00818 int& nWSR,
00820 real_t* const cputime
00822 );
00823
00836 returnValue solveQP( const real_t* const g_new,
00837 const real_t* const lb_new,
00839 const real_t* const ub_new,
00841 int& nWSR,
00843 real_t* const cputime,
00845 int nWSRperformed = 0
00849 );
00850
00851
00864 returnValue solveRegularisedQP( const real_t* const g_new,
00865 const real_t* const lb_new,
00867 const real_t* const ub_new,
00869 int& nWSR,
00871 real_t* const cputime,
00873 int nWSRperformed = 0
00876 );
00877
00878
00886 returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds,
00887 BooleanType setupAfresh
00889 );
00890
00893 returnValue setupAuxiliaryQPsolution( const real_t* const xOpt,
00895 const real_t* const yOpt
00897 );
00898
00903 returnValue setupAuxiliaryQPgradient( );
00904
00910 returnValue setupAuxiliaryQPbounds( BooleanType useRelaxation
00911 );
00912
00913
00919 returnValue setupAuxiliaryQP( const Bounds* const guessedBounds
00920 );
00921
00925 returnValue determineStepDirection( const real_t* const delta_g,
00926 const real_t* const delta_lb,
00927 const real_t* const delta_ub,
00928 BooleanType Delta_bB_isZero,
00929 real_t* const delta_xFX,
00930 real_t* const delta_xFR,
00931 real_t* const delta_yFX
00932 );
00933
00939 returnValue performStep( const real_t* const delta_g,
00940 const real_t* const delta_lb,
00941 const real_t* const delta_ub,
00942 const real_t* const delta_xFX,
00943 const real_t* const delta_xFR,
00944 const real_t* const delta_yFX,
00945 int& BC_idx,
00946 SubjectToStatus& BC_status
00947 );
00948
00953 returnValue changeActiveSet( int BC_idx,
00954 SubjectToStatus BC_status
00955 );
00956
00959 returnValue performDriftCorrection( );
00960
00965 BooleanType shallRefactorise( const Bounds* const guessedBounds
00966 ) const;
00967
00968
00972 returnValue addBound( int number,
00973 SubjectToStatus B_status,
00974 BooleanType updateCholesky
00975 );
00976
00981 returnValue removeBound( int number,
00982 BooleanType updateCholesky
00983 );
00984
00985
00988 returnValue printIteration( int iteration,
00989 int BC_idx,
00990 SubjectToStatus BC_status
00991 );
00992
00993
00994
00995
00996
00997 protected:
00998 BooleanType freeHessian;
00999 SymmetricMatrix* H;
01001 real_t* g;
01002 real_t* lb;
01003 real_t* ub;
01005 Bounds bounds;
01007 real_t* R;
01008 BooleanType haveCholesky;
01010 real_t* x;
01011 real_t* y;
01013 real_t tau;
01015 QProblemStatus status;
01017 BooleanType infeasible;
01018 BooleanType unbounded;
01020 HessianType hessianType;
01021 BooleanType isRegularised;
01023 int count;
01025 real_t *delta_xFR_TMP;
01027 real_t ramp0;
01028 real_t ramp1;
01030 Options options;
01032 Flipper flipper;
01033 };
01034
01035
01036 END_NAMESPACE_QPOASES
01037
01038 #include <qpOASES/QProblemB.ipp>
01039
01040 #endif
01041
01042
01043
01044
01045