ROL
ROL_TypeB_LinMoreAlgorithm.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_LINMOREALGORITHM_HPP
45 #define ROL_TYPEB_LINMOREALGORITHM_HPP
46 
47 #include "ROL_TypeB_Algorithm.hpp"
52 
57 namespace ROL {
58 namespace TypeB {
59 
60 template<typename Real>
61 class LinMoreAlgorithm : public TypeB::Algorithm<Real> {
62 private:
63  Ptr<TrustRegionModel_U<Real>> model_;
64 
65  // TRUST REGION PARAMETERS
66  Real delMax_;
67  Real eta0_;
68  Real eta1_;
69  Real eta2_;
70  Real gamma0_;
71  Real gamma1_;
72  Real gamma2_;
73  Real TRsafe_;
74  Real eps_;
75  bool interpRad_;
76 
77  // NONMONOTONE PARAMETER
78  bool useNM_;
80 
81  // ITERATION FLAGS/INFORMATION
83  int SPflag_;
84  int SPiter_;
85 
86  // SECANT INFORMATION
90 
91  // TRUNCATED CG INFORMATION
92  Real tol1_;
93  Real tol2_;
94  int maxit_;
95 
96  // ALGORITHM SPECIFIC PARAMETERS
97  int minit_;
98  Real mu0_;
99  Real spexp_;
100  int redlim_;
101  int explim_;
102  Real alpha_;
103  bool normAlpha_;
104  Real interpf_;
105  Real extrapf_;
106  Real qtol_;
107  Real interpfPS_;
108  int pslim_;
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 
125  bool hasEcon_;
126  Ptr<ReducedLinearConstraint<Real>> rcon_;
127  Ptr<NullSpaceOperator<Real>> ns_;
128 
132 
133 public:
134  LinMoreAlgorithm(ParameterList &list, const Ptr<Secant<Real>> &secant = nullPtr);
135 
137  void run( Vector<Real> &x,
138  const Vector<Real> &g,
139  Objective<Real> &obj,
141  std::ostream &outStream = std::cout) override;
142 
143  void writeHeader( std::ostream& os ) const override;
144 
145  void writeName( std::ostream& os ) const override;
146 
147  void writeOutput( std::ostream& os, const bool write_header = false ) const override;
148 
149 private:
150  void initialize(Vector<Real> &x,
151  const Vector<Real> &g,
152  Objective<Real> &obj,
154  std::ostream &outStream = std::cout);
155 
156  Real computeValue(Real inTol,
157  Real &outTol,
158  Real pRed,
159  Real &fold,
160  int iter,
161  const Vector<Real> &x,
162  const Vector<Real> &xold,
163  Objective<Real> &obj);
164 
165  void computeGradient(const Vector<Real> &x,
166  Vector<Real> &g,
167  Vector<Real> &pwa,
168  Real del,
169  Objective<Real> &obj,
170  bool accept,
171  Real &gtol,
172  Real &gnorm,
173  std::ostream &outStream = std::cout) const;
174 
175  // Compute the projected step s = P(x + alpha*w) - x
176  // Returns the norm of the projected step s
177  // s -- The projected step upon return
178  // w -- The direction vector w (unchanged)
179  // x -- The anchor vector x (unchanged)
180  // alpha -- The step size (unchanged)
181  Real dgpstep(Vector<Real> &s, const Vector<Real> &w,
182  const Vector<Real> &x, const Real alpha,
183  std::ostream &outStream = std::cout) const;
184 
185  // Compute Cauchy point, i.e., the minimizer of q(P(x - alpha*g)-x)
186  // subject to the trust region constraint ||P(x - alpha*g)-x|| <= del
187  // s -- The Cauchy step upon return: Primal optimization space vector
188  // alpha -- The step length for the Cauchy point upon return
189  // x -- The anchor vector x (unchanged): Primal optimization space vector
190  // g -- The (dual) gradient vector g (unchanged): Primal optimization space vector
191  // del -- The trust region radius (unchanged)
192  // model -- Trust region model
193  // dwa -- Dual working array, stores Hessian applied to step
194  // dwa1 -- Dual working array
195  Real dcauchy(Vector<Real> &s, Real &alpha, Real &q,
196  const Vector<Real> &x, const Vector<Real> &g,
197  const Real del, TrustRegionModel_U<Real> &model,
198  Vector<Real> &dwa, Vector<Real> &dwa1,
199  std::ostream &outStream = std::cout);
200 
201  // Perform projected search to determine beta such that
202  // q(P(x + beta*s)-x) <= mu0*g'(P(x + beta*s)-x) for mu0 in (0,1)
203  // x -- The anchor vector x, upon return x = P(x + beta*s): Primal optimization space vector
204  // s -- The direction vector s, upon return s = P(x + beta*s) - x: Primal optimization space vector
205  // g -- The free components of the gradient vector g (unchanged): Primal optimization space vector
206  // model -- Contains objective and bound constraint information
207  // pwa -- Primal working array
208  // dwa -- Dual working array
209  Real dprsrch(Vector<Real> &x, Vector<Real> &s, Real &q,
210  const Vector<Real> &g, TrustRegionModel_U<Real> &model,
212  Vector<Real> &pwa, Vector<Real> &dwa,
213  std::ostream &outStream = std::cout);
214 
215  // Compute sigma such that ||x+sigma*p||_inv(M) = del. This is called
216  // if dtrpcg detects negative curvature or if the step violates
217  // the trust region bound
218  // xtx -- The dot product <x, inv(M)x> (unchanged)
219  // ptp -- The dot product <p, inv(M)p> (unchanged)
220  // ptx -- The dot product <p, inv(M)x> (unchanged)
221  // del -- Trust region radius (unchanged)
222  Real dtrqsol(const Real xtx, const Real ptp, const Real ptx, const Real del) const;
223 
224  // Solve the trust region subproblem: minimize q(w) subject to the
225  // trust region constraint ||w||_inv(M) <= del using the Steihaug-Toint
226  // Conjugate Gradients algorithm
227  // w -- The step vector to be computed
228  // iflag -- Termination flag
229  // iter -- Number of CG iterations
230  // del -- Trust region radius (unchanged)
231  // model -- Trust region model
232  // bnd -- Bound constraint used to remove active variables
233  // tol -- Residual stopping tolerance (unchanged)
234  // stol -- Preconditioned residual stopping tolerance (unchanged)
235  // itermax -- Maximum number of iterations
236  // p -- Primal working array that stores the CG step
237  // q -- Dual working array that stores the Hessian applied to p
238  // r -- Primal working array that stores the preconditioned residual
239  // t -- Dual working array that stores the residual
240  // pwa -- Primal working array that stores the pruned vector in hessVec
241  // dwa -- Dual working array that stores the pruned vector in precond
242  Real dtrpcg(Vector<Real> &w, int &iflag, int &iter,
243  const Vector<Real> &g, const Vector<Real> &x,
244  const Real del, TrustRegionModel_U<Real> &model, BoundConstraint<Real> &bnd,
245  const Real tol, const Real stol, const int itermax,
247  Vector<Real> &t, Vector<Real> &pwa, Vector<Real> &dwa,
248  std::ostream &outStream = std::cout) const;
249 
251  const Vector<Real> &v,
252  const Vector<Real> &x,
255  Real &tol,
256  Vector<Real> &pwa) const;
257 
259  const Vector<Real> &v,
260  const Vector<Real> &x,
263  Real &tol,
264  Vector<Real> &dwa,
265  Vector<Real> &pwa) const;
266 
267 }; // class ROL::TypeB::LinMoreAlgorithm
268 
269 } // namespace TypeB
270 } // namespace ROL
271 
273 
274 #endif
Provides the interface to evaluate objective functions.
Real computeValue(Real inTol, Real &outTol, Real pRed, Real &fold, int iter, const Vector< Real > &x, const Vector< Real > &xold, Objective< Real > &obj)
Provides an interface to run the trust-region algorithm of Lin and More.
Real mu0_
Sufficient decrease parameter (default: 1e-2)
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)
int minit_
Maximum number of minor (subproblem solve) iterations (default: 10)
bool normAlpha_
Normalize initial Cauchy point step length (default: false)
bool hasEcon_
Flag signifies if equality constraints exist.
LinMoreAlgorithm(ParameterList &list, const Ptr< Secant< Real >> &secant=nullPtr)
Real TRsafe_
Safeguard size for numerically evaluating ratio (default: 1e2)
Real gamma0_
Radius decrease rate (negative rho) (default: 0.0625)
ESecant esec_
Secant type (default: Limited-Memory BFGS)
void applyFreePrecond(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, TrustRegionModel_U< Real > &model, BoundConstraint< Real > &bnd, Real &tol, Vector< Real > &dwa, Vector< Real > &pwa) const
Real delMax_
Maximum trust-region radius (default: ROL_INF)
Real dtrpcg(Vector< Real > &w, int &iflag, int &iter, const Vector< Real > &g, const Vector< Real > &x, const Real del, TrustRegionModel_U< Real > &model, BoundConstraint< Real > &bnd, const Real tol, const Real stol, 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 interpfPS_
Backtracking rate for projected search (default: 0.5)
bool useSecantPrecond_
Flag to use secant as a preconditioner (default: false)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
Real dgpstep(Vector< Real > &s, const Vector< Real > &w, const Vector< Real > &x, const Real alpha, std::ostream &outStream=std::cout) const
Ptr< ReducedLinearConstraint< Real > > rcon_
Equality constraint restricted to current active variables.
int SPiter_
Subproblem solver iteration count.
ETRFlag
Enumation of flags used by trust-region solvers.
Real dprsrch(Vector< Real > &x, Vector< Real > &s, Real &q, const Vector< Real > &g, TrustRegionModel_U< Real > &model, BoundConstraint< Real > &bnd, Vector< Real > &pwa, Vector< Real > &dwa, std::ostream &outStream=std::cout)
Ptr< NullSpaceOperator< Real > > ns_
Null space projection onto reduced equality constraint Jacobian.
bool writeHeader_
Flag to write header at every iteration.
Provides the interface to evaluate trust-region model functions.
Provides an interface to run bound constrained optimization algorithms.
ESecant
Enumeration of secant update algorithms.
Definition: ROL_Types.hpp:486
void writeHeader(std::ostream &os) const override
Print iterate header.
Real dtrqsol(const Real xtx, const Real ptp, const Real ptx, const Real del) const
void applyFreeHessian(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, TrustRegionModel_U< Real > &model, BoundConstraint< Real > &bnd, Real &tol, Vector< Real > &pwa) const
int maxit_
Maximum number of CG iterations (default: 20)
Real eta0_
Step acceptance threshold (default: 0.05)
int redlim_
Maximum number of Cauchy point reduction steps (default: 10)
int pslim_
Maximum number of projected search steps (default: 20)
Provides interface for and implements limited-memory secant operators.
Definition: ROL_Secant.hpp:79
bool interpRad_
Interpolate the trust-region radius if ratio is negative (default: false)
bool useSecantHessVec_
Flag to use secant as Hessian (default: false)
void initialize(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, std::ostream &outStream=std::cout)
Ptr< TrustRegionModel_U< Real > > model_
Container for trust-region model.
Real alpha_
Initial Cauchy point step length (default: 1.0)
Real spexp_
Relative tolerance exponent for subproblem solve (default: 1, range: [1,2])
int nhess_
Number of Hessian applications.
Real extrapf_
Extrapolation rate for Cauchy point computation (default: 1e1)
void writeName(std::ostream &os) const override
Print step name.
Provides the interface to apply upper and lower bound constraints.
Real qtol_
Relative tolerance for computed decrease in Cauchy point computation (default: 1-8) ...
unsigned verbosity_
Output level (default: 0)
Real interpf_
Backtracking rate for Cauchy point computation (default: 1e-1)
Real gamma2_
Radius increase rate (default: 2.5)
int SPflag_
Subproblem solver termination flag.
Real eps_
Safeguard for numerically evaluating ratio.
Real eta1_
Radius decrease threshold (default: 0.05)
void writeOutput(std::ostream &os, const bool write_header=false) const override
Print iterate status.
int explim_
Maximum number of Cauchy point expansion steps (default: 10)
Real eta2_
Radius increase threshold (default: 0.9)
Real tol1_
Absolute tolerance for truncated CG (default: 1e-4)
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
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...
Real gamma1_
Radius decrease rate (positive rho) (default: 0.25)
TRUtils::ETRFlag TRflag_
Trust-region exit flag.