8template <index_t VL, StorageOrder DefaultOrder>
15 const real_t min_denom = 1e-6;
16 const real_t norm_inf_e = fmax(min_denom,
norm_inf(ctx, e));
17 index_t num_changed = 0;
18 const auto update_simd = [&](
auto Σji,
auto eji,
auto eji_old) {
19 auto insufficient_progress = abs(eji) >=
settings.θ * abs(eji_old);
20#if BATMAT_WITH_GSI_HPC_SIMD
22 select(insufficient_progress,
settings.Δy * abs(eji) / norm_inf_e,
simd{1});
24 simd update_factor{1};
25 where(insufficient_progress, update_factor) =
settings.Δy * abs(eji) / norm_inf_e;
28 auto Σ_new = Σji * update_factor;
30#if BATMAT_WITH_GSI_HPC_SIMD
31 num_changed += reduce_count(Σ_new != Σji);
33 num_changed += popcount(Σ_new != Σji);
37 const auto update_batch = [&](
auto,
auto,
auto Σj,
auto ej,
auto ej_old) {
40 ocp.foreach_stage(ctx, update_batch, Σ, e, e_old);
41 return ctx.reduce(num_changed);
44template <index_t VL, StorageOrder DefaultOrder>
49 const auto ineq_constr_resid = [](
auto,
auto,
auto Axj,
auto b_minj,
auto b_maxj,
auto ej) {
55template <index_t VL, StorageOrder DefaultOrder>
59 const auto proj_simd = [](
auto yji,
auto b_minji,
auto b_maxji) {
60#if BATMAT_WITH_GSI_HPC_SIMD
61 yji = select(isfinite(b_minji), yji, fmax(yji,
simd{0}));
62 yji = select(isfinite(b_maxji), yji, fmin(yji,
simd{0}));
64 where(!isfinite(b_minji), yji) = fmax(yji,
simd{0});
65 where(!isfinite(b_maxji), yji) = fmin(yji,
simd{0});
69 const auto proj_batch = [&](
auto,
auto,
auto yji,
auto b_minji,
auto b_maxji) {
75template <index_t VL, StorageOrder DefaultOrder>
80 auto nrm_simd =
norms.zero_simd();
81 const auto viol_simd = [&](
auto Axji,
auto b_minji,
auto b_maxji) {
82 auto zi = fmax(b_minji, fmin(Axji, b_maxji));
83 nrm_simd =
norms(nrm_simd, Axji - zi);
85 const auto viol_batch = [&](
auto,
auto,
auto Axj,
auto b_min_j,
auto b_max_j) {
89 return ctx.reduce(
norms(nrm_simd),
norms).norm_inf();
92template <index_t VL, StorageOrder DefaultOrder>
100 auto nrm_simd =
norms.zero_simd();
101 const auto resid_simd = [&](
auto yji,
auto ŷji,
auto Σji) {
102 auto ei = (ŷji - yji) / Σji;
103 nrm_simd =
norms(nrm_simd, ei);
106 const auto resid_batch = [&](
auto,
auto,
auto ej,
auto yj,
auto ŷj,
auto Σj) {
109 ocp.foreach_stage(ctx, resid_batch, e, y, ŷ, Σ);
110 return ctx.reduce(
norms(nrm_simd),
norms).norm_inf();
113template <index_t VL, StorageOrder DefaultOrder>
120 const auto ŷ_simd = [&count_J](
auto Σi,
auto yi,
auto Axi,
auto li,
auto ui) {
121 auto ζ = Axi + yi / Σi, z = fmax(li, fmin(ζ, ui));
125 where(Ji, ŷi) = yi + Σi * (Axi - z);
127 auto ŷi = yi + Σi * (Axi - z);
129#if BATMAT_WITH_GSI_HPC_SIMD
131 count_J +=
static_cast<index_t
>(reduce_count(Ji));
135 count_J +=
static_cast<index_t
>(popcount(Ji));
137 return std::make_pair(ŷi, ΣJi);
139 const auto ŷ_batch = [&ŷ_simd]([[maybe_unused]]
auto j,
auto,
auto ŷi,
auto Ji,
auto Σi,
140 auto yi,
auto Axi,
auto li,
auto ui) {
143 Σi, yi, Axi, li, ui);
151 return ctx.reduce(count_J);
void for_each_elementwise(F &&fun, VA &&A, VAs &&...As)
Apply a function to all elements of the given matrices or vectors.
void transform_elementwise(F &&fun, VA &&A, VAs &&...As)
Apply a function to all elements of the given matrices or vectors, storing the result in the first ar...
void clamp_resid(Vx &&x, Vlo &&lo, Vhi &&hi, Vz &&z)
Elementwise clamping residual z = x - max(lo, min(x, hi)).
void transform2_elementwise(F &&fun, VA &&A, VB &&B, VAs &&...As)
Apply a function to all elements of the given matrices or vectors, storing the results in the first t...
#define GUANAQO_TRACE(name, instance,...)
real_t ineq_constr_viol(Context &ctx, const ineq_constr_vec_t &Ax) const
index_t calc_ŷ_Aᵀŷ(Context &ctx, const ineq_constr_vec_t &Ax, const ineq_constr_vec_t &Σ, const ineq_constr_vec_t &y, ineq_constr_vec_t &ŷ, var_vec_t &Aᵀŷ, active_set_t &J)
real_t norm_inf(Context &ctx, const T &x) const
Infinity or max norm of x.
auto get_timed(Timings::type Timings::*member) const
ineq_constr_vec_t b_max_strided
typename OCP_t::Context Context
CyQPALMBackendSettings settings
void project_multipliers_ineq(Context &ctx, ineq_constr_vec_t &y) const
index_t update_penalty_y(Context &ctx, ineq_constr_vec_t &Σ, const ineq_constr_vec_t &e, const ineq_constr_vec_t &e_old, const PenaltySettings &settings)
Increase the penalty parameters Σ for which the violation e has not decreased sufficiently compared t...
real_t ineq_constr_resid_al(Context &ctx, const ineq_constr_vec_t &y, const ineq_constr_vec_t &ŷ, const ineq_constr_vec_t &Σ, ineq_constr_vec_t &e)
typename OCP_t::simd simd
ineq_constr_vec_t b_min_strided
void ineq_constr_resid(Context &ctx, const ineq_constr_vec_t &Ax, ineq_constr_vec_t &e) const
void mat_vec_AT(Context &ctx, const ineq_constr_vec_t &y, var_vec_t &Aᵀy)
type ineq_constr_resid_al
static constexpr auto norms