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 {
175 if( x < zero && y < zero) {
176 return static_cast<Real
>(1);
178 if( x < zero && y >= zero ) {
181 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_;
287 con_->applyPreconditioner(*(Hvp.
get(1)),*(vp.
get(1)),*
x_,*
x_, zero);
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>());
Provides the interface to evaluate objective functions.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Ptr< Vector< Real > > w2_
Ptr< Vector< Real > > gPhi_
Ptr< Vector< Real > > Qsg_
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
const Ptr< Constraint< Real > > con_
Real quadPenaltyParameter_
ROL::Ptr< const Vector< Real > > get(size_type i) const
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Defines the linear algebra of vector space on a generic partitioned vector.
AugSystemSym(const Ptr< Constraint< Real > > &con, const Ptr< const Vector< Real > > &x, const Ptr< Vector< Real > > &Qsqrt, const Ptr< Vector< Real > > &Qv, const Real delta)
void objValue(const Vector< Real > &x, Real &tol)
const Ptr< Objective< Real > > obj_
Contains definitions of custom data types in ROL.
const Ptr< Constraint< Real > > con_
Ptr< Vector< Real > > czeros_
Real apply(const Real &x, const Real &y) const
Ptr< Vector< Real > > w1_
Real apply(const Real &x, const Real &y) const
Defines the linear algebra or vector space interface.
Ptr< Krylov< Real > > krylov_
const Ptr< Vector< Real > > Qv_
const Ptr< Vector< Real > > Q_
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
const Ptr< const Vector< Real > > x_
BoundFletcher(const ROL::Ptr< Objective< Real > > &obj, const ROL::Ptr< Constraint< Real > > &con, const ROL::Ptr< BoundConstraint< Real > > &bnd, const Vector< Real > &optVec, const Vector< Real > &conVec, ROL::ParameterList &parlist)
Ptr< Vector< Real > > QgL_
Ptr< Vector< Real > > gL_
Ptr< Vector< Real > > DQgL_
Ptr< const Vector< Real > > low_
Ptr< Vector< Real > > Tv_
Ptr< Vector< Real > > v1_
Ptr< Vector< Real > > b1_
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
Ptr< Vector< Real > > Qv_
Real value(const Vector< Real > &x, Real &tol)
Compute value.
bool isMultiplierComputed_
void computeMultipliers(const Vector< Real > &x, const Real tol)
const Ptr< const Vector< Real > > x_
Ptr< Vector< Real > > scaledc_
const Ptr< Constraint< Real > > con_
void conValue(const Vector< Real > &x, Real &tol)
Ptr< Vector< Real > > Qsqrt_
const Ptr< Constraint< Real > > con_
void computeDQ(const Vector< Real > &x)
void set(const V &x)
Set where .
const Ptr< Vector< Real > > Qsqrt_
Ptr< PartitionedVector< Real > > vv_
AugSystemPrecond(const Ptr< Constraint< Real > > con, const Ptr< const Vector< Real > > x)
Provides the interface to apply a linear operator.
Provides the interface to apply upper and lower bound constraints.
Ptr< const Vector< Real > > upp_
AugSystemNonSym(const Ptr< Constraint< Real > > &con, const Ptr< const Vector< Real > > &x, const Ptr< Vector< Real > > &Q, const Ptr< Vector< Real > > &Qv, const Real delta)
Ptr< Vector< Real > > umx_
Ptr< Vector< Real > > DQ_
const Ptr< Vector< Real > > Qv_
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
virtual void set(const Vector &x)
Set where .
Ptr< Vector< Real > > v2_
Ptr< Vector< Real > > QsgL_
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Ptr< Vector< Real > > b2_
Ptr< PartitionedVector< Real > > bb_
Ptr< PartitionedVector< Real > > ww_
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
Ptr< Vector< Real > > htmp1_
const Ptr< const Vector< Real > > x_
void computeQ(const Vector< Real > &x)
Ptr< Vector< Real > > htmp2_
void objGrad(const Vector< Real > &x, Real &tol)
Defines the general constraint operator interface.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
void solveAugmentedSystem(Vector< Real > &v1, Vector< Real > &v2, const Vector< Real > &b1, const Vector< Real > &b2, const Vector< Real > &x, Real &tol, bool refine=false)
Ptr< Vector< Real > > xzeros_