10#ifndef ROL_TYPEP_PROXGRADIENTALGORITHM_DEF_HPP
11#define ROL_TYPEP_PROXGRADIENTALGORITHM_DEF_HPP
16template<
typename Real>
23 ParameterList &lslist = list.sublist(
"Step").sublist(
"Line Search");
24 maxit_ = lslist.get(
"Function Evaluation Limit", 20);
25 alpha0_ = lslist.get(
"Initial Step Size", 1.0);
26 normAlpha_ = lslist.get(
"Normalize Initial Step Size",
false);
27 alpha0bnd_ = lslist.get(
"Lower Bound for Initial Step Size", 1e-4);
28 useralpha_ = lslist.get(
"User Defined Initial Step Size",
false);
29 usePrevAlpha_ = lslist.get(
"Use Previous Step Length as Initial Guess",
false);
30 c1_ = lslist.get(
"Sufficient Decrease Tolerance", 1e-4);
32 useAdapt_ = lslist.get(
"Use Adaptive Step Size Selection",
true);
33 initProx_ = lslist.get(
"Apply Prox to Initial Guess",
false);
34 rhodec_ = lslist.sublist(
"Line-Search Method").get(
"Backtracking Rate", 0.5);
35 rhoinc_ = lslist.sublist(
"Line-Search Method").get(
"Increase Rate" , 2.0);
36 t0_ = list.sublist(
"Status Test").get(
"Gradient Scale" , 1.0);
37 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
41template<
typename Real>
48 std::ostream &outStream) {
76 Real snew = sobj.
value(px,ftol);
94template<
typename Real>
99 std::ostream &outStream ) {
105 Real strial(0), ntrial(0), Ftrial(0), Qk(0);
106 Real strialP(0), ntrialP(0), FtrialP(0), alphaP(0);
107 Real snorm(
state_->snorm), searchSize(
state_->searchSize);
109 bool incAlpha =
false, accept =
true;
118 state_->searchSize = searchSize;
124 Ftrial = strial + ntrial;
128 incAlpha = (Ftrial -
state_->value <=
c1_*Qk);
130 outStream <<
" In TypeP::GradientAlgorithm: Line Search" << std::endl;
131 outStream <<
" Step size: " <<
state_->searchSize << std::endl;
132 outStream <<
" Trial smooth value: " << strial << std::endl;
133 outStream <<
" Trial nonsmooth value: " << ntrial << std::endl;
134 outStream <<
" Computed reduction: " <<
state_->value-Ftrial << std::endl;
135 outStream <<
" Dot product of gradient and step: " << Qk << std::endl;
136 outStream <<
" Sufficient decrease bound: " << -Qk*
c1_ << std::endl;
137 outStream <<
" Number of function evaluations: " << ls_nfval << std::endl;
138 outStream <<
" Increase alpha?: " << incAlpha << std::endl;
143 FtrialP = ntrialP + strialP;
152 pxP->set(*
state_->iterateVec);
153 alphaP =
state_->searchSize;
167 Ftrial = strial + ntrial;
172 outStream << std::endl;
173 outStream <<
" Step size: " <<
state_->searchSize << std::endl;
174 outStream <<
" Trial smooth value: " << strial << std::endl;
175 outStream <<
" Trial nonsmooth value: " << ntrial << std::endl;
176 outStream <<
" Computed reduction: " <<
state_->value-Ftrial << std::endl;
177 outStream <<
" Dot product of gradient and step: " << Qk << std::endl;
178 outStream <<
" Sufficient decrease bound: " << -Qk*
c1_ << std::endl;
179 outStream <<
" Number of function evaluations: " << ls_nfval << std::endl;
182 if (Ftrial -
state_->value >
c1_*Qk || Ftrial > FtrialP) {
183 state_->iterateVec->set(*pxP);
187 state_->searchSize = alphaP;
189 state_->stepVec->axpy(-one,x);
204 Ftrial = strial + ntrial;
209 outStream << std::endl;
210 outStream <<
" Step size: " <<
state_->searchSize << std::endl;
211 outStream <<
" Trial smooth value: " << strial << std::endl;
212 outStream <<
" Trial nonsmooth value: " << ntrial << std::endl;
213 outStream <<
" Computed reduction: " <<
state_->value-Ftrial << std::endl;
214 outStream <<
" Dot product of gradient and step: " << Qk << std::endl;
215 outStream <<
" Sufficient decrease bound: " << -Qk*
c1_ << std::endl;
216 outStream <<
" Number of function evaluations: " << ls_nfval << std::endl;
220 state_->nsval += ls_nfval;
221 state_->nnval += ls_nfval;
244 dg->set(
state_->gradientVec->dual());
247 searchSize =
state_->searchSize;
250 snorm =
state_->stepVec->norm();
251 state_->gnorm = snorm / searchSize;
259template<
typename Real>
261 std::ios_base::fmtflags osFlags(os.flags());
263 os << std::string(109,
'-') << std::endl;
264 os <<
"Proximal gradient descent";
265 os <<
" status output definitions" << std::endl << std::endl;
266 os <<
" iter - Number of iterates (steps taken)" << std::endl;
267 os <<
" value - Objective function value" << std::endl;
268 os <<
" gnorm - Norm of the proximal gradient with parameter alpha" << std::endl;
269 os <<
" snorm - Norm of the step (update to optimization vector)" << std::endl;
270 os <<
" alpha - Line search step length" << std::endl;
271 os <<
" #sval - Cumulative number of times the smooth objective function was evaluated" << std::endl;
272 os <<
" #nval - Cumulative number of times the nonsmooth objective function was evaluated" << std::endl;
273 os <<
" #grad - Cumulative number of times the gradient was computed" << std::endl;
274 os <<
" #prox - Cumulative number of times the proximal operator was computed" << std::endl;
275 os << std::string(109,
'-') << std::endl;
279 os << std::setw(6) << std::left <<
"iter";
280 os << std::setw(15) << std::left <<
"value";
281 os << std::setw(15) << std::left <<
"gnorm";
282 os << std::setw(15) << std::left <<
"snorm";
283 os << std::setw(15) << std::left <<
"alpha";
284 os << std::setw(10) << std::left <<
"#sval";
285 os << std::setw(10) << std::left <<
"#nval";
286 os << std::setw(10) << std::left <<
"#grad";
287 os << std::setw(10) << std::left <<
"#nprox";
292template<
typename Real>
294 std::ios_base::fmtflags osFlags(os.flags());
295 os << std::endl <<
"Proximal Gradient Descent with Bidirectional Line Search (Type P)" << std::endl;
299template<
typename Real>
301 std::ios_base::fmtflags osFlags(os.flags());
302 os << std::scientific << std::setprecision(6);
305 if (
state_->iter == 0 ) {
307 os << std::setw(6) << std::left <<
state_->iter;
308 os << std::setw(15) << std::left <<
state_->value;
309 os << std::setw(15) << std::left <<
state_->gnorm;
310 os << std::setw(15) << std::left <<
"---";
311 os << std::setw(15) << std::left <<
"---";
312 os << std::setw(10) << std::left <<
state_->nsval;
313 os << std::setw(10) << std::left <<
state_->nnval;
314 os << std::setw(10) << std::left <<
state_->ngrad;
315 os << std::setw(10) << std::left <<
state_->nprox;
320 os << std::setw(6) << std::left <<
state_->iter;
321 os << std::setw(15) << std::left <<
state_->value;
322 os << std::setw(15) << std::left <<
state_->gnorm;
323 os << std::setw(15) << std::left <<
state_->snorm;
324 os << std::setw(15) << std::left <<
state_->searchSize;
325 os << std::setw(10) << std::left <<
state_->nsval;
326 os << std::setw(10) << std::left <<
state_->nnval;
327 os << std::setw(10) << std::left <<
state_->ngrad;
328 os << std::setw(10) << std::left <<
state_->nprox;
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
Provides the interface to evaluate objective functions.
virtual void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
Compute the proximity operator.
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
Provides an interface to check status of optimization algorithms.
void pgstep(Vector< Real > &pgiter, Vector< Real > &pgstep, Objective< Real > &nobj, const Vector< Real > &x, const Vector< Real > &dg, Real t, Real &tol) const
const Ptr< AlgorithmState< Real > > state_
virtual void writeExitStatus(std::ostream &os) const
const Ptr< CombinedStatusTest< Real > > status_
void initialize(const Vector< Real > &x, const Vector< Real > &g)
void writeName(std::ostream &os) const override
Print step name.
void writeOutput(std::ostream &os, bool write_header=false) const override
Print iterate status.
void writeHeader(std::ostream &os) const override
Print iterate header.
void initialize(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &sobj, Objective< Real > &nobj, Vector< Real > &px, Vector< Real > &dg, std::ostream &outStream=std::cout)
ProxGradientAlgorithm(ParameterList &list)
void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &sobj, Objective< Real > &nobj, std::ostream &outStream=std::cout) override
Run algorithm on unconstrained problems (Type-U). This general interface supports the use of dual opt...
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.