proxsuite 0.6.7
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
results.hpp
Go to the documentation of this file.
1//
2// Copyright (c) 2022 INRIA
3//
7#ifndef PROXSUITE_PROXQP_RESULTS_HPP
8#define PROXSUITE_PROXQP_RESULTS_HPP
9
11#include <Eigen/Core>
17
18namespace proxsuite {
19namespace proxqp {
24
27template<typename T>
63
66template<typename T>
67struct Results
68{
69
71
75 sparse::Vec<T> se; // optimal shift to the closest feasible problem wrt
76 // equality constraints
77 sparse::Vec<T> si; // optimal shift to the closest feasible problem wrt
78 // inequality constraints
80
82
84
90 Results(isize dim = 0,
91 isize n_eq = 0,
92 isize n_in = 0,
93 bool box_constraints = false,
95 : x(dim)
96 , y(n_eq)
97 , z(n_in)
98 , se(n_eq)
99 , si(n_in)
100 {
101 if (box_constraints) {
102 z.resize(dim + n_in);
103 si.resize(dim + n_in);
104 } else {
105 z.resize(n_in);
106 si.resize(n_in);
107 }
108 x.setZero();
109 y.setZero();
110 z.setZero();
111 se.setZero();
112 si.setZero();
113 switch (dense_backend) {
115 info.rho = 1e-6;
116 break;
118 info.rho = 1.E-5;
119 break;
121 info.rho = 1.E-6;
122 break;
123 }
124 info.mu_eq_inv = 1e3;
125 info.mu_eq = 1e-3;
126 info.mu_in_inv = 1e1;
127 info.mu_in = 1e-1;
128 info.nu = 1.;
129 info.iter = 0;
130 info.iter_ext = 0;
131 info.mu_updates = 0;
132 info.rho_updates = 0;
133 info.run_time = 0;
134 info.setup_time = 0;
135 info.solve_time = 0;
136 info.objValue = 0.;
137 info.pri_res = 0.;
138 info.dua_res = 0.;
139 info.duality_gap = 0.;
140 info.iterative_residual = 0.;
142 info.sparse_backend = SparseBackend::Automatic;
143 info.minimal_H_eigenvalue_estimate = 0.;
144 }
150 {
151 x.setZero();
152 y.setZero();
153 z.setZero();
154 se.setZero();
155 si.setZero();
156 cold_start(settings);
157 }
159 {
160 info.run_time = 0;
161 info.setup_time = 0;
162 info.solve_time = 0;
163 info.objValue = 0.;
164 info.iter = 0;
165 info.iter_ext = 0;
166 info.mu_updates = 0;
167 info.rho_updates = 0;
168 info.pri_res = 0.;
169 info.dua_res = 0.;
170 info.duality_gap = 0.;
171 info.iterative_residual = 0.;
173 info.sparse_backend = SparseBackend::Automatic;
174 }
176 {
177 info.rho = 1e-6;
178 info.mu_eq_inv = 1e3;
179 info.mu_eq = 1e-3;
180 info.mu_in_inv = 1e1;
181 info.mu_in = 1e-1;
182 info.nu = 1.;
183 info.minimal_H_eigenvalue_estimate = 0.;
184 if (settings != nullopt) {
185 info.rho = settings.value().default_rho;
186 info.mu_eq = settings.value().default_mu_eq;
187 info.mu_eq_inv = T(1) / info.mu_eq;
188 info.mu_in = settings.value().default_mu_in;
189 info.mu_in_inv = T(1) / info.mu_in;
190 info.minimal_H_eigenvalue_estimate =
191 settings.value().default_H_eigenvalue_estimate;
192 }
194 }
196 {
197 x.setZero();
198 y.setZero();
199 z.setZero();
200 se.setZero();
201 si.setZero();
203 }
204};
205
206template<typename T>
207bool
208operator==(const Info<T>& info1, const Info<T>& info2)
209{
210 bool value =
211 info1.mu_eq == info2.mu_eq && info1.mu_eq_inv == info2.mu_eq_inv &&
212 info1.mu_in == info2.mu_in && info1.mu_in_inv == info2.mu_in_inv &&
213 info1.rho == info2.rho && info1.nu == info2.nu &&
214 info1.iter == info2.iter && info1.iter_ext == info2.iter_ext &&
215 info1.mu_updates == info2.mu_updates &&
216 info1.rho_updates == info2.rho_updates && info1.status == info2.status &&
217 info1.setup_time == info2.setup_time &&
218 info1.solve_time == info2.solve_time && info1.run_time == info2.run_time &&
219 info1.objValue == info2.objValue && info1.pri_res == info2.pri_res &&
220 info1.dua_res == info2.dua_res && info1.duality_gap == info2.duality_gap &&
221 info1.duality_gap == info2.duality_gap &&
223 return value;
224}
225
226template<typename T>
227bool
228operator!=(const Info<T>& info1, const Info<T>& info2)
229{
230 return !(info1 == info2);
231}
232
233template<typename T>
234bool
235operator==(const Results<T>& results1, const Results<T>& results2)
236{
237 bool value = results1.x == results2.x && results1.y == results2.y &&
238 results1.z == results2.z && results1.info == results2.info;
239 return value;
240}
241
242template<typename T>
243bool
244operator!=(const Results<T>& results1, const Results<T>& results2)
245{
246 return !(results1 == results2);
247}
248
249} // namespace proxqp
250} // namespace proxsuite
251
252#endif /* end of include guard PROXSUITE_PROXQP_RESULTS_HPP */
Eigen::Matrix< T, DYN, 1 > Vec
Definition fwd.hpp:38
bool operator!=(const Info< T > &info1, const Info< T > &info2)
Definition results.hpp:228
bool operator==(const Info< T > &info1, const Info< T > &info2)
Definition results.hpp:208
constexpr nullopt_t nullopt
Definition optional.hpp:42
This class stores the results statistics of PROXQP solvers with sparse and dense backends.
Definition results.hpp:29
sparse::isize mu_updates
Definition results.hpp:41
sparse::isize iter
Definition results.hpp:39
QPSolverOutput status
Definition results.hpp:43
SparseBackend sparse_backend
Definition results.hpp:55
sparse::isize iter_ext
Definition results.hpp:40
sparse::isize rho_updates
Definition results.hpp:42
This class stores all the results of PROXQP solvers with sparse and dense backends.
Definition results.hpp:68
sparse::Vec< T > z
Definition results.hpp:74
sparse::Vec< T > si
Definition results.hpp:77
void cold_start(optional< Settings< T > > settings=nullopt)
Definition results.hpp:175
void cleanup(optional< Settings< T > > settings=nullopt)
Definition results.hpp:149
proxsuite::linalg::veg::Vec< bool > active_constraints
Definition results.hpp:79
Results(isize dim=0, isize n_eq=0, isize n_in=0, bool box_constraints=false, DenseBackend dense_backend=DenseBackend::PrimalDualLDLT)
Definition results.hpp:90
sparse::Vec< T > y
Definition results.hpp:73
sparse::Vec< T > se
Definition results.hpp:75
sparse::Vec< T > x
Definition results.hpp:72
void cleanup_all_except_prox_parameters()
Definition results.hpp:195
This class defines the settings of PROXQP solvers with sparse and dense backends.
Definition settings.hpp:89