From a4d8266f6115a2caa98a13f2de3c28629448b88c Mon Sep 17 00:00:00 2001 From: giaf Date: Thu, 10 Aug 2023 12:14:19 +0200 Subject: [PATCH] dense_qp: add codegen --- dense_qp/d_dense_qp_utils.c | 3 + dense_qp/s_dense_qp_utils.c | 3 + dense_qp/x_dense_qp_utils.c | 615 ++++++++++++++++++++++++++++++- include/hpipm_d_dense_qp_utils.h | 6 +- include/hpipm_s_dense_qp_utils.h | 6 +- ocp_qp/x_ocp_qp_utils.c | 4 +- test_problems/test_d_dense.c | 9 + 7 files changed, 637 insertions(+), 9 deletions(-) diff --git a/dense_qp/d_dense_qp_utils.c b/dense_qp/d_dense_qp_utils.c index 47e7a18f..3be2b315 100644 --- a/dense_qp/d_dense_qp_utils.c +++ b/dense_qp/d_dense_qp_utils.c @@ -66,10 +66,13 @@ #define DENSE_QP_DIM_PRINT d_dense_qp_dim_print +#define DENSE_QP_DIM_CODEGEN d_dense_qp_dim_codegen #define DENSE_QP_PRINT d_dense_qp_print +#define DENSE_QP_CODEGEN d_dense_qp_codegen #define DENSE_QP_SOL_PRINT d_dense_qp_sol_print #define DENSE_QP_RES_PRINT d_dense_qp_res_print #define DENSE_QP_IPM_ARG_PRINT d_dense_qp_ipm_arg_print +#define DENSE_QP_IPM_ARG_CODEGEN d_dense_qp_ipm_arg_codegen diff --git a/dense_qp/s_dense_qp_utils.c b/dense_qp/s_dense_qp_utils.c index b3435fdb..dc957caf 100644 --- a/dense_qp/s_dense_qp_utils.c +++ b/dense_qp/s_dense_qp_utils.c @@ -66,10 +66,13 @@ #define DENSE_QP_DIM_PRINT s_dense_qp_dim_print +#define DENSE_QP_DIM_CODEGEN s_dense_qp_dim_codegen #define DENSE_QP_PRINT s_dense_qp_print +#define DENSE_QP_CODEGEN s_dense_qp_codegen #define DENSE_QP_SOL_PRINT s_dense_qp_sol_print #define DENSE_QP_RES_PRINT s_dense_qp_res_print #define DENSE_QP_IPM_ARG_PRINT s_dense_qp_ipm_arg_print +#define DENSE_QP_IPM_ARG_CODEGEN s_dense_qp_ipm_arg_codegen diff --git a/dense_qp/x_dense_qp_utils.c b/dense_qp/x_dense_qp_utils.c index 8e5c46eb..463efa66 100644 --- a/dense_qp/x_dense_qp_utils.c +++ b/dense_qp/x_dense_qp_utils.c @@ -60,6 +60,51 @@ void DENSE_QP_DIM_PRINT(struct DENSE_QP_DIM *qp_dim) +void DENSE_QP_DIM_CODEGEN(char *file_name, char *mode, struct DENSE_QP_DIM *qp_dim) + { + int ii; + + FILE *file = fopen(file_name, mode); + + int nv = qp_dim->nv; + int ne = qp_dim->ne; + int nb = qp_dim->nb; + int ng = qp_dim->ng; + int nsb = qp_dim->nsb; + int nsg = qp_dim->nsg; + int ns = qp_dim->ns; + + fprintf(file, "/***************\n* dim\n***************/\n"); + + // nv + fprintf(file, "/* nv */\n"); + fprintf(file, "int nv = %d;\n", nv); + // ne + fprintf(file, "/* ne */\n"); + fprintf(file, "int ne = %d;\n", ne); + // nb + fprintf(file, "/* nb */\n"); + fprintf(file, "int nb = %d;\n", nb); + // ng + fprintf(file, "/* ng */\n"); + fprintf(file, "int ng = %d;\n", ng); + // nsb + fprintf(file, "/* nsb */\n"); + fprintf(file, "int nsb = %d;\n", nsb); + // nsg + fprintf(file, "/* nsg */\n"); + fprintf(file, "int nsg = %d;\n", nsg); + // ns + fprintf(file, "/* ns */\n"); + fprintf(file, "int ns = %d;\n", ns); + + fclose(file); + + return; + } + + + void DENSE_QP_PRINT(struct DENSE_QP_DIM *qp_dim, struct DENSE_QP *qp) { int ii; @@ -108,6 +153,516 @@ void DENSE_QP_PRINT(struct DENSE_QP_DIM *qp_dim, struct DENSE_QP *qp) +void DENSE_QP_CODEGEN(char *file_name, char *mode, struct DENSE_QP_DIM *qp_dim, struct DENSE_QP *qp) + { + int ii, jj; + + FILE *file = fopen(file_name, mode); + + int nv = qp_dim->nv; + int ne = qp_dim->ne; + int nb = qp_dim->nb; + int ng = qp_dim->ng; + int ns = qp_dim->ns; + + fprintf(file, "/***************\n* qp\n***************/\n"); + + // H + fprintf(file, "/* H */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double HH[] = {"); +#else + fprintf(file, "static float HH[] = {"); +#endif + for(jj=0; jjHv, ii, jj)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SMATEL(qp->Hv, ii, jj)); +#endif + } + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *H = HH;\n"); +#else + fprintf(file, "float *H = HH;\n"); +#endif + + // A + fprintf(file, "/* A */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double AA[] = {"); +#else + fprintf(file, "static float AA[] = {"); +#endif + for(jj=0; jjA, ii, jj)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SMATEL(qp->A, ii, jj)); +#endif + } + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *A = AA;\n"); +#else + fprintf(file, "float *A = AA;\n"); +#endif + + // C + fprintf(file, "/* C */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double CC[] = {"); +#else + fprintf(file, "static float CC[] = {"); +#endif + for(ii=0; iiCt, ii, jj)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SMATEL(qp->Ct, ii, jj)); +#endif + } + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *C = CC;\n"); +#else + fprintf(file, "float *C = CC;\n"); +#endif + + // idxb + fprintf(file, "/* idxb */\n"); + fprintf(file, "static int iidxb[] = {"); + for(ii=0; iiidxb[ii]); + fprintf(file, "};\n"); + fprintf(file, "int *idxb = iidxb;\n"); + + // g + fprintf(file, "/* g */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double gg[] = {"); +#else + fprintf(file, "static float gg[] = {"); +#endif + for(ii=0; iigz, ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->gz, ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *g = gg;\n"); +#else + fprintf(file, "float *g = gg;\n"); +#endif + + // zl + fprintf(file, "/* zl */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double zzl[] = {"); +#else + fprintf(file, "static float zzl[] = {"); +#endif + for(ii=0; iigz, nv+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->gz, nv+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *zl = zzl;\n"); +#else + fprintf(file, "float *zl = zzl;\n"); +#endif + + // zu + fprintf(file, "/* zu */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double zzu[] = {"); +#else + fprintf(file, "static float zzu[] = {"); +#endif + for(ii=0; iigz, nv+ns+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->gz, nv+ns+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *zu = zzu;\n"); +#else + fprintf(file, "float *zu = zzu;\n"); +#endif + + // b + fprintf(file, "/* b */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double bb[] = {"); +#else + fprintf(file, "static float bb[] = {"); +#endif + for(ii=0; iib, ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->b, ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *b = bb;\n"); +#else + fprintf(file, "float *b = bb;\n"); +#endif + + // lb + fprintf(file, "/* lb */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double llb[] = {"); +#else + fprintf(file, "static float llb[] = {"); +#endif + for(ii=0; iid, ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d, ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *lb = llb;\n"); +#else + fprintf(file, "float *lb = llb;\n"); +#endif + + // lb_mask + fprintf(file, "/* lb_mask */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double llb_mask[] = {"); +#else + fprintf(file, "static float llb_mask[] = {"); +#endif + for(ii=0; iid_mask, ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d_mask, ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *lb_mask = llb_mask;\n"); +#else + fprintf(file, "float *lb_mask = llb_mask;\n"); +#endif + + // ub + fprintf(file, "/* ub */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double uub[] = {"); +#else + fprintf(file, "static float uub[] = {"); +#endif + for(ii=0; iid, nb+ng+ii)); +#else + fprintf(file, "%18.15e, ", -BLASFEO_SVECEL(qp->d, nb+ng+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *ub = uub;\n"); +#else + fprintf(file, "float *ub = uub;\n"); +#endif + + // ub_mask + fprintf(file, "/* ub_mask */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double uub_mask[] = {"); +#else + fprintf(file, "static float uub_mask[] = {"); +#endif + for(ii=0; iid_mask, nb+ng+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d_mask, nb+ng+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *ub_mask = uub_mask;\n"); +#else + fprintf(file, "float *ub_mask = uub_mask;\n"); +#endif + + // lg + fprintf(file, "/* lg */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double llg[] = {"); +#else + fprintf(file, "static float llg[] = {"); +#endif + for(ii=0; iid, nb+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d, nb+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *lg = llg;\n"); +#else + fprintf(file, "float *lg = llg;\n"); +#endif + + // lg_mask + fprintf(file, "/* lg_mask */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double llg_mask[] = {"); +#else + fprintf(file, "static float llg_mask[] = {"); +#endif + for(ii=0; iid_mask, nb+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d_mask, nb+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *lg_mask = llg_mask;\n"); +#else + fprintf(file, "float *lg_mask = llg_mask;\n"); +#endif + + // ug + fprintf(file, "/* ug */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double uug[] = {"); +#else + fprintf(file, "static float uug[] = {"); +#endif + for(ii=0; iid, 2*nb+ng+ii)); +#else + fprintf(file, "%18.15e, ", -BLASFEO_SVECEL(qp->d, 2*nb+ng+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *ug = uug;\n"); +#else + fprintf(file, "float *ug = uug;\n"); +#endif + + // ug_mask + fprintf(file, "/* ug_mask */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double uug_mask[] = {"); +#else + fprintf(file, "static float uug_mask[] = {"); +#endif + for(ii=0; iid_mask, 2*nb+ng+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d_mask, 2*nb+ng+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *ug_mask = uug_mask;\n"); +#else + fprintf(file, "float *ug_mask = uug_mask;\n"); +#endif + + // lls + fprintf(file, "/* lls */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double llls[] = {"); +#else + fprintf(file, "static float llls[] = {"); +#endif + for(ii=0; iid, 2*nb+2*ng+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d, 2*nb+2*ng+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *lls = llls;\n"); +#else + fprintf(file, "float *lls = llls;\n"); +#endif + + // lls_mask + fprintf(file, "/* lls_mask */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double llls_mask[] = {"); +#else + fprintf(file, "static float llls_mask[] = {"); +#endif + for(ii=0; iid_mask, 2*nb+2*ng+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d_mask, 2*nb+2*ng+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *lls_mask = llls_mask;\n"); +#else + fprintf(file, "float *lls_mask = llls_mask;\n"); +#endif + + // lus + fprintf(file, "/* lus */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double llus[] = {"); +#else + fprintf(file, "static float llus[] = {"); +#endif + for(ii=0; iid, 2*nb+2*ng+ns+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d, 2*nb+2*ng+ns+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *lus = llus;\n"); +#else + fprintf(file, "float *lus = llus;\n"); +#endif + + // lus_mask + fprintf(file, "/* lus_mask */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double llus_mask[] = {"); +#else + fprintf(file, "static float llus_mask[] = {"); +#endif + for(ii=0; iid_mask, 2*nb+2*ng+ns+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->d_mask, 2*nb+2*ng+ns+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *lus_mask = llus_mask;\n"); +#else + fprintf(file, "float *lus_mask = llus_mask;\n"); +#endif + + printf("Z = \n"); + BLASFEO_PRINT_TRAN_VEC(2*ns, qp->Z, 0); + // zl + fprintf(file, "/* Zl */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double ZZl[] = {"); +#else + fprintf(file, "static float ZZl[] = {"); +#endif + for(ii=0; iiZ, ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->Z, ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *Zl = ZZl;\n"); +#else + fprintf(file, "float *Zl = ZZl;\n"); +#endif + + // Zu + fprintf(file, "/* Zu */\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "static double ZZu[] = {"); +#else + fprintf(file, "static float ZZu[] = {"); +#endif + for(ii=0; iiZ, ns+ii)); +#else + fprintf(file, "%18.15e, ", BLASFEO_SVECEL(qp->Z, ns+ii)); +#endif + } + fprintf(file, "};\n"); +#ifdef DOUBLE_PRECISION + fprintf(file, "double *Zu = ZZu;\n"); +#else + fprintf(file, "float *Zu = ZZu;\n"); +#endif + + // idxs_rev + fprintf(file, "/* idxs_rev */\n"); + fprintf(file, "static int iidxs_rev[] = {"); + for(ii=0; iiidxs_rev[ii]); + fprintf(file, "};\n"); + fprintf(file, "int *idxs_rev = iidxs_rev;\n"); + + fclose(file); + + return; + } + + + void DENSE_QP_SOL_PRINT(struct DENSE_QP_DIM *qp_dim, struct DENSE_QP_SOL *qp_sol) { int ii; @@ -166,7 +721,7 @@ void DENSE_QP_IPM_ARG_PRINT(struct DENSE_QP_DIM *qp_dim, struct DENSE_QP_IPM_ARG { int ii; - // iter_max + // mode printf("/* mode */\n"); printf("int mode = %d;\n", arg->mode); // iter_max @@ -193,6 +748,9 @@ void DENSE_QP_IPM_ARG_PRINT(struct DENSE_QP_DIM *qp_dim, struct DENSE_QP_IPM_ARG // reg_prim printf("/* reg_prim */\n"); printf("double reg_prim = %18.15e;\n", arg->reg_prim); + // reg_dual + printf("/* reg_dual */\n"); + printf("double reg_dual = %18.15e;\n", arg->reg_dual); // warm_start printf("/* warm_start */\n"); printf("int warm_start = %d;\n", arg->warm_start); @@ -208,4 +766,59 @@ void DENSE_QP_IPM_ARG_PRINT(struct DENSE_QP_DIM *qp_dim, struct DENSE_QP_IPM_ARG +void DENSE_QP_IPM_ARG_CODEGEN(char *file_name, char *mode, struct DENSE_QP_DIM *qp_dim, struct DENSE_QP_IPM_ARG *arg) + { + int ii; + + FILE *file = fopen(file_name, mode); + + fprintf(file, "/***************\n* arg\n***************/\n"); + + // mode + fprintf(file, "/* mode */\n"); + fprintf(file, "int mode = %d;\n", arg->mode); + // iter_max + fprintf(file, "/* iter_max */\n"); + fprintf(file, "int iter_max = %d;\n", arg->iter_max); + // alpha_min + fprintf(file, "/* alpha_min */\n"); + fprintf(file, "double alpha_min = %18.15e;\n", arg->alpha_min); + // mu0 + fprintf(file, "/* mu0 */\n"); + fprintf(file, "double mu0 = %18.15e;\n", arg->mu0); + // tol_stat + fprintf(file, "/* tol_stat */\n"); + fprintf(file, "double tol_stat = %18.15e;\n", arg->res_g_max); + // tol_eq + fprintf(file, "/* tol_eq */\n"); + fprintf(file, "double tol_eq = %18.15e;\n", arg->res_b_max); + // tol_ineq + fprintf(file, "/* tol_ineq */\n"); + fprintf(file, "double tol_ineq = %18.15e;\n", arg->res_d_max); + // tol_comp + fprintf(file, "/* tol_comp */\n"); + fprintf(file, "double tol_comp = %18.15e;\n", arg->res_m_max); + // reg_prim + fprintf(file, "/* reg_prim */\n"); + fprintf(file, "double reg_prim = %18.15e;\n", arg->reg_prim); + // reg_dual + fprintf(file, "/* reg_dual */\n"); + fprintf(file, "double reg_dual = %18.15e;\n", arg->reg_dual); + // warm_start + fprintf(file, "/* warm_start */\n"); + fprintf(file, "int warm_start = %d;\n", arg->warm_start); + // pred_corr + fprintf(file, "/* pred_corr */\n"); + fprintf(file, "int pred_corr = %d;\n", arg->pred_corr); + // split_step + fprintf(file, "/* split_step */\n"); + fprintf(file, "int split_step = %d;\n", arg->split_step); + + fclose(file); + + return; + } + + + diff --git a/include/hpipm_d_dense_qp_utils.h b/include/hpipm_d_dense_qp_utils.h index ccb77aac..0bab4219 100644 --- a/include/hpipm_d_dense_qp_utils.h +++ b/include/hpipm_d_dense_qp_utils.h @@ -57,15 +57,15 @@ extern "C" { // void d_dense_qp_dim_print(struct d_dense_qp_dim *qp_dim); // -//void d_dense_qp_dim_codegen(char *file_name, char *mode, struct d_dense_qp_dim *qp_dim); +void d_dense_qp_dim_codegen(char *file_name, char *mode, struct d_dense_qp_dim *qp_dim); // void d_dense_qp_print(struct d_dense_qp_dim *qp_dim, struct d_dense_qp *qp); // -//void d_dense_qp_codegen(char *file_name, char *mode, struct d_dense_qp_dim *qp_dim, struct d_dense_qp *qp); +void d_dense_qp_codegen(char *file_name, char *mode, struct d_dense_qp_dim *qp_dim, struct d_dense_qp *qp); // void d_dense_qp_sol_print(struct d_dense_qp_dim *qp_dim, struct d_dense_qp_sol *dense_qp_sol); // -//void d_dense_qp_ipm_arg_codegen(char *file_name, char *mode, struct d_dense_qp_dim *qp_dim, struct d_dense_qp_ipm_arg *arg); +void d_dense_qp_ipm_arg_codegen(char *file_name, char *mode, struct d_dense_qp_dim *qp_dim, struct d_dense_qp_ipm_arg *arg); // void d_dense_qp_res_print(struct d_dense_qp_dim *qp_dim, struct d_dense_qp_res *dense_qp_res); // diff --git a/include/hpipm_s_dense_qp_utils.h b/include/hpipm_s_dense_qp_utils.h index 3dd93259..ec88ece7 100644 --- a/include/hpipm_s_dense_qp_utils.h +++ b/include/hpipm_s_dense_qp_utils.h @@ -57,15 +57,15 @@ extern "C" { // void s_dense_qp_dim_print(struct s_dense_qp_dim *qp_dim); // -//void s_dense_qp_dim_codegen(char *file_name, char *mode, struct s_dense_qp_dim *qp_dim); +void s_dense_qp_dim_codegen(char *file_name, char *mode, struct s_dense_qp_dim *qp_dim); // void s_dense_qp_print(struct s_dense_qp_dim *qp_dim, struct s_dense_qp *qp); // -//void s_dense_qp_codegen(char *file_name, char *mode, struct s_dense_qp_dim *qp_dim, struct s_dense_qp *qp); +void s_dense_qp_codegen(char *file_name, char *mode, struct s_dense_qp_dim *qp_dim, struct s_dense_qp *qp); // void s_dense_qp_sol_print(struct s_dense_qp_dim *qp_dim, struct s_dense_qp_sol *dense_qp_sol); // -//void s_dense_qp_ipm_arg_codegen(char *file_name, char *mode, struct s_dense_qp_dim *qp_dim, struct s_dense_qp_ipm_arg *arg); +void s_dense_qp_ipm_arg_codegen(char *file_name, char *mode, struct s_dense_qp_dim *qp_dim, struct s_dense_qp_ipm_arg *arg); // void s_dense_qp_res_print(struct s_dense_qp_dim *qp_dim, struct s_dense_qp_res *dense_qp_res); // diff --git a/ocp_qp/x_ocp_qp_utils.c b/ocp_qp/x_ocp_qp_utils.c index 96774c8c..9c85720b 100644 --- a/ocp_qp/x_ocp_qp_utils.c +++ b/ocp_qp/x_ocp_qp_utils.c @@ -1361,7 +1361,7 @@ void OCP_QP_IPM_ARG_PRINT(struct OCP_QP_DIM *qp_dim, struct OCP_QP_IPM_ARG *arg) { int ii; - // iter_max + // mode printf("/* mode */\n"); printf("int mode = %d;\n", arg->mode); // iter_max @@ -1414,7 +1414,7 @@ void OCP_QP_IPM_ARG_CODEGEN(char *file_name, char *mode, struct OCP_QP_DIM *qp_d fprintf(file, "/***************\n* arg\n***************/\n"); - // iter_max + // mode fprintf(file, "/* mode */\n"); fprintf(file, "int mode = %d;\n", arg->mode); // iter_max diff --git a/test_problems/test_d_dense.c b/test_problems/test_d_dense.c index e5f0c514..fa32b74e 100644 --- a/test_problems/test_d_dense.c +++ b/test_problems/test_d_dense.c @@ -50,6 +50,7 @@ #include #include #include +#include #include @@ -521,6 +522,14 @@ int main() printf("\ndense ipm time = %e [s]\n\n", time_dense_ipm); #endif +/************************************************ +* codegen QP data +************************************************/ + +// d_dense_qp_dim_codegen("examples/c/data/test_d_dense_data.c", "w", &qp_dim); +// d_dense_qp_codegen("examples/c/data/test_d_dense_data.c", "a", &qp_dim, &qp); +// d_dense_qp_ipm_arg_codegen("examples/c/data/test_d_dense_data.c", "a", &qp_dim, &arg); + /************************************************ * free memory ************************************************/