44 #ifndef ROL_PRIMALDUALINTERIORPOINTRESIDUAL_H 45 #define ROL_PRIMALDUALINTERIORPOINTRESIDUAL_H 78 class PrimalDualInteriorPointResidual :
public EqualityConstraint<Real> {
80 typedef Teuchos::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 Teuchos::RCP<OBJ>
obj_;
100 const Teuchos::RCP<CON>
con_;
103 Teuchos::RCP<const V>
x_;
104 Teuchos::RCP<const V>
l_;
105 Teuchos::RCP<const V>
zl_;
106 Teuchos::RCP<const V>
zu_;
108 Teuchos::RCP<const V>
xl_;
109 Teuchos::RCP<const V>
xu_;
111 const Teuchos::RCP<const V>
maskL_;
112 const Teuchos::RCP<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 = Teuchos::dyn_cast<PV>(vec);
161 return CreatePartitioned(vec_pv.
get(OPT),vec_pv.
get(EQUAL));
166 const PV &vec_pv = Teuchos::dyn_cast<
const PV>(vec);
168 return CreatePartitioned(vec_pv.
get(OPT),vec_pv.
get(EQUAL));
177 const Teuchos::RCP<CON> &con,
178 const Teuchos::RCP<BND> &bnd,
180 const Teuchos::RCP<const V> &maskL,
181 const Teuchos::RCP<const V> &maskU,
182 Teuchos::RCP<V> &scratch,
183 Real mu,
bool symmetrize ) :
184 obj_(obj), con_(con), bnd_(bnd), xl_(bnd->getLowerVectorRCP()),
185 xu_(bnd->getUpperVectorRCP()), 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 = Teuchos::dyn_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 = Teuchos::dyn_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 = Teuchos::dyn_cast<
const PV>(x);
225 PV &c_pv = Teuchos::dyn_cast<PV>(c);
228 l_ = x_pv.
get(EQUAL);
229 zl_ = x_pv.
get(LOWER);
230 zu_ = x_pv.
get(UPPER);
232 RCP<V> cx = c_pv.get(OPT);
233 RCP<V> cl = c_pv.get(EQUAL);
234 RCP<V> czl = c_pv.get(LOWER);
235 RCP<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 = Teuchos::dyn_cast<PV>(jv);
319 const PV &v_pv = Teuchos::dyn_cast<
const PV>(v);
320 const PV &x_pv = Teuchos::dyn_cast<
const PV>(x);
323 RCP<V> jvx = jv_pv.
get(OPT);
324 RCP<V> jvl = jv_pv.
get(EQUAL);
325 RCP<V> jvzl = jv_pv.
get(LOWER);
326 RCP<V> jvzu = jv_pv.
get(UPPER);
329 RCP<const V> vx = v_pv.get(OPT);
330 RCP<const V> vl = v_pv.get(EQUAL);
331 RCP<const V> vzl = v_pv.get(LOWER);
332 RCP<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
Teuchos::RCP< const V > x_
EqualityConstraint< Real > CON
Teuchos::RCP< const V > zl_
PrimalDualInteriorPointResidual(const Teuchos::RCP< OBJ > &obj, const Teuchos::RCP< CON > &con, const Teuchos::RCP< BND > &bnd, const V &x, const Teuchos::RCP< const V > &maskL, const Teuchos::RCP< const V > &maskU, Teuchos::RCP< V > &scratch, Real mu, bool symmetrize)
Teuchos::ParameterList PL
static const size_type OPT
Teuchos::RCP< const V > zu_
Teuchos::RCP< const V > xl_
Defines the linear algebra of vector space on a generic partitioned vector.
Teuchos::RCP< const V > getOptMult(const V &vec)
Teuchos::RCP< const Vector< Real > > get(size_type i) const
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 ...
static const size_type UPPER
int getNumberFunctionEvaluations(void) const
Elementwise::Multiply< Real > mult_
const Teuchos::RCP< const V > maskU_
Defines the linear algebra or vector space interface.
PartitionedVector< Real > PV
Teuchos::RCP< const V > xu_
static const size_type LOWER
Elementwise::ValueSet< Real > ValueSet
const Teuchos::RCP< BND > bnd_
Defines the equality constraint operator interface.
static const size_type EQUAL
const Teuchos::RCP< OBJ > obj_
Real apply(const Real &x, const Real &y) const
BoundConstraint< Real > BND
Teuchos::RCP< V > getOptMult(V &vec)
const Teuchos::RCP< const V > maskL_
Teuchos::RCP< V > scratch_
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.
Teuchos::RCP< const V > l_
const Teuchos::RCP< CON > con_
std::vector< PV >::size_type size_type
void reset(const Real mu)
Real apply(const Real &x, const Real &y) const
Real apply(const Real &x, const Real &y) const