DuQuad  v1.0
Quadratic Programming Optimizations
 All Data Structures Files Functions Variables Typedefs Macros
print.c
Go to the documentation of this file.
1 /*
2  * print.c
3  *
4  * Created on: Aug 21, 2014
5  * Author: Sverre
6  */
7 #include "print.h"
8 
9 void print_vector(double *v, int length) // Maybe make private function
10 {
11  int i;
12  printf("[%.8f, ", v[0]);
13  for(i=1;i<length-1;i++){
14  printf("%.8f, ", v[i]);
15  }
16  printf("%.8f", v[length-1]);
17  printf("]'\n");
18 }
19 
20 void print_matrix(const real_t *mtx, const uint32_t rows, const uint32_t cols) // Maybe make private function
21 {
22  printf("\n");
23  uint32_t i; /* row number */
24  uint32_t j; /* column number */
25  uint32_t k = 0; /* matrix index (row * column) */
26  for (i = 0; i < rows; i++) {
27  for (j = 0; j < cols; j++) {
28  printf("%.4f, ", mtx[k]);
29  k++;
30  }
31  printf("\n");
32  }
33 }
34 
35 void print_Problem(struct Problem * s)
36 {
37  printf("\n");
38  printf("\n-- Problem --\n");
39  printf("H: "); print_matrix(s->H,N,N);
40  printf("\n");
41  printf("c: "); print_vector(s->c,N);
42  printf("A: "); print_matrix(s->A,M,N);
43  printf("\n");
44  printf("b: "); print_vector(s->b,M);
45  printf("lb_hat: "); print_vector(s->lb_hat,M);
46  printf("ub_hat: "); print_vector(s->ub_hat,M);
47  printf("lb: "); print_vector(s->lb,N);
48  printf("ub: "); print_vector(s->ub,N);
49  printf("z0: "); print_vector(s->z0,N);
50 }
51 
52 void print_Options(struct Options * opt)
53 {
54  printf("\n");
55  printf("\n-- Options --\n");
56  printf("maxiter_outer: %d\n",opt->maxiter_outer);
57  printf("maxiter_inner: %d\n",opt->maxiter_inner);
58  printf("eps_ds: %f\n",opt->eps_ds);
59  printf("eps_pf: %f\n",opt->eps_pf);
60  printf("eps_inner: %f\n",opt->eps_inner);
61  printf("algorithm: %d\n",opt->algorithm);
62 }
63 
64 void print_Info(struct Info * info)
65 {
66  printf("\n");
67  printf("\n-- Info --\n");
68  printf("lb_is_inf: %d\n",info->lb_is_inf);
69  printf("ub_is_inf: %d\n",info->ub_is_inf);
70  printf("lb_hat_is_inf: %d\n",info->lb_hat_is_inf);
71  printf("ub_hat_is_inf: %d\n",info->ub_hat_is_inf);
72  printf("eigH_max: %f\n",info->eigH_max);
73  printf("eigH_min: %f\n",info->eigH_min);
74  printf("Ld: %f\n",info->Ld);
75  printf("problem_case: %d\n",info->problem_case);
76  printf("pf_vec_length: %d\n",info->pf_vec_length);
77 }
78 
79 void print_Result(struct Result *s)
80 {
81  printf("\n");
82  printf("\n-- RESULT --\n");
83  //printf("zopt: "); print_vector(s->zopt,N);
84  //printf("lambda1: "); print_vector(s->lambda1,N);
85  //printf("lambda2: "); print_vector(s->lambda2,N);
86  printf("fopt: %f\n", s->fopt);
87  printf("iterations: %d\n", s->out->iterations);
88  printf("totale iterations inner: %d\n", s->out->iterations_inner_tot);
89  printf("niter_feasible_ds: %d\n", s->out->niter_feasible_ds);
90  printf("niter_feasible_pf: %d\n", s->out->niter_feasible_pf);
91  printf("flag_last_satisfied: %d\n", s->out->flag_last_satisfied);
92  //printf("ds vector: "); print_vector(s->out->ds_vector,s->out->iterations);
93  //printf("pf vector: "); print_vector(s->out->pf_vector,s->out->iterations);
94  printf("time: %f\n", s->out->time);
95  printf("time_tot_inner: %f\n", s->out->time_tot_inner);
96  printf("exitflag: %d\n", s->exitflag);
97  printf("exitflag_inner: %d\n", s->out->exitflag_inner);
98  printf("num reached max iter inner: %d\n", s->out->num_exceeded_max_niter_inner);
99  printf("---\n");
100 }
101 
103 {
104  printf("\n");
105  printf("\n-- Problem --\n");
106  printf("H: "); print_matrix(s->H,N,N);
107  printf("c: "); print_vector(s->c,N);
108  printf("lb: "); print_vector(s->lb,N);
109  printf("ub: "); print_vector(s->ub,N);
110  printf("z0: "); print_vector(s->z0,N);
111  printf("\n");
112  printf("lb_is_inf: %d\n", s->lb_is_inf );
113  printf("ub_is_inf: %d\n", s->ub_is_inf );
114  printf("eigH_min: %f\n", s->eigH_min );
115  printf("eigH_max: %f\n", s->eigH_max );
116  printf("\n");
117 }
118 
119 void print_result_FGM(struct Struct_FGM *s, int niter)
120 {
121  printf("\n");
122  printf("\n-- RESULT --\n");
123  printf("zopt: "); print_vector(s->zopt,N);
124  printf("fopt: %f\n", s->fopt);
125  printf("niter: %d\n", niter);
126  printf("---\n");
127 }
128 
129 void print_result_GDM(struct Struct_GDM *s, int niter)
130 {
131  printf("\n");
132  printf("\n-- RESULT --\n");
133  printf("zopt: "); print_vector(s->zopt,N);
134  printf("fopt: %f\n", s->fopt);
135  printf("niter: %d\n", niter);
136  printf("---\n");
137 }
real_t time_tot_inner
Definition: qp_structs.h:54
unsigned int uint32_t
Definition: typedefs.h:19
real_t time
Definition: qp_structs.h:53
uint32_t algorithm
Definition: qp_structs.h:34
real_t eigH_min
Definition: fgm.h:37
boolean ub_is_inf
Definition: fgm.h:35
real_t Ld
Definition: qp_structs.h:45
struct Output * out
Definition: qp_structs.h:70
boolean ub_is_inf
Definition: qp_structs.h:40
uint32_t iterations_inner_tot
Definition: qp_structs.h:52
real_t * ub
Definition: fgm.h:25
boolean ub_hat_is_inf
Definition: qp_structs.h:42
real_t * lb
Definition: qp_structs.h:23
uint32_t exitflag
Definition: qp_structs.h:67
uint32_t flag_last_satisfied
Definition: qp_structs.h:55
real_t * lb
Definition: fgm.h:24
real_t eigH_max
Definition: fgm.h:36
uint32_t pf_vec_length
Definition: qp_structs.h:47
real_t eps_ds
Definition: qp_structs.h:31
real_t * zopt
Definition: gdm.h:24
real_t * H
Definition: qp_structs.h:16
real_t fopt
Definition: qp_structs.h:66
uint32_t iterations
Definition: qp_structs.h:51
real_t * H
Definition: fgm.h:22
boolean lb_is_inf
Definition: fgm.h:34
real_t * A
Definition: qp_structs.h:18
struct Options * opt
Definition: falm.h:23
struct Info * info
Definition: falm.h:24
real_t * ub
Definition: qp_structs.h:24
uint32_t maxiter_outer
Definition: qp_structs.h:29
uint32_t niter_feasible_pf
Definition: qp_structs.h:57
uint32_t M
Definition: head.h:34
uint32_t num_exceeded_max_niter_inner
Definition: qp_structs.h:59
real_t eps_inner
Definition: qp_structs.h:33
float64_t real_t
Definition: typedefs.h:25
uint32_t exitflag_inner
Definition: qp_structs.h:58
boolean lb_is_inf
Definition: qp_structs.h:39
real_t fopt
Definition: gdm.h:25
Definition: gdm.h:15
boolean lb_hat_is_inf
Definition: qp_structs.h:41
real_t * z0
Definition: fgm.h:26
uint32_t maxiter_inner
Definition: qp_structs.h:30
real_t * z0
Definition: qp_structs.h:25
real_t * c
Definition: fgm.h:23
real_t * ub_hat
Definition: qp_structs.h:22
real_t eigH_min
Definition: qp_structs.h:44
uint32_t problem_case
Definition: qp_structs.h:46
real_t fopt
Definition: fgm.h:30
real_t eps_pf
Definition: qp_structs.h:32
real_t eigH_max
Definition: qp_structs.h:43
uint32_t niter_feasible_ds
Definition: qp_structs.h:56
Definition: fgm.h:20
real_t * lb_hat
Definition: qp_structs.h:21
real_t * zopt
Definition: fgm.h:29
real_t * b
Definition: qp_structs.h:20
uint32_t N
Definition: head.h:33
real_t * c
Definition: qp_structs.h:17