ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
objective
ROL_ChainRuleObjective.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_CHAIN_RULE_OBJECTIVE_HPP
11
#define ROL_CHAIN_RULE_OBJECTIVE_HPP
12
13
#include "
ROL_Objective.hpp
"
14
#include "
ROL_Constraint.hpp
"
15
28
29
30
namespace
ROL
{
31
32
template
<
typename
Real>
33
class
ChainRuleObjective
:
public
ROL::Objective
<Real> {
34
public
:
35
42
ChainRuleObjective
(
const
Ptr<
Objective<Real>
>& obj,
43
const
Ptr<
Constraint<Real>
>& con,
44
const
Vector<Real>
& x,
45
const
Vector<Real>
& l )
46
:
obj_
(obj),
con_
(con),
g_
(l.clone()),
y_
(l.dual().clone()),
Jv_
(l.dual().clone()),
47
HJv_
(l.clone()),
JtHJv_
(x.dual().clone()),
tol_
(0) {}
48
49
virtual
~ChainRuleObjective
() =
default
;
50
58
virtual
void
update
(
const
Vector<Real>
&x,
UpdateType
type,
int
iter = -1 ) {
59
con_
->update(x,type,iter);
60
con_
->value(*
y_
,x,
tol_
);
61
obj_
->update(*
y_
,type,iter);
62
}
63
71
virtual
void
update
(
const
Vector<Real>
&x,
bool
flag =
true
,
int
iter = -1 ) {
72
con_
->update(x,flag,iter);
73
con_
->value(*
y_
,x,
tol_
);
74
obj_
->update(*
y_
,flag,iter);
75
}
76
83
virtual
Real
value
(
const
Vector<Real>
&x, Real &tol ) {
84
con_
->value(*
y_
,x,tol);
85
return
obj_
->value(*
y_
,tol);
86
}
87
96
virtual
void
gradient
(
Vector<Real>
&g,
const
Vector<Real>
&x, Real &tol ) {
97
con_
->value(*
y_
,x,tol);
98
obj_
->gradient(*
g_
,*
y_
,tol);
99
con_
->applyAdjointJacobian(g,*
g_
,x,tol);
100
}
101
110
virtual
void
hessVec
(
Vector<Real>
&hv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
111
con_
->value(*
y_
,x,tol);
112
obj_
->gradient(*
g_
,*
y_
,tol);
113
con_
->applyJacobian(*
Jv_
,v,x,tol);
114
obj_
->hessVec(*
HJv_
,*
Jv_
,*
y_
,tol);
115
con_
->applyAdjointJacobian(*
JtHJv_
,*
HJv_
,x,tol);
116
con_
->applyAdjointHessian(hv,*
g_
,v,x,tol);
117
hv.
plus
(*
JtHJv_
);
118
}
119
120
private
:
121
122
const
Ptr<Objective<Real>>
obj_
;
123
const
Ptr<Constraint<Real>>
con_
;
124
Ptr<Vector<Real>>
g_
,
y_
,
Jv_
,
HJv_
,
JtHJv_
;
125
Real
tol_
;
126
127
};
// class ChainRuleObjective
128
129
}
// namespace ROL
130
131
#endif
// ROL_CHAIN_RULE_OBJECTIVE_HPP
ROL_Constraint.hpp
ROL_Objective.hpp
ROL::ChainRuleObjective::g_
Ptr< Vector< Real > > g_
Definition
ROL_ChainRuleObjective.hpp:124
ROL::ChainRuleObjective::value
virtual Real value(const Vector< Real > &x, Real &tol)
Compute value.
Definition
ROL_ChainRuleObjective.hpp:83
ROL::ChainRuleObjective::update
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
Definition
ROL_ChainRuleObjective.hpp:71
ROL::ChainRuleObjective::ChainRuleObjective
ChainRuleObjective(const Ptr< Objective< Real > > &obj, const Ptr< Constraint< Real > > &con, const Vector< Real > &x, const Vector< Real > &l)
Constructor.
Definition
ROL_ChainRuleObjective.hpp:42
ROL::ChainRuleObjective::JtHJv_
Ptr< Vector< Real > > JtHJv_
Definition
ROL_ChainRuleObjective.hpp:124
ROL::ChainRuleObjective::update
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
Definition
ROL_ChainRuleObjective.hpp:58
ROL::ChainRuleObjective::obj_
const Ptr< Objective< Real > > obj_
Definition
ROL_ChainRuleObjective.hpp:122
ROL::ChainRuleObjective::hessVec
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Definition
ROL_ChainRuleObjective.hpp:110
ROL::ChainRuleObjective::tol_
Real tol_
Definition
ROL_ChainRuleObjective.hpp:125
ROL::ChainRuleObjective::~ChainRuleObjective
virtual ~ChainRuleObjective()=default
ROL::ChainRuleObjective::Jv_
Ptr< Vector< Real > > Jv_
Definition
ROL_ChainRuleObjective.hpp:124
ROL::ChainRuleObjective::gradient
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Definition
ROL_ChainRuleObjective.hpp:96
ROL::ChainRuleObjective::con_
const Ptr< Constraint< Real > > con_
Definition
ROL_ChainRuleObjective.hpp:123
ROL::ChainRuleObjective::HJv_
Ptr< Vector< Real > > HJv_
Definition
ROL_ChainRuleObjective.hpp:124
ROL::ChainRuleObjective::y_
Ptr< Vector< Real > > y_
Definition
ROL_ChainRuleObjective.hpp:124
ROL::Constraint
Defines the general constraint operator interface.
Definition
ROL_Constraint.hpp:52
ROL::ROL::Objective
Definition
ROL_Constraint_SerialSimOpt.hpp:44
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::plus
virtual void plus(const Vector &x)=0
Compute , where .
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::UpdateType
UpdateType
Definition
ROL_UpdateType.hpp:18
Generated by
1.17.0