ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
objective
ROL_AffineTransformObjective_Def.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_AFFINE_TRANSFORM_OBJECTIVE_DEF_H
11
#define ROL_AFFINE_TRANSFORM_OBJECTIVE_DEF_H
12
13
namespace
ROL
{
14
15
template
<
typename
Real>
16
AffineTransformObjective<Real>::AffineTransformObjective
(
const
Ptr<
Objective<Real>
> &obj,
17
const
Ptr<
Constraint<Real>
> &acon,
18
const
Vector<Real>
&range,
19
const
Ptr<
VectorController<Real>
> &storage)
20
:
obj_
(obj),
acon_
(acon),
storage_
(storage) {
21
primal_
= range.
clone
();
22
Av_
= range.
clone
();
23
dual_
= range.
dual
().clone();
24
if
(storage == nullPtr)
storage_
= makePtr<
VectorController<Real>
>();
25
}
26
27
template
<
typename
Real>
28
AffineTransformObjective<Real>::AffineTransformObjective
(
const
Ptr<
Objective<Real>
> &obj,
29
const
Ptr<
LinearConstraint<Real>
> &acon,
30
const
Ptr<
VectorController<Real>
> &storage)
31
:
obj_
(obj),
acon_
(acon),
storage_
(storage) {
32
primal_
= acon->createRangeSpaceVector();
33
Av_
= acon->createRangeSpaceVector();
34
dual_
=
primal_
->dual().clone();
35
if
(storage == nullPtr)
storage_
= makePtr<
VectorController<Real>
>();
36
}
37
38
template
<
typename
Real>
39
AffineTransformObjective<Real>::AffineTransformObjective
(
const
Ptr<
Objective<Real>
> &obj,
40
const
Ptr<
const
LinearOperator<Real>
> &A,
41
const
Ptr<
const
Vector<Real>
> &b,
42
const
Ptr<
VectorController<Real>
> &storage)
43
:
obj_
(obj),
acon_
(makePtr<
LinearConstraint
<Real>>(A,b)),
storage_
(storage) {
44
primal_
= b->clone();
45
Av_
= b->clone();
46
dual_
= b->dual().clone();
47
if
(storage == nullPtr)
storage_
= makePtr<
VectorController<Real>
>();
48
}
49
50
template
<
typename
Real>
51
void
AffineTransformObjective<Real>::update
(
const
Vector<Real>
&x,
UpdateType
type,
int
iter) {
52
storage_
->objectiveUpdate(type);
53
acon_
->update(x,type,iter);
54
obj_
->update(*
transform
(x),type,iter);
55
}
56
57
template
<
typename
Real>
58
void
AffineTransformObjective<Real>::update
(
const
Vector<Real>
&x,
bool
flag,
int
iter ) {
59
storage_
->objectiveUpdate(
true
);
60
acon_
->update(x,flag,iter);
61
obj_
->update(*
transform
(x),flag,iter);
62
}
63
64
template
<
typename
Real>
65
Real
AffineTransformObjective<Real>::value
(
const
Vector<Real>
&x, Real &tol ) {
66
return
obj_
->value(*
transform
(x),tol);
67
}
68
69
template
<
typename
Real>
70
void
AffineTransformObjective<Real>::gradient
(
Vector<Real>
&g,
const
Vector<Real>
&x, Real &tol ) {
71
obj_
->gradient(*
dual_
,*
transform
(x),tol);
72
acon_
->applyAdjointJacobian(g,*
dual_
,x,tol);
73
}
74
75
template
<
typename
Real>
76
void
AffineTransformObjective<Real>::hessVec
(
Vector<Real>
&hv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
77
acon_
->applyJacobian(*
Av_
,v,x,tol);
78
obj_
->hessVec(*
dual_
,*
Av_
,*
transform
(x),tol);
79
acon_
->applyAdjointJacobian(hv,*
dual_
,x,tol);
80
}
81
82
template
<
typename
Real>
83
void
AffineTransformObjective<Real>::setParameter
(
const
std::vector<Real> ¶m) {
84
Objective<Real>::setParameter
(param);
85
obj_
->setParameter(param);
86
}
87
88
template
<
typename
Real>
89
Ptr<const Vector<Real>>
AffineTransformObjective<Real>::transform
(
const
Vector<Real>
&x) {
90
bool
isApplied =
storage_
->get(*
primal_
,
Objective<Real>::getParameter
());
91
if
(!isApplied) {
92
Real tol = std::sqrt(
ROL_EPSILON<Real>
());
93
acon_
->value(*
primal_
,x,tol);
94
storage_
->set(*
primal_
,
Objective<Real>::getParameter
());
95
}
96
return
primal_
;
97
}
98
99
}
// namespace ROL
100
101
#endif
// ROL_AFFINE_TRANSFORM_OBJECTIVE_DEF_H
ROL::AffineTransformObjective::transform
Ptr< const Vector< Real > > transform(const Vector< Real > &x)
ROL::AffineTransformObjective::AffineTransformObjective
AffineTransformObjective(const Ptr< Objective< Real > > &obj, const Ptr< Constraint< Real > > &acon, const Vector< Real > &range, const Ptr< VectorController< Real > > &storage=nullPtr)
ROL::AffineTransformObjective::update
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
ROL::AffineTransformObjective::setParameter
void setParameter(const std::vector< Real > ¶m) override
ROL::AffineTransformObjective::value
Real value(const Vector< Real > &x, Real &tol) override
ROL::AffineTransformObjective::hessVec
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
ROL::AffineTransformObjective::gradient
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
ROL::Objective::setParameter
virtual void setParameter(const std::vector< Real > ¶m)
Definition
ROL_Objective.hpp:509
ROL::ROL::AffineTransformObjective::Av_
Ptr< Vector< Real > > Av_
Definition
ROL_Constraint_SerialSimOpt.hpp:34
ROL::ROL::AffineTransformObjective::dual_
Ptr< Vector< Real > > dual_
Definition
ROL_Constraint_SerialSimOpt.hpp:34
ROL::ROL::AffineTransformObjective::storage_
Ptr< VectorController< Real > > storage_
Definition
ROL_Constraint_SerialSimOpt.hpp:33
ROL::ROL::AffineTransformObjective::primal_
Ptr< Vector< Real > > primal_
Definition
ROL_Constraint_SerialSimOpt.hpp:34
ROL::ROL::AffineTransformObjective::transform
Ptr< const Vector< Real > > transform(const Vector< Real > &x)
Definition
ROL_AffineTransformObjective_Def.hpp:89
ROL::ROL::AffineTransformObjective::obj_
const Ptr< Objective< Real > > obj_
Definition
ROL_Constraint_SerialSimOpt.hpp:30
ROL::ROL::AffineTransformObjective::acon_
const Ptr< Constraint< Real > > acon_
Definition
ROL_Constraint_SerialSimOpt.hpp:31
ROL::ROL::Constraint
Definition
ROL_Constraint_SerialSimOpt.hpp:52
ROL::ROL::LinearConstraint
Definition
ROL_Constraint_SerialSimOpt.hpp:26
ROL::ROL::LinearOperator
Definition
ROL_Constraint_SerialSimOpt.hpp:37
ROL::ROL::Objective::getParameter
const std::vector< Real > getParameter(void) const
Definition
ROL_Constraint_SerialSimOpt.hpp:504
ROL::ROL::Objective::Objective
Objective()
Definition
ROL_Constraint_SerialSimOpt.hpp:53
ROL::ROL::VectorController
Definition
ROL_Constraint_SerialSimOpt.hpp:21
ROL::ROL::Vector
Definition
ROL_Constraint_SerialSimOpt.hpp:51
ROL::ROL::Vector::clone
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
ROL::ROL::Vector::dual
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
Definition
ROL_Constraint_SerialSimOpt.hpp:193
ROL::ROL::UpdateType
UpdateType
Definition
ROL_Constraint_SerialSimOpt.hpp:19
ROL::ROL::ROL_EPSILON
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Definition
ROL_Constraint_SerialSimOpt.hpp:57
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0