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 =
v_->dot(
g_->dual());
83 if ( pnorm2 <=
zero ) {
90 Real kappa(0), beta(0), sigma(0), alpha(0), tmp(0), sMp(0);
91 Real gv =
v_->dot(
g_->dual());
94 for (iter = 0; iter <
maxit_; iter++) {
98 kappa =
p_->dot(
Hp_->dual());
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_);
131 gv =
v_->dot(
g_->dual());
136 sMp = beta*(sMp+alpha*pnorm2);
137 pnorm2 = gv + beta*beta*pnorm2;
141 pRed_ += sigma*(gv-half*sigma*kappa);
144 if (iter == maxit_) {
160 Real tol = std::sqrt(ROL_EPSILON<Real>());
162 const Real gtol = std::min(
tol1_,
tol2_*gnorm);
166 ROL::Ptr<Vector<Real> > sc = x.
clone();
167 cauchypoint(*sc,scnorm,del,iflag,iter,x,grad,gnorm,pObj);
168 ROL::Ptr<Vector<Real> > xc = x.
clone();
175 Real snorm2 = snorm*snorm;
176 ROL::Ptr<Vector<Real> > s1 = x.
clone();
181 ROL::Ptr<Vector<Real> > g = x.
clone();
183 ROL::Ptr<Vector<Real> > Hs = x.
clone();
186 Real normg = g->norm();
189 ROL::Ptr<Vector<Real> > v = x.
clone();
193 ROL::Ptr<Vector<Real> > p = x.
clone();
196 Real pnorm2 = v->dot(*g);
199 ROL::Ptr<Vector<Real> > Hp = x.
clone();
208 Real gv = v->dot(*g);
212 for (iter = 0; iter <
maxit_; iter++) {
217 sigma = (-sMp+sqrt(sMp*sMp+pnorm2*(del*del-snorm2)))/pnorm2;
226 s1norm2 = snorm2 + 2.0*alpha*sMp + alpha*alpha*pnorm2;
228 if (s1norm2 >= del*del) {
229 sigma = (-sMp+sqrt(sMp*sMp+pnorm2*(del*del-snorm2)))/pnorm2;
235 pRed_ += 0.5*alpha*gv;
253 sMp = beta*(sMp+alpha*pnorm2);
254 pnorm2 = gv + beta*beta*pnorm2;
257 pRed_ += sigma*(gv-0.5*sigma*kappa);
260 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)