31 :
n{
C.lowerbound.size()},
m{
D.lowerbound.size()},
C{std::move(
C)},
D{std::move(
D)},
84 p = -x.cwiseMax(γ * (grad_ψ - λ))
85 .cwiseMin(γ * (grad_ψ + λ))
101 auto λ_vec = vec::Constant(
n, λ);
103 return λ * vec_util ::norm_1(x̂);
110 else if (
l1_reg.size() == 1)
123 real_t y_lb = z_lb == -alpaqa::inf<config_t> ? 0 : -M;
124 return std::max(y, y_lb);
128 real_t y_ub = z_ub == alpaqa::inf<config_t> ? 0 : M;
129 return std::min(y, y_ub);
133 auto &&y_alm = y.bottomRows(num_alm);
134 auto &&z_alm_lb =
D.
lowerbound.bottomRows(num_alm);
135 auto &&z_alm_ub =
D.
upperbound.bottomRows(num_alm);
137 y_alm = y_alm.binaryExpr(z_alm_lb, max_lb).binaryExpr(z_alm_ub, min_ub);
154 const auto add_to_J_if_in_box_interior = [&](
real_t x_fw,
index_t i) {
161 add_to_J_if_in_box_interior(x_fw, i);
164 add_to_J_if_in_box_interior(x_fw - γ * λ, i);
165 else if (x_fw < -γ * λ)
166 add_to_J_if_in_box_interior(x_fw + γ * λ, i);
169 const auto nλ =
l1_reg.size();
170 const bool λ_is_0 = nλ == 0 || (nλ == 1 &&
l1_reg(0) == 0);
174 real_t x_fw = x(i) - γ * grad_ψ(i);
175 add_to_J_if_in_box_interior(x_fw, i);
181 real_t x_fw = x(i) - γ * grad_ψ(i);
182 update_J_general(λi, x_fw, i);
189 util::check_dim_msg<config_t>(
191 "Length of problem.C.lowerbound does not match problem size problem.n");
192 util::check_dim_msg<config_t>(
194 "Length of problem.C.upperbound does not match problem size problem.n");
195 util::check_dim_msg<config_t>(
197 "Length of problem.D.lowerbound does not match problem size problem.m");
198 util::check_dim_msg<config_t>(
200 "Length of problem.D.upperbound does not match problem size problem.m");
202 util::check_dim_msg<config_t>(
204 "Length of problem.l1_reg does not match problem size problem.n, 1 or 0");
205 if (penalty_alm_split < 0 || penalty_alm_split >
m)
206 throw std::invalid_argument(
"Invalid penalty_alm_split");
Box C
Constraints of the decision variables, .
const Box & get_box_C() const
index_t eval_inactive_indices_res_lna(real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
void eval_proj_diff_g(crvec z, rvec p) const
static real_t eval_prox_grad_step_box_l1(const Box &C, const auto &λ, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
Proximal gradient step for rectangular box C with ℓ₁-regularization.
static void eval_proj_multipliers_box(const Box &D, rvec y, real_t M, index_t penalty_alm_split)
BoxConstrProblem(const BoxConstrProblem &)=default
length_t m
Number of constraints, dimension of g(x) and z.
static void eval_prox_grad_step_box_l1_impl(const Box &C, const auto &λ, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
Proximal gradient step for rectangular box C with ℓ₁-regularization.
BoxConstrProblem(Box C, Box D, vec l1_reg=vec(0))
const Box & get_box_D() const
BoxConstrProblem & operator=(const BoxConstrProblem &)=default
length_t get_m() const
Number of constraints, m.
index_t penalty_alm_split
Components of the constraint function with indices below this number are handled using a quadratic pe...
length_t n
Number of decision variables, dimension of x.
Box D
Other constraints, .
void eval_proj_multipliers(rvec y, real_t M) const
BoxConstrProblem(BoxConstrProblem &&) noexcept=default
real_t eval_prox_grad_step(real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
BoxConstrProblem(length_t n, length_t m)
static real_t eval_prox_grad_step_box_l1_scal(const Box &C, real_t λ, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
Proximal gradient step for rectangular box C with ℓ₁-regularization.
length_t get_n() const
Number of decision variables, n.
vec l1_reg
(1-norm) regularization parameter.
static real_t eval_proj_grad_step_box(const Box &C, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
Projected gradient step for rectangular box C.
#define USING_ALPAQA_CONFIG(Conf)
auto norm_1(const Eigen::MatrixBase< Derived > &v)
Get the 1-norm of the given vector.
auto projecting_difference(const auto &v, const Box< Conf > &box)
Get the difference between the given vector and its projection.
typename Conf::real_t real_t
typename Conf::rindexvec rindexvec
typename Conf::index_t index_t
typename Conf::length_t length_t
typename Conf::crvec crvec