alpaqa 1.0.0a15
Nonconvex constrained optimization
Loading...
Searching...
No Matches
indicator-box.hpp
Go to the documentation of this file.
1#pragma once
2
6#include <cassert>
7
8namespace alpaqa::sets {
9
10template <Config Conf>
11typename Conf::real_t
13 typename Conf::rmat out,
14 [[maybe_unused]] typename Conf::real_t γ) {
15 assert(in.rows() == out.rows());
16 assert(in.cols() == out.cols());
17 assert(in.size() == self.lowerbound.size());
18 assert(in.size() == self.upperbound.size());
19 assert(!(self.lowerbound.array() > self.upperbound.array()).any());
20 out = in.reshaped()
21 .cwiseMax(self.lowerbound)
22 .cwiseMin(self.upperbound)
23 .reshaped(in.rows(), in.cols());
24 return 0;
25}
26
27template <Config Conf>
28typename Conf::real_t
30 typename Conf::crmat in, typename Conf::crmat fwd_step,
31 typename Conf::rmat out, typename Conf::rmat fb_step,
32 [[maybe_unused]] typename Conf::real_t γ,
33 typename Conf::real_t γ_fwd) {
34 assert(in.rows() == fwd_step.rows());
35 assert(in.cols() == fwd_step.cols());
36 assert(in.rows() == out.rows());
37 assert(in.cols() == out.cols());
38 assert(in.rows() == fb_step.rows());
39 assert(in.cols() == fb_step.cols());
40 assert(in.size() == self.lowerbound.size());
41 assert(in.size() == self.upperbound.size());
42 assert(!(self.lowerbound.array() > self.upperbound.array()).any());
44 .reshaped()
45 .cwiseMax(self.lowerbound - in.reshaped())
46 .cwiseMin(self.upperbound - in.reshaped())
47 .reshaped(in.rows(), in.cols());
48 out = in + fb_step;
49 return 0;
50}
51
52} // namespace alpaqa
constexpr tag_invoke_fn_ns::tag_invoke_fn alpaqa_tag_invoke
std::decay_t< decltype(Tag)> tag_t
constexpr const auto inf
Definition config.hpp:85