QPALM 1.1.5a1
Proximal Augmented Lagrangian method for Quadratic Programs
Loading...
Searching...
No Matches
validate.c
Go to the documentation of this file.
1/**
2 * @file validate.c
3 * @author Ben Hermans
4 * @brief Validation of the user provided settings and data.
5 * @details The assumptions on the settings can be found in the
6 * details of the QPALMSettings tab in data structures.
7 */
8
9#include "validate.h"
10#include "lin_alg.h"
11#include "constants.h"
12
13
14/***********************************************************
15* Validation of data and settings * *
16***********************************************************/
17
19
20
21 if (!data) {
22# ifdef QPALM_PRINTING
23 qpalm_eprint("Missing data");
24# endif /* ifdef QPALM_PRINTING */
25 return FALSE;
26 }
27
28 // Lower and upper bounds
29 size_t j;
30 for (j = 0; j < data->m; j++) {
31 if (data->bmin[j] > data->bmax[j]) {
32# ifdef QPALM_PRINTING
33 qpalm_eprint("Lower bound at index %d is greater than upper bound: %.4e > %.4e",
34 (int)j, data->bmin[j], data->bmax[j]);
35# endif /* ifdef QPALM_PRINTING */
36 return FALSE;
37 }
38 }
39 return TRUE;
40}
41
42
44
45 if (!settings) {
46# ifdef QPALM_PRINTING
47 qpalm_eprint("Missing settings!");
48# endif /* ifdef QPALM_PRINTING */
49 return FALSE;
50 }
51
52 if (settings->max_iter <= 0) {
53# ifdef QPALM_PRINTING
54 qpalm_eprint("max_iter must be positive");
55# endif /* ifdef QPALM_PRINTING */
56 return FALSE;
57 }
58
59 if (settings->inner_max_iter <= 0) {
60# ifdef QPALM_PRINTING
61 qpalm_eprint("inner_max_iter must be positive");
62# endif /* ifdef QPALM_PRINTING */
63 return FALSE;
64 }
65
66 if (settings->eps_abs < 0) {
67# ifdef QPALM_PRINTING
68 qpalm_eprint("eps_abs must be nonnegative");
69# endif /* ifdef QPALM_PRINTING */
70 return FALSE;
71 }
72
73 if (settings->eps_rel < 0) {
74# ifdef QPALM_PRINTING
75 qpalm_eprint("eps_rel must be nonnegative");
76# endif /* ifdef QPALM_PRINTING */
77 return FALSE;
78 }
79
80 if ((settings->eps_rel == 0) && (settings->eps_abs == 0)) {
81# ifdef QPALM_PRINTING
82 qpalm_eprint("at least one of eps_abs and eps_rel must be positive");
83# endif /* ifdef QPALM_PRINTING */
84 return FALSE;
85 }
86
87 if (settings->eps_abs_in < 0) {
88# ifdef QPALM_PRINTING
89 qpalm_eprint("eps_abs_in must be nonnegative");
90# endif /* ifdef QPALM_PRINTING */
91 return FALSE;
92 }
93
94 if (settings->eps_rel_in < 0) {
95# ifdef QPALM_PRINTING
96 qpalm_eprint("eps_rel_in must be nonnegative");
97# endif /* ifdef QPALM_PRINTING */
98 return FALSE;
99 }
100
101 if ((settings->eps_rel_in == 0) && (settings->eps_abs_in == 0)) {
102# ifdef QPALM_PRINTING
103 qpalm_eprint("at least one of eps_abs_in and eps_rel_in must be positive");
104# endif /* ifdef QPALM_PRINTING */
105 return FALSE;
106 }
107
108 if (settings->rho <= 0 || settings->rho >= 1) {
109# ifdef QPALM_PRINTING
110 qpalm_eprint("rho must be positive and smaller than 1");
111# endif /* ifdef QPALM_PRINTING */
112 return FALSE;
113 }
114
115 if (settings->eps_prim_inf < 0) {
116# ifdef QPALM_PRINTING
117 qpalm_eprint("eps_prim_inf must be nonnegative");
118# endif /* ifdef QPALM_PRINTING */
119 return FALSE;
120 }
121
122 if (settings->eps_dual_inf < 0) {
123# ifdef QPALM_PRINTING
124 qpalm_eprint("eps_dual_inf must be nonnegative");
125# endif /* ifdef QPALM_PRINTING */
126 return FALSE;
127 }
128
129 if (settings->theta > 1) {
130# ifdef QPALM_PRINTING
131 qpalm_eprint("theta must be smaller than ot equal 1");
132# endif /* ifdef QPALM_PRINTING */
133 return FALSE;
134 }
135
136 if (settings->delta <= 1) {
137# ifdef QPALM_PRINTING
138 qpalm_eprint("delta must be greater than 1");
139# endif /* ifdef QPALM_PRINTING */
140 return FALSE;
141 }
142
143 if (settings->sigma_max <= 0) {
144# ifdef QPALM_PRINTING
145 qpalm_eprint("sigma_max must be positive");
146# endif /* ifdef QPALM_PRINTING */
147 return FALSE;
148 }
149
150 if ((settings->proximal != 0) && (settings->proximal != 1)) {
151# ifdef QPALM_PRINTING
152 qpalm_eprint("proximal must be either 0 or 1");
153# endif /* ifdef QPALM_PRINTING */
154 return FALSE;
155 }
156
157 if (settings->gamma_init <= 0) {
158# ifdef QPALM_PRINTING
159 qpalm_eprint("gamma_init must be positive");
160# endif /* ifdef QPALM_PRINTING */
161 return FALSE;
162 }
163
164 if (settings->gamma_upd < 1) {
165# ifdef QPALM_PRINTING
166 qpalm_eprint("gamma update factor must be greater than or equal to 1");
167# endif /* ifdef QPALM_PRINTING */
168 return FALSE;
169 }
170
171 if (settings->gamma_max < settings->gamma_init) {
172# ifdef QPALM_PRINTING
173 qpalm_eprint("gamma max must be greater than or equal to gamma");
174# endif /* ifdef QPALM_PRINTING */
175 return FALSE;
176 }
177
178 if (settings->scaling < 0) {
179# ifdef QPALM_PRINTING
180 qpalm_eprint("scaling must be greater than or equal to zero");
181# endif /* ifdef QPALM_PRINTING */
182 return FALSE;
183 }
184
185 if ((settings->warm_start != 0) && (settings->warm_start != 1)) {
186# ifdef QPALM_PRINTING
187 qpalm_eprint("warm_start must be either 0 or 1");
188# endif /* ifdef QPALM_PRINTING */
189 return FALSE;
190 }
191
192 if ((settings->verbose != 0) && (settings->verbose != 1)) {
193# ifdef QPALM_PRINTING
194 qpalm_eprint("verbose must be either 0 or 1");
195# endif /* ifdef QPALM_PRINTING */
196 return FALSE;
197 }
198
199 if (settings->print_iter <= 0) {
200# ifdef QPALM_PRINTING
201 qpalm_eprint("print_iter must be positive");
202# endif /* ifdef QPALM_PRINTING */
203 return FALSE;
204 }
205
206 if (settings->reset_newton_iter <= 0) {
207# ifdef QPALM_PRINTING
208 qpalm_eprint("reset_newton_iter must be positive");
209# endif /* ifdef QPALM_PRINTING */
210 return FALSE;
211 }
212
213 if ((settings->enable_dual_termination != 0) && (settings->enable_dual_termination != 1)) {
214# ifdef QPALM_PRINTING
215 qpalm_eprint("enable_dual_termination must be either 0 or 1");
216# endif /* ifdef QPALM_PRINTING */
217 return FALSE;
218 }
219
220 return TRUE;
221}
Constants used in QPALM.
#define TRUE
Definition constants.h:18
#define FALSE
Definition constants.h:19
ladel_int c_int
type for integer numbers
Definition global_opts.h:42
#define qpalm_eprint(...)
Definition global_opts.h:81
Linear algebra with vectors.
Data structure.
Definition types.h:102
size_t m
number of constraints m
Definition types.h:104
c_float * bmin
dense array for lower bounds (size m)
Definition types.h:109
c_float * bmax
dense array for upper bounds (size m)
Definition types.h:110
Settings struct.
Definition types.h:117
c_float gamma_upd
proximal penalty update factor
Definition types.h:133
c_float sigma_max
penalty factor cap
Definition types.h:129
c_float eps_abs_in
intermediate absolute convergence tolerance
Definition types.h:122
c_float gamma_max
proximal penalty parameter cap
Definition types.h:134
c_int proximal
boolean, use proximal method of multipliers or not
Definition types.h:131
c_float delta
penalty update factor
Definition types.h:128
c_int warm_start
boolean, warm start
Definition types.h:139
c_float eps_dual_inf
dual infeasibility tolerance
Definition types.h:126
c_int reset_newton_iter
frequency of performing a complete Cholesky factorization
Definition types.h:140
c_float eps_rel_in
intermediate relative convergence tolerance
Definition types.h:123
c_float rho
tolerance scaling factor
Definition types.h:124
c_float theta
penalty update criterion parameter
Definition types.h:127
c_int enable_dual_termination
boolean, enable termination based on dual objective (useful in branch and bound)
Definition types.h:141
c_float gamma_init
initial proximal penalty parameter
Definition types.h:132
c_float eps_prim_inf
primal infeasibility tolerance
Definition types.h:125
c_int inner_max_iter
maximum number of iterations per subproblem
Definition types.h:119
c_float eps_rel
relative convergence tolerance
Definition types.h:121
c_int verbose
boolean, write out progress
Definition types.h:137
c_int max_iter
maximum number of iterations
Definition types.h:118
c_int scaling
scaling iterations, if 0 then scaling is disabled
Definition types.h:135
c_float eps_abs
absolute convergence tolerance
Definition types.h:120
c_int print_iter
frequency of printing
Definition types.h:138
c_int validate_data(const QPALMData *data)
Validate problem data.
Definition validate.c:18
c_int validate_settings(const QPALMSettings *settings)
Validate problem settings.
Definition validate.c:43
Validation of the user provided settings and data.