94 p = (-γ * grad_ψ).cwiseMax(C.
lower - x).cwiseMin(C.
upper - x);
117 p = -x.cwiseMax(γ * (grad_ψ - λ))
118 .cwiseMin(γ * (grad_ψ + λ))
119 .cwiseMin(x - C.
lower)
120 .cwiseMax(x - C.
upper);
128 return norm_1(x̂.cwiseProduct(λ));
135 auto λ_vec = vec::Constant(n, λ);
138 return λ * norm_1(x̂);
145 else if constexpr (
requires {
l1_reg(0); })
161 auto y_alm = y.bottomRows(num_alm);
162 auto z_alm_lb = D.
lower.bottomRows(num_alm);
163 auto z_alm_ub = D.
upper.bottomRows(num_alm);
169 y_alm = y_alm.cwiseMax(y_alm_lb).cwiseMin(y_alm_ub);
185 const auto nλ =
l1_reg.size();
188 if constexpr (
requires {
l1_reg(0); })
189 return (nλ == 1 &&
l1_reg(0) == 0);
195 requires config_t::supports_indexvec
199 const auto add_to_J_if_in_box_interior = [&](
real_t x_fw,
index_t i) {
206 add_to_J_if_in_box_interior(x_fw, i);
209 add_to_J_if_in_box_interior(x_fw - γ * λ, i);
210 else if (x_fw < -γ * λ)
211 add_to_J_if_in_box_interior(x_fw + γ * λ, i);
214 const auto nλ =
l1_reg.size();
215 const bool λ_is_0 = nλ == 0 || (nλ == 1 &&
l1_reg(0) == 0);
219 real_t x_fw = x(i) - γ * grad_ψ(i);
220 add_to_J_if_in_box_interior(x_fw, i);
226 real_t x_fw = x(i) - γ * grad_ψ(i);
227 update_J_general(λi, x_fw, i);
235 "Length of problem.variable_bounds.lower does not match "
236 "problem size problem.num_variables");
238 "Length of problem.variable_bounds.upper does not match "
239 "problem size problem.num_variables");
241 "Length of problem.general_bounds.lower does not match "
242 "problem size problem.num_constraints");
244 "Length of problem.general_bounds.upper does not match "
245 "problem size problem.num_constraints");
248 "Length of problem.l1_reg does not match "
249 "problem size problem.num_variables, 1 or 0");
251 throw std::invalid_argument(
"Invalid penalty_alm_split");
255 [[nodiscard]] std::string
get_name()
const {
return "BoxConstrProblem"; }
std::string get_name() 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)
const Box & get_general_bounds() const
void resize(length_t num_variables, length_t num_constraints)
Change the dimensions of the problem (number of decision variables and number of constraints).
BoxConstrProblem(const BoxConstrProblem &)=default
index_t eval_inactive_indices_res_lna(real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
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.
void eval_projection_multipliers(rvec y, real_t M) const
Box general_bounds
Other constraints, .
length_t num_variables
Number of decision variables, dimension of x.
Box variable_bounds
Constraints of the decision variables, .
BoxConstrProblem & operator=(const BoxConstrProblem &)=default
BoxConstrProblem(length_t num_variables, length_t num_constraints)
Create a problem with inactive boxes , with no -regularization, and all general constraints handled u...
index_t penalty_alm_split
Components of the constraint function with indices below this number are handled using a quadratic pe...
const Box & get_variable_bounds() const
real_t eval_proximal_gradient_step(real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
alpaqa::Box< config_t > Box
void eval_projecting_difference_constraints(crvec z, rvec p) const
bool provides_get_variable_bounds() const
Only supported if the ℓ₁-regularization term is zero.
BoxConstrProblem(std::tuple< length_t, length_t > dims)
Create a problem with inactive boxes , with no -regularization, and all general constraints handled u...
BoxConstrProblem(BoxConstrProblem &&) noexcept=default
BoxConstrProblem(Box variable_bounds, Box general_bounds, vec l1_reg=vec(0), index_t penalty_alm_split=0)
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_num_constraints() const
Number of constraints , num_constraints.
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.
length_t get_num_variables() const
Number of decision variables , num_variables.
length_t num_constraints
Number of constraints, dimension of g(x) and z.
#define USING_ALPAQA_CONFIG(Conf)
void check_dim_msg(const V &v, auto sz, std::string msg)
auto norm_1(const Eigen::MatrixBase< Derived > &v)
Get the 1-norm of the given vector.
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