26 #ifndef CASADI_QPOASES_INTERFACE_HPP
27 #define CASADI_QPOASES_INTERFACE_HPP
29 #include "casadi/core/conic_impl.hpp"
30 #include "casadi/core/linsol.hpp"
31 #include <casadi/interfaces/qpoases/casadi_conic_qpoases_export.h>
32 #include <qpOASES.hpp>
47 class QpoasesInterface;
49 struct QpoasesMemory :
public ConicMemory {
54 std::string linsol_plugin;
58 qpOASES::SQProblem *sqp;
59 qpOASES::QProblemB *qp;
63 qpOASES::SymSparseMat *h;
64 qpOASES::SparseMatrix *a;
70 std::vector<casadi_int> lin_map;
73 std::vector<casadi_int> row, col, nz_map;
75 std::vector<int> h_row, h_colind, a_row, a_colind;
78 std::vector<double> nz;
98 class QpoasesInterface :
public Conic {
101 explicit QpoasesInterface();
104 static Conic* creator(
const std::string& name,
105 const std::map<std::string, Sparsity>& st) {
106 return new QpoasesInterface(name, st);
110 explicit QpoasesInterface(
const std::string& name,
111 const std::map<std::string, Sparsity>& st);
114 ~QpoasesInterface()
override;
117 const char* plugin_name()
const override {
return "qpoases";}
120 std::string class_name()
const override {
return "QpoasesInterface";}
124 static const Options options_;
125 const Options& get_options()
const override {
return options_;}
129 void init(
const Dict& opts)
override;
132 void* alloc_mem()
const override {
return new QpoasesMemory();}
135 int init_mem(
void* mem)
const override;
138 void free_mem(
void *mem)
const override {
delete static_cast<QpoasesMemory*
>(mem);}
141 int solve(
const double** arg,
double** res,
142 casadi_int* iw,
double* w,
void* mem)
const override;
145 static const std::string meta_doc;
148 static int qpoases_init(
void* mem,
int dim,
int nnz,
const int* row,
const int* col);
151 static int qpoases_sfact(
void* mem,
const double* vals);
154 static int qpoases_nfact(
void* mem,
const double* vals,
int* neig,
int* rank);
157 static int qpoases_solve(
void* mem,
int nrhs,
double* rhs);
160 static void qpoases_printf(
const char* s);
163 Dict get_stats(
void* mem)
const override;
167 void serialize_body(SerializingStream &s)
const override;
170 static ProtoFunction* deserialize(DeserializingStream& s) {
return new QpoasesInterface(s); }
174 explicit QpoasesInterface(DeserializingStream& s);
178 static bool from_BooleanType(qpOASES::BooleanType b);
179 static qpOASES::BooleanType to_BooleanType(
bool b);
180 static std::string from_SubjectToStatus(qpOASES::SubjectToStatus b);
181 static qpOASES::SubjectToStatus to_SubjectToStatus(std::string b);
182 static std::string from_PrintLevel(qpOASES::PrintLevel b);
183 static qpOASES::PrintLevel to_PrintLevel(std::string b);
188 casadi_int max_nWSR_;
190 qpOASES::Options ops_;
191 qpOASES::HessianType hess_;
194 casadi_int max_schur_;
195 std::string linsol_plugin_;
199 static void qpoases_error(
const std::string& module, casadi_int flag);
202 static std::string getErrorMessage(casadi_int flag);
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.