26 #ifndef CASADI_HPMPC_INTERFACE_HPP
27 #define CASADI_HPMPC_INTERFACE_HPP
29 #include "casadi/core/conic_impl.hpp"
30 #include "casadi/core/linsol.hpp"
31 #include <casadi/interfaces/hpmpc/casadi_conic_hpmpc_export.h>
63 #include <c_interface.h>
75 struct HpmpcMemory :
public ConicMemory {
77 std::vector<double> A, B, b, b2, Q, S, R, q, r, lb, ub, C, D, lg, ug;
78 std::vector<double*> As, Bs, bs, Qs, Ss, Rs, qs, rs, lbs, ubs, Cs, Ds, lgs, ugs;
80 std::vector<double> I;
81 std::vector<double*> Is;
82 std::vector<double> x, u, pi, lam;
83 std::vector<double*> xs, us, pis, lams;
85 std::vector<int> hidxb;
86 std::vector<int*> hidxbs;
92 std::vector<double> stats;
94 std::vector<char> workspace;
96 std::vector<double> pv;
100 std::vector<double> res;
118 class HpmpcInterface :
public Conic {
121 explicit HpmpcInterface();
124 static Conic* creator(
const std::string& name,
125 const std::map<std::string, Sparsity>& st) {
126 return new HpmpcInterface(name, st);
130 explicit HpmpcInterface(
const std::string& name,
131 const std::map<std::string, Sparsity>& st);
134 Dict get_stats(
void* mem)
const override;
137 ~HpmpcInterface()
override;
140 const char* plugin_name()
const override {
return "hpmpc";}
143 std::string class_name()
const override {
return "HpmpcInterface";}
147 static const Options options_;
148 const Options& get_options()
const override {
return options_;}
152 void init(
const Dict& opts)
override;
155 void* alloc_mem()
const override {
return new HpmpcMemory();}
158 int init_mem(
void* mem)
const override;
161 void free_mem(
void *mem)
const override {
delete static_cast<HpmpcMemory*
>(mem);}
164 int solve(
const double** arg,
double** res,
165 casadi_int* iw,
double* w,
void* mem)
const override;
168 static void mproject(
double factor,
const double* x,
const casadi_int* sp_x,
169 double* y,
const casadi_int* sp_y,
double* w);
173 static void dense_transfer(
double factor,
const double* x,
const casadi_int* sp_x,
double* y,
174 const casadi_int* sp_y,
double* w);
177 static const std::string meta_doc;
181 typedef int (*Work_size)(
int N,
int *nx,
int *nu,
int *nb,
int **hidxb,
int *ng,
int N2);
183 typedef int (*Ocp_solve)(
int *kk,
int k_max,
double mu0,
double mu_tol,
184 int N,
int *nx,
int *nu,
int *nb,
int **hidxb,
int *ng,
int N2,
int warm_start,
185 double **A,
double **B,
double **b,
double **Q,
double **S,
double **R,
double **q,
186 double **r,
double **lb,
double **ub,
double **C,
double **D,
double **lg,
double **ug,
187 double **x,
double **u,
double **pi,
double **lam,
188 double *inf_norm_res,
void *work0,
double *stat);
200 static Sparsity blocksparsity(casadi_int rows, casadi_int cols,
201 const std::vector<Block>& blocks,
bool eye=
false);
202 static void blockptr(std::vector<double *>& vs, std::vector<double>& v,
203 const std::vector<Block>& blocks,
bool eye=
false);
204 Sparsity Asp_, Bsp_, Csp_, Dsp_, Isp_, Rsp_, Ssp_, Qsp_, bsp_, lugsp_, usp_, xsp_;
205 Sparsity theirs_xsp_, theirs_usp_, theirs_Xsp_, theirs_Usp_;
206 Sparsity lamg_gapsp_, lamg_csp_, lam_ulsp_, lam_uusp_, lam_xlsp_, lam_xusp_, lam_clsp_;
207 Sparsity lam_cusp_, pisp_;
209 std::vector< Block > R_blocks, S_blocks, Q_blocks;
210 std::vector< Block > b_blocks, lug_blocks;
211 std::vector< Block > u_blocks, x_blocks;
212 std::vector< Block > lam_ul_blocks, lam_xl_blocks, lam_uu_blocks, lam_xu_blocks, lam_cl_blocks;
213 std::vector< Block > lam_cu_blocks, A_blocks, B_blocks, C_blocks, D_blocks, I_blocks;
215 std::vector<casadi_int> nxs_;
216 std::vector<casadi_int> nus_;
217 std::vector<casadi_int> ngs_;
219 casadi_int print_level_;
225 casadi_int max_iter_;
228 std::string blasfeo_target_;
232 Work_size hpmpc_d_ip_ocp_hard_tv_work_space_size_bytes;
233 Ocp_solve fortran_order_d_ip_ocp_hard_tv;
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.