ROL
ROL_TypeB_TrustRegionSPGAlgorithm_Def.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 #ifndef ROL_TYPEB_TRUSTREGIONSPGALGORITHM_DEF_HPP
45 #define ROL_TYPEB_TRUSTREGIONSPGALGORITHM_DEF_HPP
46 
47 #include <deque>
48 
49 namespace ROL {
50 namespace TypeB {
51 
52 template<typename Real>
54  const Ptr<Secant<Real>> &secant) {
55  // Set status test
56  status_->reset();
57  status_->add(makePtr<StatusTest<Real>>(list));
58 
59  ParameterList &trlist = list.sublist("Step").sublist("Trust Region");
60  // Trust-Region Parameters
61  state_->searchSize = trlist.get("Initial Radius", -1.0);
62  delMax_ = trlist.get("Maximum Radius", ROL_INF<Real>());
63  eta0_ = trlist.get("Step Acceptance Threshold", 0.05);
64  eta1_ = trlist.get("Radius Shrinking Threshold", 0.05);
65  eta2_ = trlist.get("Radius Growing Threshold", 0.9);
66  gamma0_ = trlist.get("Radius Shrinking Rate (Negative rho)", 0.0625);
67  gamma1_ = trlist.get("Radius Shrinking Rate (Positive rho)", 0.25);
68  gamma2_ = trlist.get("Radius Growing Rate", 2.5);
69  TRsafe_ = trlist.get("Safeguard Size", 100.0);
70  eps_ = TRsafe_*ROL_EPSILON<Real>();
71  interpRad_ = trlist.get("Use Radius Interpolation", false);
72  verbosity_ = trlist.sublist("General").get("Output Level", 0);
73  // Nonmonotone Parameters
74  storageNM_ = trlist.get("Nonmonotone Storage Size", 0);
75  useNM_ = (storageNM_ <= 0 ? false : true);
76  // Algorithm-Specific Parameters
77  ROL::ParameterList &lmlist = trlist.sublist("SPG");
78  mu0_ = lmlist.get("Sufficient Decrease Parameter", 1e-2);
79  spexp_ = lmlist.get("Relative Tolerance Exponent", 1.0);
80  spexp_ = std::max(static_cast<Real>(1),std::min(spexp_,static_cast<Real>(2)));
81  redlim_ = lmlist.sublist("Cauchy Point").get("Maximum Number of Reduction Steps", 10);
82  explim_ = lmlist.sublist("Cauchy Point").get("Maximum Number of Expansion Steps", 10);
83  alpha_ = lmlist.sublist("Cauchy Point").get("Initial Step Size", 1.0);
84  normAlpha_ = lmlist.sublist("Cauchy Point").get("Normalize Initial Step Size", false);
85  interpf_ = lmlist.sublist("Cauchy Point").get("Reduction Rate", 0.1);
86  extrapf_ = lmlist.sublist("Cauchy Point").get("Expansion Rate", 10.0);
87  qtol_ = lmlist.sublist("Cauchy Point").get("Decrease Tolerance", 1e-8);
88  // Spectral projected gradient parameters
89  lambdaMin_ = lmlist.sublist("Solver").get("Minimum Spectral Step Size", 1e-8);
90  lambdaMax_ = lmlist.sublist("Solver").get("Maximum Spectral Step Size", 1e8);
91  gamma_ = lmlist.sublist("Solver").get("Sufficient Decrease Tolerance", 1e-4);
92  maxSize_ = lmlist.sublist("Solver").get("Maximum Storage Size", 10);
93  maxit_ = lmlist.sublist("Solver").get("Iteration Limit", 25);
94  tol1_ = lmlist.sublist("Solver").get("Absolute Tolerance", 1e-4);
95  tol2_ = lmlist.sublist("Solver").get("Relative Tolerance", 1e-2);
96  useMin_ = lmlist.sublist("Solver").get("Use Smallest Model Iterate", true);
97  useNMSP_ = lmlist.sublist("Solver").get("Use Nonmonotone Search", false);
98  useSimpleSPG_ = !lmlist.sublist("Solver").get("Compute Cauchy Point", true);
99  // Inexactness Information
100  ParameterList &glist = list.sublist("General");
101  useInexact_.clear();
102  useInexact_.push_back(glist.get("Inexact Objective Function", false));
103  useInexact_.push_back(glist.get("Inexact Gradient", false));
104  useInexact_.push_back(glist.get("Inexact Hessian-Times-A-Vector", false));
105  // Trust-Region Inexactness Parameters
106  ParameterList &ilist = trlist.sublist("Inexact").sublist("Gradient");
107  scale0_ = ilist.get("Tolerance Scaling", static_cast<Real>(0.1));
108  scale1_ = ilist.get("Relative Tolerance", static_cast<Real>(2));
109  // Inexact Function Evaluation Information
110  ParameterList &vlist = trlist.sublist("Inexact").sublist("Value");
111  scale_ = vlist.get("Tolerance Scaling", static_cast<Real>(1.e-1));
112  omega_ = vlist.get("Exponent", static_cast<Real>(0.9));
113  force_ = vlist.get("Forcing Sequence Initial Value", static_cast<Real>(1.0));
114  updateIter_ = vlist.get("Forcing Sequence Update Frequency", static_cast<int>(10));
115  forceFactor_ = vlist.get("Forcing Sequence Reduction Factor", static_cast<Real>(0.1));
116  // Output Parameters
117  verbosity_ = list.sublist("General").get("Output Level",0);
118  writeHeader_ = verbosity_ > 2;
119  // Secant Information
120  useSecantPrecond_ = list.sublist("General").sublist("Secant").get("Use as Preconditioner", false);
121  useSecantHessVec_ = list.sublist("General").sublist("Secant").get("Use as Hessian", false);
123  if (useSecantPrecond_ && !useSecantHessVec_) mode = SECANTMODE_INVERSE;
124  else if (useSecantHessVec_ && !useSecantPrecond_) mode = SECANTMODE_FORWARD;
125  // Initialize trust region model
126  model_ = makePtr<TrustRegionModel_U<Real>>(list,secant,mode);
127  if (secant == nullPtr) {
128  esec_ = StringToESecant(list.sublist("General").sublist("Secant").get("Type","Limited-Memory BFGS"));
129  }
130 }
131 
132 template<typename Real>
134  const Vector<Real> &g,
135  Real ftol,
136  Objective<Real> &obj,
138  std::ostream &outStream) {
139  //const Real one(1);
140  if (proj_ == nullPtr)
141  proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
142  // Initialize data
144  nhess_ = 0;
145  // Update approximate gradient and approximate objective function.
146  proj_->project(x,outStream); state_->nproj++;
147  state_->iterateVec->set(x);
148  obj.update(x,UpdateType::Initial,state_->iter);
149  state_->value = obj.value(x,ftol);
150  state_->nfval++;
151  //obj.gradient(*state_->gradientVec,x,ftol);
152  computeGradient(x,*state_->gradientVec,*state_->stepVec,state_->searchSize,obj,true,gtol_,state_->gnorm,outStream);
153  state_->ngrad++;
154  //state_->stepVec->set(x);
155  //state_->stepVec->axpy(-one,state_->gradientVec->dual());
156  //proj_->project(*state_->stepVec,outStream); state_->nproj++;
157  //state_->stepVec->axpy(-one,x);
158  //state_->gnorm = state_->stepVec->norm();
159  state_->snorm = ROL_INF<Real>();
160  // Normalize initial CP step length
161  if (normAlpha_) alpha_ /= state_->gradientVec->norm();
162  // Compute initial trust region radius if desired.
163  if ( state_->searchSize <= static_cast<Real>(0) )
164  state_->searchSize = state_->gradientVec->norm();
165 }
166 
167 template<typename Real>
169  Real &outTol,
170  Real pRed,
171  Real &fold,
172  int iter,
173  const Vector<Real> &x,
174  const Vector<Real> &xold,
175  Objective<Real> &obj) {
176  outTol = std::sqrt(ROL_EPSILON<Real>());
177  if ( useInexact_[0] ) {
178  if (!(iter%updateIter_) && (iter!=0)) force_ *= forceFactor_;
179  const Real one(1);
180  Real eta = static_cast<Real>(0.999)*std::min(eta1_,one-eta2_);
181  outTol = scale_*std::pow(eta*std::min(pRed,force_),one/omega_);
182  if (inTol > outTol) fold = obj.value(xold,outTol);
183  }
184  // Evaluate objective function at new iterate
185  obj.update(x,UpdateType::Trial);
186  Real fval = obj.value(x,outTol);
187  return fval;
188 }
189 
190 template<typename Real>
192  Vector<Real> &g,
193  Vector<Real> &pwa,
194  Real del,
195  Objective<Real> &obj,
196  bool accept,
197  Real &gtol,
198  Real &gnorm,
199  std::ostream &outStream) const {
200  if ( useInexact_[1] ) {
201  const Real one(1);
202  Real gtol0 = scale0_*del;
203  if (accept) gtol = gtol0 + one;
204  else gtol0 = scale0_*std::min(gnorm,del);
205  while ( gtol > gtol0 ) {
206  gtol = gtol0;
207  obj.gradient(g,x,gtol);
208  gnorm = TypeB::Algorithm<Real>::optimalityCriterion(x,g,pwa,outStream);
209  gtol0 = scale0_*std::min(gnorm,del);
210  }
211  }
212  else {
213  if (accept) {
214  gtol = std::sqrt(ROL_EPSILON<Real>());
215  obj.gradient(g,x,gtol);
216  gnorm = TypeB::Algorithm<Real>::optimalityCriterion(x,g,pwa,outStream);
217  }
218  }
219 }
220 
221 template<typename Real>
223  const Vector<Real> &g,
224  Objective<Real> &obj,
226  std::ostream &outStream ) {
227  const Real zero(0), one(1);
228  //Real tol0 = std::sqrt(ROL_EPSILON<Real>());
229  Real inTol = static_cast<Real>(0.1)*ROL_OVERFLOW<Real>(), outTol(inTol);
230  Real ftrial(0), pRed(0), rho(1), q(0);
231  // Initialize trust-region data
232  std::vector<std::string> output;
233  initialize(x,g,inTol,obj,bnd,outStream);
234  Ptr<Vector<Real>> gmod = g.clone();
235  Ptr<Vector<Real>> pwa1 = x.clone(), pwa2 = x.clone();
236  Ptr<Vector<Real>> pwa3 = x.clone(), pwa4 = x.clone();
237  Ptr<Vector<Real>> pwa5 = x.clone(), pwa6 = x.clone();
238  Ptr<Vector<Real>> pwa7 = x.clone();
239  Ptr<Vector<Real>> dwa1 = g.clone(), dwa2 = g.clone();
240  // Initialize nonmonotone data
241  Real rhoNM(0), sigmac(0), sigmar(0);
242  Real fr(state_->value), fc(state_->value), fmin(state_->value);
243  TRUtils::ETRFlag TRflagNM;
244  int L(0);
245 
246  // Output
247  if (verbosity_ > 0) writeOutput(outStream,true);
248 
249  while (status_->check(*state_)) {
250  // Build trust-region model
251  model_->setData(obj,*state_->iterateVec,*state_->gradientVec,gtol_);
252 
253  /**** SOLVE TRUST-REGION SUBPROBLEM ****/
254  q = zero;
255  gmod->set(*state_->gradientVec);
256  if (useSimpleSPG_)
257  dpsg_simple(x,q,*gmod,*state_->iterateVec,state_->searchSize,*model_,
258  *pwa1,*pwa2,*dwa1,outStream);
259  else {
260  // Compute Cauchy point (TRON notation: x = x[1])
261  dcauchy(*state_->stepVec,alpha_,q,*state_->iterateVec,
262  state_->gradientVec->dual(),state_->searchSize,
263  *model_,*dwa1,*dwa2,outStream); // Solve 1D optimization problem for alpha
264  x.plus(*state_->stepVec); // Set x = x[0] + alpha*g
265 
266  // Model gradient at s = x[1] - x[0]
267  gmod->plus(*dwa1); // hessVec from Cauchy point computation
268 
269  // Apply SPG starting from the Cauchy point
270  dpsg(x,q,*gmod,*state_->iterateVec,state_->searchSize,*model_,
271  *pwa1,*pwa2,*pwa3,*pwa4,*pwa5,*pwa6,*pwa7,*dwa1,outStream);
272  }
273 
274  // Update storage and compute predicted reduction
275  pRed = -q;
276  state_->stepVec->set(x); state_->stepVec->axpy(-one,*state_->iterateVec);
277  state_->snorm = state_->stepVec->norm();
278 
279  // Compute trial objective value
280  ftrial = computeValue(inTol,outTol,pRed,state_->value,state_->iter,x,*state_->iterateVec,obj);
281  state_->nfval++;
282 
283  // Compute ratio of acutal and predicted reduction
284  TRflag_ = TRUtils::SUCCESS;
285  TRUtils::analyzeRatio<Real>(rho,TRflag_,state_->value,ftrial,pRed,eps_,outStream,verbosity_>1);
286  if (useNM_) {
287  TRUtils::analyzeRatio<Real>(rhoNM,TRflagNM,fr,ftrial,pRed+sigmar,eps_,outStream,verbosity_>1);
288  TRflag_ = (rho < rhoNM ? TRflagNM : TRflag_);
289  rho = (rho < rhoNM ? rhoNM : rho );
290  }
291 
292  // Update algorithm state
293  state_->iter++;
294  // Accept/reject step and update trust region radius
295  if ((rho < eta0_ && TRflag_ == TRUtils::SUCCESS) || (TRflag_ >= 2)) { // Step Rejected
296  x.set(*state_->iterateVec);
297  obj.update(x,UpdateType::Revert,state_->iter);
298  if (interpRad_ && (rho < zero && TRflag_ != TRUtils::TRNAN)) {
299  // Negative reduction, interpolate to find new trust-region radius
300  state_->searchSize = TRUtils::interpolateRadius<Real>(*state_->gradientVec,*state_->stepVec,
301  state_->snorm,pRed,state_->value,ftrial,state_->searchSize,gamma0_,gamma1_,eta2_,
302  outStream,verbosity_>1);
303  }
304  else { // Shrink trust-region radius
305  state_->searchSize = gamma1_*std::min(state_->snorm,state_->searchSize);
306  }
307  computeGradient(x,*state_->gradientVec,*pwa1,state_->searchSize,obj,false,gtol_,state_->gnorm,outStream);
308  }
309  else if ((rho >= eta0_ && TRflag_ != TRUtils::NPOSPREDNEG)
310  || (TRflag_ == TRUtils::POSPREDNEG)) { // Step Accepted
311  state_->value = ftrial;
312  obj.update(x,UpdateType::Accept,state_->iter);
313  inTol = outTol;
314  if (useNM_) {
315  sigmac += pRed; sigmar += pRed;
316  if (ftrial < fmin) { fmin = ftrial; fc = fmin; sigmac = zero; L = 0; }
317  else {
318  L++;
319  if (ftrial > fc) { fc = ftrial; sigmac = zero; }
320  if (L == storageNM_) { fr = fc; sigmar = sigmac; }
321  }
322  }
323  // Increase trust-region radius
324  if (rho >= eta2_) state_->searchSize = std::min(gamma2_*state_->searchSize, delMax_);
325  // Compute gradient at new iterate
326  dwa1->set(*state_->gradientVec);
327  computeGradient(x,*state_->gradientVec,*pwa1,state_->searchSize,obj,true,gtol_,state_->gnorm,outStream);
328  state_->ngrad++;
329  state_->iterateVec->set(x);
330  // Update secant information in trust-region model
331  model_->update(x,*state_->stepVec,*dwa1,*state_->gradientVec,
332  state_->snorm,state_->iter);
333  }
334 
335  // Update Output
336  if (verbosity_ > 0) writeOutput(outStream,writeHeader_);
337  }
338  if (verbosity_ > 0) TypeB::Algorithm<Real>::writeExitStatus(outStream);
339 }
340 
341 template<typename Real>
343  const Vector<Real> &x, const Real alpha,
344  std::ostream &outStream) const {
345  s.set(x); s.axpy(alpha,w);
346  proj_->project(s,outStream); state_->nproj++;
347  s.axpy(static_cast<Real>(-1),x);
348  return s.norm();
349 }
350 
351 template<typename Real>
353  Real &alpha,
354  Real &q,
355  const Vector<Real> &x,
356  const Vector<Real> &g,
357  const Real del,
359  Vector<Real> &dwa, Vector<Real> &dwa1,
360  std::ostream &outStream) {
361  const Real half(0.5);
362  // const Real zero(0); // Unused
363  Real tol = std::sqrt(ROL_EPSILON<Real>());
364  bool interp = false;
365  Real gs(0), snorm(0);
366  // Compute s = P(x[0] - alpha g[0])
367  snorm = dgpstep(s,g,x,-alpha,outStream);
368  if (snorm > del) {
369  interp = true;
370  }
371  else {
372  model.hessVec(dwa,s,x,tol); nhess_++;
373  gs = s.dot(g);
374  //q = half * s.dot(dwa.dual()) + gs;
375  q = half * s.apply(dwa) + gs;
376  interp = (q > mu0_*gs);
377  }
378  // Either increase or decrease alpha to find approximate Cauchy point
379  int cnt = 0;
380  if (interp) {
381  bool search = true;
382  while (search) {
383  alpha *= interpf_;
384  snorm = dgpstep(s,g,x,-alpha,outStream);
385  if (snorm <= del) {
386  model.hessVec(dwa,s,x,tol); nhess_++;
387  gs = s.dot(g);
388  //q = half * s.dot(dwa.dual()) + gs;
389  q = half * s.apply(dwa) + gs;
390  search = (q > mu0_*gs) && (cnt < redlim_);
391  }
392  cnt++;
393  }
394  }
395  else {
396  bool search = true;
397  Real alphas = alpha;
398  Real qs = q;
399  dwa1.set(dwa);
400  while (search) {
401  alpha *= extrapf_;
402  snorm = dgpstep(s,g,x,-alpha,outStream);
403  if (snorm <= del && cnt < explim_) {
404  model.hessVec(dwa,s,x,tol); nhess_++;
405  gs = s.dot(g);
406  //q = half * s.dot(dwa.dual()) + gs;
407  q = half * s.apply(dwa) + gs;
408  if (q <= mu0_*gs && std::abs(q-qs) > qtol_*std::abs(qs)) {
409  dwa1.set(dwa);
410  search = true;
411  alphas = alpha;
412  qs = q;
413  }
414  else {
415  q = qs;
416  dwa.set(dwa1);
417  search = false;
418  }
419  }
420  else {
421  search = false;
422  }
423  cnt++;
424  }
425  alpha = alphas;
426  snorm = dgpstep(s,g,x,-alpha,outStream);
427  }
428  if (verbosity_ > 1) {
429  outStream << " Cauchy point" << std::endl;
430  outStream << " Step length (alpha): " << alpha << std::endl;
431  outStream << " Step length (alpha*g): " << snorm << std::endl;
432  outStream << " Model decrease (pRed): " << -q << std::endl;
433  if (!interp) {
434  outStream << " Number of extrapolation steps: " << cnt << std::endl;
435  }
436  }
437  return snorm;
438 }
439 
440 template<typename Real>
442  Real &q,
443  Vector<Real> &gmod,
444  const Vector<Real> &x,
445  Real del,
447  Vector<Real> &pwa,
448  Vector<Real> &pwa1,
449  Vector<Real> &dwa,
450  std::ostream &outStream) {
451  // Use SPG to approximately solve TR subproblem:
452  // min 1/2 <H(y-x), (y-x)> + <g, (y-x)> subject to y\in C, ||y|| \le del
453  //
454  // Inpute:
455  // y = Primal vector
456  // x = Current iterate
457  // g = Current gradient
458  const Real half(0.5), one(1), safeguard(1e2*ROL_EPSILON<Real>());
459  Real tol(std::sqrt(ROL_EPSILON<Real>()));
460  Real alpha(1), alphaMax(1), s0s0(0), ss0(0), sHs(0), lambdaTmp(1), snorm(0);
461  pwa1.zero();
462 
463  // Set y = x
464  y.set(x);
465 
466  // Compute initial step
467  Real coeff = one/gmod.norm();
468  Real lambda = std::max(lambdaMin_,std::min(coeff,lambdaMax_));
469  pwa.set(y); pwa.axpy(-lambda,gmod.dual()); // pwa = x - lambda gmod.dual()
470  proj_->project(pwa,outStream); state_->nproj++; // pwa = P(x - lambda gmod.dual())
471  pwa.axpy(-one,y); // pwa = P(x - lambda gmod.dual()) - x = step
472  Real gs = gmod.apply(pwa); // gs = <step, model gradient>
473  Real ss = pwa.dot(pwa); // Norm squared of step
474  Real gnorm = std::sqrt(ss);
475 
476  // Compute initial projected gradient norm
477  const Real gtol = std::min(tol1_,tol2_*gnorm);
478 
479  if (verbosity_ > 1)
480  outStream << " Spectral Projected Gradient" << std::endl;
481 
482  SPiter_ = 0;
483  while (SPiter_ < maxit_) {
484  SPiter_++;
485 
486  // Evaluate model Hessian
487  model.hessVec(dwa,pwa,x,tol); nhess_++; // dwa = H step
488  sHs = dwa.apply(pwa); // sHs = <step, H step>
489 
490  // Perform line search
491  alphaMax = 1;
492  if (gnorm >= del-safeguard) { // Trust-region constraint is violated
493  ss0 = pwa1.dot(pwa);
494  alphaMax = std::min(one, (-ss0 + std::sqrt(ss0*ss0 - ss*(s0s0-del*del)))/ss);
495  }
496  if (sHs <= safeguard)
497  alpha = alphaMax;
498  else
499  alpha = std::min(alphaMax, -gs/sHs);
500 
501  // Update model quantities
502  q += alpha * (gs + half * alpha * sHs); // Update model value
503  gmod.axpy(alpha,dwa); // Update model gradient
504  y.axpy(alpha,pwa); // New iterate
505 
506  // Check trust-region constraint violation
507  pwa1.set(y); pwa1.axpy(-one,x);
508  s0s0 = pwa1.dot(pwa1);
509  snorm = std::sqrt(s0s0);
510 
511  if (verbosity_ > 1) {
512  outStream << std::endl;
513  outStream << " Iterate: " << SPiter_ << std::endl;
514  outStream << " Spectral step length (lambda): " << lambda << std::endl;
515  outStream << " Step length (alpha): " << alpha << std::endl;
516  outStream << " Model decrease (pRed): " << -q << std::endl;
517  outStream << " Optimality criterion: " << gnorm << std::endl;
518  outStream << " Step norm: " << snorm << std::endl;
519  outStream << std::endl;
520  }
521 
522  if (snorm >= del - safeguard) { SPflag_ = 2; break; }
523 
524  // Compute new spectral step
525  lambdaTmp = (sHs <= safeguard ? one/gmod.norm() : ss/sHs);
526  lambda = std::max(lambdaMin_,std::min(lambdaTmp,lambdaMax_));
527  pwa.set(y); pwa.axpy(-lambda,gmod.dual());
528  proj_->project(pwa,outStream); state_->nproj++;
529  pwa.axpy(-one,y);
530  gs = gmod.apply(pwa);
531  ss = pwa.dot(pwa);
532  gnorm = std::sqrt(ss);
533 
534  if (gnorm <= gtol) { SPflag_ = 0; break; }
535  }
536  SPflag_ = (SPiter_==maxit_) ? 1 : SPflag_;
537 }
538 
539 template<typename Real>
541  Real &q,
542  Vector<Real> &gmod,
543  const Vector<Real> &x,
544  Real del,
546  Vector<Real> &ymin,
547  Vector<Real> &pwa,
548  Vector<Real> &pwa1,
549  Vector<Real> &pwa2,
550  Vector<Real> &pwa3,
551  Vector<Real> &pwa4,
552  Vector<Real> &pwa5,
553  Vector<Real> &dwa,
554  std::ostream &outStream) {
555  // Use SPG to approximately solve TR subproblem:
556  // min 1/2 <H(y-x), (y-x)> + <g, (y-x)> subject to y\in C, ||y|| \le del
557  //
558  // Inpute:
559  // y = Cauchy step
560  // x = Current iterate
561  // g = Current gradient
562  const Real zero(0), half(0.5), one(1), two(2); //, eps(std::sqrt(ROL_EPSILON<Real>()));
563  Real tol(std::sqrt(ROL_EPSILON<Real>()));
564  Real alpha(1), sHs(0), alphaTmp(1), mmax(0), qmin(0), lambdaTmp(1);
565  std::deque<Real> mqueue; mqueue.push_back(q);
566 
567  if (useNMSP_ && useMin_) { qmin = q; ymin.set(y); }
568 
569  // Compute initial projected gradient norm
570  pwa1.set(gmod.dual());
571  pwa.set(y); pwa.axpy(-one,pwa1);
572  dproj(pwa,x,del,pwa2,pwa3,pwa4,pwa5,outStream);
573  pwa.axpy(-one,y);
574  Real gnorm = pwa.norm();
575  const Real gtol = std::min(tol1_,tol2_*gnorm);
576 
577  // Compute initial step
578  Real coeff = one/gmod.norm();
579  Real lambda = std::max(lambdaMin_,std::min(coeff,lambdaMax_));
580  pwa.set(y); pwa.axpy(-lambda,pwa1); // pwa = y - lambda gmod.dual()
581  dproj(pwa,x,del,pwa2,pwa3,pwa4,pwa5,outStream); // pwa = P(y - lambda gmod.dual())
582  pwa.axpy(-one,y); // pwa = P(y - lambda gmod.dual()) - y = step
583  Real gs = gmod.apply(pwa); // gs = <step, model gradient>
584  Real ss = pwa.dot(pwa); // Norm squared of step
585 
586  if (verbosity_ > 1)
587  outStream << " Spectral Projected Gradient" << std::endl;
588 
589  SPiter_ = 0;
590  while (SPiter_ < maxit_) {
591  SPiter_++;
592 
593  // Evaluate model Hessian
594  model.hessVec(dwa,pwa,x,tol); nhess_++; // dwa = H step
595  sHs = dwa.apply(pwa); // sHs = <step, H step>
596 
597  // Perform line search
598  if (useNMSP_) { // Nonmonotone
599  mmax = *std::max_element(mqueue.begin(),mqueue.end());
600  alphaTmp = (-(one-gamma_)*gs + std::sqrt(std::pow((one-gamma_)*gs,two)-two*sHs*(q-mmax)))/sHs;
601  }
602  else { // Exact
603  alphaTmp = -gs/sHs;
604  }
605  alpha = (sHs > zero ? std::min(one,std::max(zero,alphaTmp)) : one);
606 
607  // Update model quantities
608  q += alpha * (gs + half * alpha * sHs); // Update model value
609  gmod.axpy(alpha,dwa); // Update model gradient
610  y.axpy(alpha,pwa); // New iterate
611 
612  // Update nonmonotone line search information
613  if (useNMSP_) {
614  if (static_cast<int>(mqueue.size())==maxSize_) mqueue.pop_front();
615  mqueue.push_back(q);
616  if (useMin_ && q <= qmin) { qmin = q; ymin.set(y); }
617  }
618 
619  // Compute projected gradient norm
620  pwa1.set(gmod.dual());
621  pwa.set(y); pwa.axpy(-one,pwa1);
622  dproj(pwa,x,del,pwa2,pwa3,pwa4,pwa5,outStream);
623  pwa.axpy(-one,y);
624  gnorm = pwa.norm();
625 
626  if (verbosity_ > 1) {
627  outStream << std::endl;
628  outStream << " Iterate: " << SPiter_ << std::endl;
629  outStream << " Spectral step length (lambda): " << lambda << std::endl;
630  outStream << " Step length (alpha): " << alpha << std::endl;
631  outStream << " Model decrease (pRed): " << -q << std::endl;
632  outStream << " Optimality criterion: " << gnorm << std::endl;
633  outStream << std::endl;
634  }
635  if (gnorm < gtol) break;
636 
637  // Compute new spectral step
638  //lambda = (sHs<=eps ? lambdaMax_ : std::max(lambdaMin_,std::min(ss/sHs,lambdaMax_)));
639  lambdaTmp = (sHs == 0 ? coeff : ss/sHs);
640  lambda = std::max(lambdaMin_,std::min(lambdaTmp,lambdaMax_));
641  pwa.set(y); pwa.axpy(-lambda,pwa1);
642  dproj(pwa,x,del,pwa2,pwa3,pwa4,pwa5,outStream);
643  pwa.axpy(-one,y);
644  gs = gmod.apply(pwa);
645  ss = pwa.dot(pwa);
646  }
647  if (useNMSP_ && useMin_) { q = qmin; y.set(ymin); }
648  SPflag_ = (SPiter_==maxit_) ? 1 : 0;
649 }
650 
651 template<typename Real>
653  const Vector<Real> &x0,
654  Real del,
655  Vector<Real> &y0,
656  Vector<Real> &y1,
657  Vector<Real> &yc,
658  Vector<Real> &pwa,
659  std::ostream &outStream) const {
660  // Solve ||P(t*x0 + (1-t)*(x-x0))-x0|| = del using Brent's method
661  const Real zero(0), half(0.5), one(1), two(2), three(3);
662  const Real eps(ROL_EPSILON<Real>()), tol0(1e1*eps), fudge(1.0-1e-2*sqrt(eps));
663  Real f0(0), f1(0), fc(0), t0(0), t1(1), tc(0), d1(1), d2(1), tol(1);
664  Real p(0), q(0), r(0), s(0), m(0);
665  int cnt(state_->nproj);
666  y1.set(x);
667  proj_->project(y1,outStream); state_->nproj++;
668  pwa.set(y1); pwa.axpy(-one,x0);
669  f1 = pwa.norm();
670  if (f1 <= del) {
671  x.set(y1);
672  return;
673  }
674  y0.set(x0);
675  tc = t0; fc = f0; yc.set(y0);
676  d1 = t1-t0; d2 = d1;
677  int code = 0;
678  while (true) {
679  if (std::abs(fc-del) < std::abs(f1-del)) {
680  t0 = t1; t1 = tc; tc = t0;
681  f0 = f1; f1 = fc; fc = f0;
682  y0.set(y1); y1.set(yc); yc.set(y0);
683  }
684  tol = two*eps*std::abs(t1) + half*tol0;
685  m = half*(tc - t1);
686  if (std::abs(m) <= tol) { code = 1; break; }
687  if ((f1 >= fudge*del && f1 <= del)) break;
688  if (std::abs(d1) < tol || std::abs(f0-del) <= std::abs(f1-del)) {
689  d1 = m; d2 = d1;
690  }
691  else {
692  s = (f1-del)/(f0-del);
693  if (t0 == tc) {
694  p = two*m*s;
695  q = one-s;
696  }
697  else {
698  q = (f0-del)/(fc-del);
699  r = (f1-del)/(fc-del);
700  p = s*(two*m*q*(q-r)-(t1-t0)*(r-one));
701  q = (q-one)*(r-one)*(s-one);
702  }
703  if (p > zero) q = -q;
704  else p = -p;
705  s = d1;
706  d1 = d2;
707  if (two*p < three*m*q-std::abs(tol*q) && p < std::abs(half*s*q)) {
708  d2 = p/q;
709  }
710  else {
711  d1 = m; d2 = d1;
712  }
713  }
714  t0 = t1; f0 = f1; y0.set(y1);
715  if (std::abs(d2) > tol) t1 += d2;
716  else if (m > zero) t1 += tol;
717  else t1 -= tol;
718  y1.set(x); y1.scale(t1); y1.axpy(one-t1,x0);
719  proj_->project(y1,outStream); state_->nproj++;
720  pwa.set(y1); pwa.axpy(-one,x0);
721  f1 = pwa.norm();
722  if ((f1 > del && fc > del) || (f1 <= del && fc <= del)) {
723  tc = t0; fc = f0; yc.set(y0);
724  d1 = t1-t0; d2 = d1;
725  }
726  }
727  if (code==1 && f1>del) x.set(yc);
728  else x.set(y1);
729  if (verbosity_ > 1) {
730  outStream << std::endl;
731  outStream << " Trust-Region Subproblem Projection" << std::endl;
732  outStream << " Number of polyhedral projections: " << state_->nproj-cnt << std::endl;
733  if (code == 1 && f1 > del) {
734  outStream << " Transformed Multiplier: " << tc << std::endl;
735  outStream << " Dual Residual: " << fc-del << std::endl;
736  }
737  else {
738  outStream << " Transformed Multiplier: " << t1 << std::endl;
739  outStream << " Dual Residual: " << f1-del << std::endl;
740  }
741  outStream << " Exit Code: " << code << std::endl;
742  outStream << std::endl;
743  }
744 }
745 
746 // BRACKETING AND BRENTS FOR UNTRANSFORMED MULTIPLIER
747 //template<typename Real>
748 //void TrustRegionSPGAlgorithm<Real>::dproj(Vector<Real> &x,
749 // const Vector<Real> &x0,
750 // Real del,
751 // Vector<Real> &y0,
752 // Vector<Real> &y1,
753 // Vector<Real> &yc,
754 // Vector<Real> &pwa,
755 // std::ostream &outStream) const {
756 // // Solve ||P(t*x0 + (1-t)*(x-x0))-x0|| = del using Brent's method
757 // const Real zero(0), half(0.5), one(1), two(2), three(3);
758 // const Real eps(ROL_EPSILON<Real>()), tol0(1e1*eps), fudge(1.0-1e-2*sqrt(eps));
759 // Real f0(0), f1(0), fc(0), u0(0), u1(0), uc(0), t0(1), t1(0), tc(0), d1(1), d2(1), tol(1);
760 // Real p(0), q(0), r(0), s(0), m(0);
761 // int cnt(state_->nproj);
762 // y0.set(x);
763 // proj_->project(y0,outStream); state_->nproj++;
764 // pwa.set(y0); pwa.axpy(-one,x0);
765 // f0 = pwa.norm();
766 // if (f0 <= del) {
767 // x.set(y0);
768 // return;
769 // }
770 //
771 // // Bracketing
772 // t1 = static_cast<Real>(1e-1);
773 // f1 = one+del;
774 // while (f1 >= del) {
775 // t1 *= static_cast<Real>(5e-2);
776 // y1.set(x); y1.scale(t1); y1.axpy(one-t1,x0);
777 // proj_->project(y1,outStream); state_->nproj++;
778 // pwa.set(y1); pwa.axpy(-one,x0);
779 // f1 = pwa.norm();
780 // }
781 // u1 = (one-t1)/t1;
782 //
783 // // Brents
784 // uc = u0; tc = t0; fc = f0; yc.set(y0);
785 // d1 = u1-u0; d2 = d1;
786 // int code = 0;
787 // while (true) {
788 // if (std::abs(fc-del) < std::abs(f1-del)) {
789 // u0 = u1; u1 = uc; uc = u0;
790 // t0 = t1; t1 = tc; tc = t0;
791 // f0 = f1; f1 = fc; fc = f0;
792 // y0.set(y1); y1.set(yc); yc.set(y0);
793 // }
794 // tol = two*eps*abs(u1) + half*tol0;
795 // m = half*(uc - u1);
796 // if (std::abs(m) <= tol) { code = 1; break; }
797 // if ((f1 >= fudge*del && f1 <= del)) break;
798 // if (std::abs(d1) < tol || std::abs(f0-del) <= std::abs(f1-del)) {
799 // d1 = m; d2 = d1;
800 // }
801 // else {
802 // s = (f1-del)/(f0-del);
803 // if (u0 == uc) {
804 // p = two*m*s;
805 // q = one-s;
806 // }
807 // else {
808 // q = (f0-del)/(fc-del);
809 // r = (f1-del)/(fc-del);
810 // p = s*(two*m*q*(q-r)-(u1-u0)*(r-one));
811 // q = (q-one)*(r-one)*(s-one);
812 // }
813 // if (p > zero) q = -q;
814 // else p = -p;
815 // s = d1;
816 // d1 = d2;
817 // if (two*p < three*m*q-std::abs(tol*q) && p < std::abs(half*s*q)) {
818 // d2 = p/q;
819 // }
820 // else {
821 // d1 = m; d2 = d1;
822 // }
823 // }
824 // u0 = u1; t0 = t1; f0 = f1; y0.set(y1);
825 // if (std::abs(d2) > tol) u1 += d2;
826 // else if (m > zero) u1 += tol;
827 // else u1 -= tol;
828 // t1 = one/(one+u1);
829 // y1.set(x); y1.scale(t1); y1.axpy(one-t1,x0);
830 // proj_->project(y1,outStream); state_->nproj++;
831 // pwa.set(y1); pwa.axpy(-one,x0);
832 // f1 = pwa.norm();
833 // if ((f1 > del && fc > del) || (f1 <= del && fc <= del)) {
834 // uc = u0; tc = t0; fc = f0; yc.set(y0);
835 // d1 = u1-u0; d2 = d1;
836 // }
837 // }
838 // if (code==1 && f1>del) x.set(yc);
839 // else x.set(y1);
840 // if (verbosity_ > 1) {
841 // outStream << std::endl;
842 // outStream << " Trust-Region Subproblem Projection" << std::endl;
843 // outStream << " Number of polyhedral projections: " << state_->nproj-cnt << std::endl;
844 // if (code == 1 && f1 > del) {
845 // outStream << " Multiplier: " << uc << std::endl;
846 // outStream << " Transformed Multiplier: " << tc << std::endl;
847 // outStream << " Dual Residual: " << fc-del << std::endl;
848 // }
849 // else {
850 // outStream << " Multiplier: " << u1 << std::endl;
851 // outStream << " Transformed Multiplier: " << t1 << std::endl;
852 // outStream << " Dual Residual: " << f1-del << std::endl;
853 // }
854 // outStream << " Exit Code: " << code << std::endl;
855 // outStream << std::endl;
856 // }
857 //}
858 
859 // RIDDERS' METHOD FOR TRUST-REGION PROJECTION
860 //template<typename Real>
861 //void TrustRegionSPGAlgorithm<Real>::dproj(Vector<Real> &x,
862 // const Vector<Real> &x0,
863 // Real del,
864 // Vector<Real> &y,
865 // Vector<Real> &y1,
866 // Vector<Real> &yc,
867 // Vector<Real> &p,
868 // std::ostream &outStream) const {
869 // // Solve ||P(t*x0 + (1-t)*(x-x0))-x0|| = del using Ridder's method
870 // const Real half(0.5), one(1), tol(1e1*ROL_EPSILON<Real>());
871 // const Real fudge(1.0-1e-2*std::sqrt(ROL_EPSILON<Real>()));
872 // Real e0(0), e1(0), e2(0), e(0), a0(0), a1(0.5), a2(1), a(0);
873 // int cnt(state_->nproj);
874 // y.set(x);
875 // proj_->project(y,outStream); state_->nproj++;
876 // p.set(y); p.axpy(-one,x0);
877 // e2 = p.norm();
878 // if (e2 <= del) {
879 // x.set(y);
880 // return;
881 // }
882 // bool code = 1;
883 // while (a2-a0 > tol) {
884 // a1 = half*(a0+a2);
885 // y.set(x); y.scale(a1); y.axpy(one-a1,x0);
886 // proj_->project(y,outStream); state_->nproj++;
887 // p.set(y); p.axpy(-one,x0);
888 // e1 = p.norm();
889 // if (e1 >= fudge*del && e1 <= del) break;
890 // a = a1-(a1-a0)*(e1-del)/std::sqrt((e1-del)*(e1-del)-(e0-del)*(e2-del));
891 // y.set(x); y.scale(a); y.axpy(one-a,x0);
892 // proj_->project(y,outStream); state_->nproj++;
893 // p.set(y); p.axpy(-one,x0);
894 // e = p.norm();
895 // if (e < fudge*del) {
896 // if (e1 < fudge*del) { e0 = (a < a1 ? e1 : e); a0 = (a < a1 ? a1 : a); }
897 // else { e0 = e; a0 = a; e2 = e1; a2 = a1; };
898 // }
899 // else if (e > del) {
900 // if (e1 < fudge*del) { e0 = e1; a0 = a1; e2 = e; a2 = a; }
901 // else { e2 = (a < a1 ? e : e1); a2 = (a < a1 ? a : a1); }
902 // }
903 // else {
904 // code = 0;
905 // break; // Exit if fudge*del <= snorm <= del
906 // }
907 // }
908 // x.set(y);
909 // if (verbosity_ > 1) {
910 // outStream << std::endl;
911 // outStream << " Trust-Region Subproblem Projection" << std::endl;
912 // outStream << " Number of polyhedral projections: " << state_->nproj-cnt << std::endl;
913 // outStream << " Transformed Multiplier: " << a1 << std::endl;
914 // outStream << " Dual Residual: " << e1-del << std::endl;
915 // outStream << " Exit Code: " << code << std::endl;
916 // outStream << std::endl;
917 // }
918 //}
919 
920 template<typename Real>
921 void TrustRegionSPGAlgorithm<Real>::writeHeader( std::ostream& os ) const {
922  std::ios_base::fmtflags osFlags(os.flags());
923  if (verbosity_ > 1) {
924  os << std::string(114,'-') << std::endl;
925  os << " SPG trust-region method status output definitions" << std::endl << std::endl;
926  os << " iter - Number of iterates (steps taken)" << std::endl;
927  os << " value - Objective function value" << std::endl;
928  os << " gnorm - Norm of the gradient" << std::endl;
929  os << " snorm - Norm of the step (update to optimization vector)" << std::endl;
930  os << " delta - Trust-Region radius" << std::endl;
931  os << " #fval - Number of times the objective function was evaluated" << std::endl;
932  os << " #grad - Number of times the gradient was computed" << std::endl;
933  os << " #hess - Number of times the Hessian was applied" << std::endl;
934  os << " #proj - Number of times the projection was computed" << std::endl;
935  os << std::endl;
936  os << " tr_flag - Trust-Region flag" << std::endl;
937  for( int flag = TRUtils::SUCCESS; flag != TRUtils::UNDEFINED; ++flag ) {
938  os << " " << NumberToString(flag) << " - "
939  << TRUtils::ETRFlagToString(static_cast<TRUtils::ETRFlag>(flag)) << std::endl;
940  }
941  os << std::endl;
942  os << " iterSPG - Number of Spectral Projected Gradient iterations" << std::endl << std::endl;
943  os << " flagSPG - Trust-Region Truncated CG flag" << std::endl;
944  os << " 0 - Converged" << std::endl;
945  os << " 1 - Iteration Limit Exceeded" << std::endl;
946  os << std::string(114,'-') << std::endl;
947  }
948  os << " ";
949  os << std::setw(6) << std::left << "iter";
950  os << std::setw(15) << std::left << "value";
951  os << std::setw(15) << std::left << "gnorm";
952  os << std::setw(15) << std::left << "snorm";
953  os << std::setw(15) << std::left << "delta";
954  os << std::setw(10) << std::left << "#fval";
955  os << std::setw(10) << std::left << "#grad";
956  os << std::setw(10) << std::left << "#hess";
957  os << std::setw(10) << std::left << "#proj";
958  os << std::setw(10) << std::left << "tr_flag";
959  os << std::setw(10) << std::left << "iterSPG";
960  os << std::setw(10) << std::left << "flagSPG";
961  os << std::endl;
962  os.flags(osFlags);
963 }
964 
965 template<typename Real>
966 void TrustRegionSPGAlgorithm<Real>::writeName( std::ostream& os ) const {
967  std::ios_base::fmtflags osFlags(os.flags());
968  os << std::endl << "SPG Trust-Region Method (Type B, Bound Constraints)" << std::endl;
969  os.flags(osFlags);
970 }
971 
972 template<typename Real>
973 void TrustRegionSPGAlgorithm<Real>::writeOutput( std::ostream& os, bool write_header ) const {
974  std::ios_base::fmtflags osFlags(os.flags());
975  os << std::scientific << std::setprecision(6);
976  if ( state_->iter == 0 ) writeName(os);
977  if ( write_header ) writeHeader(os);
978  if ( state_->iter == 0 ) {
979  os << " ";
980  os << std::setw(6) << std::left << state_->iter;
981  os << std::setw(15) << std::left << state_->value;
982  os << std::setw(15) << std::left << state_->gnorm;
983  os << std::setw(15) << std::left << "---";
984  os << std::setw(15) << std::left << state_->searchSize;
985  os << std::setw(10) << std::left << state_->nfval;
986  os << std::setw(10) << std::left << state_->ngrad;
987  os << std::setw(10) << std::left << nhess_;
988  os << std::setw(10) << std::left << state_->nproj;
989  os << std::setw(10) << std::left << "---";
990  os << std::setw(10) << std::left << "---";
991  os << std::setw(10) << std::left << "---";
992  os << std::endl;
993  }
994  else {
995  os << " ";
996  os << std::setw(6) << std::left << state_->iter;
997  os << std::setw(15) << std::left << state_->value;
998  os << std::setw(15) << std::left << state_->gnorm;
999  os << std::setw(15) << std::left << state_->snorm;
1000  os << std::setw(15) << std::left << state_->searchSize;
1001  os << std::setw(10) << std::left << state_->nfval;
1002  os << std::setw(10) << std::left << state_->ngrad;
1003  os << std::setw(10) << std::left << nhess_;
1004  os << std::setw(10) << std::left << state_->nproj;
1005  os << std::setw(10) << std::left << TRflag_;
1006  os << std::setw(10) << std::left << SPiter_;
1007  os << std::setw(10) << std::left << SPflag_;
1008  os << std::endl;
1009  }
1010  os.flags(osFlags);
1011 }
1012 
1013 } // namespace TypeB
1014 } // namespace ROL
1015 
1016 #endif
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...
Definition: ROL_Vector.hpp:226
virtual void scale(const Real alpha)=0
Compute where .
void writeOutput(std::ostream &os, const bool write_header=false) const override
Print iterate status.
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual Real apply(const Vector< Real > &x) const
Apply to a dual vector. This is equivalent to the call .
Definition: ROL_Vector.hpp:238
virtual void plus(const Vector &x)=0
Compute , where .
void dpsg_simple(Vector< Real > &y, Real &q, Vector< Real > &gmod, const Vector< Real > &x, Real del, TrustRegionModel_U< Real > &model, Vector< Real > &pwa, Vector< Real > &pwa1, Vector< Real > &dwa, std::ostream &outStream=std::cout)
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition: ROL_Vector.hpp:153
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
TrustRegionSPGAlgorithm(ParameterList &list, const Ptr< Secant< Real >> &secant=nullPtr)
void computeGradient(const Vector< Real > &x, Vector< Real > &g, Vector< Real > &pwa, Real del, Objective< Real > &obj, bool accept, Real &gtol, Real &gnorm, std::ostream &outStream=std::cout) const
virtual void writeExitStatus(std::ostream &os) const
ESecant StringToESecant(std::string s)
Definition: ROL_Types.hpp:543
Real dcauchy(Vector< Real > &s, Real &alpha, Real &q, const Vector< Real > &x, const Vector< Real > &g, const Real del, TrustRegionModel_U< Real > &model, Vector< Real > &dwa, Vector< Real > &dwa1, std::ostream &outStream=std::cout)
virtual void zero()
Set to zero vector.
Definition: ROL_Vector.hpp:167
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
void dpsg(Vector< Real > &y, Real &q, Vector< Real > &gmod, const Vector< Real > &x, Real del, TrustRegionModel_U< Real > &model, Vector< Real > &ymin, Vector< Real > &pwa, Vector< Real > &pwa1, Vector< Real > &pwa2, Vector< Real > &pwa3, Vector< Real > &pwa4, Vector< Real > &pwa5, Vector< Real > &dwa, std::ostream &outStream=std::cout)
void writeName(std::ostream &os) const override
Print step name.
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
Real dgpstep(Vector< Real > &s, const Vector< Real > &w, const Vector< Real > &x, const Real alpha, std::ostream &outStream=std::cout) const
virtual Real dot(const Vector &x) const =0
Compute where .
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.
ETRFlag
Enumation of flags used by trust-region solvers.
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
std::string NumberToString(T Number)
Definition: ROL_Types.hpp:81
Provides the interface to evaluate trust-region model functions.
void initialize(Vector< Real > &x, const Vector< Real > &g, Real ftol, Objective< Real > &obj, BoundConstraint< Real > &bnd, std::ostream &outStream=std::cout)
void writeHeader(std::ostream &os) const override
Print iterate header.
ESecantMode
Definition: ROL_Secant.hpp:57
Provides interface for and implements limited-memory secant operators.
Definition: ROL_Secant.hpp:79
void dproj(Vector< Real > &x, const Vector< Real > &x0, Real del, Vector< Real > &y0, Vector< Real > &y1, Vector< Real > &yc, Vector< Real > &pwa, std::ostream &outStream=std::cout) const
Provides an interface to check status of optimization algorithms.
std::string ETRFlagToString(ETRFlag trf)
Provides the interface to apply upper and lower bound constraints.
Real optimalityCriterion(const Vector< Real > &x, const Vector< Real > &g, Vector< Real > &primal, std::ostream &outStream=std::cout) const
void initialize(const Vector< Real > &x, const Vector< Real > &g)
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:209
void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, std::ostream &outStream=std::cout) override
Run algorithm on bound constrained problems (Type-B). This general interface supports the use of dual...
virtual Real norm() const =0
Returns where .
Real computeValue(Real inTol, Real &outTol, Real pRed, Real &fold, int iter, const Vector< Real > &x, const Vector< Real > &xold, Objective< Real > &obj)