blob: d756c2a49fd42a9a13283dd254d536ef92a18c7d [file] [log] [blame]
Austin Schuh9049e202022-02-20 17:34:16 -08001#ifndef AUXIL_H
2# define AUXIL_H
3
4# ifdef __cplusplus
5extern "C" {
6# endif // ifdef __cplusplus
7
8# include "types.h"
9
10
11/***********************************************************
12* Auxiliary functions needed to compute ADMM iterations * *
13***********************************************************/
14# if EMBEDDED != 1
15
16/**
17 * Compute rho estimate from residuals
18 * @param work Workspace
19 * @return rho estimate
20 */
21c_float compute_rho_estimate(OSQPWorkspace *work);
22
23/**
24 * Adapt rho value based on current unscaled primal/dual residuals
25 * @param work Workspace
26 * @return Exitflag
27 */
28c_int adapt_rho(OSQPWorkspace *work);
29
30/**
31 * Set values of rho vector based on constraint types
32 * @param work Workspace
33 */
34void set_rho_vec(OSQPWorkspace *work);
35
36/**
37 * Update values of rho vector based on updated constraints.
38 * If the constraints change, update the linear systems solver.
39 *
40 * @param work Workspace
41 * @return Exitflag
42 */
43c_int update_rho_vec(OSQPWorkspace *work);
44
45# endif // EMBEDDED
46
47/**
48 * Swap c_float vector pointers
49 * @param a first vector
50 * @param b second vector
51 */
52void swap_vectors(c_float **a,
53 c_float **b);
54
55
56/**
57 * Cold start workspace variables xz and y
58 * @param work Workspace
59 */
60void cold_start(OSQPWorkspace *work);
61
62
63/**
64 * Update x_tilde and z_tilde variable (first ADMM step)
65 * @param work [description]
66 */
67void update_xz_tilde(OSQPWorkspace *work);
68
69
70/**
71 * Update x (second ADMM step)
72 * Update also delta_x (For for dual infeasibility)
73 * @param work Workspace
74 */
75void update_x(OSQPWorkspace *work);
76
77
78/**
79 * Update z (third ADMM step)
80 * @param work Workspace
81 */
82void update_z(OSQPWorkspace *work);
83
84
85/**
86 * Update y variable (fourth ADMM step)
87 * Update also delta_y to check for primal infeasibility
88 * @param work Workspace
89 */
90void update_y(OSQPWorkspace *work);
91
92
93/**
94 * Compute objective function from data at value x
95 * @param work OSQPWorkspace structure
96 * @param x Value x
97 * @return Objective function value
98 */
99c_float compute_obj_val(OSQPWorkspace *work,
100 c_float *x);
101
102/**
103 * Check whether QP has solution
104 * @param info OSQPInfo
105 */
106c_int has_solution(OSQPInfo *info);
107
108/**
109 * Store the QP solution
110 * @param work Workspace
111 */
112void store_solution(OSQPWorkspace *work);
113
114
115/**
116 * Update solver information
117 * @param work Workspace
118 * @param iter Iteration number
119 * @param compute_objective Boolean (if compute the objective or not)
120 * @param polish Boolean (if called from polish)
121 */
122void update_info(OSQPWorkspace *work,
123 c_int iter,
124 c_int compute_objective,
125 c_int polish);
126
127
128/**
129 * Reset solver information (after problem updates)
130 * @param info Information structure
131 */
132void reset_info(OSQPInfo *info);
133
134
135/**
136 * Update solver status (value and string)
137 * @param info OSQPInfo
138 * @param status_val new status value
139 */
140void update_status(OSQPInfo *info,
141 c_int status_val);
142
143
144/**
145 * Check if termination conditions are satisfied
146 * If the boolean flag is ON, it checks for approximate conditions (10 x larger
147 * tolerances than the ones set)
148 *
149 * @param work Workspace
150 * @param approximate Boolean
151 * @return Residuals check
152 */
153c_int check_termination(OSQPWorkspace *work,
154 c_int approximate);
155
156
157# ifndef EMBEDDED
158
159/**
160 * Validate problem data
161 * @param data OSQPData to be validated
162 * @return Exitflag to check
163 */
164c_int validate_data(const OSQPData *data);
165
166
167/**
168 * Validate problem settings
169 * @param settings OSQPSettings to be validated
170 * @return Exitflag to check
171 */
172c_int validate_settings(const OSQPSettings *settings);
173
174
175# endif // #ifndef EMBEDDED
176
177# ifdef __cplusplus
178}
179# endif // ifdef __cplusplus
180
181#endif // ifndef AUXIL_H