44 #ifndef ROL_PRIMALDUALINTERIORPOINTRESIDUAL_H 45 #define ROL_PRIMALDUALINTERIORPOINTRESIDUAL_H 78 class PrimalDualInteriorPointResidual :
public Constraint<Real> {
80 typedef ROL::ParameterList
PL;
94 static const size_type
OPT = 0;
95 static const size_type
EQUAL = 1;
96 static const size_type
LOWER = 2;
97 static const size_type
UPPER = 3;
99 const ROL::Ptr<OBJ>
obj_;
100 const ROL::Ptr<CON>
con_;
103 ROL::Ptr<const V>
x_;
104 ROL::Ptr<const V>
l_;
105 ROL::Ptr<const V>
zl_;
106 ROL::Ptr<const V>
zu_;
108 ROL::Ptr<const V>
xl_;
109 ROL::Ptr<const V>
xu_;
111 const ROL::Ptr<const V>
maskL_;
112 const ROL::Ptr<const V>
maskU_;
129 class SafeDivide :
public Elementwise::BinaryFunction<Real> {
131 Real
apply(
const Real &x,
const Real &y )
const {
132 return y != 0 ? x/y : 0;
138 class SetZeros :
public Elementwise::BinaryFunction<Real> {
140 Real
apply(
const Real &x,
const Real &y )
const {
141 return y==1.0 ? 0 : x;
148 class InFill :
public Elementwise::BinaryFunction<Real> {
150 Real
apply(
const Real &x,
const Real &y )
const {
151 return x == 0 ? y : x;
159 PV &vec_pv =
dynamic_cast<PV&
>(vec);
161 return CreatePartitioned(vec_pv.
get(OPT),vec_pv.
get(EQUAL));
166 const PV &vec_pv =
dynamic_cast<const PV&
>(vec);
168 return CreatePartitioned(vec_pv.
get(OPT),vec_pv.
get(EQUAL));
177 const ROL::Ptr<CON> &con,
178 const ROL::Ptr<BND> &bnd,
180 const ROL::Ptr<const V> &maskL,
181 const ROL::Ptr<const V> &maskU,
182 ROL::Ptr<V> &scratch,
183 Real mu,
bool symmetrize ) :
184 obj_(obj), con_(con), bnd_(bnd), xl_(bnd->getLowerBound()),
185 xu_(bnd->getUpperBound()), maskL_(maskL), maskU_(maskU), scratch_(scratch),
186 mu_(mu), symmetrize_(symmetrize), one_(1.0), zero_(0.0), nfval_(0),
187 ngrad_(0), ncval_(0) {
190 const PV &x_pv =
dynamic_cast<const PV&
>(x);
193 l_ = x_pv.
get(EQUAL);
194 zl_ = x_pv.
get(LOWER);
195 zu_ = x_pv.
get(UPPER);
203 const PV &x_pv =
dynamic_cast<const PV&
>(x);
206 l_ = x_pv.
get(EQUAL);
207 zl_ = x_pv.
get(LOWER);
208 zu_ = x_pv.
get(UPPER);
210 obj_->update(*x_,flag,iter);
211 con_->update(*x_,flag,iter);
217 void value( V &c,
const V &x, Real &tol ) {
221 Elementwise::Shift<Real> subtract_mu(-mu_);
222 Elementwise::Fill<Real> fill_minus_mu(-mu_);
224 const PV &x_pv =
dynamic_cast<const PV&
>(x);
225 PV &c_pv =
dynamic_cast<PV&
>(c);
228 l_ = x_pv.
get(EQUAL);
229 zl_ = x_pv.
get(LOWER);
230 zu_ = x_pv.
get(UPPER);
232 ROL::Ptr<V> cx = c_pv.
get(OPT);
233 ROL::Ptr<V> cl = c_pv.
get(EQUAL);
234 ROL::Ptr<V> czl = c_pv.
get(LOWER);
235 ROL::Ptr<V> czu = c_pv.
get(UPPER);
240 obj_->gradient(*cx,*x_,tol);
243 con_->applyAdjointJacobian(*scratch_,*l_,*x_,tol);
247 cx->axpy(-one_,*zl_);
254 con_->value(*cl,*x_,tol);
262 czl->applyUnary(fill_minus_mu);
263 czl->applyBinary(div_,*zl_);
266 scratch_->axpy(-1.0,*xl_);
268 czl->plus(*scratch_);
273 czl->axpy(-1.0,*xl_);
274 czl->applyBinary(mult_,*zl_);
275 czl->applyUnary(subtract_mu);
279 czl->applyBinary(mult_,*maskL_);
286 czu->applyUnary(fill_minus_mu);
287 czu->applyBinary(div_,*zu_);
290 scratch_->axpy(-1.0, *x_);
292 czu->plus(*scratch_);
298 czu->applyBinary(mult_,*zu_);
299 czu->applyUnary(subtract_mu);
303 czu->applyBinary(mult_,*maskU_);
318 PV &jv_pv =
dynamic_cast<PV&
>(jv);
319 const PV &v_pv =
dynamic_cast<const PV&
>(v);
320 const PV &x_pv =
dynamic_cast<const PV&
>(x);
323 ROL::Ptr<V> jvx = jv_pv.
get(OPT);
324 ROL::Ptr<V> jvl = jv_pv.
get(EQUAL);
325 ROL::Ptr<V> jvzl = jv_pv.
get(LOWER);
326 ROL::Ptr<V> jvzu = jv_pv.
get(UPPER);
329 ROL::Ptr<const V> vx = v_pv.
get(OPT);
330 ROL::Ptr<const V> vl = v_pv.
get(EQUAL);
331 ROL::Ptr<const V> vzl = v_pv.
get(LOWER);
332 ROL::Ptr<const V> vzu = v_pv.
get(UPPER);
335 l_ = x_pv.
get(EQUAL);
336 zl_ = x_pv.
get(LOWER);
337 zu_ = x_pv.
get(UPPER);
344 obj_->hessVec(*jvx,*vx,*x_,tol);
345 con_->applyAdjointHessian(*scratch_,*l_,*vx,*x_,tol);
346 jvx->plus(*scratch_);
347 con_->applyAdjointJacobian(*scratch_,*vl,*x_,tol);
348 jvx->plus(*scratch_);
352 scratch_->applyBinary(mult_,*maskL_);
353 jvx->axpy(-1.0,*scratch_);
357 scratch_->applyBinary(mult_,*maskU_);
358 jvx->plus(*scratch_);
364 con_->applyJacobian(*jvl,*vx,*x_,tol);
375 jvzl->axpy(-1.0,*xl_);
376 jvzl->applyBinary(mult_,*vzl);
377 jvzl->applyBinary(div_,*zl_);
390 jvzl->applyBinary(mult_,*zl_);
394 scratch_->axpy(-1.0,*xl_);
395 scratch_->applyBinary(mult_,*vzl);
397 jvzl->plus(*scratch_);
402 jvzl->applyBinary(mult_,*maskL_);
403 jvzl->applyBinary(inFill_,*vzl);
414 jvzu->axpy(-1.0,*x_);
415 jvzu->applyBinary(mult_,*vzu);
416 jvzu->applyBinary(div_,*zu_);
427 scratch_->applyBinary(mult_,*vx);
431 jvzu->axpy(-1.0,*x_);
432 jvzu->applyBinary(mult_,*vzu);
434 jvzu->axpy(-1.0,*scratch_);
439 jvzu->applyBinary(mult_,*maskU_);
440 jvzu->applyBinary(inFill_,*vzu);
468 #endif // ROL_PRIMALDUALINTERIORPOINTRESIDUAL_H
Provides the interface to evaluate objective functions.
void value(V &c, const V &x, Real &tol)
Evaluate the constraint operator at .
int getNumberConstraintEvaluations(void) const
static const size_type OPT
const ROL::Ptr< const V > maskU_
Defines the linear algebra of vector space on a generic partitioned vector.
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update constraint functions. x is the optimization variable, flag = true if optimization variable is ...
ROL::Ptr< V > getOptMult(V &vec)
static const size_type UPPER
int getNumberFunctionEvaluations(void) const
Elementwise::Multiply< Real > mult_
Defines the linear algebra or vector space interface.
PartitionedVector< Real > PV
static const size_type LOWER
const ROL::Ptr< const V > maskL_
PrimalDualInteriorPointResidual(const ROL::Ptr< OBJ > &obj, const ROL::Ptr< CON > &con, const ROL::Ptr< BND > &bnd, const V &x, const ROL::Ptr< const V > &maskL, const ROL::Ptr< const V > &maskU, ROL::Ptr< V > &scratch, Real mu, bool symmetrize)
Elementwise::ValueSet< Real > ValueSet
const ROL::Ptr< OBJ > obj_
ROL::Ptr< const V > getOptMult(const V &vec)
static const size_type EQUAL
Real apply(const Real &x, const Real &y) const
BoundConstraint< Real > BND
int getNumberGradientEvaluations(void) const
void applyJacobian(V &jv, const V &v, const V &x, Real &tol)
Apply the constraint Jacobian at , , to vector .
Provides the interface to apply upper and lower bound constraints.
std::vector< PV >::size_type size_type
void reset(const Real mu)
const ROL::Ptr< BND > bnd_
Real apply(const Real &x, const Real &y) const
const ROL::Ptr< CON > con_
ROL::Ptr< const Vector< Real > > get(size_type i) const
Real apply(const Real &x, const Real &y) const
Defines the general constraint operator interface.