10 #ifndef ROL_TRUNCATEDCG_H
11 #define ROL_TRUNCATEDCG_H
27 ROL::Ptr<Vector<Real> >
s_;
28 ROL::Ptr<Vector<Real> >
g_;
29 ROL::Ptr<Vector<Real> >
v_;
30 ROL::Ptr<Vector<Real> >
p_;
31 ROL::Ptr<Vector<Real> >
Hp_;
44 Real em4(1e-4), em2(1e-2);
45 maxit_ = parlist.sublist(
"General").sublist(
"Krylov").get(
"Iteration Limit",20);
46 tol1_ = parlist.sublist(
"General").sublist(
"Krylov").get(
"Absolute Tolerance",em4);
47 tol2_ = parlist.sublist(
"General").sublist(
"Krylov").get(
"Relative Tolerance",em2);
68 Real tol = std::sqrt(ROL_EPSILON<Real>());
69 const Real
zero(0), one(1), two(2), half(0.5);
73 Real snorm2(0), s1norm2(0);
76 Real gnorm =
g_->norm(), normg = gnorm;
81 p_->set(*
v_);
p_->scale(-one);
82 Real pnorm2 =
g_->apply(*
v_);
83 if ( pnorm2 <=
zero ) {
90 Real kappa(0), beta(0), sigma(0), alpha(0), tmp(0), sMp(0);
91 Real gv =
g_->apply(*
v_);
94 for (iter = 0; iter <
maxit_; iter++) {
98 kappa =
Hp_->apply(*
p_);
100 sigma = (-sMp+sqrt(sMp*sMp+pnorm2*(del*del-snorm2)))/pnorm2;
109 s1norm2 = snorm2 + two*alpha*sMp + alpha*alpha*pnorm2;
111 if (s1norm2 >= del*del) {
112 sigma = (-sMp+sqrt(sMp*sMp+pnorm2*(del*del-snorm2)))/pnorm2;
118 pRed_ += half*alpha*gv;
123 g_->axpy(alpha,*
Hp_);
125 if (normg < gtol)
break;
134 sMp = beta*(sMp+alpha*pnorm2);
135 pnorm2 = gv + beta*beta*pnorm2;
138 if (iflag > 0)
pRed_ += sigma*(gv-half*sigma*kappa);
140 if (iter == maxit_) iflag = 1;
141 if (iflag != 1) iter++;
152 Real tol = std::sqrt(ROL_EPSILON<Real>());
154 const Real gtol = std::min(
tol1_,
tol2_*gnorm);
158 ROL::Ptr<Vector<Real> > sc = x.
clone();
159 cauchypoint(*sc,scnorm,del,iflag,iter,x,grad,gnorm,pObj);
160 ROL::Ptr<Vector<Real> > xc = x.
clone();
167 Real snorm2 = snorm*snorm;
168 ROL::Ptr<Vector<Real> > s1 = x.
clone();
173 ROL::Ptr<Vector<Real> > g = x.
clone();
175 ROL::Ptr<Vector<Real> > Hs = x.
clone();
178 Real normg = g->norm();
181 ROL::Ptr<Vector<Real> > v = x.
clone();
185 ROL::Ptr<Vector<Real> > p = x.
clone();
188 Real pnorm2 = v->dot(*g);
191 ROL::Ptr<Vector<Real> > Hp = x.
clone();
200 Real gv = v->dot(*g);
204 for (iter = 0; iter <
maxit_; iter++) {
209 sigma = (-sMp+sqrt(sMp*sMp+pnorm2*(del*del-snorm2)))/pnorm2;
218 s1norm2 = snorm2 + 2.0*alpha*sMp + alpha*alpha*pnorm2;
220 if (s1norm2 >= del*del) {
221 sigma = (-sMp+sqrt(sMp*sMp+pnorm2*(del*del-snorm2)))/pnorm2;
227 pRed_ += 0.5*alpha*gv;
245 sMp = beta*(sMp+alpha*pnorm2);
246 pnorm2 = gv + beta*beta*pnorm2;
249 pRed_ += sigma*(gv-0.5*sigma*kappa);
252 if (iter == maxit_) {
ROL::Ptr< Vector< Real > > v_
void initialize(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g)
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
virtual void initialize(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g)
void reducedHessVec(Vector< Real > &Hv, const Vector< Real > &v, const Vector< Real > &p, const Vector< Real > &d, const Vector< Real > &x, Real &tol)
Apply the reduced Hessian to a vector, v. The reduced Hessian first removes elements of v correspondi...
Contains definitions of custom data types in ROL.
ROL::Ptr< Vector< Real > > s_
Provides interface for and implements trust-region subproblem solvers.
Provides the interface to evaluate trust-region model functions.
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
virtual const Ptr< const Vector< Real > > getGradient(void) const
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
virtual void dualTransform(Vector< Real > &tv, const Vector< Real > &v)
void setPredictedReduction(const Real pRed)
TruncatedCG(ROL::ParameterList &parlist)
ROL::Ptr< Vector< Real > > g_
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &s, Real &tol)
Apply Hessian approximation to vector.
void run(Vector< Real > &s, Real &snorm, int &iflag, int &iter, const Real del, TrustRegionModel< Real > &model)
ROL::Ptr< Vector< Real > > Hp_
Provides interface for truncated CG trust-region subproblem solver.
ROL::Ptr< Vector< Real > > primalVector_
virtual void set(const Vector &x)
Set where .
virtual Real norm() const =0
Returns where .
void reducedPrecond(Vector< Real > &Mv, const Vector< Real > &v, const Vector< Real > &p, const Vector< Real > &d, const Vector< Real > &x, Real &tol)
Apply the reduced preconditioner to a vector, v. The reduced preconditioner first removes elements of...
ROL::Ptr< Vector< Real > > p_
virtual void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &s, Real &tol)
Apply preconditioner to vector.
virtual void primalTransform(Vector< Real > &tv, const Vector< Real > &v)