alpaqa
matlab
Nonconvex constrained optimization
Loading...
Searching...
No Matches
src
alpaqa
include
alpaqa
functions
indicator-box.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
alpaqa/config/config.hpp
>
4
#include <
alpaqa/functions/prox.hpp
>
5
#include <
alpaqa/problem/box.hpp
>
6
#include <cassert>
7
8
namespace
alpaqa::sets
{
9
10
template
<Config Conf>
11
typename
Conf::real_t
12
alpaqa_tag_invoke
(
tag_t<alpaqa::prox>
,
Box<Conf>
&self,
typename
Conf::crmat
in
,
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
27
template
<Config Conf>
28
typename
Conf::real_t
29
alpaqa_tag_invoke
(
tag_t<alpaqa::prox_step>
,
Box<Conf>
&self,
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());
43
fb_step
= (
γ_fwd
*
fwd_step
)
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
box.hpp
config.hpp
alpaqa::sets
Definition
indicator-box.hpp:8
alpaqa::tag_invoke_ns::alpaqa_tag_invoke
constexpr tag_invoke_fn_ns::tag_invoke_fn alpaqa_tag_invoke
Definition
tag-invoke.hpp:41
alpaqa::tag_t
std::decay_t< decltype(Tag)> tag_t
Definition
tag-invoke.hpp:74
alpaqa::inf
constexpr const auto inf
Definition
config.hpp:85
prox.hpp
alpaqa::sets::Box
Definition
box.hpp:11
alpaqa::sets::Box::upperbound
vec upperbound
Definition
box.hpp:28
alpaqa::sets::Box::lowerbound
vec lowerbound
Definition
box.hpp:27
Generated on Wed Nov 15 2023 for alpaqa by
1.9.8