45 #ifndef ROL_BOUNDFLETCHER_H
46 #define ROL_BOUNDFLETCHER_H
53 #include "ROL_Ptr.hpp"
66 Ptr<const Vector<Real> >
low_;
67 Ptr<const Vector<Real> >
upp_;
99 Ptr<Vector<Real> >
Q_;
122 Ptr<Vector<Real> >
w_;
123 Ptr<Vector<Real> >
v_;
152 class DiffLower :
public Elementwise::BinaryFunction<Real> {
155 Real
apply(
const Real& x,
const Real& y)
const {
156 const Real NINF(ROL_NINF<Real>());
157 return (y <= NINF ?
static_cast<Real
>(-1.) : x - y);
161 class DiffUpper :
public Elementwise::BinaryFunction<Real> {
164 Real
apply(
const Real& x,
const Real& y)
const {
165 const Real INF(ROL_INF<Real>());
166 return (y >= INF ?
static_cast<Real
>(-1.) : y - x);
170 class FormQ :
public Elementwise::BinaryFunction<Real> {
173 Real
apply(
const Real& x,
const Real& y)
const {
176 return static_cast<Real
>(1);
178 if( x < zero && y >=
zero ) {
184 return std::min(x, y);
188 class FormDQ :
public Elementwise::BinaryFunction<Real> {
191 Real
apply(
const Real& x,
const Real& y)
const {
192 Real
zero(0.), one(1.), mone(-1.);
196 if( x < zero && y >=
zero ) {
214 const Ptr<Constraint<Real> >
con_;
215 const Ptr<const Vector<Real> >
x_;
217 const Ptr<Vector<Real> >
Qv_;
230 con_->applyAdjointJacobian(*(Hvp.
get(0)), *(vp.
get(1)), *
x_, tol);
231 Hvp.
get(0)->applyBinary(Elementwise::Multiply<Real>(), *
Qsqrt_);
232 Hvp.
get(0)->plus(*(vp.
get(0)));
235 Qv_->applyBinary(Elementwise::Multiply<Real>(), *
Qsqrt_);
243 const Ptr<Constraint<Real> >
con_;
244 const Ptr<const Vector<Real> >
x_;
245 const Ptr<Vector<Real> >
Q_;
246 const Ptr<Vector<Real> >
Qv_;
259 con_->applyAdjointJacobian(*(Hvp.
get(0)), *(vp.
get(1)), *
x_, tol);
260 Hvp.
get(0)->plus(*(vp.
get(0)));
263 Qv_->applyBinary(Elementwise::Multiply<Real>(), *
Q_);
271 const Ptr<Constraint<Real> >
con_;
272 const Ptr<const Vector<Real> >
x_;
297 ROL::ParameterList &parlist)
300 low_ = bnd->getLowerBound();
301 upp_ = bnd->getUpperBound();
304 y_ = conVec.
dual().clone();
305 g_ = optVec.
dual().clone();
321 w_ = optVec.
dual().clone();
322 v_ = conVec.
dual().clone();
333 vv_ = makePtr<PartitionedVector<Real>>(std::vector<Ptr<Vector<Real>> >({
v1_,
v2_}));
337 ww_ = makePtr<PartitionedVector<Real>>(std::vector<Ptr<Vector<Real>> >({
w1_,
w2_}));
341 bb_ = makePtr<PartitionedVector<Real>>(std::vector<Ptr<Vector<Real>> >({
b1_,
b2_}));
343 ROL::ParameterList& sublist = parlist.sublist(
"Step").sublist(
"Fletcher");
344 HessianApprox_ = sublist.get(
"Level of Hessian Approximation", 0);
346 AugSolve_ = sublist.get(
"Type of Augmented System Solve", 0);
352 delta_ = sublist.get(
"Regularization Parameter", 0.0);
354 useInexact_ = sublist.get(
"Inexact Solves",
false);
356 ROL::ParameterList krylovList;
357 Real atol =
static_cast<Real
>(1e-12);
358 Real rtol =
static_cast<Real
>(1e-2);
359 krylovList.sublist(
"General").sublist(
"Krylov").set(
"Type",
"GMRES");
360 krylovList.sublist(
"General").sublist(
"Krylov").set(
"Absolute Tolerance", atol);
361 krylovList.sublist(
"General").sublist(
"Krylov").set(
"Relative Tolerance", rtol);
362 krylovList.sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 200);
363 krylov_ = KrylovFactory<Real>(krylovList);
367 obj_->update(x,flag,iter);
368 con_->update(x,flag,iter);
433 w_->applyBinary(Elementwise::Multiply<Real>(), *
Qsqrt_);
434 con_->applyAdjointHessian( *
gPhi_, *
y_, *
w_, x, tol2 ); tol2 = origTol;
435 obj_->hessVec( *
Tv_, *
w_, x, tol2 ); tol2 = origTol;
436 gPhi_->axpy(
static_cast<Real
>(-1), *
Tv_ );
438 con_->applyAdjointJacobian( *
Tv_, *
v_, x, tol2); tol2 = origTol;
441 Tv_->applyBinary(Elementwise::Multiply<Real>(), *
DQgL_);
444 con_->applyAdjointHessian( *
Tv_, *
v_, *
QgL_, x, tol2 ); tol2 = origTol;
458 Tv_->applyBinary( Elementwise::Multiply<Real>(), *
DQgL_ );
459 gPhi_->axpy(
static_cast<Real
>(-1), *
Tv_);
461 w_->applyBinary( Elementwise::Multiply<Real>(), *
Q_ );
462 obj_->hessVec( *
Tv_, *
w_, x, tol2); tol2 = origTol;
463 gPhi_->axpy(
static_cast<Real
>(-1), *
Tv_ );
464 con_->applyAdjointHessian( *
Tv_, *
y_, *
w_, x, tol2 ); tol2 = origTol;
467 con_->applyAdjointHessian( *
Tv_, *
v_, *
QgL_, x, tol2 ); tol2 = origTol;
477 con_->applyAdjointJacobian( *
Tv_, *
c_, x, tol2 ); tol2 = origTol;
493 value(x, tol2); tol2 = origTol;
500 obj_->hessVec( hv, v, x, tol2 ); tol2 = origTol;
501 con_->applyAdjointHessian( *
Tv_, *
y_, v, x, tol2 ); tol2 = origTol;
502 hv.
axpy(
static_cast<Real
>(-1), *
Tv_ );
506 htmp1_->applyBinary(Elementwise::Multiply<Real>(), *
Qsqrt_);
507 htmp1_->scale(
static_cast<Real
>(-1));
510 Tv_->applyBinary( Elementwise::Multiply<Real>(), v );
512 con_->applyJacobian( *
htmp2_, *
Tv_, x, tol2); tol2 = origTol;
515 con_->applyAdjointJacobian( *
Tv_, *
v_, x, tol2 ); tol2 = origTol;
518 con_->applyJacobian( *
htmp2_, v, x, tol2 ); tol2 = origTol;
520 con_->applyAdjointJacobian( *
Tv_, *
v_, x, tol2 ); tol2 = origTol;
522 Tv_->applyBinary( Elementwise::Multiply<Real>(), *
DQgL_ );
525 w_->applyBinary( Elementwise::Multiply<Real>(), *
Qsqrt_ );
526 obj_->hessVec( *
Tv_, *
w_, x, tol2 ); tol2 = origTol;
527 hv.
axpy(
static_cast<Real
>(-1), *
Tv_);
528 con_->applyAdjointHessian( *
Tv_, *
y_, *
w_, x, tol2 ); tol2 = origTol;
534 obj_->hessVec( hv, v, x, tol2 ); tol2 = origTol;
535 con_->applyAdjointHessian( *
Tv_, *
y_, v, x, tol2 ); tol2 = origTol;
536 hv.
axpy(
static_cast<Real
>(-1), *
Tv_ );
540 Tv_->applyBinary( Elementwise::Multiply<Real>(), *
DQgL_ );
542 Tv_->scale(
static_cast<Real
>(-1) );
543 con_->applyJacobian( *
htmp2_, *
Tv_, x, tol2 ); tol2 = origTol;
547 con_->applyJacobian( *
htmp2_, v, x, tol2 ); tol2 = origTol;
551 Tv_->applyBinary( Elementwise::Multiply<Real>(), *
DQgL_ );
552 hv.
axpy(
static_cast<Real
>(-1), *
Tv_ );
554 w_->applyBinary( Elementwise::Multiply<Real>(), *
Q_ );
555 obj_->hessVec( *
Tv_, *
w_, x, tol2 ); tol2 = tol;
556 hv.
axpy(
static_cast<Real
>(-1), *
Tv_);
557 con_->applyAdjointHessian( *
Tv_, *
y_, *
w_, x, tol2 ); tol2 = origTol;
564 con_->applyJacobian( *
b2_, v, x, tol2 ); tol2 = origTol;
565 con_->applyAdjointJacobian( *
Tv_, *
b2_, x, tol2 ); tol2 = origTol;
567 con_->applyAdjointHessian( *
Tv_, *
c_, v, x, tol2); tol2 = origTol;
579 bool refine =
false) {
581 ROL::Ptr<LinearOperator<Real> > K;
588 K = ROL::makePtr<AugSystemNonSym>(
con_, makePtrFromRef(x),
Q_,
Qv_,
delta_);
592 ROL::Ptr<LinearOperator<Real> > P
593 = ROL::makePtr<AugSystemPrecond>(
con_, makePtrFromRef(x));
603 K->apply(*
vv_, *
ww_, tol); tol = origTol;
605 b1_->axpy(
static_cast<Real
>(-1), *
v1_ );
606 b2_->axpy(
static_cast<Real
>(-1), *
v2_ );
614 krylov_->resetAbsoluteTolerance(tol);
648 Qsg_->applyBinary(Elementwise::Multiply<Real>(), *
Qsqrt_);
654 gL_->applyBinary(Elementwise::Divide<Real>(), *
Qsqrt_);
656 QgL_->applyBinary(Elementwise::Multiply<Real>(), *
Qsqrt_);
663 QgL_->applyBinary(Elementwise::Multiply<Real>(), *
Q_);
669 DQgL_->applyBinary(Elementwise::Multiply<Real>(), *
DQ_);
685 Qsqrt_->applyUnary(Elementwise::SquareRoot<Real>());