ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
objective
ROL_l1Objective.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Rapid Optimization Library (ROL) Package
4
//
5
// Copyright 2014 NTESS and the ROL contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef ROL_L1OBJECTIVE_H
11
#define ROL_L1OBJECTIVE_H
12
13
#include "
ROL_Objective.hpp
"
14
21
22
23
namespace
ROL
{
24
25
template
<
typename
Real>
26
class
l1Objective
:
public
Objective
<Real> {
27
private
:
28
const
Ptr<Vector<Real>>
weights_
,
shift_
;
29
Ptr<Vector<Real>>
tmp_
;
30
31
struct
ProjSymBnd
:
public
Elementwise::BinaryFunction<Real> {
32
Real
apply
(
const
Real &xc,
const
Real &yc)
const
{
return
std::min(yc, std::max(-yc, xc)); }
33
}
psb_
;
34
35
public
:
36
37
l1Objective
(
const
Ptr<
Vector<Real>
> &weights)
38
:
weights_
(weights),
shift_
(weights->dual().clone()) {
39
shift_
->zero();
40
tmp_
=
shift_
->clone();
41
}
42
43
l1Objective
(
const
Ptr<
Vector<Real>
> &weights,
const
Ptr<
Vector<Real>
> &shift)
44
:
weights_
(weights),
shift_
(shift) {
45
tmp_
=
shift_
->clone();
46
}
47
48
Real
value
(
const
Vector<Real>
&x, Real &tol ) {
49
tmp_
->set(x);
50
tmp_
->axpy(
static_cast<
Real
>
(-1),*
shift_
);
51
tmp_
->applyUnary(Elementwise::AbsoluteValue<Real>());
52
return
weights_
->apply(*
tmp_
);
53
}
54
55
void
gradient
(
Vector<Real>
&g,
const
Vector<Real>
&x, Real &tol ) {
56
g.
set
(x);
57
g.
axpy
(
static_cast<
Real
>
(-1),*
shift_
);
58
g.
applyUnary
(Elementwise::Sign<Real>());
59
g.
applyBinary
(Elementwise::Multiply<Real>(), *
weights_
);
60
}
61
62
Real
dirDeriv
(
const
Vector<Real>
&x,
const
Vector<Real>
&d, Real &tol ) {
63
gradient
(*
tmp_
, x, tol);
64
return
tmp_
->apply(d);
65
}
66
67
void
prox
(
Vector<Real>
&Pv,
const
Vector<Real>
&v, Real t, Real &tol){
68
Pv.
set
(*
shift_
);
69
Pv.
axpy
(
static_cast<
Real
>
(-1), v);
70
Pv.
scale
(
static_cast<
Real
>
(1) / t);
71
Pv.
applyBinary
(
psb_
, *
weights_
);
72
Pv.
scale
(t);
73
Pv.
plus
(v);
74
}
75
//TODO: input prox jacobian
76
};
// class l1Objective
77
78
}
// namespace ROL
79
80
#endif
ROL_Objective.hpp
ROL::ROL::Objective::Objective
Objective()
Definition
ROL_Constraint_SerialSimOpt.hpp:53
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL::Vector::set
virtual void set(const Vector &x)
Set where .
Definition
ROL_Vector.hpp:176
ROL::Vector::applyUnary
virtual void applyUnary(const Elementwise::UnaryFunction< Real > &f)
Definition
ROL_Vector.hpp:209
ROL::Vector::applyBinary
virtual void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector &x)
Definition
ROL_Vector.hpp:215
ROL::Vector::scale
virtual void scale(const Real alpha)=0
Compute where .
ROL::Vector::plus
virtual void plus(const Vector &x)=0
Compute , where .
ROL::Vector::axpy
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition
ROL_Vector.hpp:120
ROL::l1Objective::l1Objective
l1Objective(const Ptr< Vector< Real > > &weights, const Ptr< Vector< Real > > &shift)
Definition
ROL_l1Objective.hpp:43
ROL::l1Objective::shift_
const Ptr< Vector< Real > > shift_
Definition
ROL_l1Objective.hpp:28
ROL::l1Objective::prox
void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
Definition
ROL_l1Objective.hpp:67
ROL::l1Objective::weights_
const Ptr< Vector< Real > > weights_
Definition
ROL_l1Objective.hpp:28
ROL::l1Objective::gradient
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Definition
ROL_l1Objective.hpp:55
ROL::l1Objective::tmp_
Ptr< Vector< Real > > tmp_
Definition
ROL_l1Objective.hpp:29
ROL::l1Objective::dirDeriv
Real dirDeriv(const Vector< Real > &x, const Vector< Real > &d, Real &tol)
Definition
ROL_l1Objective.hpp:62
ROL::l1Objective::psb_
ROL::l1Objective::ProjSymBnd psb_
ROL::l1Objective::l1Objective
l1Objective(const Ptr< Vector< Real > > &weights)
Definition
ROL_l1Objective.hpp:37
ROL::l1Objective::value
Real value(const Vector< Real > &x, Real &tol)
Definition
ROL_l1Objective.hpp:48
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::l1Objective::ProjSymBnd
Definition
ROL_l1Objective.hpp:31
ROL::l1Objective::ProjSymBnd::apply
Real apply(const Real &xc, const Real &yc) const
Definition
ROL_l1Objective.hpp:32
Generated by
1.17.0