ROL
ROL_TypeB_LSecantBAlgorithm.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_LSECANTBALGORITHM_HPP
11#define ROL_TYPEB_LSECANTBALGORITHM_HPP
12
14#include "ROL_SecantFactory.hpp"
17
23namespace ROL {
24namespace TypeB {
25
26template<typename Real>
27class LSecantBAlgorithm : public TypeB::Algorithm<Real> {
28private:
29 // ITERATION FLAGS/INFORMATION
30 int SPflag_;
31 int SPiter_;
32
33 // SECANT INFORMATION
37 Ptr<Secant<Real>> secant_;
38
39 // TRUNCATED CG INFORMATION
40 Real tol1_;
41 Real tol2_;
42 int maxit_;
43
44 // ALGORITHM SPECIFIC PARAMETERS
45 Real mu0_;
46 Real spexp_;
47 int redlim_;
48 int explim_;
49 Real alpha_;
51 Real interpf_;
52 Real extrapf_;
53 Real qtol_;
55
56 unsigned verbosity_;
58
59 bool hasEcon_;
60 Ptr<ReducedLinearConstraint<Real>> rcon_;
61 Ptr<NullSpaceOperator<Real>> ns_;
62
63 using TypeB::Algorithm<Real>::state_;
64 using TypeB::Algorithm<Real>::status_;
65 using TypeB::Algorithm<Real>::proj_;
66
67public:
68 LSecantBAlgorithm(ParameterList &list, const Ptr<Secant<Real>> &secant = nullPtr);
69
70 using TypeB::Algorithm<Real>::run;
71 void run( Vector<Real> &x,
72 const Vector<Real> &g,
73 Objective<Real> &obj,
75 std::ostream &outStream = std::cout) override;
76
77 void writeHeader( std::ostream& os ) const override;
78
79 void writeName( std::ostream& os ) const override;
80
81 void writeOutput( std::ostream& os, const bool write_header = false ) const override;
82
83private:
85 const Vector<Real> &g,
86 Objective<Real> &obj,
88 std::ostream &outStream = std::cout);
89
90 // Compute the projected step s = P(x + alpha*w) - x
91 // Returns the norm of the projected step s
92 // s -- The projected step upon return
93 // w -- The direction vector w (unchanged)
94 // x -- The anchor vector x (unchanged)
95 // alpha -- The step size (unchanged)
96 Real dgpstep(Vector<Real> &s, const Vector<Real> &w,
97 const Vector<Real> &x, const Real alpha,
98 std::ostream &outStream = std::cout) const;
99
100 // Compute Cauchy point, i.e., the minimizer of q(P(x - alpha*g)-x)
101 // subject to the trust region constraint ||P(x - alpha*g)-x|| <= del
102 // s -- The Cauchy step upon return: Primal optimization space vector
103 // alpha -- The step length for the Cauchy point upon return
104 // x -- The anchor vector x (unchanged): Primal optimization space vector
105 // g -- The (dual) gradient vector g (unchanged): Primal optimization space vector
106 // secant -- Secant Hessian approximation
107 // dwa -- Dual working array, stores Hessian applied to step
108 // dwa1 -- Dual working array
109 Real dcauchy(Vector<Real> &s, Real &alpha, Real &q,
110 const Vector<Real> &x, const Vector<Real> &g,
111 Secant<Real> &secant,
112 Vector<Real> &dwa, Vector<Real> &dwa1,
113 std::ostream &outStream = std::cout);
114
115 // Perform line search to determine beta such that
116 // f(x + beta*s) <= f(x) _ mu0*beta*g's for mu0 in (0,1)
117 // x -- The anchor vector x, upon return x = x + beta*s: Primal optimization space vector
118 // s -- The direction vector s, upon return s = beta*s; Primal optimization space vector
119 // fnew -- New objective function value
120 // beta -- Line search step length
121 // fold -- Old objective function value
122 // gs -- Gradient applied to the unscaled step s;
123 // obj -- Objective function
124 // pwa -- Primal working array
125 Real dsrch(Vector<Real> &x, Vector<Real> &s, Real &fnew, Real &beta,
126 Real fold, Real gs, Objective<Real> &obj,
127 Vector<Real> &pwa, std::ostream &outStream = std::cout);
128
129 // Solve the quadratic subproblem: minimize q(w) subject to the
130 // linear constraints using the Conjugate Gradients algorithm
131 // w -- The step vector to be computed
132 // iflag -- Termination flag
133 // iter -- Number of CG iterations
134 // secant -- Secant Hessian approximation
135 // bnd -- Bound constraint used to remove active variables
136 // tol -- Residual stopping tolerance (unchanged)
137 // stol -- Preconditioned residual stopping tolerance (unchanged)
138 // itermax -- Maximum number of iterations
139 // p -- Primal working array that stores the CG step
140 // q -- Dual working array that stores the Hessian applied to p
141 // r -- Primal working array that stores the preconditioned residual
142 // t -- Dual working array that stores the residual
143 // pwa -- Primal working array that stores the pruned vector in hessVec
144 // dwa -- Dual working array that stores the pruned vector in precond
145 Real dpcg(Vector<Real> &w, int &iflag, int &iter,
146 const Vector<Real> &g, const Vector<Real> &x,
148 const Real tol, const Real stol, const int itermax,
151 std::ostream &outStream = std::cout) const;
152
154 const Vector<Real> &v,
155 const Vector<Real> &x,
156 Secant<Real> &secant,
158 Real &tol,
159 Vector<Real> &pwa) const;
160
162 const Vector<Real> &v,
163 const Vector<Real> &x,
164 Secant<Real> &secant,
166 Real &tol,
167 Vector<Real> &dwa,
168 Vector<Real> &pwa) const;
169
170}; // class ROL::TypeB::LSecantBAlgorithm
171
172} // namespace TypeB
173} // namespace ROL
174
176
177#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 an interface to run bound constrained optimization algorithms.
Ptr< PolyhedralProjection< Real > > proj_
const Ptr< AlgorithmState< Real > > state_
const Ptr< CombinedStatusTest< Real > > status_
Provides an interface to run the line-search algorithm of Byrd, Lu, Nocedal and Zhu (similar to L-BFG...
Real alpha_
Initial Cauchy point step length (default: 1.0)
Ptr< ReducedLinearConstraint< Real > > rcon_
Equality constraint restricted to current active variables.
int SPiter_
Subproblem solver iteration count.
ESecant esec_
Secant type (default: Limited-Memory BFGS)
bool normAlpha_
Normalize initial Cauchy point step length (default: false)
Ptr< NullSpaceOperator< Real > > ns_
Null space projection onto reduced equality constraint Jacobian.
bool writeHeader_
Flag to write header at every iteration.
void writeOutput(std::ostream &os, const bool write_header=false) const override
Print iterate status.
void applyFreeHessian(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Secant< Real > &secant, BoundConstraint< Real > &bnd, Real &tol, Vector< Real > &pwa) const
int redlim_
Maximum number of Cauchy point reduction steps (default: 10)
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 interpfPS_
Backtracking rate for projected search (default: 0.5)
Real interpf_
Backtracking rate for Cauchy point computation (default: 1e-1)
Real spexp_
Relative tolerance exponent for subproblem solve (default: 1, range: [1,2])
Real dcauchy(Vector< Real > &s, Real &alpha, Real &q, const Vector< Real > &x, const Vector< Real > &g, Secant< Real > &secant, Vector< Real > &dwa, Vector< Real > &dwa1, std::ostream &outStream=std::cout)
Real dpcg(Vector< Real > &w, int &iflag, int &iter, const Vector< Real > &g, const Vector< Real > &x, Secant< Real > &secant, 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, Secant< Real > &secant, BoundConstraint< Real > &bnd, Real &tol, Vector< Real > &dwa, Vector< Real > &pwa) const
Ptr< Secant< Real > > secant_
Secant object.
Real dgpstep(Vector< Real > &s, const Vector< Real > &w, const Vector< Real > &x, const Real alpha, std::ostream &outStream=std::cout) const
Real qtol_
Relative tolerance for computed decrease in Cauchy point computation (default: 1-8)
int maxit_
Maximum number of CG iterations (default: 20)
void writeHeader(std::ostream &os) const override
Print iterate header.
Real extrapf_
Extrapolation rate for Cauchy point computation (default: 1e1)
int SPflag_
Subproblem solver termination flag.
void initialize(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, std::ostream &outStream=std::cout)
Real dsrch(Vector< Real > &x, Vector< Real > &s, Real &fnew, Real &beta, Real fold, Real gs, Objective< Real > &obj, Vector< Real > &pwa, std::ostream &outStream=std::cout)
Real tol2_
Relative tolerance for truncated CG (default: 1e-2)
Real tol1_
Absolute tolerance for truncated CG (default: 1e-4)
bool useSecantPrecond_
Flag to use secant as a preconditioner (default: false)
bool hasEcon_
Flag signifies if equality constraints exist.
Real mu0_
Sufficient decrease parameter (default: 1e-2)
void writeName(std::ostream &os) const override
Print step name.
unsigned verbosity_
Output level (default: 0)
bool useSecantHessVec_
Flag to use secant as Hessian (default: false)
int explim_
Maximum number of Cauchy point expansion steps (default: 10)
Defines the linear algebra or vector space interface.