external_packages/qpOASES-3.0beta/include/qpOASES/QProblem.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2011 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
37 #ifndef QPOASES_QPROBLEM_HPP
38 #define QPOASES_QPROBLEM_HPP
39 
40 
41 #include <qpOASES/QProblemB.hpp>
42 #include <qpOASES/Constraints.hpp>
43 #include <qpOASES/ConstraintProduct.hpp>
44 #include <qpOASES/Matrices.hpp>
45 
46 
48 
49 
61 class QProblem : public QProblemB
62 {
63  /* allow SolutionAnalysis class to access private members */
64  friend class SolutionAnalysis;
65 
66  /*
67  * PUBLIC MEMBER FUNCTIONS
68  */
69  public:
71  QProblem( );
72 
78  QProblem( int _nV,
79  int _nC,
80  HessianType _hessianType = HST_UNKNOWN
81  );
82 
84  QProblem( const QProblem& rhs
85  );
86 
88  virtual ~QProblem( );
89 
91  QProblem& operator=( const QProblem& rhs
92  );
93 
94 
98  virtual returnValue reset( );
99 
100 
114  const real_t* const _g,
115  Matrix *_A,
116  const real_t* const _lb,
118  const real_t* const _ub,
120  const real_t* const _lbA,
122  const real_t* const _ubA,
124  int& nWSR,
126  real_t* const cputime
128  );
129 
130 
143  returnValue init( const real_t* const _H,
145  const real_t* const _g,
146  const real_t* const _A,
147  const real_t* const _lb,
149  const real_t* const _ub,
151  const real_t* const _lbA,
153  const real_t* const _ubA,
155  int& nWSR,
157  real_t* const cputime
159  );
160 
173  returnValue init( const char* const H_file,
175  const char* const g_file,
176  const char* const A_file,
177  const char* const lb_file,
179  const char* const ub_file,
181  const char* const lbA_file,
183  const char* const ubA_file,
185  int& nWSR,
187  real_t* const cputime
189  );
190 
211  const real_t* const _g,
212  Matrix *_A,
213  const real_t* const _lb,
215  const real_t* const _ub,
217  const real_t* const _lbA,
219  const real_t* const _ubA,
221  int& nWSR,
223  real_t* const cputime,
225  const real_t* const xOpt,
227  const real_t* const yOpt,
229  const Bounds* const guessedBounds,
230  const Constraints* const guessedConstraints
231  );
232 
252  returnValue init( const real_t* const _H,
254  const real_t* const _g,
255  const real_t* const _A,
256  const real_t* const _lb,
258  const real_t* const _ub,
260  const real_t* const _lbA,
262  const real_t* const _ubA,
264  int& nWSR,
266  real_t* const cputime,
268  const real_t* const xOpt,
270  const real_t* const yOpt,
272  const Bounds* const guessedBounds,
273  const Constraints* const guessedConstraints
274  );
275 
295  returnValue init( const char* const H_file,
297  const char* const g_file,
298  const char* const A_file,
299  const char* const lb_file,
301  const char* const ub_file,
303  const char* const lbA_file,
305  const char* const ubA_file,
307  int& nWSR,
309  real_t* const cputime,
311  const real_t* const xOpt,
313  const real_t* const yOpt,
315  const Bounds* const guessedBounds,
316  const Constraints* const guessedConstraints
317  );
318 
319 
333  returnValue hotstart( const real_t* const g_new,
334  const real_t* const lb_new,
336  const real_t* const ub_new,
338  const real_t* const lbA_new,
340  const real_t* const ubA_new,
342  int& nWSR,
344  real_t* const cputime
346  );
347 
364  returnValue hotstart( const char* const g_file,
365  const char* const lb_file,
367  const char* const ub_file,
369  const char* const lbA_file,
371  const char* const ubA_file,
373  int& nWSR,
375  real_t* const cputime
377  );
378 
393  returnValue hotstart( const real_t* const g_new,
394  const real_t* const lb_new,
396  const real_t* const ub_new,
398  const real_t* const lbA_new,
400  const real_t* const ubA_new,
402  int& nWSR,
404  real_t* const cputime,
406  const Bounds* const guessedBounds,
408  const Constraints* const guessedConstraints
410  );
411 
429  returnValue hotstart( const char* const g_file,
430  const char* const lb_file,
432  const char* const ub_file,
434  const char* const lbA_file,
436  const char* const ubA_file,
438  int& nWSR,
440  real_t* const cputime,
442  const Bounds* const guessedBounds,
444  const Constraints* const guessedConstraints
446  );
447 
452  returnValue solveCurrentEQP ( const int n_rhs,
453  const real_t* g_in,
454  const real_t* lb_in,
456  const real_t* ub_in,
458  const real_t* lbA_in,
460  const real_t* ubA_in,
461  real_t* x_out,
462  real_t* y_out
463  );
464 
465 
469  inline returnValue getConstraints( Constraints& _constraints
470  ) const;
471 
472 
475  inline int getNC( ) const;
476 
479  inline int getNEC( ) const;
480 
483  inline int getNAC( ) const;
484 
487  inline int getNIAC( ) const;
488 
491  virtual int getNZ( ) const;
492 
493 
497  virtual returnValue getDualSolution( real_t* const yOpt
498  ) const;
499 
500 
503  returnValue setConstraintProduct( ConstraintProduct* const _constraintProduct
504  );
505 
506 
509  virtual returnValue printProperties( );
510 
511 
512  /*
513  * PROTECTED MEMBER FUNCTIONS
514  */
515  protected:
518  returnValue clear( );
519 
522  returnValue copy( const QProblem& rhs
523  );
524 
537  returnValue solveInitialQP( const real_t* const xOpt,
539  const real_t* const yOpt,
541  const Bounds* const guessedBounds,
543  const Constraints* const guessedConstraints,
545  int& nWSR,
547  real_t* const cputime
549  );
550 
563  returnValue solveQP( const real_t* const g_new,
564  const real_t* const lb_new,
566  const real_t* const ub_new,
568  const real_t* const lbA_new,
570  const real_t* const ubA_new,
572  int& nWSR,
574  real_t* const cputime,
576  int nWSRperformed = 0
580  );
581 
582 
596  const real_t* const lb_new,
598  const real_t* const ub_new,
600  const real_t* const lbA_new,
602  const real_t* const ubA_new,
604  int& nWSR,
606  real_t* const cputime,
608  int nWSRperformed = 0
611  );
612 
613 
617  virtual returnValue setupSubjectToType( );
618 
622  virtual returnValue setupSubjectToType( const real_t* const lb_new,
623  const real_t* const ub_new,
624  const real_t* const lbA_new,
625  const real_t* const ubA_new
626  );
627 
635 
642 
647 
648 
657  const real_t* const yOpt,
659  const Bounds* const guessedBounds,
660  const Constraints* const guessedConstraints,
661  Bounds* auxiliaryBounds,
663  Constraints* auxiliaryConstraints
665  ) const;
666 
675  returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds,
676  const Constraints* const auxiliaryConstraints,
677  BooleanType setupAfresh
679  );
680 
685  const real_t* const yOpt
687  );
688 
694 
700  returnValue setupAuxiliaryQPbounds( const Bounds* const auxiliaryBounds,
701  const Constraints* const auxiliaryConstraints,
702  BooleanType useRelaxation
703  );
704 
705 
711  returnValue addConstraint( int number,
712  SubjectToStatus C_status,
713  BooleanType updateCholesky,
714  BooleanType ensureLI = BT_TRUE
715  );
716 
723  );
724 
733  returnValue addConstraint_ensureLI( int number,
734  SubjectToStatus C_status
735  );
736 
742  returnValue addBound( int number,
743  SubjectToStatus B_status,
744  BooleanType updateCholesky,
745  BooleanType ensureLI = BT_TRUE
746  );
747 
752  returnValue addBound_checkLI( int number
753  );
754 
763  returnValue addBound_ensureLI( int number,
764  SubjectToStatus B_status
765  );
766 
772  returnValue removeConstraint( int number,
773  BooleanType updateCholesky,
774  BooleanType allowFlipping = BT_FALSE,
775  BooleanType ensureNZC = BT_FALSE
776  );
777 
783  returnValue removeBound( int number,
784  BooleanType updateCholesky,
785  BooleanType allowFlipping = BT_FALSE,
786  BooleanType ensureNZC = BT_FALSE
787  );
788 
789 
794  const int* const idxList,
795  const real_t* const num,
796  const real_t* const den,
797  real_t epsNum,
798  real_t epsDen,
799  real_t& t,
800  int& BC_idx
801  ) const;
802 
803 
808  BooleanType removeBoundNotConstraint,
809  int remIdx,
810  BooleanType &exchangeHappened,
811  BooleanType &addBoundNotConstraint,
812  int &addIdx,
813  SubjectToStatus &addStatus
814  );
815 
816 
820  returnValue backsolveT( const real_t* const b,
821  BooleanType transposed,
822  real_t* const a
823  ) const;
824 
825 
829  const real_t* const lbA_new,
830  const real_t* const ubA_new,
831  const real_t* const lb_new,
832  const real_t* const ub_new,
833  real_t* const delta_g,
834  real_t* const delta_lbA,
835  real_t* const delta_ubA,
836  real_t* const delta_lb,
837  real_t* const delta_ub,
838  BooleanType& Delta_bC_isZero,
839  BooleanType& Delta_bB_isZero
840  );
841 
846  returnValue determineStepDirection( const real_t* const delta_g,
847  const real_t* const delta_lbA,
848  const real_t* const delta_ubA,
849  const real_t* const delta_lb,
850  const real_t* const delta_ub,
851  BooleanType Delta_bC_isZero,
852  BooleanType Delta_bB_isZero,
853  real_t* const delta_xFX,
854  real_t* const delta_xFR,
855  real_t* const delta_yAC,
856  real_t* const delta_yFX
857  );
858 
864  returnValue performStep( const real_t* const delta_g,
865  const real_t* const delta_lbA,
866  const real_t* const delta_ubA,
867  const real_t* const delta_lb,
868  const real_t* const delta_ub,
869  const real_t* const delta_xFX,
870  const real_t* const delta_xFR,
871  const real_t* const delta_yAC,
872  const real_t* const delta_yFX,
873  int& BC_idx,
874  SubjectToStatus& BC_status,
875  BooleanType& BC_isBound
876  );
877 
882  returnValue changeActiveSet( int BC_idx,
883  SubjectToStatus BC_status,
884  BooleanType BC_isBound
885  );
886 
887 
891  real_t relativeHomotopyLength( const real_t* const g_new,
892  const real_t* const lb_new,
893  const real_t* const ub_new,
894  const real_t* const lbA_new,
895  const real_t* const ubA_new
896  );
897 
898 
902  virtual returnValue performRamping( );
903 
904 
908 
909 
916  virtual returnValue setupAuxiliaryQP( const Bounds* const guessedBounds,
917  const Constraints* const guessedConstraints
918  );
919 
924  BooleanType shallRefactorise( const Bounds* const guessedBounds,
925  const Constraints* const guessedConstraints
926  ) const;
927 
934  const real_t* const _g,
935  Matrix *_A,
936  const real_t* const _lb,
938  const real_t* const _ub,
940  const real_t* const _lbA,
942  const real_t* const _ubA
944  );
945 
946 
953  returnValue setupQPdata( const real_t* const _H,
955  const real_t* const _g,
956  const real_t* const _A,
957  const real_t* const _lb,
959  const real_t* const _ub,
961  const real_t* const _lbA,
963  const real_t* const _ubA
965  );
966 
975  returnValue setupQPdataFromFile( const char* const H_file,
977  const char* const g_file,
978  const char* const A_file,
979  const char* const lb_file,
981  const char* const ub_file,
983  const char* const lbA_file,
985  const char* const ubA_file
987  );
988 
994  returnValue loadQPvectorsFromFile( const char* const g_file,
995  const char* const lb_file,
997  const char* const ub_file,
999  const char* const lbA_file,
1001  const char* const ubA_file,
1003  real_t* const g_new,
1004  real_t* const lb_new,
1005  real_t* const ub_new,
1006  real_t* const lbA_new,
1007  real_t* const ubA_new
1008  ) const;
1009 
1010 
1013  returnValue printIteration( int iteration,
1014  int BC_idx,
1015  SubjectToStatus BC_status,
1016  BooleanType BC_isBound
1017  );
1018 
1019 
1024  inline returnValue setA( Matrix *A_new
1025  );
1026 
1031  inline returnValue setA( const real_t* const A_new
1032  );
1033 
1034 
1038  inline returnValue setLBA( const real_t* const lbA_new
1039  );
1040 
1044  inline returnValue setLBA( int number,
1045  real_t value
1046  );
1047 
1051  inline returnValue setUBA( const real_t* const ubA_new
1052  );
1053 
1057  inline returnValue setUBA( int number,
1058  real_t value
1059  );
1060 
1061  /*
1062  * PROTECTED MEMBER VARIABLES
1063  */
1064  protected:
1075  int sizeT;
1093  int idxAddB;
1094  int idxRemB;
1095  int idxAddC;
1096  int idxRemC;
1097 };
1098 
1099 
1101 
1102 #include <qpOASES/QProblem.ipp>
1103 
1104 #endif /* QPOASES_QPROBLEM_HPP */
1105 
1106 
1107 /*
1108  * end of file
1109  */
returnValue addConstraint_ensureLI(int number, SubjectToStatus C_status)
returnValue addBound_ensureLI(int number, SubjectToStatus B_status)
returnValue setupQPdataFromFile(const char *const H_file, const char *const g_file, const char *const A_file, const char *const lb_file, const char *const ub_file, const char *const lbA_file, const char *const ubA_file)
returnValue solveCurrentEQP(const int n_rhs, const real_t *g_in, const real_t *lb_in, const real_t *ub_in, const real_t *lbA_in, const real_t *ubA_in, real_t *x_out, real_t *y_out)
returnValue init(const real_t *const _H, const real_t *const _g, const real_t *const _A, const real_t *const _lb, const real_t *const _ub, const real_t *const _lbA, const real_t *const _ubA, int &nWSR, const real_t *const yOpt=0, real_t *const cputime=0)
Interface for specifying user-defined evaluations of constraint products.
BooleanType shallRefactorise(const Bounds *const guessedBounds, const Constraints *const guessedConstraints) const
returnValue removeConstraint(int number, BooleanType updateCholesky)
Implements the online active set strategy for box-constrained QPs.
returnValue solveRegularisedQP(const real_t *const g_new, const real_t *const lb_new, const real_t *const ub_new, const real_t *const lbA_new, const real_t *const ubA_new, int &nWSR, real_t *const cputime, int nWSRperformed=0)
real_t relativeHomotopyLength(const real_t *const g_new, const real_t *const lb_new, const real_t *const ub_new, const real_t *const lbA_new, const real_t *const ubA_new)
returnValue setupAuxiliaryQPsolution(const real_t *const xOpt, const real_t *const yOpt)
Allows to pass back messages to the calling function.
returnValue setLBA(const real_t *const lbA_new)
returnValue ensureNonzeroCurvature(BooleanType removeBoundNotConstraint, int remIdx, BooleanType &exchangeHappened, BooleanType &addBoundNotConstraint, int &addIdx, SubjectToStatus &addStatus)
returnValue hotstart(const real_t *const g_new, const real_t *const lb_new, const real_t *const ub_new, const real_t *const lbA_new, const real_t *const ubA_new, int &nWSR, real_t *const cputime)
returnValue performPlainRatioTest(int nIdx, const int *const idxList, const real_t *const num, const real_t *const den, real_t epsNum, real_t epsDen, real_t &t, int &BC_idx) const
returnValue obtainAuxiliaryWorkingSet(const real_t *const xOpt, const real_t *const yOpt, const Bounds *const guessedBounds, const Constraints *const guessedConstraints, Bounds *auxiliaryBounds, Constraints *auxiliaryConstraints) const
returnValue solveInitialQP(const real_t *const xOpt, const real_t *const yOpt, const Bounds *const guessedBounds, const Constraints *const guessedConstraints, int &nWSR, real_t *const cputime)
int getNAC()
returnValue setupQPdata(const real_t *const _H, const real_t *const _g, const real_t *const _A, const real_t *const _lb, const real_t *const _ub, const real_t *const _lbA, const real_t *const _ubA)
returnValue backsolveT(const real_t *const b, BooleanType transposed, real_t *const a)
returnValue changeActiveSet(int BC_idx, SubjectToStatus BC_status, BooleanType BC_isBound)
returnValue setConstraintProduct(ConstraintProduct *const _constraintProduct)
returnValue setupAuxiliaryQPbounds(const Bounds *const auxiliaryBounds, const Constraints *const auxiliaryConstraints, BooleanType useRelaxation)
returnValue getConstraints(Constraints *const _constraints) const
int getNEC() const
returnValue determineStepDirection(const real_t *const delta_g, const real_t *const delta_lbA, const real_t *const delta_ubA, const real_t *const delta_lb, const real_t *const delta_ub, BooleanType Delta_bC_isZero, BooleanType Delta_bB_isZero, real_t *const delta_xFX, real_t *const delta_xFR, real_t *const delta_yAC, real_t *const delta_yFX)
Abstract base class for interfacing tailored matrix-vector operations.
returnValue loadQPvectorsFromFile(const char *const g_file, const char *const lb_file, const char *const ub_file, const char *const lbA_file, const char *const ubA_file, real_t *const g_new, real_t *const lb_new, real_t *const ub_new, real_t *const lbA_new, real_t *const ubA_new) const
void rhs(const real_t *x, real_t *f)
returnValue solveQP(const real_t *const g_new, const real_t *const lb_new, const real_t *const ub_new, const real_t *const lbA_new, const real_t *const ubA_new, int &nWSR, real_t *const cputime, int nWSRperformed=0)
int getNC() const
returnValue addBound(int number, SubjectToStatus B_status, BooleanType updateCholesky)
returnValue copy(const QProblem &rhs)
returnValue performStep(const real_t *const delta_g, const real_t *const delta_lbA, const real_t *const delta_ubA, const real_t *const delta_lb, const real_t *const delta_ub, const real_t *const delta_xFX, const real_t *const delta_xFR, const real_t *const delta_yAC, const real_t *const delta_yFX, int &BC_idx, SubjectToStatus &BC_status, BooleanType &BC_isBound)
virtual returnValue setupAuxiliaryQP(const Bounds *const guessedBounds, const Constraints *const guessedConstraints)
#define BT_TRUE
Definition: acado_types.hpp:47
returnValue removeBound(int number, BooleanType updateCholesky)
returnValue determineDataShift(const real_t *const g_new, const real_t *const lbA_new, const real_t *const ubA_new, const real_t *const lb_new, const real_t *const ub_new, real_t *const delta_g, real_t *const delta_lbA, real_t *const delta_ubA, real_t *const delta_lb, real_t *const delta_ub, BooleanType &Delta_bC_isZero, BooleanType &Delta_bB_isZero)
#define HST_UNKNOWN
#define BT_FALSE
Definition: acado_types.hpp:49
Manages working sets of bounds (= box constraints).
returnValue printIteration(int iteration, int BC_idx, SubjectToStatus BC_status, BooleanType BC_isBound)
double real_t
Definition: AD_test.c:10
Implements the online active set strategy for QPs with general constraints.
returnValue setupAuxiliaryWorkingSet(const Bounds *const auxiliaryBounds, const Constraints *const auxiliaryConstraints, BooleanType setupAfresh)
returnValue setA(const real_t *const A_new)
returnValue setUBA(const real_t *const ubA_new)
int getNIAC()
returnValue addConstraint(int number, SubjectToStatus C_status, BooleanType updateCholesky)
Abstract base class for interfacing matrix-vector operations tailored to symmetric matrices...


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:01