ROL
ROL_TrustRegionStep.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_TRUSTREGIONSTEP_H
45 #define ROL_TRUSTREGIONSTEP_H
46 
47 #include "ROL_Step.hpp"
48 #include "ROL_Types.hpp"
49 #include "ROL_Secant.hpp"
50 #include "ROL_TrustRegion.hpp"
51 #include <sstream>
52 #include <iomanip>
53 
126 namespace ROL {
127 
128 template <class Real>
129 class TrustRegionStep : public Step<Real> {
130 private:
131 
132  // ADDITIONAL VECTOR STORAGE
133  Teuchos::RCP<Vector<Real> > xnew_;
134  Teuchos::RCP<Vector<Real> > xold_;
135  Teuchos::RCP<Vector<Real> > gp_;
136 
137  // TRUST REGION INFORMATION
138  Teuchos::RCP<TrustRegion<Real> > trustRegion_;
139  Teuchos::RCP<TrustRegionModel<Real> > model_;
142  Real delMax_;
144  int SPflag_;
145  int SPiter_;
146  bool bndActive_;
147 
148  // SECANT INFORMATION
149  Teuchos::RCP<Secant<Real> > secant_;
153 
154  // BOUND CONSTRAINED PARAMETERS
155  Real scaleEps_;
157 
158  // POST SMOOTHING PARAMETERS
159  Real alpha_init_;
160  int max_fval_;
161  Real mu_;
162  Real beta_;
163 
164  // COLEMAN-LI PARAMETERS
168 
169  // INEXACT COMPUTATION PARAMETERS
170  std::vector<bool> useInexact_;
171  Real scale0_;
172  Real scale1_;
173 
174  // VERBOSITY SETTING
176 
183  void parseParameterList(Teuchos::ParameterList &parlist) {
184  Teuchos::RCP<StepState<Real> > step_state = Step<Real>::getState();
185  // Trust-Region Parameters
186  Teuchos::ParameterList &slist = parlist.sublist("Step");
187  Teuchos::ParameterList &list = slist.sublist("Trust Region");
188  step_state->searchSize = list.get("Initial Radius", static_cast<Real>(-1));
189  delMax_ = list.get("Maximum Radius", static_cast<Real>(1.e8));
190  // Inexactness Information
191  Teuchos::ParameterList &glist = parlist.sublist("General");
192  useInexact_.clear();
193  useInexact_.push_back(glist.get("Inexact Objective Function", false));
194  useInexact_.push_back(glist.get("Inexact Gradient", false));
195  useInexact_.push_back(glist.get("Inexact Hessian-Times-A-Vector", false));
196  // Trust-Region Inexactness Parameters
197  Teuchos::ParameterList &ilist = list.sublist("Inexact").sublist("Gradient");
198  scale0_ = ilist.get("Tolerance Scaling", static_cast<Real>(0.1));
199  scale1_ = ilist.get("Relative Tolerance", static_cast<Real>(2));
200  // Initialize Trust Region Subproblem Solver Object
201  etr_ = StringToETrustRegion(list.get("Subproblem Solver", "Dogleg"));
202  TRmodel_ = StringToETrustRegionModel(list.get("Subproblem Model", "Kelley-Sachs"));
203  useProjectedGrad_ = glist.get("Projected Gradient Criticality Measure", false);
204  trustRegion_ = TrustRegionFactory<Real>(parlist);
205  // Scale for epsilon active sets
206  scaleEps_ = glist.get("Scale for Epsilon Active Sets", static_cast<Real>(1));
207  verbosity_ = glist.get("Print Verbosity", 0);
208  // Post-smoothing parameters
209  max_fval_ = list.sublist("Post-Smoothing").get("Function Evaluation Limit", 20);
210  alpha_init_ = list.sublist("Post-Smoothing").get("Initial Step Size", static_cast<Real>(1));
211  mu_ = list.sublist("Post-Smoothing").get("Tolerance", static_cast<Real>(0.9999));
212  beta_ = list.sublist("Post-Smoothing").get("Rate", static_cast<Real>(0.01));
213  // Coleman-Li parameters
214  stepBackMax_ = list.sublist("Coleman-Li").get("Maximum Step Back", static_cast<Real>(0.9999));
215  stepBackScale_ = list.sublist("Coleman-Li").get("Maximum Step Scale", static_cast<Real>(1));
216  singleReflect_ = list.sublist("Coleman-Li").get("Single Reflection", true);
217  }
218 
234  AlgorithmState<Real> &algo_state ) {
235  Real oem2(1.e-2), one(1), oe4(1.e4);
236  Teuchos::RCP<StepState<Real> > state = Step<Real>::getState();
237  if ( useInexact_[1] ) {
238  Real c = scale0_*std::max(oem2,std::min(one,oe4*algo_state.gnorm));
239  Real gtol1 = c*(state->searchSize);
240  Real gtol0 = scale1_*gtol1 + one;
241  while ( gtol0 > gtol1*scale1_ ) {
242  obj.gradient(*(state->gradientVec),x,gtol1);
243  algo_state.gnorm = computeCriticalityMeasure(*(state->gradientVec),x,bnd);
244  gtol0 = gtol1;
245  c = scale0_*std::max(oem2,std::min(one,oe4*algo_state.gnorm));
246  gtol1 = c*std::min(algo_state.gnorm,state->searchSize);
247  }
248  algo_state.ngrad++;
249  }
250  else {
251  Real gtol = std::sqrt(ROL_EPSILON<Real>());
252  obj.gradient(*(state->gradientVec),x,gtol);
253  algo_state.ngrad++;
254  algo_state.gnorm = computeCriticalityMeasure(*(state->gradientVec),x,bnd);
255  }
256  }
257 
267  if ( bnd.isActivated() ) {
268  if ( useProjectedGrad_ ) {
269  gp_->set(g);
270  bnd.computeProjectedGradient( *gp_, x );
271  return gp_->norm();
272  }
273  else {
274  Real one(1);
275  xnew_->set(x);
276  xnew_->axpy(-one,g.dual());
277  bnd.project(*xnew_);
278  xnew_->axpy(-one,x);
279  return xnew_->norm();
280  }
281  }
282  else {
283  return g.norm();
284  }
285  }
286 
287 public:
288 
290  using Step<Real>::compute;
291  using Step<Real>::update;
292 
293  virtual ~TrustRegionStep() {}
294 
302  TrustRegionStep( Teuchos::ParameterList & parlist )
303  : Step<Real>(),
304  xnew_(Teuchos::null), xold_(Teuchos::null), gp_(Teuchos::null),
305  trustRegion_(Teuchos::null), model_(Teuchos::null),
308  SPflag_(0), SPiter_(0), bndActive_(false),
309  secant_(Teuchos::null), esec_(SECANT_LBFGS),
310  useSecantHessVec_(false), useSecantPrecond_(false),
311  scaleEps_(1), useProjectedGrad_(false),
312  alpha_init_(1), max_fval_(20), mu_(0.9999), beta_(0.01),
313  stepBackMax_(0.9999), stepBackScale_(1), singleReflect_(true),
314  scale0_(1), scale1_(1),
315  verbosity_(0) {
316  // Parse input parameterlist
317  parseParameterList(parlist);
318  // Create secant object
319  Teuchos::ParameterList &glist = parlist.sublist("General");
320  esec_ = StringToESecant(glist.sublist("Secant").get("Type","Limited-Memory BFGS"));
321  useSecantPrecond_ = glist.sublist("Secant").get("Use as Preconditioner", false);
322  useSecantHessVec_ = glist.sublist("Secant").get("Use as Hessian", false);
323  secant_ = SecantFactory<Real>(parlist);
324  }
325 
335  TrustRegionStep( Teuchos::RCP<Secant<Real> > &secant, Teuchos::ParameterList &parlist )
336  : Step<Real>(),
337  xnew_(Teuchos::null), xold_(Teuchos::null), gp_(Teuchos::null),
338  trustRegion_(Teuchos::null), model_(Teuchos::null),
341  SPflag_(0), SPiter_(0), bndActive_(false),
342  secant_(Teuchos::null), esec_(SECANT_LBFGS),
343  useSecantHessVec_(false), useSecantPrecond_(false),
344  scaleEps_(1), useProjectedGrad_(false),
345  alpha_init_(1), max_fval_(20), mu_(0.9999), beta_(0.01),
346  stepBackMax_(0.9999), stepBackScale_(1), singleReflect_(true),
347  scale0_(1), scale1_(1),
348  verbosity_(0) {
349  // Parse input parameterlist
350  parseParameterList(parlist);
351  // Create secant object
352  Teuchos::ParameterList &glist = parlist.sublist("General");
353  useSecantPrecond_ = glist.sublist("Secant").get("Use as Preconditioner", false);
354  useSecantHessVec_ = glist.sublist("Secant").get("Use as Hessian", false);
355  if ( secant_ == Teuchos::null ) {
356  Teuchos::ParameterList Slist;
357  Slist.sublist("General").sublist("Secant").set("Type","Limited-Memory BFGS");
358  Slist.sublist("General").sublist("Secant").set("Maximum Storage",10);
359  secant_ = SecantFactory<Real>(Slist);
360  }
361  }
362 
371  void initialize( Vector<Real> &x, const Vector<Real> &s, const Vector<Real> &g,
373  AlgorithmState<Real> &algo_state ) {
374  Real p1(0.1), oe10(1.e10), zero(0), one(1), half(0.5), three(3), two(2), six(6);
375  Teuchos::RCP<StepState<Real> > step_state = Step<Real>::getState();
376  bndActive_ = bnd.isActivated();
377 
378  trustRegion_->initialize(x,s,g);
379 
380  Real htol = std::sqrt(ROL_EPSILON<Real>());
381  Real ftol = p1*ROL_OVERFLOW<Real>();
382 
383  step_state->descentVec = s.clone();
384  step_state->gradientVec = g.clone();
385 
386  if ( bnd.isActivated() ) {
387  // Make initial guess feasible
388  bnd.project(x);
389  xnew_ = x.clone();
390  xold_ = x.clone();
391 
392  // Make initial guess strictly feasible
394  xold_->set(*bnd.getUpperVectorRCP()); // u
395  xold_->axpy(-one,*bnd.getLowerVectorRCP()); // u - l
396  Real minDiff = static_cast<Real>(1e-1)
397  * std::min(one, half * xold_->reduce(Elementwise::ReductionMin<Real>()));
398 
399  class LowerFeasible : public Elementwise::BinaryFunction<Real> {
400  private:
401  const Real eps_;
402  public:
403  LowerFeasible(const Real eps) : eps_(eps) {}
404  Real apply( const Real &x, const Real &y ) const {
405  const Real tol = static_cast<Real>(100)*ROL_EPSILON<Real>();
406  return (x < y+tol) ? y+eps_ : x;
407  }
408  };
409  x.applyBinary(LowerFeasible(minDiff), *bnd.getLowerVectorRCP());
410 
411  class UpperFeasible : public Elementwise::BinaryFunction<Real> {
412  private:
413  const Real eps_;
414  public:
415  UpperFeasible(const Real eps) : eps_(eps) {}
416  Real apply( const Real &x, const Real &y ) const {
417  const Real tol = static_cast<Real>(100)*ROL_EPSILON<Real>();
418  return (x > y-tol) ? y-eps_ : x;
419  }
420  };
421  x.applyBinary(UpperFeasible(minDiff), *bnd.getUpperVectorRCP());
422  }
423  }
424  gp_ = g.clone();
425 
426  // Update approximate gradient and approximate objective function.
427  obj.update(x,true,algo_state.iter);
428  updateGradient(x,obj,bnd,algo_state);
429  algo_state.snorm = oe10;
430  algo_state.value = obj.value(x,ftol);
431  algo_state.nfval++;
432 
433  // Try to apply inverse Hessian
434  if ( !useSecantHessVec_ &&
436  try {
437  Teuchos::RCP<Vector<Real> > v = g.clone();
438  Teuchos::RCP<Vector<Real> > hv = x.clone();
439  obj.invHessVec(*hv,*v,x,htol);
440  }
441  catch (std::exception &e) {
442  useSecantHessVec_ = true;
443  }
444  }
445 
446  // Evaluate Objective Function at Cauchy Point
447  if ( step_state->searchSize <= zero ) {
448  Teuchos::RCP<Vector<Real> > Bg = g.clone();
449  if ( useSecantHessVec_ ) {
450  secant_->applyB(*Bg,(step_state->gradientVec)->dual());
451  }
452  else {
453  obj.hessVec(*Bg,(step_state->gradientVec)->dual(),x,htol);
454  }
455  Real gBg = Bg->dot(*(step_state->gradientVec));
456  Real alpha = one;
457  if ( gBg > ROL_EPSILON<Real>() ) {
458  alpha = algo_state.gnorm*algo_state.gnorm/gBg;
459  }
460  // Evaluate the objective function at the Cauchy point
461  Teuchos::RCP<Vector<Real> > cp = s.clone();
462  cp->set((step_state->gradientVec)->dual());
463  cp->scale(-alpha);
464  Teuchos::RCP<Vector<Real> > xcp = x.clone();
465  xcp->set(x);
466  xcp->plus(*cp);
467  if ( bnd.isActivated() ) {
468  bnd.project(*xcp);
469  }
470  obj.update(*xcp);
471  Real fnew = obj.value(*xcp,ftol); // MUST DO SOMETHING HERE WITH FTOL
472  algo_state.nfval++;
473  // Perform cubic interpolation to determine initial trust region radius
474  Real gs = cp->dot((step_state->gradientVec)->dual());
475  Real a = fnew - algo_state.value - gs - half*alpha*alpha*gBg;
476  if ( std::abs(a) < ROL_EPSILON<Real>() ) {
477  // a = 0 implies the objective is quadratic in the negative gradient direction
478  step_state->searchSize = std::min(alpha*algo_state.gnorm,delMax_);
479  }
480  else {
481  Real b = half*alpha*alpha*gBg;
482  Real c = gs;
483  if ( b*b-three*a*c > ROL_EPSILON<Real>() ) {
484  // There is at least one critical point
485  Real t1 = (-b-std::sqrt(b*b-three*a*c))/(three*a);
486  Real t2 = (-b+std::sqrt(b*b-three*a*c))/(three*a);
487  if ( six*a*t1 + two*b > zero ) {
488  // t1 is the minimizer
489  step_state->searchSize = std::min(t1*alpha*algo_state.gnorm,delMax_);
490  }
491  else {
492  // t2 is the minimizer
493  step_state->searchSize = std::min(t2*alpha*algo_state.gnorm,delMax_);
494  }
495  }
496  else {
497  step_state->searchSize = std::min(alpha*algo_state.gnorm,delMax_);
498  }
499  }
500  }
501  }
502 
514  AlgorithmState<Real> &algo_state ) {
515  // Get step state
516  Teuchos::RCP<StepState<Real> > step_state = Step<Real>::getState();
517  // Build trust-region model
518  if (bnd.isActivated()) {
520 // Real eps = scaleEps_*algo_state.gnorm;
521  Real eps = scaleEps_ * std::min(std::pow(algo_state.gnorm,static_cast<Real>(0.75)),
522  static_cast<Real>(0.01));
523  model_ = Teuchos::rcp(new ROL::KelleySachsModel<Real>(obj,
524  bnd,
525  x,
526  *(step_state->gradientVec),
527  eps,
528  secant_,
531  }
532  else if ( TRmodel_ == TRUSTREGION_MODEL_COLEMANLI ) {
533  model_ = Teuchos::rcp(new ROL::ColemanLiModel<Real>(obj,
534  bnd,
535  x,
536  *(step_state->gradientVec),
537  secant_,
540  step_state->searchSize,
541  stepBackMax_,
543  singleReflect_));
544  }
545  else {
546  TEUCHOS_TEST_FOR_EXCEPTION( true, std::invalid_argument,
547  ">>> ERROR (ROL::TrustRegionStep): Invalid trust-region model!");
548  }
549  }
550  else {
551  model_ = Teuchos::rcp(new ROL::TrustRegionModel<Real>(obj,
552  x,
553  *(step_state->gradientVec),
554  secant_,
557  }
558  // Minimize trust-region model over trust-region constraint
559  SPflag_ = 0; SPiter_ = 0;
560  trustRegion_->run(s,algo_state.snorm,SPflag_,SPiter_,step_state->searchSize,*model_);
561  }
562 
575  const Vector<Real> &s,
576  Objective<Real> &obj,
577  BoundConstraint<Real> &bnd,
578  AlgorithmState<Real> &algo_state ) {
579  // Get step state
580  Teuchos::RCP<StepState<Real> > state = Step<Real>::getState();
581  // Store previous step for constraint computations
582  if ( bnd.isActivated() ) {
583  xold_->set(x);
584  }
585  // Update trust-region information;
586  // Performs a hard update on the objective function
588  state->nfval = 0;
589  state->ngrad = 0;
590  Real fold = algo_state.value;
591  Real fnew(0);
592  algo_state.iter++;
593  trustRegion_->update(x,fnew,state->searchSize,state->nfval,state->ngrad,TRflag_,
594  s,algo_state.snorm,fold,*(state->gradientVec),algo_state.iter,
595  obj,bnd,*model_);
596  algo_state.nfval += state->nfval;
597  algo_state.ngrad += state->ngrad;
598  // If step is accepted ...
599  // Compute new gradient and update secant storage
602  // Perform line search (smoothing) to ensure decrease
604  Real tol = std::sqrt(ROL_EPSILON<Real>());
605  // Compute new gradient
606  obj.gradient(*gp_,x,tol); // MUST DO SOMETHING HERE WITH TOL
607  algo_state.ngrad++;
608  // Compute smoothed step
609  Real alpha(1);
610  xnew_->set(x);
611  xnew_->axpy(-alpha*alpha_init_,gp_->dual());
612  bnd.project(*xnew_);
613  // Compute new objective value
614  obj.update(*xnew_,true,algo_state.iter);
615  Real ftmp = obj.value(*xnew_,tol); // MUST DO SOMETHING HERE WITH TOL
616  algo_state.nfval++;
617  // Perform smoothing
618  int cnt = 0;
619  alpha = static_cast<Real>(1)/alpha_init_;
620  while ( (fnew-ftmp) <= mu_*(fnew-fold) ) {
621  xnew_->set(x);
622  xnew_->axpy(-alpha*alpha_init_,gp_->dual());
623  bnd.project(*xnew_);
624  obj.update(*xnew_,true,algo_state.iter);
625  ftmp = obj.value(*xnew_,tol); // MUST DO SOMETHING HERE WITH TOL
626  algo_state.nfval++;
627  if ( cnt >= max_fval_ ) {
628  break;
629  }
630  alpha *= beta_;
631  cnt++;
632  }
633  // Store objective function and iteration information
634  fnew = ftmp;
635  x.set(*xnew_);
636  }
637  // Store previous gradient for secant update
639  gp_->set(*(state->gradientVec));
640  }
641  // Update objective function and approximate model
642  updateGradient(x,obj,bnd,algo_state);
643  // Update secant information
645  if ( bnd.isActivated() ) { // Compute new constrained step
646  xnew_->set(x);
647  xnew_->axpy(-static_cast<Real>(1),*xold_);
648  secant_->updateStorage(x,*(state->gradientVec),*gp_,*xnew_,algo_state.snorm,algo_state.iter+1);
649  }
650  else {
651  secant_->updateStorage(x,*(state->gradientVec),*gp_,s,algo_state.snorm,algo_state.iter+1);
652  }
653  }
654  // Update algorithm state
655  (algo_state.iterateVec)->set(x);
656  }
657  // Update algorithm state
658  algo_state.value = fnew;
659  }
660 
665  std::string printHeader( void ) const {
666  std::stringstream hist;
667 
668  if(verbosity_>0) {
669  hist << std::string(114,'-') << "\n";
670 
671  hist << "Trust-Region status output definitions\n\n";
672 
673  hist << " iter - Number of iterates (steps taken) \n";
674  hist << " value - Objective function value \n";
675  hist << " gnorm - Norm of the gradient\n";
676  hist << " snorm - Norm of the step (update to optimization vector)\n";
677  hist << " delta - Trust-Region radius\n";
678  hist << " #fval - Number of times the objective function was evaluated\n";
679  hist << " #grad - Number of times the gradient was computed\n";
680 
681 
682 
683  hist << "\n";
684  hist << " tr_flag - Trust-Region flag" << "\n";
685  for( int flag = TRUSTREGION_FLAG_SUCCESS; flag != TRUSTREGION_FLAG_UNDEFINED; ++flag ) {
686  hist << " " << NumberToString(flag) << " - "
687  << ETrustRegionFlagToString(static_cast<ETrustRegionFlag>(flag)) << "\n";
688 
689  }
690 
691  if( etr_ == TRUSTREGION_TRUNCATEDCG ) {
692  hist << "\n";
693  hist << " iterCG - Number of Truncated CG iterations\n\n";
694  hist << " flagGC - Trust-Region Truncated CG flag" << "\n";
695  for( int flag = CG_FLAG_SUCCESS; flag != CG_FLAG_UNDEFINED; ++flag ) {
696  hist << " " << NumberToString(flag) << " - "
697  << ECGFlagToString(static_cast<ECGFlag>(flag)) << "\n";
698  }
699  }
700 
701  hist << std::string(114,'-') << "\n";
702  }
703 
704  hist << " ";
705  hist << std::setw(6) << std::left << "iter";
706  hist << std::setw(15) << std::left << "value";
707  hist << std::setw(15) << std::left << "gnorm";
708  hist << std::setw(15) << std::left << "snorm";
709  hist << std::setw(15) << std::left << "delta";
710  hist << std::setw(10) << std::left << "#fval";
711  hist << std::setw(10) << std::left << "#grad";
712  hist << std::setw(10) << std::left << "tr_flag";
713  if ( etr_ == TRUSTREGION_TRUNCATEDCG ) {
714  hist << std::setw(10) << std::left << "iterCG";
715  hist << std::setw(10) << std::left << "flagCG";
716  }
717  hist << "\n";
718  return hist.str();
719  }
720 
725  std::string printName( void ) const {
726  std::stringstream hist;
727  hist << "\n" << ETrustRegionToString(etr_) << " Trust-Region Solver";
730  hist << " with " << ESecantToString(esec_) << " Preconditioning\n";
731  }
732  else if ( !useSecantPrecond_ && useSecantHessVec_ ) {
733  hist << " with " << ESecantToString(esec_) << " Hessian Approximation\n";
734  }
735  else {
736  hist << " with " << ESecantToString(esec_) << " Preconditioning and Hessian Approximation\n";
737  }
738  }
739  else {
740  hist << "\n";
741  }
742  if ( bndActive_ ) {
743  hist << "Trust-Region Model: " << ETrustRegionModelToString(TRmodel_) << "\n";
744  }
745  return hist.str();
746  }
747 
755  std::string print( AlgorithmState<Real> & algo_state, bool print_header = false ) const {
756  const Teuchos::RCP<const StepState<Real> >& step_state = Step<Real>::getStepState();
757 
758  std::stringstream hist;
759  hist << std::scientific << std::setprecision(6);
760  if ( algo_state.iter == 0 ) {
761  hist << printName();
762  }
763  if ( print_header ) {
764  hist << printHeader();
765  }
766  if ( algo_state.iter == 0 ) {
767  hist << " ";
768  hist << std::setw(6) << std::left << algo_state.iter;
769  hist << std::setw(15) << std::left << algo_state.value;
770  hist << std::setw(15) << std::left << algo_state.gnorm;
771  hist << std::setw(15) << std::left << " ";
772  hist << std::setw(15) << std::left << step_state->searchSize;
773  hist << "\n";
774  }
775  else {
776  hist << " ";
777  hist << std::setw(6) << std::left << algo_state.iter;
778  hist << std::setw(15) << std::left << algo_state.value;
779  hist << std::setw(15) << std::left << algo_state.gnorm;
780  hist << std::setw(15) << std::left << algo_state.snorm;
781  hist << std::setw(15) << std::left << step_state->searchSize;
782  hist << std::setw(10) << std::left << algo_state.nfval;
783  hist << std::setw(10) << std::left << algo_state.ngrad;
784  hist << std::setw(10) << std::left << TRflag_;
785  if ( etr_ == TRUSTREGION_TRUNCATEDCG ) {
786  hist << std::setw(10) << std::left << SPiter_;
787  hist << std::setw(10) << std::left << SPflag_;
788  }
789  hist << "\n";
790  }
791  return hist.str();
792  }
793 
794 }; // class Step
795 
796 } // namespace ROL
797 
798 #endif
std::string ECGFlagToString(ECGFlag cgf)
Definition: ROL_Types.hpp:832
Provides the interface to evaluate objective functions.
void parseParameterList(Teuchos::ParameterList &parlist)
Parse input ParameterList.
ESecant esec_
Secant type.
bool bndActive_
Flag whether bound is activated.
std::string ETrustRegionModelToString(ETrustRegionModel tr)
std::string printHeader(void) const
Print iterate header.
Real mu_
Post-Smoothing tolerance for projected methods.
std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
bool useSecantPrecond_
Flag whether to use a secant preconditioner.
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Provides the interface to compute optimization steps.
Definition: ROL_Step.hpp:69
virtual void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector &x)
Definition: ROL_Vector.hpp:222
void initialize(Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Initialize step.
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Teuchos::RCP< StepState< Real > > getState(void)
Definition: ROL_Step.hpp:74
Contains definitions of custom data types in ROL.
Real alpha_init_
Initial line-search parameter for projected methods.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Provides the interface to evaluate trust-region model functions.
TrustRegionStep(Teuchos::RCP< Secant< Real > > &secant, Teuchos::ParameterList &parlist)
Constructor.
ESecant StringToESecant(std::string s)
Definition: ROL_Types.hpp:477
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:74
Teuchos::RCP< Vector< Real > > gp_
Container for previous gradient vector.
Teuchos::RCP< Vector< Real > > xold_
Container for previous iteration vector.
Teuchos::RCP< Secant< Real > > secant_
Container for secant approximation.
Real computeCriticalityMeasure(const Vector< Real > &g, const Vector< Real > &x, BoundConstraint< Real > &bnd)
Compute the criticality measure.
ETrustRegionModel TRmodel_
Trust-region subproblem model type.
State for algorithm class. Will be used for restarts.
Definition: ROL_Types.hpp:91
Real scaleEps_
Scaling for epsilon-active sets.
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
bool isActivated(void)
Check if bounds are on.
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:213
std::string NumberToString(T Number)
Definition: ROL_Types.hpp:80
ETrustRegion etr_
Trust-region subproblem solver type.
Teuchos::RCP< Vector< Real > > xnew_
Container for updated iteration vector.
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step.
ESecant
Enumeration of secant update algorithms.
Definition: ROL_Types.hpp:420
ETrustRegionModel StringToETrustRegionModel(std::string s)
int SPflag_
Subproblem solver termination flag.
const Teuchos::RCP< const StepState< Real > > getStepState(void) const
Get state for step object.
Definition: ROL_Step.hpp:293
ETrustRegionFlag TRflag_
Trust-region exit flag.
bool useSecantHessVec_
Flag whether to use a secant Hessian.
int SPiter_
Subproblem solver iteration count.
std::vector< bool > useInexact_
Flags for inexact (0) objective function, (1) gradient, (2) Hessian.
Provides interface for and implements limited-memory secant operators.
Definition: ROL_Secant.hpp:70
Real scale0_
Scale for inexact gradient computation.
virtual const Teuchos::RCP< const Vector< Real > > getUpperVectorRCP(void) const
Return the ref count pointer to the upper bound vector.
Real delMax_
Maximum trust-region radius.
virtual void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply inverse Hessian approximation to vector.
TrustRegionStep(Teuchos::ParameterList &parlist)
Constructor.
Provides the interface to evaluate interior trust-region model functions from the Coleman-Li bound co...
ETrustRegionModel
Enumeration of trust-region model types.
Provides the interface to apply upper and lower bound constraints.
void computeProjectedGradient(Vector< Real > &g, const Vector< Real > &x)
Compute projected gradient.
int verbosity_
Print additional information to screen if > 0.
std::string printName(void) const
Print step name.
ETrustRegion StringToETrustRegion(std::string s)
Provides the interface to evaluate projected trust-region model functions from the Kelley-Sachs bound...
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful.
virtual const Teuchos::RCP< const Vector< Real > > getLowerVectorRCP(void) const
Return the ref count pointer to the lower bound vector.
Teuchos::RCP< TrustRegionModel< Real > > model_
Container for trust-region model.
Teuchos::RCP< Vector< Real > > iterateVec
Definition: ROL_Types.hpp:105
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:196
virtual Real norm() const =0
Returns where .
int max_fval_
Maximum function evaluations in line-search for projected methods.
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
ETrustRegion
Enumeration of trust-region solver types.
std::string ETrustRegionFlagToString(ETrustRegionFlag trf)
ETrustRegionFlag
Enumation of flags used by trust-region solvers.
std::string ETrustRegionToString(ETrustRegion tr)
std::string ESecantToString(ESecant tr)
Definition: ROL_Types.hpp:429
bool useProjectedGrad_
Flag whether to use the projected gradient criticality measure.
Teuchos::RCP< TrustRegion< Real > > trustRegion_
Container for trust-region solver object.
Real beta_
Post-Smoothing rate for projected methods.
Real scale1_
Scale for inexact gradient computation.
void updateGradient(Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update gradient to iteratively satisfy inexactness condition.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
Provides the interface to compute optimization steps with trust regions.