ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
step
interiorpoint
ROL_MeritFunction.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_MERITFUNCTION_H
11
#define ROL_MERITFUNCTION_H
12
13
#include "
ROL_Objective.hpp
"
14
#include "ROL_InequalityConstraint.hpp"
15
#include "
ROL_PartitionedVector.hpp
"
16
17
/* Nonsmooth merit function as depicted in Eq. 19.36 of Nocedal and Wright Second Edition
18
19
\f[
20
\phi_\nu(x,s) = f(x) - \mu\sum\limits_{i=1}^m \ln(s_i)
21
+ \nu \| c_E(x)\| + \nu + \| c_I(x)-s\|
22
\f]
23
24
using the Euclidean norm without squares
25
*/
26
27
28
namespace
ROL
{
29
namespace
InteriorPoint
{
30
31
template
<
class
Real>
32
class
MeritFunction
:
public
Objective
<Real> {
33
34
typedef
Vector<Real>
V
;
35
typedef
PartitionedVector<Real>
PV
;
36
typedef
Objective<Real>
OBJ
;
37
typedef
Constraint<Real>
EQCON
;
38
typedef
InequalityConstraint<Real>
INCON
;
39
40
typedef
ROL::ParameterList
PLIST
;
41
42
43
typedef
typename
PV::size_type
uint
;
44
45
const
static
uint
OPT
= 0;
46
const
static
uint
SLACK
= 1;
47
48
49
private
:
50
51
ROL::Ptr<OBJ>
obj_
;
// Raw objective function
52
ROL::Ptr<EQCON>
eqcon_
;
// constraint
53
ROL::Ptr<INCON>
incon_
;
// Inequality constraint
54
ROL::Ptr<BND>
bnd_
;
// Bound constraint
55
56
Real
mu_
;
// Penalty parameter for log barrier on slack
57
Real
nu_
;
// Penalty parameter for constraint norms
58
59
ROL::Ptr<OBJ>
obj_
;
60
ROL::Ptr<EQCON>
eqcon_
;
61
ROL::Ptr<INCON>
incon_
;
62
63
ROL::Ptr<V>
xopt_
;
64
ROL::Ptr<V>
slack_
;
65
66
ROL::Ptr<V>
gopt_
;
// Gradient of the objective function
67
68
ROL::Ptr<V>
sfun_
;
// store elementwise function of slack variable
69
70
71
ROL::Ptr<V>
eqmult_
;
// constraint Lagrange multiplier
72
ROL::Ptr<V>
inmult_
;
// Inequality constraint Lagrange multiplier
73
74
ROL::Ptr<V>
ce_
;
// constraint vector
75
ROL::Ptr<V>
ci_
;
// Inequation constraint vector
76
77
ROL::Ptr<V>
jced_
;
// Jacobian applied to d
78
ROL::Ptr<V>
jcid_
;
// Inequality Jacobian applied to d
79
80
Real
cenorm_
;
81
Real
cinorm_
;
82
83
84
static
const
Elementwise::Logarithm<Real>
LOG_
;
85
static
const
Elementwise::Reciprocal<Real>
RECIP_
;
86
static
const
Elementwise::ReductionSum<Real>
SUM_
;
87
88
89
public
:
90
91
MeritFunction
( ROL::Ptr<OBJ> &obj,
92
ROL::Ptr<EQCON> &eqcon,
93
ROL::Ptr<INCON> &incon,
94
const
V
& x,
95
const
V
& eqmult,
96
const
V
& inmult,
97
PLIST
&parlist ) :
98
obj_
(obj),
eqcon_
(eqcon),
incon_
(incon) {
99
100
const
PV
&xpv =
dynamic_cast<
const
PV
&
>
(x);
101
xopt_
= xpv.
get
(
OPT
);
102
slack_
= xpv.
get
(
SLACK
);
103
sfun_
=
slack_
->clone();
104
105
gopt_
=
xopt_
->dual().clone();
106
107
PLIST
&iplist = parlist.sublist(
"Step"
).sublist(
"Primal-Dual Interior Point"
);
108
mu_
= iplist.get(
"Initial Slack Penalty"
);
109
nu_
= iplist.get(
"Initial Constraint Norm Penalty"
);
110
111
}
112
113
114
Real
value
(
const
V
&x, Real &tol ) {
115
116
const
PV
&xpv =
dynamic_cast<
const
PV
&
>
(x);
117
xopt_
= xpv.
get
(
OPT
);
118
slack_
= xpv.
get
(
SLACK
);
119
120
sfun_
->set(*
slack_
);
121
122
sfun_
->applyUnary(
LOG_
);
123
124
Real val =
obj_
->value(*
xopt_
,tol);
125
126
val +=
mu_
*logs_->reduce(
SUM_
);
127
128
eqcon_
->value(*
ce_
,*
xopt_
,tol);
129
incon_
->value(*
ci_
,*
xopt_
,tol);
130
131
cenorm_
=
ce_
->norm();
132
cinorm_
=
ci_
->norm();
133
134
val +=
nu_
*(
cenorm_
+
cinorm_
);
135
136
return
val;
137
}
138
139
140
Real
dirDeriv
(
const
V
&x,
const
V
&d, Real tol ) {
141
142
const
PV
&xpv =
dynamic_cast<
const
PV
&
>
(x);
143
xopt_
= xpv.
get
(
OPT
);
144
slack_
= xpv.
get
(
SLACK
);
145
146
const
PV
&dpv =
dynamic_cast<
const
PV
&
>
(d);
147
ROL::Ptr<V> dopt = dpv.
get
(
OPT
);
148
ROL::Ptr<V> dslack = dpv.
get
(
SLACK
);
149
150
sfun_
->set(*slack);
151
sfun_
->applyUnary(
RECIP_
);
152
153
ce_
->applyJacobian(*
jced_
,*dopt,*xopt,tol);
154
ci_
->applyJacobian(*
jcid_
,*dopt,*xopt,tol);
155
156
obj_
->gradient(*
gopt_
,*xopt,tol);
157
158
159
// Contributions to directional derivatives
160
Real ddopt =
gopt_
->dot(*dopt);
161
162
Real ddslack =
sfun_
->dot(*dslack);
163
164
Real ddce =
ce_
->dot(*
jced_
)/
cenorm_
;
165
166
Real ddci =
ci_
->dot(*
jcid_
)/
cinorm_
;
167
168
Real ddsn =
slack_
->dot(*dslack)/slack->norm();
169
170
return
ddopt -
mu_
*ddslack +
nu_
*(ddce + ddci + ddsn);
171
172
}
173
174
175
void
updateBarrier
( Real mu ) {
176
mu_
= mu;
177
}
178
179
180
181
};
// class MeritFunction
182
183
}
// namespace InteriorPoint
184
}
// namespace ROL
185
186
187
#endif
// ROL_MERITFUNCTION_H
188
189
190
191
192
193
194
195
196
197
198
ROL_Objective.hpp
ROL_PartitionedVector.hpp
ROL::Constraint
Defines the general constraint operator interface.
Definition
ROL_Constraint.hpp:52
ROL::InteriorPoint::MeritFunction::ci_
ROL::Ptr< V > ci_
Definition
ROL_MeritFunction.hpp:75
ROL::InteriorPoint::MeritFunction::value
Real value(const V &x, Real &tol)
Definition
ROL_MeritFunction.hpp:114
ROL::InteriorPoint::MeritFunction::PLIST
ROL::ParameterList PLIST
Definition
ROL_MeritFunction.hpp:40
ROL::InteriorPoint::MeritFunction::LOG_
static const Elementwise::Logarithm< Real > LOG_
Definition
ROL_MeritFunction.hpp:84
ROL::InteriorPoint::MeritFunction::jcid_
ROL::Ptr< V > jcid_
Definition
ROL_MeritFunction.hpp:78
ROL::InteriorPoint::MeritFunction::xopt_
ROL::Ptr< V > xopt_
Definition
ROL_MeritFunction.hpp:63
ROL::InteriorPoint::MeritFunction::EQCON
Constraint< Real > EQCON
Definition
ROL_MeritFunction.hpp:37
ROL::InteriorPoint::MeritFunction::sfun_
ROL::Ptr< V > sfun_
Definition
ROL_MeritFunction.hpp:68
ROL::InteriorPoint::MeritFunction::dirDeriv
Real dirDeriv(const V &x, const V &d, Real tol)
Definition
ROL_MeritFunction.hpp:140
ROL::InteriorPoint::MeritFunction::eqmult_
ROL::Ptr< V > eqmult_
Definition
ROL_MeritFunction.hpp:71
ROL::InteriorPoint::MeritFunction::updateBarrier
void updateBarrier(Real mu)
Definition
ROL_MeritFunction.hpp:175
ROL::InteriorPoint::MeritFunction::obj_
ROL::Ptr< OBJ > obj_
Definition
ROL_MeritFunction.hpp:51
ROL::InteriorPoint::MeritFunction::incon_
ROL::Ptr< INCON > incon_
Definition
ROL_MeritFunction.hpp:53
ROL::InteriorPoint::MeritFunction::jced_
ROL::Ptr< V > jced_
Definition
ROL_MeritFunction.hpp:77
ROL::InteriorPoint::MeritFunction::inmult_
ROL::Ptr< V > inmult_
Definition
ROL_MeritFunction.hpp:72
ROL::InteriorPoint::MeritFunction::INCON
InequalityConstraint< Real > INCON
Definition
ROL_MeritFunction.hpp:38
ROL::InteriorPoint::MeritFunction::uint
PV::size_type uint
Definition
ROL_MeritFunction.hpp:43
ROL::InteriorPoint::MeritFunction::RECIP_
static const Elementwise::Reciprocal< Real > RECIP_
Definition
ROL_MeritFunction.hpp:85
ROL::InteriorPoint::MeritFunction::slack_
ROL::Ptr< V > slack_
Definition
ROL_MeritFunction.hpp:64
ROL::InteriorPoint::MeritFunction::mu_
Real mu_
Definition
ROL_MeritFunction.hpp:56
ROL::InteriorPoint::MeritFunction::gopt_
ROL::Ptr< V > gopt_
Definition
ROL_MeritFunction.hpp:66
ROL::InteriorPoint::MeritFunction::cinorm_
Real cinorm_
Definition
ROL_MeritFunction.hpp:81
ROL::InteriorPoint::MeritFunction::PV
PartitionedVector< Real > PV
Definition
ROL_MeritFunction.hpp:35
ROL::InteriorPoint::MeritFunction::SLACK
static const uint SLACK
Definition
ROL_MeritFunction.hpp:46
ROL::InteriorPoint::MeritFunction::cenorm_
Real cenorm_
Definition
ROL_MeritFunction.hpp:80
ROL::InteriorPoint::MeritFunction::eqcon_
ROL::Ptr< EQCON > eqcon_
Definition
ROL_MeritFunction.hpp:52
ROL::InteriorPoint::MeritFunction::OBJ
Objective< Real > OBJ
Definition
ROL_MeritFunction.hpp:36
ROL::InteriorPoint::MeritFunction::V
Vector< Real > V
Definition
ROL_MeritFunction.hpp:34
ROL::InteriorPoint::MeritFunction::nu_
Real nu_
Definition
ROL_MeritFunction.hpp:57
ROL::InteriorPoint::MeritFunction::ce_
ROL::Ptr< V > ce_
Definition
ROL_MeritFunction.hpp:74
ROL::InteriorPoint::MeritFunction::MeritFunction
MeritFunction(ROL::Ptr< OBJ > &obj, ROL::Ptr< EQCON > &eqcon, ROL::Ptr< INCON > &incon, const V &x, const V &eqmult, const V &inmult, PLIST &parlist)
Definition
ROL_MeritFunction.hpp:91
ROL::InteriorPoint::MeritFunction::OPT
static const uint OPT
Definition
ROL_MeritFunction.hpp:45
ROL::InteriorPoint::MeritFunction::bnd_
ROL::Ptr< BND > bnd_
Definition
ROL_MeritFunction.hpp:54
ROL::InteriorPoint::MeritFunction::SUM_
static const Elementwise::ReductionSum< Real > SUM_
Definition
ROL_MeritFunction.hpp:86
ROL::PartitionedVector
Defines the linear algebra of vector space on a generic partitioned vector.
Definition
ROL_PartitionedVector.hpp:26
ROL::PartitionedVector::size_type
std::vector< PV >::size_type size_type
Definition
ROL_PartitionedVector.hpp:38
ROL::PartitionedVector::get
ROL::Ptr< const Vector< Real > > get(size_type i) const
Definition
ROL_PartitionedVector.hpp:221
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::InteriorPoint
Definition
ROL_InteriorPoint.hpp:19
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0