26 #ifndef CASADI_HPIPM_INTERFACE_HPP
27 #define CASADI_HPIPM_INTERFACE_HPP
29 #include "casadi/core/conic_impl.hpp"
30 #include "casadi/core/linsol.hpp"
31 #include <casadi/interfaces/hpipm/casadi_conic_hpipm_export.h>
59 #include <blasfeo_d_aux_ext_dep.h>
61 #include <hpipm_d_ocp_qp_ipm.h>
62 #include <hpipm_d_ocp_qp_dim.h>
63 #include <hpipm_d_ocp_qp.h>
64 #include <hpipm_d_ocp_qp_sol.h>
65 #include <hpipm_d_ocp_qp_utils.h>
69 #include "hpipm_runtime.hpp"
78 struct HpipmMemory :
public ConicMemory {
100 class HpipmInterface :
public Conic {
103 explicit HpipmInterface();
106 static Conic* creator(
const std::string& name,
107 const std::map<std::string, Sparsity>& st) {
108 return new HpipmInterface(name, st);
112 explicit HpipmInterface(
const std::string& name,
113 const std::map<std::string, Sparsity>& st);
116 Dict get_stats(
void* mem)
const override;
119 ~HpipmInterface()
override;
122 const char* plugin_name()
const override {
return "hpipm";}
125 std::string class_name()
const override {
return "HpipmInterface";}
129 static const Options options_;
130 const Options& get_options()
const override {
return options_;}
133 void set_hpipm_prob();
134 void set_hpipm_prob(CodeGenerator& g)
const;
137 void codegen_body(CodeGenerator& g)
const override;
140 void init(
const Dict& opts)
override;
143 void* alloc_mem()
const override {
return new HpipmMemory();}
146 int init_mem(
void* mem)
const override;
149 void free_mem(
void *mem)
const override {
delete static_cast<HpipmMemory*
>(mem);}
152 void set_work(
void* mem,
const double**& arg,
double**& res,
153 casadi_int*& iw,
double*& w)
const override;
156 int solve(
const double** arg,
double** res,
157 casadi_int* iw,
double* w,
void* mem)
const override;
160 static void mproject(
double factor,
const double* x,
const casadi_int* sp_x,
161 double* y,
const casadi_int* sp_y,
double* w);
165 static void dense_transfer(
double factor,
const double* x,
const casadi_int* sp_x,
double* y,
166 const casadi_int* sp_y,
double* w);
169 static const std::string meta_doc;
171 void serialize_body(SerializingStream &s)
const override;
174 static ProtoFunction* deserialize(DeserializingStream& s) {
return new HpipmInterface(s); }
177 explicit HpipmInterface(DeserializingStream& s);
182 static Sparsity blocksparsity(casadi_int rows, casadi_int cols,
183 const std::vector<casadi_hpipm_block>& blocks,
bool eye=
false);
184 static void blockptr(std::vector<double *>& vs, std::vector<double>& v,
185 const std::vector<casadi_hpipm_block>& blocks,
bool eye=
false);
186 Sparsity Asp_, Bsp_, Csp_, Dsp_, Isp_, Rsp_, Ssp_, Qsp_, bsp_, lugsp_, usp_, xsp_;
187 Sparsity theirs_xsp_, theirs_usp_, theirs_Xsp_, theirs_Usp_;
188 Sparsity lamg_gapsp_;
189 Sparsity lam_cusp_, pisp_;
191 std::vector< casadi_hpipm_block > R_blocks, S_blocks, Q_blocks;
192 std::vector< casadi_hpipm_block > b_blocks, lug_blocks;
193 std::vector< casadi_hpipm_block > u_blocks, x_blocks;
194 std::vector< casadi_hpipm_block > lam_ul_blocks, lam_xl_blocks,
195 lam_uu_blocks, lam_xu_blocks, lam_cl_blocks;
196 std::vector< casadi_hpipm_block > lam_cu_blocks, A_blocks, B_blocks,
197 C_blocks, D_blocks, I_blocks;
199 std::vector<int> nxs_;
200 std::vector<int> nus_;
201 std::vector<int> ngs_;
202 std::vector<int> zeros_;
204 casadi_int print_level_;
209 d_ocp_qp_ipm_arg hpipm_options_;
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.