ROL
ROL_TypeB_TrustRegionSPGAlgorithm.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_HPP
45 #define ROL_TYPEB_TRUSTREGIONSPGALGORITHM_HPP
46 
47 #include "ROL_TypeB_Algorithm.hpp"
50 
55 namespace ROL {
56 namespace TypeB {
57 
58 template<typename Real>
60 private:
61  Ptr<TrustRegionModel_U<Real>> model_;
62 
63  // TRUST REGION PARAMETERS
64  Real delMax_;
65  Real eta0_;
66  Real eta1_;
67  Real eta2_;
68  Real gamma0_;
69  Real gamma1_;
70  Real gamma2_;
71  Real TRsafe_;
72  Real eps_;
73  bool interpRad_;
74 
75  // ITERATION FLAGS/INFORMATION
77  int SPflag_;
78  int SPiter_;
79 
80  // SECANT INFORMATION
84 
85  // TRUNCATED CG INFORMATION
86  Real tol1_;
87  Real tol2_;
88  int maxit_;
89 
90  // ALGORITHM SPECIFIC PARAMETERS
91  bool useNM_;
93  Real mu0_;
94  Real spexp_;
95  int redlim_;
96  int explim_;
97  Real alpha_;
98  bool normAlpha_;
99  Real interpf_;
100  Real extrapf_;
101  Real qtol_;
104  Real gamma_;
105  int maxSize_;
106  bool useMin_;
107  bool useNMSP_;
109 
110  // Inexactness Parameters
111  std::vector<bool> useInexact_;
112  Real scale0_;
113  Real scale1_;
114  Real scale_;
115  Real omega_;
116  Real force_;
119  Real gtol_;
120 
121  mutable int nhess_;
122  unsigned verbosity_;
124 
128 
129 public:
130  TrustRegionSPGAlgorithm(ParameterList &list, const Ptr<Secant<Real>> &secant = nullPtr);
131 
133  void run( Vector<Real> &x,
134  const Vector<Real> &g,
135  Objective<Real> &obj,
137  std::ostream &outStream = std::cout) override;
138 
139  void writeHeader( std::ostream& os ) const override;
140 
141  void writeName( std::ostream& os ) const override;
142 
143  void writeOutput( std::ostream& os, const bool write_header = false ) const override;
144 
145 private:
146  void initialize(Vector<Real> &x,
147  const Vector<Real> &g,
148  Real ftol,
149  Objective<Real> &obj,
151  std::ostream &outStream = std::cout);
152 
153  Real computeValue(Real inTol,
154  Real &outTol,
155  Real pRed,
156  Real &fold,
157  int iter,
158  const Vector<Real> &x,
159  const Vector<Real> &xold,
160  Objective<Real> &obj);
161 
162  void computeGradient(const Vector<Real> &x,
163  Vector<Real> &g,
164  Vector<Real> &pwa,
165  Real del,
166  Objective<Real> &obj,
167  bool accept,
168  Real &gtol,
169  Real &gnorm,
170  std::ostream &outStream = std::cout) const;
171 
172  // Compute the projected step s = P(x + alpha*w) - x
173  // Returns the norm of the projected step s
174  // s -- The projected step upon return
175  // w -- The direction vector w (unchanged)
176  // x -- The anchor vector x (unchanged)
177  // alpha -- The step size (unchanged)
178  Real dgpstep(Vector<Real> &s, const Vector<Real> &w,
179  const Vector<Real> &x, const Real alpha,
180  std::ostream &outStream = std::cout) const;
181 
182  // Compute Cauchy point, i.e., the minimizer of q(P(x - alpha*g)-x)
183  // subject to the trust region constraint ||P(x - alpha*g)-x|| <= del
184  // s -- The Cauchy step upon return: Primal optimization space vector
185  // alpha -- The step length for the Cauchy point upon return
186  // x -- The anchor vector x (unchanged): Primal optimization space vector
187  // g -- The (dual) gradient vector g (unchanged): Primal optimization space vector
188  // del -- The trust region radius (unchanged)
189  // model -- Trust region model
190  // dwa -- Dual working array, stores Hessian applied to step
191  // dwa1 -- Dual working array
192  Real dcauchy(Vector<Real> &s, Real &alpha, Real &q,
193  const Vector<Real> &x, const Vector<Real> &g,
194  const Real del, TrustRegionModel_U<Real> &model,
195  Vector<Real> &dwa, Vector<Real> &dwa1,
196  std::ostream &outStream = std::cout);
197 
198  void dpsg_simple(Vector<Real> &y, Real &q, Vector<Real> &gmod, const Vector<Real> &x,
199  Real del, TrustRegionModel_U<Real> &model, Vector<Real> &pwa,
200  Vector<Real> &pwa1, Vector<Real> &dwa, std::ostream &outStream = std::cout);
201 
202  void dpsg(Vector<Real> &y, Real &q, Vector<Real> &gmod, const Vector<Real> &x,
203  Real del, TrustRegionModel_U<Real> &model, Vector<Real> &ymin,
204  Vector<Real> &pwa, Vector<Real> &pwa1, Vector<Real> &pwa2,
205  Vector<Real> &pwa3, Vector<Real> &pwa4, Vector<Real> &pwa5,
206  Vector<Real> &dwa, std::ostream &outStream = std::cout);
207 
208  void dproj(Vector<Real> &x, const Vector<Real> &x0, Real del,
209  Vector<Real> &y0, Vector<Real> &y1, Vector<Real> &yc,
210  Vector<Real> &pwa, std::ostream &outStream = std::cout) const;
211 
212 }; // class ROL::TypeB::TrustRegionSPGAlgorithm
213 
214 } // namespace TypeB
215 } // namespace ROL
216 
218 
219 #endif
bool writeHeader_
Flag to write header at every iteration.
int maxit_
Maximum number of CG iterations (default: 25)
Provides the interface to evaluate objective functions.
int SPflag_
Subproblem solver termination flag.
void writeOutput(std::ostream &os, const bool write_header=false) const override
Print iterate status.
Real eta1_
Radius decrease threshold (default: 0.05)
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)
Real qtol_
Relative tolerance for computed decrease in Cauchy point computation (default: 1-8) ...
Real extrapf_
Extrapolation rate for Cauchy point computation (default: 1e1)
TrustRegionSPGAlgorithm(ParameterList &list, const Ptr< Secant< Real >> &secant=nullPtr)
Real spexp_
Relative tolerance exponent for subproblem solve (default: 1, range: [1,2])
Real gamma2_
Radius increase rate (default: 2.5)
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
int SPiter_
Subproblem solver iteration count.
Real interpf_
Backtracking rate for Cauchy point computation (default: 1e-1)
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)
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)
Real eps_
Safeguard for numerically evaluating ratio.
void writeName(std::ostream &os) const override
Print step name.
Real delMax_
Maximum trust-region radius (default: ROL_INF)
Real dgpstep(Vector< Real > &s, const Vector< Real > &w, const Vector< Real > &x, const Real alpha, std::ostream &outStream=std::cout) const
ETRFlag
Enumation of flags used by trust-region solvers.
Real TRsafe_
Safeguard size for numerically evaluating ratio (default: 1e2)
bool interpRad_
Interpolate the trust-region radius if ratio is negative (default: false)
Real gamma1_
Radius decrease rate (positive rho) (default: 0.25)
Real eta0_
Step acceptance threshold (default: 0.05)
Provides the interface to evaluate trust-region model functions.
TRUtils::ETRFlag TRflag_
Trust-region exit flag.
void initialize(Vector< Real > &x, const Vector< Real > &g, Real ftol, Objective< Real > &obj, BoundConstraint< Real > &bnd, std::ostream &outStream=std::cout)
Provides an interface to run bound constrained optimization algorithms.
Real tol2_
Relative tolerance for truncated CG (default: 1e-2)
ESecant
Enumeration of secant update algorithms.
Definition: ROL_Types.hpp:486
void writeHeader(std::ostream &os) const override
Print iterate header.
Real eta2_
Radius increase threshold (default: 0.9)
int redlim_
Maximum number of Cauchy point reduction steps (default: 10)
Real tol1_
Absolute tolerance for truncated CG (default: 1e-4)
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
Real mu0_
Sufficient decrease parameter (default: 1e-2)
Ptr< TrustRegionModel_U< Real > > model_
Container for trust-region model.
bool normAlpha_
Normalize initial Cauchy point step length (default: false)
Provides the interface to apply upper and lower bound constraints.
bool useSecantHessVec_
Flag to use secant as Hessian (default: false)
bool useSecantPrecond_
Flag to use secant as a preconditioner (default: false)
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 explim_
Maximum number of Cauchy point expansion steps (default: 10)
ESecant esec_
Secant type (default: Limited-Memory BFGS)
Real alpha_
Initial Cauchy point step length (default: 1.0)
Provides an interface to run the trust-region algorithm.
Real gamma0_
Radius decrease rate (negative rho) (default: 0.0625)
Real computeValue(Real inTol, Real &outTol, Real pRed, Real &fold, int iter, const Vector< Real > &x, const Vector< Real > &xold, Objective< Real > &obj)