ROL
ROL_TypeB_KelleySachsAlgorithm.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_TYPEB_KELLEYSACHSALGORITHM_HPP
11 #define ROL_TYPEB_KELLEYSACHSALGORITHM_HPP
12 
13 #include "ROL_TypeB_Algorithm.hpp"
18 
23 namespace ROL {
24 namespace TypeB {
25 
26 template<typename Real>
27 class KelleySachsAlgorithm : public TypeB::Algorithm<Real> {
28 private:
29  Ptr<TrustRegionModel_U<Real>> model_;
30 
31  // TRUST REGION PARAMETERS
32  Real delMax_;
33  Real eta0_;
34  Real eta1_;
35  Real eta2_;
36  Real gamma0_;
37  Real gamma1_;
38  Real gamma2_;
39  Real TRsafe_;
40  Real eps_;
41 
42  // ITERATION FLAGS/INFORMATION
44  int SPflag_;
45  int SPiter_;
46 
47  // SECANT INFORMATION
51 
52  // TRUNCATED CG INFORMATION
53  int maxit_;
54  Real tol1_;
55  Real tol2_;
56 
57  // ALGORITHM SPECIFIC PARAMETERS
58  int minit_;
59  Real mu0_;
60  Real mu1_;
61  Real eps0_;
62  Real beta_;
63  Real alpha0_;
64 
65  mutable int nhess_;
66  unsigned verbosity_;
67  bool writeHeader_;
68 
72 
73 public:
74  KelleySachsAlgorithm(ParameterList &list, const Ptr<Secant<Real>> &secant = nullPtr);
75 
77  void run( Vector<Real> &x,
78  const Vector<Real> &g,
79  Objective<Real> &obj,
81  std::ostream &outStream = std::cout) override;
82 
83  void run( Problem<Real> &problem,
84  std::ostream &outStream = std::cout ) override;
85 
86  void run( Vector<Real> &x,
87  const Vector<Real> &g,
88  Objective<Real> &obj,
90  Constraint<Real> &linear_econ,
91  Vector<Real> &linear_emul,
92  const Vector<Real> &linear_eres,
93  std::ostream &outStream = std::cout ) override;
94 
95  void writeHeader( std::ostream& os ) const override;
96 
97  void writeName( std::ostream& os ) const override;
98 
99  void writeOutput( std::ostream& os, const bool write_header = false ) const override;
100 
101 private:
102  void initialize(Vector<Real> &x,
103  const Vector<Real> &g,
104  Objective<Real> &obj,
106  std::ostream &outStream = std::cout);
107 
108  // Compute sigma such that ||x+sigma*p||_inv(M) = del. This is called
109  // if trpcg detects negative curvature or if the step violates
110  // the trust region bound
111  // xtx -- The dot product <x, inv(M)x> (unchanged)
112  // ptp -- The dot product <p, inv(M)p> (unchanged)
113  // ptx -- The dot product <p, inv(M)x> (unchanged)
114  // del -- Trust region radius (unchanged)
115  Real trqsol(const Real xtx, const Real ptp, const Real ptx, const Real del) const;
116 
117  // Solve the trust region subproblem: minimize q(w) subject to the
118  // trust region constraint ||w||_inv(M) <= del using the Steihaug-Toint
119  // Conjugate Gradients algorithm
120  // w -- The step vector to be computed
121  // iflag -- Termination flag
122  // iter -- Number of CG iterations
123  // g -- Free components of gradient (unchanged)
124  // x -- Current iterate (unchanged)
125  // g0 -- Gradient (unchanged)
126  // del -- Trust region radius (unchanged)
127  // model -- Trust region model
128  // bnd -- Bound constraint used to remove active variables
129  // eps -- Epsilon binding set tolerance
130  // tol -- Residual stopping tolerance (unchanged)
131  // stol -- Preconditioned residual stopping tolerance (unchanged)
132  // itermax -- Maximum number of iterations
133  // p -- Primal working array that stores the CG step
134  // q -- Dual working array that stores the Hessian applied to p
135  // r -- Primal working array that stores the preconditioned residual
136  // t -- Dual working array that stores the residual
137  // pwa -- Primal working array that stores the pruned vector in hessVec
138  // dwa -- Dual working array that stores the pruned vector in precond
139  Real trpcg(Vector<Real> &w, int &iflag, int &iter,
140  const Vector<Real> &g, const Vector<Real> &x,
141  const Vector<Real> &g0,
142  const Real del, TrustRegionModel_U<Real> &model,
143  BoundConstraint<Real> &bnd, Real eps,
144  const Real tol, const int itermax,
146  Vector<Real> &t, Vector<Real> &pwa, Vector<Real> &dwa,
147  std::ostream &outStream = std::cout) const;
148 
150  const Vector<Real> &v,
151  const Vector<Real> &x,
152  const Vector<Real> &g,
153  Real eps,
156  Real &tol,
157  Vector<Real> &pwa,
158  Vector<Real> &dwa) const;
159 
161  const Vector<Real> &v,
162  const Vector<Real> &x,
163  const Vector<Real> &g,
164  Real eps,
167  Real &tol,
168  Vector<Real> &pwa,
169  Vector<Real> &dwa) const;
170 
171 }; // class ROL::TypeB::KelleySachsAlgorithm
172 
173 } // namespace TypeB
174 } // namespace ROL
175 
177 
178 #endif
Provides the interface to evaluate objective functions.
Real eta0_
Step acceptance threshold (default: 0.05)
unsigned verbosity_
Output level (default: 0)
int nhess_
Number of Hessian applications.
Real gamma2_
Radius increase rate (default: 2.5)
bool useSecantPrecond_
Flag to use secant as a preconditioner (default: false)
Provides an interface to run the trust-region algorithm of Kelley and Sachs.
Real eta2_
Radius increase threshold (default: 0.9)
TRUtils::ETRFlag TRflag_
Trust-region exit flag.
Real gamma1_
Radius decrease rate (positive rho) (default: 0.25)
int maxit_
Maximum number of CG iterations (default: 20)
void writeOutput(std::ostream &os, const bool write_header=false) const override
Print iterate status.
Real gamma0_
Radius decrease rate (negative rho) (default: 0.0625)
Ptr< TrustRegionModel_U< Real > > model_
Container for trust-region model.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
int SPiter_
Subproblem solver iteration count.
Real alpha0_
Initial step size for projected search (default: 1)
KelleySachsAlgorithm(ParameterList &list, const Ptr< Secant< Real >> &secant=nullPtr)
ETRFlag
Enumation of flags used by trust-region solvers.
Real tol2_
Relative tolerance for truncated CG (default: 1e-2)
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...
int minit_
Maximum number of minor (subproblem solve) iterations (default: 10)
void initialize(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, std::ostream &outStream=std::cout)
Provides the interface to evaluate trust-region model functions.
void applyFreePrecond(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g, Real eps, TrustRegionModel_U< Real > &model, BoundConstraint< Real > &bnd, Real &tol, Vector< Real > &pwa, Vector< Real > &dwa) const
Provides an interface to run bound constrained optimization algorithms.
ESecant
Enumeration of secant update algorithms.
Definition: ROL_Types.hpp:456
ESecant esec_
Secant type (default: Limited-Memory BFGS)
void applyFreeHessian(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g, Real eps, TrustRegionModel_U< Real > &model, BoundConstraint< Real > &bnd, Real &tol, Vector< Real > &pwa, Vector< Real > &dwa) const
Real eta1_
Radius decrease threshold (default: 0.05)
Provides interface for and implements limited-memory secant operators.
Definition: ROL_Secant.hpp:45
Real trqsol(const Real xtx, const Real ptp, const Real ptx, const Real del) const
Real mu1_
Sufficient decrease parameter postsmoothing (default: 0.9999)
Real eps_
Safeguard for numerically evaluating ratio.
int SPflag_
Subproblem solver termination flag.
Real mu0_
Sufficient decrease parameter (default: 1e-2)
void writeHeader(std::ostream &os) const override
Print iterate header.
void writeName(std::ostream &os) const override
Print step name.
Provides the interface to apply upper and lower bound constraints.
Real eps0_
Epsilon binding set tolerance (default: 1e-3)
bool writeHeader_
Flag to write header at every iteration.
Real tol1_
Absolute tolerance for truncated CG (default: 1e-4)
Real TRsafe_
Safeguard size for numerically evaluating ratio (default: 1e2)
Real trpcg(Vector< Real > &w, int &iflag, int &iter, const Vector< Real > &g, const Vector< Real > &x, const Vector< Real > &g0, const Real del, TrustRegionModel_U< Real > &model, BoundConstraint< Real > &bnd, Real eps, const Real tol, const int itermax, Vector< Real > &p, Vector< Real > &q, Vector< Real > &r, Vector< Real > &t, Vector< Real > &pwa, Vector< Real > &dwa, std::ostream &outStream=std::cout) const
Real beta_
Projected search backtracking rate (default: 1e-2)
Real delMax_
Maximum trust-region radius (default: ROL_INF)
Defines the general constraint operator interface.
bool useSecantHessVec_
Flag to use secant as Hessian (default: false)