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_;
92  int maxNM_;
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_;
108 
109  // Inexactness Parameters
110  std::vector<bool> useInexact_;
111  Real scale0_;
112  Real scale1_;
113  Real scale_;
114  Real omega_;
115  Real force_;
118 
119  mutable int nhess_;
120  unsigned verbosity_;
122 
126 
127 public:
128  TrustRegionSPGAlgorithm(ParameterList &list, const Ptr<Secant<Real>> &secant = nullPtr);
129 
131  void run( Vector<Real> &x,
132  const Vector<Real> &g,
133  Objective<Real> &obj,
135  std::ostream &outStream = std::cout) override;
136 
137  void writeHeader( std::ostream& os ) const override;
138 
139  void writeName( std::ostream& os ) const override;
140 
141  void writeOutput( std::ostream& os, bool write_header = false ) const override;
142 
143 private:
144  void initialize(Vector<Real> &x,
145  const Vector<Real> &g,
146  Real ftol,
147  Objective<Real> &obj,
149  std::ostream &outStream = std::cout);
150 
151  Real computeValue(Real inTol,
152  Real &outTol,
153  Real pRed,
154  Real &fold,
155  int iter,
156  const Vector<Real> &x,
157  const Vector<Real> &xold,
158  Objective<Real> &obj);
159 
160  Real computeGradient(const Vector<Real> &x,
161  Vector<Real> &g,
162  Vector<Real> &pwa,
163  Real del,
164  Objective<Real> &obj,
165  std::ostream &outStream = std::cout) const;
166 
167  // Compute the projected step s = P(x + alpha*w) - x
168  // Returns the norm of the projected step s
169  // s -- The projected step upon return
170  // w -- The direction vector w (unchanged)
171  // x -- The anchor vector x (unchanged)
172  // alpha -- The step size (unchanged)
173  Real dgpstep(Vector<Real> &s, const Vector<Real> &w,
174  const Vector<Real> &x, const Real alpha,
175  std::ostream &outStream = std::cout) const;
176 
177  // Compute Cauchy point, i.e., the minimizer of q(P(x - alpha*g)-x)
178  // subject to the trust region constraint ||P(x - alpha*g)-x|| <= del
179  // s -- The Cauchy step upon return: Primal optimization space vector
180  // alpha -- The step length for the Cauchy point upon return
181  // x -- The anchor vector x (unchanged): Primal optimization space vector
182  // g -- The (dual) gradient vector g (unchanged): Primal optimization space vector
183  // del -- The trust region radius (unchanged)
184  // model -- Trust region model
185  // dwa -- Dual working array, stores Hessian applied to step
186  // dwa1 -- Dual working array
187  Real dcauchy(Vector<Real> &s, Real &alpha, Real &q,
188  const Vector<Real> &x, const Vector<Real> &g,
189  const Real del, TrustRegionModel_U<Real> &model,
190  Vector<Real> &dwa, Vector<Real> &dwa1,
191  std::ostream &outStream = std::cout);
192 
193  void dpsg(Vector<Real> &y, Real &q, Vector<Real> &gmod, const Vector<Real> &x,
194  Real del, TrustRegionModel_U<Real> &model, Vector<Real> &ymin,
195  Vector<Real> &pwa, Vector<Real> &pwa1, Vector<Real> &pwa2,
196  Vector<Real> &pwa3, Vector<Real> &pwa4, Vector<Real> &pwa5,
197  Vector<Real> &dwa, std::ostream &outStream = std::cout);
198 
199  void dproj(Vector<Real> &x, const Vector<Real> &x0, Real del,
200  Vector<Real> &y0, Vector<Real> &y1, Vector<Real> &yc,
201  Vector<Real> &pwa, std::ostream &outStream = std::cout) const;
202 
203 }; // class ROL::TypeB::TrustRegionSPGAlgorithm
204 
205 } // namespace TypeB
206 } // namespace ROL
207 
209 
210 #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.
Real eta1_
Radius decrease threshold (default: 0.05)
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)
int SPiter_
Subproblem solver iteration count.
Real interpf_
Backtracking rate for Cauchy point computation (default: 1e-1)
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 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)
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:484
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
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.
Real computeGradient(const Vector< Real > &x, Vector< Real > &g, Vector< Real > &pwa, Real del, Objective< Real > &obj, std::ostream &outStream=std::cout) const
bool useSecantHessVec_
Flag to use secant as Hessian (default: false)
void writeOutput(std::ostream &os, bool write_header=false) const override
Print iterate status.
bool useSecantPrecond_
Flag to use secant as a preconditioner (default: false)
Real dgpstep(Vector< Real > &s, const Vector< Real > &w, const Vector< Real > &x, const Real alpha, std::ostream &outStream=std::cout) const
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)