19void c_strcpy(
char dest[],
const char source[]) {
21 for(i = 0; (dest[i] = source[i]) !=
'\0'; i++);
31 new->eps_abs = settings->
eps_abs;
32 new->eps_rel = settings->
eps_rel;
35 new->rho = settings->
rho;
38 new->theta = settings->
theta;
39 new->delta = settings->
delta;
46 new->scaling = settings->
scaling;
48 new->verbose = settings->
verbose;
99 qpalm_eprint(
"Unrecognised status value %" LADEL_PRIi, status_val);
112 qpalm_print(
"\n QPALM Version " QPALM_VERSION_STR
" \n\n");
113 qpalm_print(
"Iter | P. res | D. res | Stepsize | Objective \n");
114 qpalm_print(
"==========================================================\n");
118 qpalm_print(
"%4" LADEL_PRIi
" | %.4e | %.4e | %.4e | %.4e \n", iter,
126 qpalm_print(
"\n\n=============================================================\n");
127 size_t characters_box;
131 snprintf(buf, 80,
"| QPALM finished successfully. |\n");
132 characters_box = strlen(buf);
140 snprintf(buf, 80,
"| QPALM has terminated because the dual objective at the |\n");
141 characters_box = strlen(buf);
144 qpalm_print(
"| current iterate is higher than the value specified in |\n");
149 snprintf(buf, 80,
"| QPALM detected a primal infeasible problem. You can check |\n");
150 characters_box = strlen(buf);
153 qpalm_print(
"| the certificate of this infeasiblity. If you think the |\n");
154 qpalm_print(
"| problem might not be infeasible, try lowering the |\n");
155 qpalm_print(
"| infeasiblity tolerance eps_prim_inf. |\n");
158 snprintf(buf, 80,
"| QPALM detected a dual infeasible problem. You can check |\n");
159 characters_box = strlen(buf);
162 qpalm_print(
"| the certificate of this infeasiblity. If you think the |\n");
163 qpalm_print(
"| problem might not be dual infeasible, try lowering the |\n");
164 qpalm_print(
"| infeasiblity tolerance eps_dual_inf. |\n");
167 snprintf(buf, 80,
"| QPALM hit the maximum number of iterations. |\n");
168 characters_box = strlen(buf);
176 snprintf(buf, 80,
"| QPALM has exceeded the specified time limit. |\n");
177 characters_box = strlen(buf);
185 snprintf(buf, 80,
"| QPALM was cancelled. |\n");
186 characters_box = strlen(buf);
199 size_t characters_runtime;
201 snprintf(buf, 80,
"| runtime: %4.2f seconds", work->
info->
run_time);
202 characters_runtime = strlen(buf);
206 snprintf(buf, 80,
"| runtime: %4.2f milliseconds", work->
info->
run_time*1000);
207 characters_runtime = strlen(buf);
211 for (; characters_runtime < characters_box-2; characters_runtime++) {
217 qpalm_print(
"=============================================================\n");
234 QueryPerformanceFrequency(&t->freq);
235 QueryPerformanceCounter(&t->tic);
240 QueryPerformanceCounter(&t->toc);
241 return (t->toc.QuadPart - t->tic.QuadPart) / (
c_float)t->freq.QuadPart;
245# elif defined __APPLE__
250 t->tic = mach_absolute_time();
257 t->toc = mach_absolute_time();
258 duration = t->toc - t->tic;
261 mach_timebase_info(&(t->tinfo));
262 duration *= t->tinfo.numer;
263 duration /= t->tinfo.denom;
265 return (
c_float)duration / 1e9;
269# elif defined __MACH__
274 t->tic = mach_absolute_time();
281 t->toc = mach_absolute_time();
282 duration = t->toc - t->tic;
285 mach_timebase_info(&(t->tinfo));
286 duration *= t->tinfo.numer;
287 duration /= t->tinfo.denom;
289 return (
c_float)duration / 1e9;
293# elif defined __linux__
298 clock_gettime(CLOCK_MONOTONIC, &t->tic);
304 struct timespec temp;
306 clock_gettime(CLOCK_MONOTONIC, &t->toc);
308 if ((t->toc.tv_nsec - t->tic.tv_nsec) < 0) {
309 temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec - 1;
310 temp.tv_nsec = 1000000000 + t->toc.tv_nsec - t->tic.tv_nsec;
312 temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec;
313 temp.tv_nsec = t->toc.tv_nsec - t->tic.tv_nsec;
#define QPALM_MAX_ITER_REACHED
status to indicate termination due to reaching the maximum number of iterations
#define QPALM_USER_CANCELLATION
status to indicate the user has cancelled the solve
#define QPALM_ERROR
status to indicate an error has occured (this error should automatically be printed)
#define QPALM_DUAL_INFEASIBLE
status to indicate the problem is dual infeasible
#define QPALM_TIME_LIMIT_REACHED
status to indicate the problem's runtime has exceeded the specified time limit
#define QPALM_PRIMAL_INFEASIBLE
status to indicate the problem is primal infeasible
#define QPALM_SOLVED
status to indicate the problem is solved to optimality given the specified tolerances
#define QPALM_DUAL_TERMINATED
status to indicate the problem has a dual objective that is higher than the specified bound
#define QPALM_UNSOLVED
status to indicate the problem is unsolved.
void * qpalm_malloc(size_t size)
Custom memory allocation, print and utility functions, and data types for floats and ints.
ladel_int c_int
type for integer numbers
ladel_double c_float
type for floating point numbers
#define qpalm_eprint(...)
Linear algebra with vectors.
Solver return information.
c_float run_time
total time (seconds)
c_float pri_res_norm
norm of primal residual
c_float dual_objective
dual objective function value (= NaN if enable_dual_termination is false)
char status[32]
status string, e.g. 'solved'
c_float objective
objective function value
c_int status_val
status as c_int, defined in constants.h
c_float dua_res_norm
norm of dual residual
c_float gamma_upd
proximal penalty update factor
c_float sigma_max
penalty factor cap
c_float eps_abs_in
intermediate absolute convergence tolerance
c_float gamma_max
proximal penalty parameter cap
c_int proximal
boolean, use proximal method of multipliers or not
c_float delta
penalty update factor
c_int warm_start
boolean, warm start
c_float sigma_init
initial penalty parameter (guideline)
c_float eps_dual_inf
dual infeasibility tolerance
c_int reset_newton_iter
frequency of performing a complete Cholesky factorization
c_float dual_objective_limit
termination value for the dual objective (useful in branch and bound)
c_float eps_rel_in
intermediate relative convergence tolerance
c_float rho
tolerance scaling factor
c_float time_limit
time limit
c_float theta
penalty update criterion parameter
c_int max_rank_update
maximum rank for the sparse factorization update
c_int enable_dual_termination
boolean, enable termination based on dual objective (useful in branch and bound)
c_float max_rank_update_fraction
maximum rank (relative to n+m) for the factorization update
c_float gamma_init
initial proximal penalty parameter
c_float eps_prim_inf
primal infeasibility tolerance
c_int inner_max_iter
maximum number of iterations per subproblem
c_float eps_rel
relative convergence tolerance
c_int verbose
boolean, write out progress
c_int max_iter
maximum number of iterations
c_int scaling
scaling iterations, if 0 then scaling is disabled
c_int nonconvex
boolean, indicates whether the QP is nonconvex
c_float eps_abs
absolute convergence tolerance
c_int ordering
ordering method for factorization
c_int factorization_method
factorize KKT or Schur complement
c_int print_iter
frequency of printing
c_float eps_pri
primal tolerance
QPALMInfo * info
solver information
c_float eps_dua
dual tolerance
QPALMSettings * settings
problem settings
Internal data structures used in QPALM.
struct QPALM_TIMER QPALMTimer
QPALM Timer for statistics.
QPALMSettings * copy_settings(const QPALMSettings *settings)
Copy settings creating a new settings structure.
void update_status(QPALMInfo *info, c_int status_val)
Update solver status (value and string).
void print_iteration(c_int iter, QPALMWorkspace *work)
Print information about the current iteration.
void c_strcpy(char dest[], const char source[])
Custom string copy to avoid string.h library.
void print_header(void)
Print the header with QPALM version number and fields.
void print_final_message(QPALMWorkspace *work)
Print final message as a box with info.
c_float qpalm_toc(QPALMTimer *t)
Report time in seconds since last call to qpalm_tic.
void qpalm_tic(QPALMTimer *t)
Start timer.