44 #ifndef ROL_COLEMANLIMODEL_HPP 45 #define ROL_COLEMANLIMODEL_HPP 64 Teuchos::RCP<BoundConstraint<Real> >
bnd_;
65 Teuchos::RCP<Secant<Real> >
sec_;
68 Teuchos::RCP<Vector<Real> >
step_;
71 Teuchos::RCP<Vector<Real> >
Dmat_;
72 Teuchos::RCP<Vector<Real> >
Cmat_;
81 Elementwise::Multiply<Real>
mult_;
82 Elementwise::Divide<Real>
div_;
104 const Teuchos::RCP<const Vector<Real> > l =
bnd_->getLowerVectorRCP();
105 const Teuchos::RCP<const Vector<Real> > u =
bnd_->getUpperVectorRCP();
108 Cmat_->set(gc->dual());
109 Cmat_->applyUnary(Elementwise::Sign<Real>());
111 class NegGradInfU :
public Elementwise::BinaryFunction<Real> {
114 Real apply(
const Real &x,
const Real &y)
const {
115 const Real zero(0), one(1), INF(ROL_INF<Real>());
116 return (x < zero && y == INF) ? zero : one;
119 prim_->set(gc->dual());
120 prim_->applyBinary(NegGradInfU(), *u);
123 class PosGradNinfL :
public Elementwise::BinaryFunction<Real> {
125 PosGradNinfL(
void) {}
126 Real apply(
const Real &x,
const Real &y)
const {
127 const Real zero(0), one(1), NINF(ROL_NINF<Real>());
128 return (x >= zero && y == NINF) ? zero : one;
131 prim_->set(gc->dual());
132 prim_->applyBinary(PosGradNinfL(), *l);
141 const Teuchos::RCP<const Vector<Real> > l =
bnd_->getLowerVectorRCP();
142 const Teuchos::RCP<const Vector<Real> > u =
bnd_->getUpperVectorRCP();
143 const Real zero(0), one(1), INF(ROL_INF<Real>()), NINF(ROL_NINF<Real>());
144 const int LESS_THAN = 0;
145 const int EQUAL_TO = 1;
146 const int GREATER_THAN = 2;
151 reflectStep_->applyBinary(Elementwise::ValueSet<Real>(zero, LESS_THAN),gc->dual());
153 reflectScal_->applyBinary(Elementwise::ValueSet<Real>(INF, LESS_THAN),*u);
165 reflectScal_->applyBinary(Elementwise::ValueSet<Real>(INF, EQUAL_TO),*u);
170 prim_->applyUnary(Elementwise::Fill<Real>(-one));
178 reflectStep_->applyUnary(Elementwise::Shift<Real>(one));
180 reflectScal_->applyBinary(Elementwise::ValueSet<Real>(NINF, GREATER_THAN),*l);
192 reflectScal_->applyBinary(Elementwise::ValueSet<Real>(NINF, EQUAL_TO),*l);
197 prim_->applyUnary(Elementwise::Fill<Real>(one));
206 Dmat_->applyUnary(Elementwise::AbsoluteValue<Real>());
207 Dmat_->applyUnary(Elementwise::SquareRoot<Real>());
213 bnd_ = Teuchos::rcpFromRef(bnd);
244 const Real TRradius,
const Real stepBackMax,
const Real stepBackScale,
245 const bool singleReflect =
true )
256 const bool useSecantPrecond,
const bool useSecantHessVec,
257 const Real TRradius,
const Real stepBackMax,
const Real stepBackScale,
258 const bool singleReflect =
true )
271 hv_->scale(static_cast<Real>(0.5));
308 Real tol = std::sqrt(ROL_EPSILON<Real>());
315 Real lowerBoundV(ROL_NINF<Real>()), upperBoundV(ROL_INF<Real>());
319 Real valueV =
minimize1D(tauV, lowerBoundV, upperBoundV, v);
337 Real lowerBoundR(ROL_NINF<Real>()), upperBoundR(ROL_INF<Real>());
347 bool useCauchyPoint = (valueG < valueV);
348 if (useCauchyPoint) {
361 bool useReflectStep = (valueR < VALUE);
362 if (useReflectStep) {
376 Real snorm =
step_->norm();
409 const Teuchos::RCP<const Vector<Real> > l =
bnd_->getLowerVectorRCP();
410 const Teuchos::RCP<const Vector<Real> > u =
bnd_->getUpperVectorRCP();
412 Real pnorm = p.
norm();
415 class PruneNegative :
public Elementwise::BinaryFunction<Real> {
419 PruneNegative(
const Real val ) : val_(val) {}
420 Real apply(
const Real &x,
const Real &y)
const {
421 return (y < static_cast<Real>(0)) ? x/y : val_;
424 class PrunePositive :
public Elementwise::BinaryFunction<Real> {
428 PrunePositive(
const Real val ) : val_(val) {}
429 Real apply(
const Real &x,
const Real &y)
const {
430 return (y > static_cast<Real>(0)) ? x/y : val_;
436 prim_->applyBinary(PrunePositive(ROL_NINF<Real>()),p);
437 Real lowerBound1 =
prim_->reduce(Elementwise::ReductionMax<Real>());
440 prim_->applyBinary(PruneNegative(ROL_NINF<Real>()),p);
441 Real lowerBound2 =
prim_->reduce(Elementwise::ReductionMax<Real>());
443 Real lowerBound3 = std::max(lowerBound1, lowerBound2);
447 prim_->applyBinary(PrunePositive(ROL_INF<Real>()),p);
448 Real upperBound1 =
prim_->reduce(Elementwise::ReductionMin<Real>());
451 prim_->applyBinary(PruneNegative(ROL_INF<Real>()),p);
452 Real upperBound2 =
prim_->reduce(Elementwise::ReductionMin<Real>());
454 Real upperBound3 = std::min(upperBound1, upperBound2);
457 lowerBound = std::max(lowerBound3, -
TRradius_/pnorm);
458 upperBound = std::min(upperBound3,
TRradius_/pnorm);
463 Real tol = std::sqrt(ROL_EPSILON<Real>());
467 Real c2 =
static_cast<Real
>(0.5) *
hv_->dot(p.
dual());
469 Real c1 =
prim_->dot(p);
472 Real lval = (c2 * lowerBound + c1) * lowerBound;
473 Real rval = (c2 * upperBound + c1) * upperBound;
474 tau = (lval < rval) ? lowerBound : upperBound;
475 if (c2 > static_cast<Real>(0)) {
476 Real uncMin =
static_cast<Real
>(-0.5) * c1/c2;
477 tau = (uncMin > lowerBound && uncMin < upperBound) ? uncMin : tau;
481 return (c2 * tau + c1) * tau;
494 Real lowerBound(ROL_NINF<Real>()), upperBound(ROL_INF<Real>());
498 Real tau(1),
value(0);
512 class LowerBound :
public Elementwise::BinaryFunction<Real> {
514 Real apply(
const Real &x,
const Real &y )
const {
515 return (x == y) ?
static_cast<Real
>(-1) : static_cast<Real>(1);
519 prim_->applyBinary(LowerBound(),*
bnd_->getLowerVectorRCP());
522 class UpperBound :
public Elementwise::BinaryFunction<Real> {
524 Real apply(
const Real &x,
const Real &y )
const {
525 return (x == y) ?
static_cast<Real
>(-1) : static_cast<Real>(1);
529 prim_->applyBinary(UpperBound(),*
bnd_->getUpperVectorRCP());
537 class LowerBound :
public Elementwise::BinaryFunction<Real> {
539 Real apply(
const Real &x,
const Real &y )
const {
540 return (x < y) ?
static_cast<Real
>(-1) : static_cast<Real>(1);
544 prim_->applyBinary(LowerBound(),*
bnd_->getLowerVectorRCP());
547 class UpperBound :
public Elementwise::BinaryFunction<Real> {
549 Real apply(
const Real &x,
const Real &y )
const {
550 return (x > y) ?
static_cast<Real
>(-1) : static_cast<Real>(1);
554 prim_->applyBinary(UpperBound(),*
bnd_->getUpperVectorRCP());
560 Teuchos::RCP<Vector<Real> > lx = xc->clone(), ux = xc->clone();
564 class SafeDivide :
public Elementwise::BinaryFunction<Real> {
568 SafeDivide(
const Real val ) : val_(val) {}
569 Real apply(
const Real &x,
const Real &y)
const {
571 return (y == zero) ? val_ : x/y;
576 lx->set(*
bnd_->getLowerVectorRCP());
578 lx->applyBinary(SafeDivide(ROL_INF<Real>()), d);
581 ux->set(*
bnd_->getUpperVectorRCP());
583 ux->applyBinary(SafeDivide(ROL_INF<Real>()), d);
586 lx->applyBinary(Elementwise::Max<Real>(),*ux);
589 return lx->reduce(Elementwise::ReductionMin<Real>());
595 class Greater :
public Elementwise::BinaryFunction<Real> {
598 Real apply(
const Real &x,
const Real &y)
const {
599 return (x > y) ?
static_cast<Real
>(1) : static_cast<Real>(0);
603 prim_->applyBinary(Greater(),*
bnd_->getLowerVectorRCP());
604 Real lowerFeasible =
prim_->reduce(Elementwise::ReductionMin<Real>());
606 class Lesser :
public Elementwise::BinaryFunction<Real> {
609 Real apply(
const Real &x,
const Real &y)
const {
610 return (x < y) ?
static_cast<Real
>(1) : static_cast<Real>(0);
614 prim_->applyBinary(Lesser(),*
bnd_->getUpperVectorRCP());
615 Real upperFeasible =
prim_->reduce(Elementwise::ReductionMin<Real>());
617 return (upperFeasible * lowerFeasible > 0);
624 #endif // ROL_COLEMANLIMODEL_HPP Provides the interface to evaluate objective functions.
const bool useSecantHessVec_
void initialize(Objective< Real > &obj, BoundConstraint< Real > &bnd, const Vector< Real > &x, const Vector< Real > &g)
const Real stepBackScale_
virtual void scale(const Real alpha)=0
Compute where .
Teuchos::RCP< Vector< Real > > step_
virtual void plus(const Vector &x)=0
Compute , where .
void computeFullReflectiveStep(Vector< Real > &Rv, const Vector< Real > &v, const Vector< Real > &Dv)
virtual void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector &x)
void gradient(Vector< Real > &g, const Vector< Real > &s, Real &tol)
Compute gradient.
bool isStrictlyFeasibleStep(const Vector< Real > &d) const
void dualTransform(Vector< Real > &tv, const Vector< Real > &v)
void updatePredictedReduction(Real &pred, const Vector< Real > &s)
void updateActualReduction(Real &ared, const Vector< Real > &s)
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &s, Real &tol)
Apply Hessian approximation to vector.
void primalTransform(Vector< Real > &tiv, const Vector< Real > &v)
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
const Teuchos::RCP< BoundConstraint< Real > > getBoundConstraint(void) const
Teuchos::RCP< Vector< Real > > cauchyStep_
Provides the interface to evaluate trust-region model functions.
ColemanLiModel(Objective< Real > &obj, BoundConstraint< Real > &bnd, const Vector< Real > &x, const Vector< Real > &g, const Teuchos::RCP< Secant< Real > > &sec, const bool useSecantPrecond, const bool useSecantHessVec, const Real TRradius, const Real stepBackMax, const Real stepBackScale, const bool singleReflect=true)
Defines the linear algebra or vector space interface.
Elementwise::Divide< Real > div_
Elementwise::Multiply< Real > mult_
Teuchos::RCP< Vector< Real > > Cmat_
Teuchos::RCP< BoundConstraint< Real > > bnd_
void applyD(Vector< Real > &Dv, const Vector< Real > &v)
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Teuchos::RCP< Vector< Real > > reflectScal_
Teuchos::RCP< Secant< Real > > sec_
const bool singleReflect_
Real minimize1D(Real &tau, const Real lowerBound, const Real upperBound, const Vector< Real > &p)
Real value(const Vector< Real > &s, Real &tol)
Compute value.
virtual const Teuchos::RCP< const Vector< Real > > getGradient(void) const
Provides interface for and implements limited-memory secant operators.
Teuchos::RCP< Vector< Real > > reflectStep_
Real computeCauchyPoint(void)
Teuchos::RCP< Vector< Real > > cauchyScal_
void applyInverseD(Vector< Real > &Dv, const Vector< Real > &v)
void applyC(Vector< Real > &Cv, const Vector< Real > &v)
ColemanLiModel(Objective< Real > &obj, BoundConstraint< Real > &bnd, const Vector< Real > &x, const Vector< Real > &g, const Real TRradius, const Real stepBackMax, const Real stepBackScale, const bool singleReflect=true)
Provides the interface to evaluate interior trust-region model functions from the Coleman-Li bound co...
void getScalarBounds(Real &lowerBound, Real &upperBound, const Vector< Real > &p)
Real computeAlpha(const Vector< Real > &d)
Provides the interface to apply upper and lower bound constraints.
Teuchos::RCP< Vector< Real > > hv_
void constructInverseD(void)
Teuchos::RCP< Vector< Real > > prim_
virtual void set(const Vector &x)
Set where .
Teuchos::RCP< Vector< Real > > Dmat_
virtual Real norm() const =0
Returns where .
ColemanLiModel(Objective< Real > &obj, BoundConstraint< Real > &bnd, const Vector< Real > &x, const Vector< Real > &g)
const bool useSecantPrecond_
Teuchos::RCP< Vector< Real > > dual_
void computeReflectiveStep(Vector< Real > &Rv, const Vector< Real > &v, const Vector< Real > &Dv)
virtual const Teuchos::RCP< Objective< Real > > getObjective(void) const
virtual const Teuchos::RCP< const Vector< Real > > getIterate(void) const