proxsuite 0.7.3
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
10#include <algorithm>
12#include <Eigen/Core>
18
19namespace proxsuite {
20namespace proxqp {
25
28template<typename T>
60
64
67template<typename T>
68struct Results
69{
70
72
76 sparse::Vec<T> se; // optimal shift to the closest feasible problem wrt
77 // equality constraints
78 sparse::Vec<T> si; // optimal shift to the closest feasible problem wrt
79 // inequality constraints
81
83
85
91 Results(isize dim = 0,
92 isize n_eq = 0,
93 isize n_in = 0,
94 bool box_constraints = false,
96 : x(dim)
97 , y(n_eq)
98 , z(n_in)
99 , se(n_eq)
100 , si(n_in)
101 {
102 if (box_constraints) {
103 z.resize(dim + n_in);
104 si.resize(dim + n_in);
105 } else {
106 z.resize(n_in);
107 si.resize(n_in);
108 }
109 x.setZero();
110 y.setZero();
111 z.setZero();
112 se.setZero();
113 si.setZero();
114 switch (dense_backend) {
116 info.rho = 1e-6;
117 break;
119 info.rho = 1.E-5;
120 break;
122 info.rho = 1.E-6;
123 break;
124 }
125 info.mu_eq_inv = 1e3;
126 info.mu_eq = 1e-3;
127 info.mu_in_inv = 1e1;
128 info.mu_in = 1e-1;
129 info.nu = 1.;
130 info.iter = 0;
131 info.iter_ext = 0;
132 info.mu_updates = 0;
133 info.rho_updates = 0;
134 info.run_time = 0;
135 info.setup_time = 0;
136 info.solve_time = 0;
137 info.objValue = 0.;
138 info.pri_res = 0.;
139 info.dua_res = 0.;
140 info.duality_gap = 0.;
141 info.iterative_residual = 0.;
143 info.sparse_backend = SparseBackend::Automatic;
144 info.minimal_H_eigenvalue_estimate = 0.;
145 }
146
151 {
152 x.setZero();
153 y.setZero();
154 z.setZero();
155 se.setZero();
156 si.setZero();
157 cold_start(settings);
158 }
160 {
161 info.run_time = 0;
162 info.setup_time = 0;
163 info.solve_time = 0;
164 info.objValue = 0.;
165 info.iter = 0;
166 info.iter_ext = 0;
167 info.mu_updates = 0;
168 info.rho_updates = 0;
169 info.pri_res = 0.;
170 info.dua_res = 0.;
171 info.duality_gap = 0.;
172 info.iterative_residual = 0.;
174 info.sparse_backend = SparseBackend::Automatic;
175 }
177 {
178 info.rho = 1e-6;
179 info.mu_eq_inv = 1e3;
180 info.mu_eq = 1e-3;
181 info.mu_in_inv = 1e1;
182 info.mu_in = 1e-1;
183 info.nu = 1.;
184 info.minimal_H_eigenvalue_estimate = 0.;
185 if (settings != nullopt) {
186 info.rho = settings.value().default_rho;
187 info.mu_eq = settings.value().default_mu_eq;
188 info.mu_eq_inv = T(1) / info.mu_eq;
189 info.mu_in = settings.value().default_mu_in;
190 info.mu_in_inv = T(1) / info.mu_in;
191 info.minimal_H_eigenvalue_estimate =
192 settings.value().default_H_eigenvalue_estimate;
193 }
195 }
197 {
198 x.setZero();
199 y.setZero();
200 z.setZero();
201 se.setZero();
202 si.setZero();
204 }
205};
206
207template<typename T>
208bool
209operator==(const Info<T>& info1, const Info<T>& info2)
210{
211 bool value =
212 info1.mu_eq == info2.mu_eq && info1.mu_eq_inv == info2.mu_eq_inv &&
213 info1.mu_in == info2.mu_in && info1.mu_in_inv == info2.mu_in_inv &&
214 info1.rho == info2.rho && info1.nu == info2.nu &&
215 info1.iter == info2.iter && info1.iter_ext == info2.iter_ext &&
216 info1.mu_updates == info2.mu_updates &&
217 info1.rho_updates == info2.rho_updates && info1.status == info2.status &&
218 info1.setup_time == info2.setup_time &&
219 info1.solve_time == info2.solve_time && info1.run_time == info2.run_time &&
220 info1.objValue == info2.objValue && info1.pri_res == info2.pri_res &&
221 info1.dua_res == info2.dua_res && info1.duality_gap == info2.duality_gap &&
223 info1.sparse_backend == info2.sparse_backend &&
225 return value;
226}
227
228template<typename T>
229bool
230operator!=(const Info<T>& info1, const Info<T>& info2)
231{
232 return !(info1 == info2);
233}
234
235template<typename T>
236bool
237operator==(const Results<T>& results1, const Results<T>& results2)
238{
239 bool value = results1.x == results2.x && results1.y == results2.y &&
240 results1.z == results2.z && results1.se == results2.se &&
241 results1.si == results2.si && results1.info == results2.info;
242 if (value) {
243 auto const& ac1 = results1.active_constraints;
244 auto const& ac2 = results2.active_constraints;
245 value = ac1.len() == ac2.len() &&
246 std::equal(ac1.ptr(), ac1.ptr() + ac1.len(), ac2.ptr());
247 }
248 return value;
249}
250
251template<typename T>
252bool
253operator!=(const Results<T>& results1, const Results<T>& results2)
254{
255 return !(results1 == results2);
256}
257
258} // namespace proxqp
259} // namespace proxsuite
260
261#endif /* end of include guard PROXSUITE_PROXQP_RESULTS_HPP */
_detail::_meta::make_signed< usize >::Type isize
Definition typedefs.hpp:43
Eigen::Matrix< T, DYN, 1 > Vec
Definition fwd.hpp:38
bool operator!=(const Info< T > &info1, const Info< T > &info2)
Definition results.hpp:230
bool operator==(const Info< T > &info1, const Info< T > &info2)
Definition results.hpp:209
constexpr nullopt_t nullopt
Definition optional.hpp:42
tl::optional< T > optional
Definition optional.hpp:40
VEG_NODISCARD VEG_INLINE auto len() const VEG_NOEXCEPT -> isize
Definition vec.hpp:970
This class stores the results statistics of PROXQP solvers with sparse and dense backends.
Definition results.hpp:30
sparse::isize mu_updates
Definition results.hpp:42
sparse::isize iter
Definition results.hpp:40
QPSolverOutput status
Definition results.hpp:44
SparseBackend sparse_backend
Definition results.hpp:56
sparse::isize iter_ext
Definition results.hpp:41
sparse::isize rho_updates
Definition results.hpp:43
This class stores all the results of PROXQP solvers with sparse and dense backends.
Definition results.hpp:69
sparse::Vec< T > z
Definition results.hpp:75
sparse::Vec< T > si
Definition results.hpp:78
void cold_start(optional< Settings< T > > settings=nullopt)
Definition results.hpp:176
void cleanup(optional< Settings< T > > settings=nullopt)
Definition results.hpp:150
proxsuite::linalg::veg::Vec< bool > active_constraints
Definition results.hpp:80
Results(isize dim=0, isize n_eq=0, isize n_in=0, bool box_constraints=false, DenseBackend dense_backend=DenseBackend::PrimalDualLDLT)
Definition results.hpp:91
sparse::Vec< T > y
Definition results.hpp:74
sparse::Vec< T > se
Definition results.hpp:76
sparse::Vec< T > x
Definition results.hpp:73
void cleanup_all_except_prox_parameters()
Definition results.hpp:196
This class defines the settings of PROXQP solvers with sparse and dense backends.
Definition settings.hpp:89