ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
step
interiorpoint
ROL_PrimalDualInteriorPointReducedResidual.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_PRIMALDUALINTERIORPOINTREDUCEDRESIDUAL_H
11
#define ROL_PRIMALDUALINTERIORPOINTREDUCEDRESIDUAL_H
12
13
#include "
ROL_InteriorPointPenalty.hpp
"
14
#include "
ROL_Constraint.hpp
"
15
16
#include <iostream>
17
73
74
namespace
ROL
{
75
76
template
<
class
Real>
77
class
PrimalDualInteriorPointResidual
:
public
Constraint
<Real> {
78
79
typedef
ROL::ParameterList
PL
;
80
81
typedef
Vector<Real>
V
;
82
typedef
PartitionedVector<Real>
PV
;
83
typedef
Objective<Real>
OBJ
;
84
typedef
Constraint<Real>
CON
;
85
typedef
BoundConstraint<Real>
BND
;
86
typedef
LinearOperator<Real>
LOP
;
87
typedef
InteriorPointPenalty<Real>
PENALTY
;
88
89
typedef
Elementwise::ValueSet<Real>
ValueSet
;
90
91
typedef
typename
PV::size_type
size_type
;
92
93
private
:
94
95
static
const
size_type
OPT
= 0;
96
static
const
size_type
EQUAL
= 1;
97
static
const
size_type
LOWER
= 2;
98
static
const
size_type
UPPER
= 3;
99
100
ROL::Ptr<const V>
x_
;
// Optimization vector
101
ROL::Ptr<const V>
l_
;
// constraint multiplier
102
ROL::Ptr<const V>
zl_
;
// Lower bound multiplier
103
ROL::Ptr<const V>
zu_
;
// Upper bound multiplier
104
105
ROL::Ptr<const V>
xl_
;
// Lower bound
106
ROL::Ptr<const V>
xu_
;
// Upper bound
107
108
const
ROL::Ptr<const V>
maskL_
;
109
const
ROL::Ptr<const V>
maskU_
;
110
111
ROL::Ptr<V>
scratch_
;
112
113
const
ROL::Ptr<PENALTY>
penalty_
;
114
const
ROL::Ptr<OBJ>
obj_
;
115
const
ROL::Ptr<CON>
con_
;
116
117
118
public
:
119
120
PrimalDualInteriorPointResidual
(
const
ROL::Ptr<PENALTY> &penalty,
121
const
ROL::Ptr<CON> &con,
122
const
V
&x,
123
ROL::Ptr<V> &scratch ) :
124
penalty_
(penalty),
con_
(con),
scratch_
(scratch) {
125
126
obj_
=
penalty_
->getObjective();
127
maskL_
=
penalty_
->getLowerMask();
128
maskU_
=
penalty_
->getUpperMask();
129
130
ROL::Ptr<BND> bnd =
penalty_
->getBoundConstraint();
131
xl_
= bnd->getLowerBound();
132
xu_
= bnd->getUpperBound();
133
134
135
// Get access to the four components
136
const
PV
&x_pv =
dynamic_cast<
const
PV
&
>
(x);
137
138
x_
= x_pv.
get
(
OPT
);
139
l_
= x_pv.
get
(
EQUAL
);
140
zl_
= x_pv.
get
(
LOWER
);
141
zu_
= x_pv.
get
(
UPPER
);
142
143
}
144
145
146
void
update
(
const
Vector<Real>
&x,
bool
flag =
true
,
int
iter = -1 ) {
147
148
// Get access to the four components
149
const
PV
&x_pv =
dynamic_cast<
const
PV
&
>
(x);
150
151
x_
= x_pv.
get
(
OPT
);
152
l_
= x_pv.
get
(
EQUAL
);
153
zl_
= x_pv.
get
(
LOWER
);
154
zu_
= x_pv.
get
(
UPPER
);
155
156
obj_
->update(*
x_
,flag,iter);
157
con_
->update(*
x_
,flag,iter);
158
}
159
160
161
// Evaluate the gradient of the Lagrangian
162
void
value
(
V
&c,
const
V
&x, Real &tol ) {
163
164
165
PV
&c_pv =
dynamic_cast<
PV
&
>
(c);
166
const
PV
&x_pv =
dynamic_cast<
const
PV
&
>
(x);
167
168
x_
= x_pv.
get
(
OPT
);
169
l_
= x_pv.
get
(
EQUAL
);
170
zl_
= x_pv.
get
(
LOWER
);
171
zu_
= x_pv.
get
(
UPPER
);
172
173
ROL::Ptr<V> cx = c_pv.
get
(
OPT
);
174
ROL::Ptr<V> cl = c_pv.
get
(
EQUAL
);
175
176
// TODO: Add check as to whether we really need to recompute these
177
penalty_
->gradient(*cx,*
x_
,tol);
178
con_
->applyAdjointJacobian(*
scratch_
,*
l_
,*
x_
,tol);
179
180
// \f$ c_x = \nabla \phi_mu(x) + J^\ast \lambda \f$
181
cx_->plus(*
scratch_
);
182
183
con_
->value(*cl_,*
x_
,tol);
184
185
}
186
187
void
applyJacobian
(
V
&jv,
const
V
&v,
const
V
&x, Real &tol ) {
188
189
190
191
PV
&jv_pv =
dynamic_cast<
PV
&
>
(jv);
192
const
PV
&v_pv =
dynamic_cast<
const
PV
&
>
(v);
193
const
PV
&x_pv =
dynamic_cast<
const
PV
&
>
(x);
194
195
// output vector components
196
ROL::Ptr<V> jvx = jv_pv.
get
(
OPT
);
197
ROL::Ptr<V> jvl = jv_pv.
get
(
EQUAL
);
198
199
// input vector components
200
ROL::Ptr<const V> vx = v_pv.
get
(
OPT
);
201
ROL::Ptr<const V> vl = v_pv.
get
(
EQUAL
);
202
203
x_
= x_pv.
get
(
OPT
);
204
l_
= x_pv.
get
(
EQUAL
);
205
206
// \f$
207
obj_
->hessVec(*jvx,*vx,*
x_
,tol);
208
con_
->applyAdjointHessian(*
scratch_
,*
l_
,*vx,*
x_
,tol);
209
jvx->plus(*
scratch_
);
210
211
// \f$J^\ast d_\lambda \f$
212
con_
->applyAdjointJacobian(*
scratch_
,*vl,*
x_
,tol);
213
jvx->plus(*
scratch_
);
214
215
216
Elementwise::DivideAndInvert<Real> divinv;
217
Elementwise::Multiply<Real> mult;
218
219
// Note that indices corresponding to infinite bounds should automatically lead to
220
// zero diagonal contributions to the Sigma operators
221
scratch_
->set(*
x_
);
222
scratch_
->axpy(-1.0,*
xl_
);
// x-l
223
scratch_
->applyBinary(divinv,*
zl_
);
// zl/(x-l)
224
scratch_
->applyBinary(mult,*vx);
// zl*vx/(x-l) = Sigma_l*vx
225
226
jvx->plu(*
scratch_
);
227
228
scratch_
->set(*
xu_
);
229
scratch_
->axpy(-1.0,*
x_
);
// u-x
230
scratch_
->applyBinary(divinv,*
zu_
);
// zu/(u-x)
231
scratch_
->applyBinary(mult,*vx);
// zu*vx/(u-x) = Sigma_u*vx
232
233
jvx->plus(*
scratch_
);
234
235
236
237
238
239
240
241
// \f[ [W+(X-L)^{-1}+(U-X)^{-1}]d_x + J^\ast d_\lambda =
242
// -g_x + (U-X)^{-1}g_{z_u} - (L-X)^{-1}g_{z_l} \f]
243
244
245
246
}
247
248
int
getNumberFunctionEvaluations
(
void
)
const
{
249
return
nfval_
;
250
}
251
252
int
getNumberGradientEvaluations
(
void
)
const
{
253
return
ngrad_
;
254
}
255
256
int
getNumberConstraintEvaluations
(
void
)
const
{
257
return
ncval_
;
258
}
259
260
261
};
// class PrimalDualInteriorPointResidual
262
263
}
// namespace ROL
264
265
#endif
// ROL_PRIMALDUALKKTOPERATOR_H
ROL_Constraint.hpp
ROL_InteriorPointPenalty.hpp
ROL::BoundConstraint
Provides the interface to apply upper and lower bound constraints.
Definition
ROL_BoundConstraint.hpp:39
ROL::InteriorPointPenalty
Provides the interface to evaluate the Interior Pointy log barrier penalty function with upper and lo...
Definition
ROL_InteriorPointPenalty.hpp:29
ROL::LinearOperator
Provides the interface to apply a linear operator.
Definition
ROL_LinearOperator.hpp:37
ROL::Objective
Provides the interface to evaluate objective functions.
Definition
ROL_Objective.hpp:44
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::PrimalDualInteriorPointResidual::applyJacobian
void applyJacobian(V &jv, const V &v, const V &x, Real &tol)
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:187
ROL::PrimalDualInteriorPointResidual::maskU_
const ROL::Ptr< const V > maskU_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:109
ROL::PrimalDualInteriorPointResidual::update
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:146
ROL::PrimalDualInteriorPointResidual::PV
PartitionedVector< Real > PV
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:82
ROL::PrimalDualInteriorPointResidual::value
void value(V &c, const V &x, Real &tol)
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:162
ROL::PrimalDualInteriorPointResidual::OPT
static const size_type OPT
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:95
ROL::PrimalDualInteriorPointResidual::getNumberFunctionEvaluations
int getNumberFunctionEvaluations(void) const
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:248
ROL::PrimalDualInteriorPointResidual::PL
ROL::ParameterList PL
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:79
ROL::PrimalDualInteriorPointResidual::ngrad_
int ngrad_
Definition
ROL_PrimalDualInteriorPointResidual.hpp:90
ROL::PrimalDualInteriorPointResidual::zu_
ROL::Ptr< const V > zu_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:103
ROL::PrimalDualInteriorPointResidual::scratch_
ROL::Ptr< V > scratch_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:111
ROL::PrimalDualInteriorPointResidual::PrimalDualInteriorPointResidual
PrimalDualInteriorPointResidual(const ROL::Ptr< PENALTY > &penalty, const ROL::Ptr< CON > &con, const V &x, ROL::Ptr< V > &scratch)
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:120
ROL::PrimalDualInteriorPointResidual::con_
const ROL::Ptr< CON > con_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:115
ROL::PrimalDualInteriorPointResidual::CON
Constraint< Real > CON
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:84
ROL::PrimalDualInteriorPointResidual::zl_
ROL::Ptr< const V > zl_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:102
ROL::PrimalDualInteriorPointResidual::OBJ
Objective< Real > OBJ
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:83
ROL::PrimalDualInteriorPointResidual::EQUAL
static const size_type EQUAL
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:96
ROL::PrimalDualInteriorPointResidual::UPPER
static const size_type UPPER
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:98
ROL::PrimalDualInteriorPointResidual::PENALTY
InteriorPointPenalty< Real > PENALTY
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:87
ROL::PrimalDualInteriorPointResidual::ValueSet
Elementwise::ValueSet< Real > ValueSet
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:89
ROL::PrimalDualInteriorPointResidual::x_
ROL::Ptr< const V > x_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:100
ROL::PrimalDualInteriorPointResidual::getNumberGradientEvaluations
int getNumberGradientEvaluations(void) const
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:252
ROL::PrimalDualInteriorPointResidual::LOP
LinearOperator< Real > LOP
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:86
ROL::PrimalDualInteriorPointResidual::xu_
ROL::Ptr< const V > xu_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:106
ROL::PrimalDualInteriorPointResidual::xl_
ROL::Ptr< const V > xl_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:105
ROL::PrimalDualInteriorPointResidual::LOWER
static const size_type LOWER
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:97
ROL::PrimalDualInteriorPointResidual::obj_
const ROL::Ptr< OBJ > obj_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:114
ROL::PrimalDualInteriorPointResidual::BND
BoundConstraint< Real > BND
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:85
ROL::PrimalDualInteriorPointResidual::getNumberConstraintEvaluations
int getNumberConstraintEvaluations(void) const
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:256
ROL::PrimalDualInteriorPointResidual::V
Vector< Real > V
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:81
ROL::PrimalDualInteriorPointResidual::l_
ROL::Ptr< const V > l_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:101
ROL::PrimalDualInteriorPointResidual::maskL_
const ROL::Ptr< const V > maskL_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:108
ROL::PrimalDualInteriorPointResidual::penalty_
const ROL::Ptr< PENALTY > penalty_
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:113
ROL::PrimalDualInteriorPointResidual::ncval_
int ncval_
Definition
ROL_PrimalDualInteriorPointResidual.hpp:91
ROL::PrimalDualInteriorPointResidual::size_type
PV::size_type size_type
Definition
ROL_PrimalDualInteriorPointReducedResidual.hpp:91
ROL::PrimalDualInteriorPointResidual::nfval_
int nfval_
Definition
ROL_PrimalDualInteriorPointResidual.hpp:89
ROL::ROL::Constraint::Constraint
Constraint(void)
Definition
ROL_Constraint_SerialSimOpt.hpp:59
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0