QPALM 1.0.0
Proximal Augmented Lagrangian method for Quadratic Programs
termination.h
Go to the documentation of this file.
1/**
2 * @file termination.h
3 * @author Ben Hermans
4 * @brief Routines to check the termination and infeasibility criteria.
5 * @details The routines in this file compute the primal and dual residuals,
6 * the primal and dual tolerances, check whether the problem is solved
7 * completely, unscale and store the solution if that is the case, check
8 * whether the intermediate problem is solved and whether one of the
9 * infeasibility criteria hold. In other words, all routines related to
10 * the termination of the optimization algorithm are grouped in this file.
11 */
12#ifndef TERMINATION_H
13# define TERMINATION_H
14
15# ifdef __cplusplus
16extern "C" {
17# endif
18
19#include "types.h"
20
21/**
22 * Calls the routines that compute the norm of the residuals and the tolerances.
23 *
24 * @param work Workspace
25 */
27
28/**
29 * Calculates the infinity norm of the primal residual and stores it in work->info->pri_res_norm.
30 *
31 * The primal residual is given by @f$Ax-z@f$. In the scaled case, the
32 * residual used for checking is unscaled and is @f$E^{-1}(Ax-z)@f$ instead.
33 *
34 * @param work Workspace
35 */
37
38/**
39 * Calculates the infinity norm of the dual residual and the residual of the subproblem
40 * and stores them in work->info->dua_res_norm and work->info->dua2_res_norm respectively.
41 *
42 * The dual residual is given by @f$\nabla \varphi@f$. In the scaled case, the
43 * residual used for checking is unscaled and is @f$D^{-1}\nabla \varphi@f$ instead.
44 * If the work->settings->proximal is true, then the dual residual is
45 * @f$\nabla \varphi - \frac{1}{\gamma}(x-x_0)@f$. If work->settings->proximal is true
46 * and the problem is scaled, then the dual residual is
47 * @f$D^{-1}(\nabla \varphi - \frac{1}{\gamma}(x-x_0))@f$.
48 * The residual of the subproblem is @f$\nabla \varphi@f$ or @f$D^{-1}\nabla \varphi@f$
49 * in the scaled case.
50 *
51 * @param work Workspace
52 */
54
55/**
56 * Calculates the primal tolerance and stores it in work->eps_pri.
57 *
58 * For the primal tolerance an absolute and relative contribution are added.
59 * It is given by
60 * @f$\epsilon_\textrm{abs} + \epsilon_\textrm{rel} \textrm{max}(\|Ax\|_\infty, \|z\|_\infty)@f$.
61 * In the scaled case, the relative contributions are unscaled and the primal
62 * tolerance is given by
63 * @f$\epsilon_\textrm{abs} + \epsilon_\textrm{rel} \textrm{max}(\|E^{-1}Ax\|_\infty, \|E^{-1}z\|_\infty)@f$.
64 *
65 * @param work Workspace
66 */
68
69/**
70 * Calculates the dual tolerance for the problem and current subproblem and stores them
71 * in work->eps_dua and worl->eps_dua_in respectively.
72 *
73 * For the dual tolerance an absolute and relative contribution are added.
74 * It is given by
75 * @f$\epsilon_\textrm{abs} + \epsilon_\textrm{rel} \textrm{max}(\|Qx\|_\infty, \|q\|_\infty, \|A^T y\|_\infty)@f$.
76 * In the scaled case, the relative contributions are unscaled and the primal
77 * tolerance is given by
78 * @f$\epsilon_\textrm{abs} + \epsilon_\textrm{rel}c^{-1}\textrm{max}(\|D^{-1}Qx\|_\infty, \|D^{-1}q\|_\infty, \|D^{-1}A^T y\|_\infty)@f$.
79 * The tolerance for the subproblem is given by the same formulas, with @f$\epsilon_\textrm{abs,in}@f$
80 * and @f$\epsilon_\textrm{rel,in}@f$ instead of @f$\epsilon_\textrm{abs}@f$ and @f$\epsilon_\textrm{rel}@f$.
81 *
82 * @param work Workspace
83 */
85
86/**
87 * Check whether the primal and dual residual norms are smaller than the primal and dual tolerances.
88 *
89 * @param work Workspace
90 * @return Exitflag indicating whether the problem is solved.
91 */
93
94/**
95 * Check whether the problem is primal infeasible.
96 *
97 * The infeasibility criterion used here was introduced in \cite osqp-infeasibility.
98 * The problem is primal infeasible if for @f$\delta y = \Sigma\bigl(Ax-z)\bigr) \neq 0@f$, with
99 * @f$\Sigma = \textrm{diag}(\sigma)@f$ the following condtions hold:
100 * @f{align*}{
101 * \|A^T \delta y\|_\infty & \leq \varepsilon_\textrm{prim,inf} \|\delta y\|_\infty,
102 * \\
103 * b_\textrm{max}^T [\delta y]_+ + b_\textrm{min}^T [\delta y]_- & \leq -\varepsilon_\textrm{prim,inf} \|\delta y\|_\infty.
104 * @f}
105 * In case the problems is scaled the conditions turn into the following:
106 * @f{align*}{
107 * \|D^{-1}A^T \delta y\|_\infty & \leq \varepsilon_\textrm{prim,inf} \|E\delta y\|_\infty,
108 * \\
109 * b_\textrm{max}^T [\delta y]_+ + b_\textrm{min}^T [\delta y]_- & \leq -\varepsilon_\textrm{prim,inf} \|E\delta y\|_\infty.
110 * @f}
111 *
112 * If the above conditions hold, @f$\delta y@f$, or in the scaled case @f$c^{-1} E\delta y@f$, is the certificate of primal infeasibility.
113 *
114 * @param work Workspace
115 * @return Exitflag indicating whether the problem is primal infeasible.
116 */
118
119
120/**
121 * Check whether the problem is dual infeasible.
122 *
123 * The infeasibility criterion used here was introduced in \cite osqp-infeasibility.
124 * The problem is dual infeasible if for @f$\delta x = x-x_\textrm{prev} \neq 0@f$ the following condtions hold:
125 * @f{align*}{
126 * \|Q\delta x\|_\infty &\leq \varepsilon_\textrm{dua, inf} \|\delta x\|_\infty, \\
127 * q^T \delta x & \leq - \varepsilon_\textrm{dua, inf} \|\delta x\|_\infty,
128 * @f}
129 *
130 * @f{align*}{
131 (A\delta x)_i =
132 \begin{cases}
133 \geq \varepsilon_{\rm dua,inf} \|\delta x\|_\infty & \textrm{if } b_{\textrm{max},i} = +\infty
134 \\
135 \leq -\varepsilon_{\rm dua,inf} \|\delta x\|_\infty & \textrm{if } b_{\textrm{min},i} = -\infty
136 \\
137 \in [-\varepsilon_{\rm dua,inf},\varepsilon_{\rm dua,inf}] \|\delta x\|_\infty & \textrm{if } b_{\textrm{max},i}, b_{\textrm{min},i} \in {\rm I\!R}.
138 \end{cases}
139 * @f}
140 * In case the problems is scaled the conditions turn into the following:
141 * @f{align*}{
142 * \|D^{-1}Q\delta x\|_\infty &\leq c \cdot \varepsilon_\textrm{dua, inf} \|D\delta x\|_\infty, \\
143 * q^T \delta x & \leq - c \cdot \varepsilon_\textrm{dua, inf} \|D\delta x\|_\infty,
144 * @f}
145 *
146 * @f{align*}{
147 (E^{-1}A\delta x)_i =
148 \begin{cases}
149 \geq \varepsilon_{\rm dua,inf} \|D\delta x\|_\infty & \textrm{if } b_{\textrm{max},i} = +\infty
150 \\
151 \leq -\varepsilon_{\rm dua,inf} \|D\delta x\|_\infty & \textrm{if } b_{\textrm{min},i} = -\infty
152 \\
153 \in [-\varepsilon_{\rm dua,inf},\varepsilon_{\rm dua,inf}] \|D\delta x\|_\infty & \textrm{if } b_{\textrm{max},i}, b_{\textrm{min},i} \in {\rm I\!R}.
154 \end{cases}
155 * @f}
156 *
157 * If the above conditions hold, @f$\delta x@f$, or in the scaled case @f$D\delta x@f$, is the certificate of dual infeasibility.
158 *
159 * @param work Workspace
160 * @return Exitflag indicating whether the problem is dual infeasible.
161 */
163
164/**
165 * Check whether the subproblem is solved.
166 *
167 * This amounts to checking whether the residual of the subproblem smaller than or
168 * equal is to the tolerance of the subproblem, as mentioned in calculate_dual_residuals
169 * and calculate_dual_tolerances.
170 *
171 * @param work Workspace
172 * @return Exitflag indicating whether the subproblem is solved.
173 *
174 */
176
177
178/**
179 *
180 * Helper function to store the (unscaled) solution in the solution struct.
181 *
182 * The primal/dual solution @f$x,y@f$ is copied to work->solution->x, work->solution->y.
183 * In case the problem is scaled, the soltution is first unscaled, and the solution vectors
184 * @f$Dx, c^{-1}Ey@f$ are stored in work->solution->x, work->solution->y.
185 *
186 * @param work Workspace
187 */
189
190
191
192# ifdef __cplusplus
193}
194# endif
195
196#endif // ifndef TERMINATION_H
ladel_int c_int
type for integer numbers
Definition: global_opts.h:42
QPALM Workspace.
Definition: types.h:197
c_int is_primal_infeasible(QPALMWorkspace *work)
Check whether the problem is primal infeasible.
Definition: termination.c:111
void calculate_residual_norms_and_tolerances(QPALMWorkspace *work)
Calls the routines that compute the norm of the residuals and the tolerances.
Definition: termination.c:19
void store_solution(QPALMWorkspace *work)
Helper function to store the (unscaled) solution in the solution struct.
Definition: termination.c:217
c_int is_solved(QPALMWorkspace *work)
Check whether the primal and dual residual norms are smaller than the primal and dual tolerances.
Definition: termination.c:106
c_int is_dual_infeasible(QPALMWorkspace *work)
Check whether the problem is dual infeasible.
Definition: termination.c:159
c_int check_subproblem_termination(QPALMWorkspace *work)
Check whether the subproblem is solved.
Definition: termination.c:229
void calculate_primal_tolerance(QPALMWorkspace *work)
Calculates the primal tolerance and stores it in work->eps_pri.
Definition: termination.c:67
void calculate_dual_tolerances(QPALMWorkspace *work)
Calculates the dual tolerance for the problem and current subproblem and stores them in work->eps_dua...
Definition: termination.c:83
void calculate_dual_residuals(QPALMWorkspace *work)
Calculates the infinity norm of the dual residual and the residual of the subproblem and stores them ...
Definition: termination.c:36
void calculate_primal_residual(QPALMWorkspace *work)
Calculates the infinity norm of the primal residual and stores it in work->info->pri_res_norm.
Definition: termination.c:26
Internal data structures used in QPALM.