25 #ifndef SRC_OPTIMIZATION_INCLUDE_CORBO_OPTIMIZATION_SOLVER_QP_SOLVER_OSQP_H_ 26 #define SRC_OPTIMIZATION_INCLUDE_CORBO_OPTIMIZATION_SOLVER_QP_SOLVER_OSQP_H_ 47 class SolverOsqp :
public QpSolverInterface
50 using Ptr = std::shared_ptr<SolverOsqp>;
51 using UPtr = std::unique_ptr<SolverOsqp>;
71 bool zero_x_warmstart =
false)
override;
76 bool update_q =
true,
bool update_A =
true,
bool update_bounds =
true)
override;
84 void enforceNewStructure(
bool new_structure =
true)
override { _force_new_structure = new_structure; }
88 OSQPSettings* getOsqpSettings() {
return _settings.get(); }
91 void clear()
override;
93 #ifdef MESSAGE_SUPPORT 94 void toMessage(corbo::messages::SolverOsqp& message)
const;
97 void fromMessage(
const corbo::messages::SolverOsqp& message, std::stringstream* issues =
nullptr);
100 void toMessage(corbo::messages::QpSolver& message)
const override { toMessage(*message.mutable_solver_osqp()); }
102 void fromMessage(
const corbo::messages::QpSolver& message, std::stringstream* issues =
nullptr)
override 104 fromMessage(message.solver_osqp(), issues);
109 SolverStatus convertOsqpExitFlagToSolverStatus(c_int status)
const;
112 std::unique_ptr<OSQPSettings> _settings;
114 OSQPWorkspace* _work =
nullptr;
116 Eigen::VectorXd _zero;
118 bool _force_new_structure =
false;
120 bool _initialized =
false;
137 using Ptr = std::shared_ptr<SolverOsqp>;
138 using UPtr = std::unique_ptr<SolverOsqp>;
149 bool zero_x_warmstart =
false)
override 158 bool update_q =
true,
bool update_A =
true,
bool update_bounds =
true)
override 174 #ifdef MESSAGE_SUPPORT 176 void toMessage(corbo::messages::QpSolver& )
const override {
printWarning(); }
178 void fromMessage(
const corbo::messages::QpSolver& , std::stringstream* issues)
override 180 if (issues) *issues <<
"SolverOsqp cannot be selected since it is not installed properly." << std::endl;
196 #endif // SRC_OPTIMIZATION_INCLUDE_CORBO_OPTIMIZATION_SOLVER_QP_SOLVER_OSQP_H_ SolverStatus solve(SparseMatrix &P, Eigen::Ref< Eigen::VectorXd > q, SparseMatrix &A, Eigen::Ref< Eigen::VectorXd > lbA, Eigen::Ref< Eigen::VectorXd > ubA, Eigen::Ref< Eigen::VectorXd > lb, Eigen::Ref< Eigen::VectorXd > ub, bool new_structure=true, bool zero_x_warmstart=false) override
Solve full QP.
std::shared_ptr< SolverOsqp > Ptr
Interface to the external solver OSQP.
void clear() override
clear internal caches
void updatePrimalSolutionWarmStart(const Eigen::Ref< const Eigen::VectorXd > &x) override
A versatible sparse matrix representation.
#define PRINT_WARNING(msg)
Print msg-stream.
Eigen::SparseMatrix< double, Eigen::ColMajor, long long > SparseMatrix
bool isSupportingSimpleBounds() override
Generic interface for QP solver implementations.
#define FACTORY_REGISTER_QP_SOLVER(type)
MatrixType A(a, *n, *n, *lda)
void printWarning() const
Eigen::Ref< Eigen::VectorXd > getDualSolution() override
std::unique_ptr< SolverOsqp > UPtr
virtual bool initialize()
Initialize the qp solver.
SolverStatus solve(SparseMatrix &P, Eigen::Ref< Eigen::VectorXd > q, SparseMatrix &A, Eigen::Ref< Eigen::VectorXd > lbA, Eigen::Ref< Eigen::VectorXd > ubA, bool new_structure=true, bool zero_x_warmstart=false, bool update_P=true, bool update_q=true, bool update_A=true, bool update_bounds=true) override
Solve QP without simple bounds.
EIGEN_DEVICE_FUNC const Scalar & q
Eigen::Ref< Eigen::VectorXd > getPrimalSolution() override
A matrix or vector expression mapping an existing expression.
QpSolverInterface::Ptr getInstance() const override
Return a newly created instance of the current solver.
std::shared_ptr< QpSolverInterface > Ptr
void updateDualSolutionWarmStart(const Eigen::Ref< const Eigen::VectorXd > &y) override
void enforceNewStructure(bool new_structure=true) override
std::unique_ptr< QpSolverInterface > UPtr