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