Class QPOasesBackEnd
Defined in File QPOasesBackEnd.h
Inheritance Relationships
Base Type
public OpenSoT::solvers::BackEnd
(Class BackEnd)
Class Documentation
-
class QPOasesBackEnd : public OpenSoT::solvers::BackEnd
The QPOasesBackEnd class handle variables, options and execution of a single qpOases problem.
Is implemented using Eigen. Based on the qpOASES solver https://github.com/coin-or/qpOASES This represent the Back-End.
Public Functions
-
QPOasesBackEnd(const int number_of_variables, const int number_of_constraints, OpenSoT::HessianType hessian_type = OpenSoT::HST_UNKNOWN, const double eps_regularisation = QPOASES_DEFAULT_EPS_REGULARISATION)
QPOasesBackEnd constructor with creation of a QP problem.
- Parameters
number_of_variables – of the QP problem
number_of_constraints – of the QP problem
hessian_type – of the QP problem
eps_regularization – set the Scaling factor of identity matrix used for Hessian regularisation. final_eps_regularisation = standard_eps_regularisation * eps_regularisation this parameter is particular important for the optimization!
-
~QPOasesBackEnd()
~QPOasesBackEnd destructor
-
void setDefaultOptions()
setDefaultOptions to internal qpOases problem.
Default are set to: opt.setToMPC(); opt.printLevel = qpOASES::PL_NONE; opt.enableRegularisation = qpOASES::BT_TRUE; opt.epsRegularisation *= _epsRegularisation; opt.numRegularisationSteps = 2; opt.numRefinementSteps = 1; opt.enableFlippingBounds = qpOASES::BT_TRUE;
-
inline const std::shared_ptr<qpOASES::SQProblem> &getProblem()
getProblem return the internal QP problem
- Returns
reference to internal QP problem
-
virtual boost::any getOptions()
getOptions return the options of the QP problem
- Returns
options
-
virtual void setOptions(const boost::any &options)
setOptions of the QP problem.
- Parameters
options –
-
virtual bool initProblem(const Eigen::MatrixXd &H, const Eigen::VectorXd &g, const Eigen::MatrixXd &A, const Eigen::VectorXd &lA, const Eigen::VectorXd &uA, const Eigen::VectorXd &l, const Eigen::VectorXd &u)
initProblem initialize the QP problem and get the solution, the dual solution, bounds and constraints.
The QP problem has the following structure:
st. lA <= Ax <= uA l <= x <= umin = ||Hx - g||
- Parameters
H – Task Matrix
g – Task references
A – Constraint Matrix
lA – lower constraint Eigen::VectorXd
uA – upper constraint Eigen::VectorXd
l – lower bounds
u – upper bounds
- Returns
true if the problem can be solved
-
virtual bool updateTask(const Eigen::MatrixXd &H, const Eigen::VectorXd &g)
This set of function update current problem copying input data.
Use these methods to update existing matrices of the QP problem.
updateTask update internal H and g: _H = H _g = g for now is not possible to have different size of H and g wrt internal ones
- Parameters
H – updated task matrix
g – updated reference Eigen::VectorXd
- Returns
true if task is correctly updated
-
virtual bool updateConstraints(const Eigen::Ref<const Eigen::MatrixXd> &A, const Eigen::Ref<const Eigen::VectorXd> &lA, const Eigen::Ref<const Eigen::VectorXd> &uA)
updateConstraints update internal A, lA and uA _A = A _lA = lA _uA = uA A, lA and uA can change rows size to allow variable constraints
- Parameters
A – update constraint matrix
lA – update lower constraint Eigen::VectorXd
uA – update upper constraint Eigen::VectorXd
- Returns
true if constraints are correctly updated
-
virtual bool solve()
solve the QP problem
- Returns
true if the QP problem is solved
-
OpenSoT::HessianType getHessianType()
getHessianType return the hessian type f the problem
- Returns
hessian type
-
void setHessianType(const OpenSoT::HessianType ht)
setHessianType of the problem
- Parameters
ht – hessian type
-
inline int getnWSR()
getnWSR return maximum number of working set recalculations
- Returns
maximum number of working set recalculations
-
inline void setnWSR(const int nWSR)
setnWSR set maximum number of working set recalculations
- Parameters
nWSR – Maximum number of working set recalculations
-
inline const qpOASES::Bounds &getActiveBounds()
getActiveBounds return the active bounds of the solved QP problem
- Returns
active bounds
-
inline const qpOASES::Constraints &getActiveConstraints()
getActiveConstraints return the active constraints of the solved QP problem
- Returns
active constraints
-
virtual void _printProblemInformation()
printProblemInformation print some extra information about the problem
- Parameters
problem_number – a number to identify the problem
problem_id – a string to identify the problem
constraints_id – a string to identify the constraints associated to the problem
bounds_id – a string to identify the bounds associated to the problem
-
virtual double getObjective()
getObjective return the value of the cost function at the optimum
- Returns
finite value: Optimal objective function value (QP was solved) +infinity: QP was not yet solved
-
virtual bool setEpsRegularisation(const double eps)
setEpsRegularisation OVERWRITES the actual eps regularisation factor
- Parameters
eps – the new regularisation factor
- Returns
false if eps < 0
-
inline virtual double getEpsRegularisation()
getEpsRegularisation return internal solver eps
- Returns
eps value
Protected Functions
-
void printConstraintsInfo()
printConstraintsInfo function that print informations when the problem is not feasible
-
void checkINFTY()
checkINFTY if a bound/constraint is set to a value less than -INFTY then the bound/constraint is set to -INFTY, if a bound/constraint is set to a value more than INFTY then the bound/constraint is set to INFTY.
Protected Attributes
-
std::shared_ptr<qpOASES::SQProblem> _problem
_problem is the internal SQProblem
-
std::shared_ptr<qpOASES::Bounds> _bounds
_bounds are the active bounds of the SQProblem
-
std::shared_ptr<qpOASES::Constraints> _constraints
_constraints are the active constraints of the SQProblem
-
int _nWSR
_nWSR is the maximum number of working set recalculations
-
double _epsRegularisation
_epsRegularisation is a factor that multiplies standard epsRegularisation of qpOases
-
std::shared_ptr<qpOASES::Options> _opt
_opt solver options
-
Eigen::VectorXd _dual_solution
Solution of the QP problem.
-
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> _A_rm
-
QPOasesBackEnd(const int number_of_variables, const int number_of_constraints, OpenSoT::HessianType hessian_type = OpenSoT::HST_UNKNOWN, const double eps_regularisation = QPOASES_DEFAULT_EPS_REGULARISATION)