Skip to content

Commit

Permalink
add tree_{qp,qcqp}_ipm_get_obj
Browse files Browse the repository at this point in the history
  • Loading branch information
giaf committed Aug 12, 2022
1 parent 04152e3 commit 9fa4c1f
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 58 deletions.
2 changes: 2 additions & 0 deletions include/hpipm_d_tree_ocp_qcqp_ipm.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ void d_tree_ocp_qcqp_ipm_get_max_res_ineq(struct d_tree_ocp_qcqp_ipm_ws *ws, dou
//
void d_tree_ocp_qcqp_ipm_get_max_res_comp(struct d_tree_ocp_qcqp_ipm_ws *ws, double *res_comp);
//
void d_tree_ocp_qcqp_ipm_get_obj(struct d_tree_ocp_qcqp_ipm_ws *ws, double *obj);
//
void d_tree_ocp_qcqp_ipm_get_stat(struct d_tree_ocp_qcqp_ipm_ws *ws, double **stat);
//
void d_tree_ocp_qcqp_ipm_get_stat_m(struct d_tree_ocp_qcqp_ipm_ws *ws, int *stat_m);
Expand Down
2 changes: 2 additions & 0 deletions include/hpipm_d_tree_ocp_qp_ipm.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ void d_tree_ocp_qp_ipm_get_max_res_ineq(struct d_tree_ocp_qp_ipm_ws *ws, double
//
void d_tree_ocp_qp_ipm_get_max_res_comp(struct d_tree_ocp_qp_ipm_ws *ws, double *res_comp);
//
void d_tree_ocp_qp_ipm_get_obj(struct d_tree_ocp_qp_ipm_ws *ws, double *obj);
//
void d_tree_ocp_qp_ipm_get_stat(struct d_tree_ocp_qp_ipm_ws *ws, double **stat);
//
void d_tree_ocp_qp_ipm_get_stat_m(struct d_tree_ocp_qp_ipm_ws *ws, int *stat_m);
Expand Down
2 changes: 2 additions & 0 deletions include/hpipm_s_tree_ocp_qcqp_ipm.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ void s_tree_ocp_qcqp_ipm_get_max_res_ineq(struct s_tree_ocp_qcqp_ipm_ws *ws, flo
//
void s_tree_ocp_qcqp_ipm_get_max_res_comp(struct s_tree_ocp_qcqp_ipm_ws *ws, float *res_comp);
//
void s_tree_ocp_qcqp_ipm_get_obj(struct s_tree_ocp_qcqp_ipm_ws *ws, float *obj);
//
void s_tree_ocp_qcqp_ipm_get_stat(struct s_tree_ocp_qcqp_ipm_ws *ws, float **stat);
//
void s_tree_ocp_qcqp_ipm_get_stat_m(struct s_tree_ocp_qcqp_ipm_ws *ws, int *stat_m);
Expand Down
2 changes: 2 additions & 0 deletions include/hpipm_s_tree_ocp_qp_ipm.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ void s_tree_ocp_qp_ipm_get_max_res_ineq(struct s_tree_ocp_qp_ipm_ws *ws, float *
//
void s_tree_ocp_qp_ipm_get_max_res_comp(struct s_tree_ocp_qp_ipm_ws *ws, float *res_comp);
//
void s_tree_ocp_qp_ipm_get_obj(struct s_tree_ocp_qp_ipm_ws *ws, float *obj);
//
void s_tree_ocp_qp_ipm_get_stat(struct s_tree_ocp_qp_ipm_ws *ws, float **stat);
//
void s_tree_ocp_qp_ipm_get_stat_m(struct s_tree_ocp_qp_ipm_ws *ws, int *stat_m);
Expand Down
16 changes: 9 additions & 7 deletions test_problems/test_d_cast_qcqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
#define KEEP_X0 0

// printing
//#ifndef PRINT
#define PRINT 0
//#endif



Expand Down Expand Up @@ -710,7 +712,7 @@ int main()
************************************************/

hpipm_size_t dim_size = d_ocp_qcqp_dim_memsize(N);
printf("\ndim size = %d\n", dim_size);
printf("\ndim size = %ld\n", dim_size);
void *dim_mem = malloc(dim_size);

struct d_ocp_qcqp_dim dim;
Expand All @@ -733,7 +735,7 @@ int main()
************************************************/

hpipm_size_t qcqp_size = d_ocp_qcqp_memsize(&dim);
printf("\nqp size = %d\n", qcqp_size);
printf("\nqp size = %ld\n", qcqp_size);
void *qcqp_mem = malloc(qcqp_size);

struct d_ocp_qcqp qcqp;
Expand Down Expand Up @@ -825,7 +827,7 @@ int main()
************************************************/

hpipm_size_t dense_dim_size = d_dense_qcqp_dim_memsize();
printf("\ndense dim size = %d\n", dense_dim_size);
printf("\ndense dim size = %ld\n", dense_dim_size);
void *dense_dim_mem = malloc(dense_dim_size);

struct d_dense_qcqp_dim dense_dim;
Expand All @@ -841,7 +843,7 @@ int main()

// qp
hpipm_size_t dense_qp_size = d_dense_qcqp_memsize(&dense_dim);
printf("\nqp size = %d\n", dense_qp_size);
printf("\nqp size = %ld\n", dense_qp_size);
void *dense_qp_mem = malloc(dense_qp_size);

struct d_dense_qcqp dense_qp;
Expand All @@ -856,7 +858,7 @@ int main()
************************************************/

hpipm_size_t dense_qp_sol_size = d_dense_qcqp_sol_memsize(&dense_dim);
printf("\ndense qp sol size = %d\n", dense_qp_sol_size);
printf("\ndense qp sol size = %ld\n", dense_qp_sol_size);
void *dense_qp_sol_mem = malloc(dense_qp_sol_size);

struct d_dense_qcqp_sol dense_qp_sol;
Expand All @@ -867,7 +869,7 @@ int main()
************************************************/

hpipm_size_t ipm_arg_size = d_dense_qcqp_ipm_arg_memsize(&dense_dim);
printf("\nipm arg size = %d\n", ipm_arg_size);
printf("\nipm arg size = %ld\n", ipm_arg_size);
void *ipm_arg_mem = malloc(ipm_arg_size);

struct d_dense_qcqp_ipm_arg dense_arg;
Expand All @@ -889,7 +891,7 @@ int main()
************************************************/

hpipm_size_t dense_ipm_size = d_dense_qcqp_ipm_ws_memsize(&dense_dim, &dense_arg);
printf("\ndense ipm size = %d\n", dense_ipm_size);
printf("\ndense ipm size = %ld\n", dense_ipm_size);
void *dense_ipm_mem = malloc(dense_ipm_size);

struct d_dense_qcqp_ipm_ws dense_workspace;
Expand Down
10 changes: 5 additions & 5 deletions test_problems/test_d_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ int main()

hpipm_size_t dense_qp_dim_size = d_dense_qp_dim_memsize();
#if PRINT
printf("\nqp dim size = %d\n", dense_qp_dim_size);
printf("\nqp dim size = %ld\n", dense_qp_dim_size);
#endif
void *qp_dim_mem = malloc(dense_qp_dim_size);

Expand All @@ -292,7 +292,7 @@ int main()

hpipm_size_t qp_size = d_dense_qp_memsize(&qp_dim);
#if PRINT
printf("\nqp size = %d\n", qp_size);
printf("\nqp size = %ld\n", qp_size);
#endif
void *qp_mem = malloc(qp_size);

Expand Down Expand Up @@ -353,7 +353,7 @@ int main()

hpipm_size_t qp_sol_size = d_dense_qp_sol_memsize(&qp_dim);
#if PRINT
printf("\nqp sol size = %d\n", qp_sol_size);
printf("\nqp sol size = %ld\n", qp_sol_size);
#endif
void *qp_sol_mem = malloc(qp_sol_size);

Expand All @@ -366,7 +366,7 @@ int main()

hpipm_size_t ipm_arg_size = d_dense_qp_ipm_arg_memsize(&qp_dim);
#if PRINT
printf("\nipm arg size = %d\n", ipm_arg_size);
printf("\nipm arg size = %ld\n", ipm_arg_size);
#endif
void *ipm_arg_mem = malloc(ipm_arg_size);

Expand Down Expand Up @@ -417,7 +417,7 @@ int main()

hpipm_size_t ipm_size = d_dense_qp_ipm_ws_memsize(&qp_dim, &arg);
#if PRINT
printf("\nipm size = %d\n", ipm_size);
printf("\nipm size = %ld\n", ipm_size);
#endif
void *ipm_mem = malloc(ipm_size);

Expand Down
10 changes: 5 additions & 5 deletions test_problems/test_d_dense_qcqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int main()

hpipm_size_t dense_qcqp_dim_size = d_dense_qcqp_dim_memsize();
#if PRINT
printf("\nqp dim size = %d\n", dense_qcqp_dim_size);
printf("\nqp dim size = %ld\n", dense_qcqp_dim_size);
#endif
void *qp_dim_mem = malloc(dense_qcqp_dim_size);

Expand All @@ -130,7 +130,7 @@ int main()

hpipm_size_t qp_size = d_dense_qcqp_memsize(&qcqp_dim);
#if PRINT
printf("\nqp size = %d\n", qp_size);
printf("\nqp size = %ld\n", qp_size);
#endif
void *qp_mem = malloc(qp_size);

Expand Down Expand Up @@ -168,7 +168,7 @@ int main()

hpipm_size_t qp_sol_size = d_dense_qcqp_sol_memsize(&qcqp_dim);
#if PRINT
printf("\nqp sol size = %d\n", qp_sol_size);
printf("\nqp sol size = %ld\n", qp_sol_size);
#endif
void *qp_sol_mem = malloc(qp_sol_size);

Expand All @@ -186,7 +186,7 @@ int main()

hpipm_size_t ipm_arg_size = d_dense_qcqp_ipm_arg_memsize(&qcqp_dim);
#if PRINT
printf("\nipm arg size = %d\n", ipm_arg_size);
printf("\nipm arg size = %ld\n", ipm_arg_size);
#endif
void *ipm_arg_mem = malloc(ipm_arg_size);

Expand Down Expand Up @@ -234,7 +234,7 @@ int main()

hpipm_size_t ipm_size = d_dense_qcqp_ipm_ws_memsize(&qcqp_dim, &arg);
#if PRINT
printf("\nipm size = %d\n", ipm_size);
printf("\nipm size = %ld\n", ipm_size);
#endif
void *ipm_mem = malloc(ipm_size);

Expand Down
14 changes: 7 additions & 7 deletions test_problems/test_d_tree_ocp.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ int main()

hpipm_size_t tree_memsize = sctree_memsize(md, Nr, Nh);
#if PRINT
printf("\ntree memsize = %d\n", tree_memsize);
printf("\ntree memsize = %ld\n", tree_memsize);
#endif
void *tree_memory = malloc(tree_memsize);

Expand Down Expand Up @@ -870,7 +870,7 @@ int main()

hpipm_size_t dim_size = d_tree_ocp_qp_dim_memsize(Nn);
#if PRINT
printf("\ndim size = %d\n", dim_size);
printf("\ndim size = %ld\n", dim_size);
#endif
void *dim_mem = malloc(dim_size);

Expand All @@ -884,7 +884,7 @@ int main()

hpipm_size_t tree_ocp_qp_memsize = d_tree_ocp_qp_memsize(&dim);
#if PRINT
printf("\ntree ocp qp memsize = %d\n", tree_ocp_qp_memsize);
printf("\ntree ocp qp memsize = %ld\n", tree_ocp_qp_memsize);
#endif
void *tree_ocp_qp_memory = malloc(tree_ocp_qp_memsize);

Expand Down Expand Up @@ -933,7 +933,7 @@ exit(1);

hpipm_size_t tree_ocp_qp_sol_size = d_tree_ocp_qp_sol_memsize(&dim);
#if PRINT
printf("\ntree ocp qp sol memsize = %d\n", tree_ocp_qp_sol_size);
printf("\ntree ocp qp sol memsize = %ld\n", tree_ocp_qp_sol_size);
#endif
void *tree_ocp_qp_sol_memory = malloc(tree_ocp_qp_sol_size);

Expand All @@ -946,7 +946,7 @@ exit(1);

hpipm_size_t ipm_arg_size = d_tree_ocp_qp_ipm_arg_memsize(&dim);
#if PRINT
printf("\nipm arg size = %d\n", ipm_arg_size);
printf("\nipm arg size = %ld\n", ipm_arg_size);
#endif
void *ipm_arg_mem = malloc(ipm_arg_size);

Expand Down Expand Up @@ -974,7 +974,7 @@ exit(1);

hpipm_size_t ipm_size = d_tree_ocp_qp_ipm_ws_memsize(&dim, &arg);
#if PRINT
printf("\nipm size = %d\n", ipm_size);
printf("\nipm size = %ld\n", ipm_size);
#endif
void *ipm_memory = malloc(ipm_size);

Expand Down Expand Up @@ -1106,7 +1106,7 @@ exit(1);
printf("\nipm residuals max: res_g = %e, res_b = %e, res_d = %e, res_m = %e\n", res_stat, res_eq, res_ineq, res_comp);

printf("\nipm iter = %d\n", iter);
printf("\nalpha_aff\tmu_aff\t\tsigma\t\talpha_prim\talpha_dual\tmu\t\tres_stat\tres_eq\t\tres_ineq\tres_comp\tlq fact\t\titref pred\titref corr\tlin res stat\tlin res eq\tlin res ineq\tlin res comp\n");
printf("\nalpha_aff\tmu_aff\t\tsigma\t\talpha_prim\talpha_dual\tmu\t\tres_stat\tres_eq\t\tres_ineq\tres_comp\tobj\t\tlq fact\t\titref pred\titref corr\tlin res stat\tlin res eq\tlin res ineq\tlin res comp\n");
d_print_exp_tran_mat(stat_m, iter+1, stat, stat_m);

printf("\nocp ipm time = %e [s]\n\n", time_ocp_ipm);
Expand Down
14 changes: 7 additions & 7 deletions test_problems/test_d_tree_ocp_qcqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ int main()

hpipm_size_t tree_memsize = sctree_memsize(md, Nr, Nh);
#if PRINT
printf("\ntree memsize = %d\n", tree_memsize);
printf("\ntree memsize = %ld\n", tree_memsize);
#endif
void *tree_memory = malloc(tree_memsize);

Expand Down Expand Up @@ -940,7 +940,7 @@ int main()

hpipm_size_t dim_size = d_tree_ocp_qcqp_dim_memsize(Nn);
#if PRINT
printf("\ndim size = %d\n", dim_size);
printf("\ndim size = %ld\n", dim_size);
#endif
void *dim_mem = malloc(dim_size);

Expand Down Expand Up @@ -975,7 +975,7 @@ int main()

hpipm_size_t tree_ocp_qp_memsize = d_tree_ocp_qcqp_memsize(&dim);
#if PRINT
printf("\ntree ocp qp memsize = %d\n", tree_ocp_qp_memsize);
printf("\ntree ocp qp memsize = %ld\n", tree_ocp_qp_memsize);
#endif
void *tree_ocp_qp_memory = malloc(tree_ocp_qp_memsize);

Expand Down Expand Up @@ -1041,7 +1041,7 @@ int main()

hpipm_size_t tree_ocp_qp_sol_size = d_tree_ocp_qcqp_sol_memsize(&dim);
#if PRINT
printf("\ntree ocp qp sol memsize = %d\n", tree_ocp_qp_sol_size);
printf("\ntree ocp qp sol memsize = %ld\n", tree_ocp_qp_sol_size);
#endif
void *tree_ocp_qp_sol_memory = malloc(tree_ocp_qp_sol_size);

Expand All @@ -1054,7 +1054,7 @@ int main()

hpipm_size_t ipm_arg_size = d_tree_ocp_qcqp_ipm_arg_memsize(&dim);
#if PRINT
printf("\nipm arg size = %d\n", ipm_arg_size);
printf("\nipm arg size = %ld\n", ipm_arg_size);
#endif
void *ipm_arg_mem = malloc(ipm_arg_size);

Expand Down Expand Up @@ -1082,7 +1082,7 @@ int main()

hpipm_size_t ipm_size = d_tree_ocp_qcqp_ipm_ws_memsize(&dim, &arg);
#if PRINT
printf("\nipm size = %d\n", ipm_size);
printf("\nipm size = %ld\n", ipm_size);
#endif
void *ipm_memory = malloc(ipm_size);

Expand Down Expand Up @@ -1244,7 +1244,7 @@ int main()
printf("\nipm residuals max: res_g = %e, res_b = %e, res_d = %e, res_m = %e\n", res_stat, res_eq, res_ineq, res_comp);

printf("\nipm iter = %d\n", iter);
printf("\nalpha_aff\tmu_aff\t\tsigma\t\talpha_prim\talpha_dual\tmu\t\tres_stat\tres_eq\t\tres_ineq\tres_comp\tlq fact\t\titref pred\titref corr\tlin res stat\tlin res eq\tlin res ineq\tlin res comp\n");
printf("\nalpha_aff\tmu_aff\t\tsigma\t\talpha_prim\talpha_dual\tmu\t\tres_stat\tres_eq\t\tres_ineq\tres_comp\tobj\t\tlq fact\t\titref pred\titref corr\tlin res stat\tlin res eq\tlin res ineq\tlin res comp\n");
d_print_exp_tran_mat(stat_m, iter+1, stat, stat_m);

printf("\nocp ipm time = %e [s]\n\n", time_ocp_ipm);
Expand Down
1 change: 1 addition & 0 deletions tree_ocp_qp/d_tree_ocp_qcqp_ipm.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
#define TREE_OCP_QCQP_IPM_GET_MAX_RES_EQ d_tree_ocp_qcqp_ipm_get_max_res_eq
#define TREE_OCP_QCQP_IPM_GET_MAX_RES_INEQ d_tree_ocp_qcqp_ipm_get_max_res_ineq
#define TREE_OCP_QCQP_IPM_GET_MAX_RES_COMP d_tree_ocp_qcqp_ipm_get_max_res_comp
#define TREE_OCP_QCQP_IPM_GET_OBJ d_tree_ocp_qcqp_ipm_get_obj
#define TREE_OCP_QCQP_IPM_GET_STAT d_tree_ocp_qcqp_ipm_get_stat
#define TREE_OCP_QCQP_IPM_GET_STAT_M d_tree_ocp_qcqp_ipm_get_stat_m
#define TREE_OCP_QCQP_INIT_VAR d_tree_ocp_qcqp_init_var
Expand Down
1 change: 1 addition & 0 deletions tree_ocp_qp/d_tree_ocp_qp_ipm.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
#define TREE_OCP_QP_IPM_GET_MAX_RES_EQ d_tree_ocp_qp_ipm_get_max_res_eq
#define TREE_OCP_QP_IPM_GET_MAX_RES_INEQ d_tree_ocp_qp_ipm_get_max_res_ineq
#define TREE_OCP_QP_IPM_GET_MAX_RES_COMP d_tree_ocp_qp_ipm_get_max_res_comp
#define TREE_OCP_QP_IPM_GET_OBJ d_tree_ocp_qp_ipm_get_obj
#define TREE_OCP_QP_IPM_GET_STAT d_tree_ocp_qp_ipm_get_stat
#define TREE_OCP_QP_IPM_GET_STAT_M d_tree_ocp_qp_ipm_get_stat_m
#define TREE_OCP_QP_INIT_VAR d_tree_ocp_qp_init_var
Expand Down
1 change: 1 addition & 0 deletions tree_ocp_qp/s_tree_ocp_qcqp_ipm.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
#define TREE_OCP_QCQP_IPM_GET_MAX_RES_EQ s_tree_ocp_qcqp_ipm_get_max_res_eq
#define TREE_OCP_QCQP_IPM_GET_MAX_RES_INEQ s_tree_ocp_qcqp_ipm_get_max_res_ineq
#define TREE_OCP_QCQP_IPM_GET_MAX_RES_COMP s_tree_ocp_qcqp_ipm_get_max_res_comp
#define TREE_OCP_QCQP_IPM_GET_OBJ s_tree_ocp_qcqp_ipm_get_obj
#define TREE_OCP_QCQP_IPM_GET_STAT s_tree_ocp_qcqp_ipm_get_stat
#define TREE_OCP_QCQP_IPM_GET_STAT_M s_tree_ocp_qcqp_ipm_get_stat_m
#define TREE_OCP_QCQP_INIT_VAR s_tree_ocp_qcqp_init_var
Expand Down
1 change: 1 addition & 0 deletions tree_ocp_qp/s_tree_ocp_qp_ipm.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
#define TREE_OCP_QP_IPM_GET_MAX_RES_EQ s_tree_ocp_qp_ipm_get_max_res_eq
#define TREE_OCP_QP_IPM_GET_MAX_RES_INEQ s_tree_ocp_qp_ipm_get_max_res_ineq
#define TREE_OCP_QP_IPM_GET_MAX_RES_COMP s_tree_ocp_qp_ipm_get_max_res_comp
#define TREE_OCP_QP_IPM_GET_OBJ s_tree_ocp_qp_ipm_get_obj
#define TREE_OCP_QP_IPM_GET_STAT s_tree_ocp_qp_ipm_get_stat
#define TREE_OCP_QP_IPM_GET_STAT_M s_tree_ocp_qp_ipm_get_stat_m
#define TREE_OCP_QP_INIT_VAR s_tree_ocp_qp_init_var
Expand Down
Loading

0 comments on commit 9fa4c1f

Please sign in to comment.