10 #ifndef ROL_TRUNCATEDCG_U_H
11 #define ROL_TRUNCATEDCG_U_H
36 Real em4(1e-4), em2(1e-2);
37 maxit_ = parlist.sublist(
"General").sublist(
"Krylov").get(
"Iteration Limit",20);
38 tol1_ = parlist.sublist(
"General").sublist(
"Krylov").get(
"Absolute Tolerance",em4);
39 tol2_ = parlist.sublist(
"General").sublist(
"Krylov").get(
"Relative Tolerance",em2);
57 Real tol = std::sqrt(ROL_EPSILON<Real>());
58 const Real
zero(0), one(1), two(2), half(0.5);
62 Real snorm2(0), s1norm2(0);
65 Real gnorm =
g_->norm(), normg = gnorm;
70 p_->set(*
v_);
p_->scale(-one);
71 Real pnorm2 =
v_->apply(*
g_);
72 if ( pnorm2 <=
zero ) {
79 Real kappa(0), beta(0), sigma(0), alpha(0), tmp(0), sMp(0);
83 for (iter = 0; iter <
maxit_; iter++) {
87 kappa =
p_->apply(*
Hp_);
89 sigma = (-sMp+sqrt(sMp*sMp+pnorm2*(del*del-snorm2)))/pnorm2;
99 s1norm2 = snorm2 + two*alpha*sMp + alpha*alpha*pnorm2;
101 if (s1norm2 >= del*del) {
102 sigma = (-sMp+sqrt(sMp*sMp+pnorm2*(del*del-snorm2)))/pnorm2;
109 pRed += half*alpha*gv;
114 g_->axpy(alpha,*
Hp_);
116 if (normg < gtol)
break;
125 sMp = beta*(sMp+alpha*pnorm2);
126 pnorm2 = gv + beta*beta*pnorm2;
129 if (iflag > 0) pRed += sigma*(gv-half*sigma*kappa);
130 else snorm = std::sqrt(snorm2);
132 if (iter == maxit_) iflag = 1;
133 if (iflag != 1) iter++;
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 .
void initialize(const Vector< Real > &x, const Vector< Real > &g)
TruncatedCG_U(ParameterList &parlist)
Contains definitions of custom data types in ROL.
Ptr< Vector< Real > > Hp_
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &s, Real &tol) override
Apply Hessian approximation to vector.
void solve(Vector< Real > &s, Real &snorm, Real &pRed, int &iflag, int &iter, const Real del, TrustRegionModel_U< Real > &model)
Provides the interface to evaluate trust-region model functions.
virtual const Ptr< const Vector< Real > > getGradient(void) const
Provides interface for and implements trust-region subproblem solvers.
virtual void set(const Vector &x)
Set where .
Provides interface for truncated CG trust-region subproblem solver.
virtual void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &s, Real &tol) override
Apply preconditioner to vector.