118 bool preconditioning_for_infeasible_problems,
124 auto S = delta_.to_eigen();
126 isize n = qp.H.nrows();
127 isize n_eq = qp.AT.ncols();
128 isize n_in = qp.CT.ncols();
135 I* Hi = qp.H.row_indices_mut();
136 T* Hx = qp.H.values_mut();
138 I* ATi = qp.AT.row_indices_mut();
139 T* ATx = qp.AT.values_mut();
141 I* CTi = qp.CT.row_indices_mut();
142 T* CTx = qp.CT.values_mut();
144 T
const machine_eps = std::numeric_limits<T>::epsilon();
146 while (infty_norm((1 - delta.array()).matrix()) > epsilon) {
147 if (iter == max_iter) {
156 auto _a_infty_norm = stack.make_new(proxsuite::linalg::veg::Tag<T>{}, n);
157 auto _c_infty_norm = stack.make_new(proxsuite::linalg::veg::Tag<T>{}, n);
158 auto _h_infty_norm = stack.make_new(proxsuite::linalg::veg::Tag<T>{}, n);
159 T* a_infty_norm = _a_infty_norm.ptr_mut();
160 T* c_infty_norm = _c_infty_norm.ptr_mut();
161 T* h_infty_norm = _h_infty_norm.ptr_mut();
176 for (
isize j = 0; j < n; ++j) {
177 delta(j) = T(1) / (machine_eps + sqrt(std::max({
185 if (preconditioning_for_infeasible_problems) {
186 delta.tail(n_eq + n_in).setOnes();
191 usize col_start = qp.AT.col_start(j);
192 usize col_end = qp.AT.col_end(j);
194 for (
usize p = col_start; p < col_end; ++p) {
195 T aji = fabs(ATx[p]);
196 a_row_norm = std::max(a_row_norm, aji);
198 delta(n +
isize(j)) = T(1) / (machine_eps + sqrt(a_row_norm));
203 usize col_start = qp.CT.col_start(j);
204 usize col_end = qp.CT.col_end(j);
206 for (
usize p = col_start; p < col_end; ++p) {
207 T cji = fabs(CTx[p]);
208 c_row_norm = std::max(c_row_norm, cji);
210 delta(n + n_eq +
isize(j)) = T(1) / (machine_eps + sqrt(c_row_norm));
223 usize col_start = qp.AT.col_start(j);
224 usize col_end = qp.AT.col_end(j);
226 T delta_j = delta(n +
isize(j));
228 for (
usize p = col_start; p < col_end; ++p) {
229 usize i = zero_extend(ATi[p]);
231 T delta_i = delta(
isize(i));
232 aji = delta_i * (aji * delta_j);
238 usize col_start = qp.CT.col_start(j);
239 usize col_end = qp.CT.col_end(j);
241 T delta_j = delta(n + n_eq +
isize(j));
243 for (
usize p = col_start; p < col_end; ++p) {
244 usize i = zero_extend(CTi[p]);
246 T delta_i = delta(
isize(i));
247 cji = delta_i * (cji * delta_j);
255 usize col_start = qp.H.col_start(j);
256 usize col_end = qp.H.col_end(j);
257 T delta_j = delta(
isize(j));
259 if (col_end > col_start) {
263 usize i = zero_extend(Hi[p]);
267 Hx[p] = delta_j * Hx[p] * delta(
isize(i));
269 if (p <= col_start) {
279 usize col_start = qp.H.col_start(j);
280 usize col_end = qp.H.col_end(j);
281 T delta_j = delta(
isize(j));
283 for (
usize p = col_start; p < col_end; ++p) {
284 usize i = zero_extend(Hi[p]);
288 Hx[p] = delta_j * Hx[p] * delta(
isize(i));
296 qp.g.to_eigen().array() *= delta.head(n).array();
297 qp.b.to_eigen().array() *= delta.segment(n, n_eq).array();
298 qp.l.to_eigen().array() *= delta.tail(n_in).array();
299 qp.u.to_eigen().array() *= delta.tail(n_in).array();
302 auto _h_infty_norm = stack.make_new(proxsuite::linalg::veg::Tag<T>{}, n);
303 T* h_infty_norm = _h_infty_norm.ptr_mut();
317 for (
isize i = 0; i < n; ++i) {
318 avg += h_infty_norm[i];
322 gamma = 1 / std::max(avg, T(1));
324 qp.g.to_eigen() *= gamma;
325 qp.H.to_eigen() *= gamma;
327 S.array() *= delta.array();