solvers/solver-osqp.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2022 INRIA
3 //
4 // This file is part of tsid
5 // tsid is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 // tsid is distributed in the hope that it will be
10 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Lesser Public License for more details. You should have
13 // received a copy of the GNU Lesser General Public License along with
14 // tsid If not, see
15 // <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef __solvers_osqp_hpp__
19 #define __solvers_osqp_hpp__
20 
22 #include "OsqpEigen/OsqpEigen.h"
23 #include <Eigen/Sparse>
24 
25 #ifdef PROFILE_OSQP
26 #define START_PROFILER_OSQP(x) START_PROFILER(x)
27 #define STOP_PROFILER_OSQP(x) STOP_PROFILER(x)
28 #else
29 #define START_PROFILER_OSQP(x)
30 #define STOP_PROFILER_OSQP(x)
31 #endif
32 
33 namespace tsid {
34 namespace solvers {
38 class TSID_DLLAPI SolverOSQP : public SolverHQPBase {
39  public:
40  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
41 
47 
48  SolverOSQP(const std::string& name);
49  SolverOSQP(const SolverOSQP& other);
50 
51  void resize(unsigned int n, unsigned int neq, unsigned int nin) override;
52 
54  void retrieveQPData(const HQPData& problemData,
55  const bool hessianRegularization = false) override;
56 
58  const QPData getQPData() const { return m_qpData; }
59 
61  const HQPOutput& solve(const HQPData& problemData) override;
62 
64  double getObjectiveValue() override;
65 
67  bool setMaximumIterations(unsigned int maxIter) override;
68 
69  void setSigma(double sigma);
70  void setAlpha(double alpha);
71  void setRho(double rho);
72  void setEpsilonAbsolute(double epsAbs);
73  void setEpsilonRelative(double epsRel);
74  void setVerbose(bool isVerbose = false);
75 
76  protected:
77  void sendMsg(const std::string& s);
78 
79  double m_objValue;
81 
82  OsqpEigen::Solver m_solver;
83 
84  unsigned int m_neq;
85  unsigned int m_nin;
86  unsigned int m_n;
87 
89 
90  double m_rho;
91  double m_sigma;
92  double m_alpha;
93  double m_epsAbs;
94  double m_epsRel;
97 };
98 } // namespace solvers
99 } // namespace tsid
100 
101 #endif // ifndef __solvers_osqp_hpp__
tsid::solvers::SolverOSQP::m_neq
unsigned int m_neq
Definition: solvers/solver-osqp.hpp:84
tsid::solvers::SolverOSQP::m_alpha
double m_alpha
Definition: solvers/solver-osqp.hpp:92
tsid::solvers::SolverOSQP::m_isVerbose
bool m_isVerbose
Definition: solvers/solver-osqp.hpp:95
tsid::solvers::SolverOSQP
Definition: solvers/solver-osqp.hpp:38
tsid::solvers::SolverOSQP::Vector
math::Vector Vector
Definition: solvers/solver-osqp.hpp:43
tsid::solvers::SolverOSQP::Matrix
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef math::Matrix Matrix
Definition: solvers/solver-osqp.hpp:42
test_Solvers.neq
int neq
Definition: test_Solvers.py:13
tsid::solvers::SolverOSQP::m_epsAbs
double m_epsAbs
Definition: solvers/solver-osqp.hpp:93
tsid::solvers::SolverOSQP::m_isDataInitialized
bool m_isDataInitialized
Definition: solvers/solver-osqp.hpp:96
tsid::solvers::SolverOSQP::m_qpData
QPDataTpl< double > m_qpData
number of variables
Definition: solvers/solver-osqp.hpp:88
tsid::solvers::SolverOSQP::m_rho
double m_rho
Definition: solvers/solver-osqp.hpp:90
tsid::solvers::SolverOSQP::ConstRefMatrix
math::ConstRefMatrix ConstRefMatrix
Definition: solvers/solver-osqp.hpp:46
tsid::solvers::QPDataTpl< double >
solve
Mat & solve(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< Mat > &y)
tsid::solvers::SolverOSQP::m_epsRel
double m_epsRel
Definition: solvers/solver-osqp.hpp:94
tsid::math::RefVector
Eigen::Ref< Vector > RefVector
Definition: math/fwd.hpp:47
tsid::solvers::HQPOutput
Definition: solver-HQP-output.hpp:29
tsid::solvers::SolverOSQP::m_hessian_regularization
double m_hessian_regularization
Definition: solvers/solver-osqp.hpp:80
tsid::solvers::SolverHQPBase
Abstract interface for a Quadratic Program (HQP) solver.
Definition: solver-HQP-base.hpp:34
test_Solvers.nin
int nin
Definition: test_Solvers.py:14
tsid::math::Matrix
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition: math/fwd.hpp:36
setup.name
name
Definition: setup.in.py:179
solver-HQP-base.hpp
tsid::math::ConstRefVector
const typedef Eigen::Ref< const Vector > ConstRefVector
Definition: math/fwd.hpp:48
tsid::solvers::SolverOSQP::m_nin
unsigned int m_nin
number of equality constraints
Definition: solvers/solver-osqp.hpp:85
tsid::math::Vector
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hpp:35
tsid::solvers::SolverOSQP::m_solver
OsqpEigen::Solver m_solver
Definition: solvers/solver-osqp.hpp:82
tsid::solvers::SolverOSQP::m_sigma
double m_sigma
Definition: solvers/solver-osqp.hpp:91
tsid::solvers::SolverOSQP::getQPData
const QPData getQPData() const
Definition: solvers/solver-osqp.hpp:58
tsid
Definition: bindings/python/constraint/constraint-bound.cpp:21
test_Formulation.s
s
Definition: test_Formulation.py:115
tsid::math::ConstRefMatrix
const typedef Eigen::Ref< const Matrix > ConstRefMatrix
Definition: math/fwd.hpp:51
tsid::solvers::SolverOSQP::ConstRefVector
math::ConstRefVector ConstRefVector
Definition: solvers/solver-osqp.hpp:45
ex_4_conf.alpha
int alpha
Definition: ex_4_conf.py:41
tsid::solvers::SolverOSQP::m_objValue
double m_objValue
Definition: solvers/solver-osqp.hpp:79
tsid::solvers::SolverOSQP::RefVector
math::RefVector RefVector
Definition: solvers/solver-osqp.hpp:44
tsid::solvers::HQPData
pinocchio::container::aligned_vector< ConstraintLevel > HQPData
Definition: solvers/fwd.hpp:99
n
Vec3f n
tsid::solvers::SolverOSQP::m_n
unsigned int m_n
number of inequality constraints
Definition: solvers/solver-osqp.hpp:86


tsid
Author(s): Andrea Del Prete, Justin Carpentier
autogenerated on Thu Apr 3 2025 02:47:16