Skip to content

Commit

Permalink
Move alpaqa::Box to alpaqa::sets
Browse files Browse the repository at this point in the history
This avoids alpaqa_tag_invoke ambiguities
  • Loading branch information
tttapa committed Sep 6, 2023
1 parent 16559b4 commit 6415693
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/alpaqa/include/alpaqa/functions/indicator-box.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include <alpaqa/config/config.hpp>
#include <alpaqa/problem/box.hpp>
#include <alpaqa/functions/prox.hpp>
#include <alpaqa/problem/box.hpp>
#include <cassert>

namespace alpaqa {
namespace alpaqa::sets {

template <Config Conf>
typename Conf::real_t
Expand Down
2 changes: 1 addition & 1 deletion src/alpaqa/include/alpaqa/problem/box-constr-problem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class BoxConstrProblem {
}

/// @see @ref TypeErasedProblem::eval_proj_diff_g
void eval_proj_diff_g(crvec z, rvec p) const { p = alpaqa::projecting_difference(z, D); }
void eval_proj_diff_g(crvec z, rvec p) const { p = projecting_difference(z, D); }

static void eval_proj_multipliers_box(const Box &D, rvec y, real_t M,
index_t penalty_alm_split) {
Expand Down
6 changes: 6 additions & 0 deletions src/alpaqa/include/alpaqa/problem/box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace alpaqa {

namespace sets {

template <Config Conf = DefaultConfig>
struct Box {
USING_ALPAQA_CONFIG(Conf);
Expand Down Expand Up @@ -76,4 +78,8 @@ inline auto dist_squared(const auto &v, ///< [in] The vector to project
return d.dot(Σ.asDiagonal() * d);
}

} // namespace sets

using sets::Box;

} // namespace alpaqa
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ class CasADiControlProblem {
void eval_proj_diff_g(crvec z, rvec e) const {
for (index_t t = 0; t < N; ++t)
e.segment(t * nc, nc) =
alpaqa::projecting_difference(z.segment(t * nc, nc), D);
projecting_difference(z.segment(t * nc, nc), D);
e.segment(N * nc, nc_N) =
alpaqa::projecting_difference(z.segment(N * nc, nc_N), D_N);
projecting_difference(z.segment(N * nc, nc_N), D_N);
}
/// @see @ref TypeErasedControlProblem::eval_proj_multipliers
void eval_proj_multipliers(rvec y, real_t M) const {
Expand Down
8 changes: 4 additions & 4 deletions test/inner/test-panoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ TEST(PANOC, calc_ψ_grad_ψ) {
vec invΣy = Σ.asDiagonal().inverse() * y;

auto ψ_fun = [&op, &f, &g, &Σ, &invΣy](crvec x) -> real_t {
return f(x) + 0.5 * alpaqa::dist_squared(g(x) + invΣy, op.D, Σ);
return f(x) + 0.5 * dist_squared(g(x) + invΣy, op.D, Σ);
};

// Compute ψ and ∇ψ manually
vec ζ = g(x) + invΣy;
vec ẑ = alpaqa::project(ζ, op.D);
vec ẑ = project(ζ, op.D);
vec d = ζ - ẑ;
vec ŷ = Σ.asDiagonal() * d;
real_t ψ = f(x) + 0.5 * d.dot(ŷ);
Expand Down Expand Up @@ -251,12 +251,12 @@ TEST(PANOC, hessian) {
vec invΣy = Σ.asDiagonal().inverse() * y;

auto ψ_fun = [&op, &f, &g, &Σ, &invΣy](crvec x) -> real_t {
return f(x) + 0.5 * alpaqa::dist_squared(g(x) + invΣy, op.D, Σ);
return f(x) + 0.5 * dist_squared(g(x) + invΣy, op.D, Σ);
};

// Compute ψ and ∇ψ manually
vec ζ = g(x) + invΣy;
vec ẑ = alpaqa::project(ζ, op.D);
vec ẑ = project(ζ, op.D);
vec d = ζ - ẑ;
vec ŷ = Σ.asDiagonal() * d;
real_t ψ = f(x) + 0.5 * d.dot(ŷ);
Expand Down

0 comments on commit 6415693

Please sign in to comment.