44 #ifndef ROL_TYPEP_IPIANOALGORITHM_DEF_HPP
45 #define ROL_TYPEP_IPIANOALGORITHM_DEF_HPP
50 template<
typename Real>
57 ParameterList &lslist = list.sublist(
"Step").sublist(
"iPiano");
58 t0_ = list.sublist(
"Status Test").get(
"Gradient Scale", 1.0);
59 maxit_ = lslist.get(
"Reduction Iteration Limit", 20);
60 useConstBeta_ = lslist.get(
"Use Constant Beta",
false);
61 beta_ = lslist.get(
"Momentum Parameter", 0.25);
62 rhodec_ = lslist.get(
"Backtracking Rate", 0.5);
63 rhoinc_ = lslist.get(
"Increase Rate", 2.0);
64 c1_ = lslist.get(
"Upper Interpolation Factor", 1e-5);
65 c2_ = lslist.get(
"Lower Interpolation Factor", 1e-6);
66 L_ = lslist.get(
"Initial Lipschitz Constant Estimate", 0.5/t0_);
67 initProx_ = lslist.get(
"Apply Prox to Initial Guess",
false);
68 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
69 writeHeader_ = verbosity_ > 2;
72 template<
typename Real>
79 std::ostream &outStream) {
80 Real ftol = std::sqrt(ROL_EPSILON<Real>());
85 nobj.
prox(*state_->iterateVec,x,t0_,ftol); state_->nprox++;
86 x.
set(*state_->iterateVec);
89 state_->svalue = sobj.
value(x,ftol); state_->nsval++;
91 state_->nvalue = nobj.
value(x,ftol); state_->nnval++;
92 state_->value = state_->svalue + state_->nvalue;
93 sobj.
gradient(*state_->gradientVec,x,ftol); state_->ngrad++;
94 dg.
set(state_->gradientVec->dual());
95 pgstep(*state_->iterateVec, *state_->stepVec, nobj, x, dg, t0_, ftol);
96 state_->snorm = state_->stepVec->norm();
97 state_->gnorm = state_->snorm / t0_;
100 template<
typename Real>
105 std::ostream &outStream ) {
106 const Real half(0.5), one(1), two(2);
109 initialize(x,g,sobj,nobj,*sP,*dg,outStream);
110 Real strial(0), strialP(0), snormP(0), LP(0), alphaP(0), betaP(0), gs(0), b(0);
111 Real tol(std::sqrt(ROL_EPSILON<Real>()));
117 if (verbosity_ > 0) writeOutput(outStream,
true);
120 while (status_->check(*state_)) {
122 if (!useConstBeta_) {
123 b = (c1_ + half * L_) / (c2_ + half * L_);
124 beta_ = (b - one) / (b - half);
126 alpha_ = two * (1 - beta_) / (two * c2_ + L_);
128 state_->stepVec->set(x);
129 state_->stepVec->axpy(-alpha_, *dg);
130 state_->stepVec->axpy(beta_, x);
131 state_->stepVec->axpy(-beta_, *xold);
132 nobj.
prox(*state_->iterateVec, *state_->stepVec, alpha_, tol); state_->nprox++;
133 state_->stepVec->set(*state_->iterateVec);
134 state_->stepVec->axpy(-one,x);
135 state_->snorm = state_->stepVec->norm();
139 strial = sobj.
value(*state_->iterateVec,tol); state_->nsval++;
140 gs = state_->gradientVec->apply(*state_->stepVec);
142 if (strial <= state_->svalue + gs + half * L_ * state_->snorm * state_->snorm) {
144 for (
int i = 0; i < maxit_; ++i) {
152 snormP = state_->snorm;
153 xP->set(*state_->iterateVec);
154 sP->set(*state_->stepVec);
157 if (!useConstBeta_) {
158 b = (c1_ + half * L_) / (c2_ + half * L_);
159 beta_ = (b - one) / (b - half);
161 alpha_ = two * (one - beta_) / (two * c2_ + L_);
163 state_->stepVec->set(x);
164 state_->stepVec->axpy(-alpha_, *dg);
165 state_->stepVec->axpy(beta_, x);
166 state_->stepVec->axpy(-beta_, *xold);
167 nobj.
prox(*state_->iterateVec, *state_->stepVec, alpha_, tol); state_->nprox++;
168 state_->stepVec->set(*state_->iterateVec);
169 state_->stepVec->axpy(-one,x);
170 state_->snorm = state_->stepVec->norm();
173 strial = sobj.
value(*state_->iterateVec,tol); state_->nsval++;
174 gs = state_->gradientVec->apply(*state_->stepVec);
175 if (strial > state_->svalue + gs + half * L_ * state_->snorm * state_->snorm) {
181 state_->snorm = snormP;
182 state_->iterateVec->set(*xP);
183 state_->stepVec->set(*sP);
197 while (strial > state_->svalue + gs + half * L_ * state_->snorm * state_->snorm) {
200 if (!useConstBeta_) {
201 b = (c1_ + half * L_) / (c2_ + half * L_);
202 beta_ = (b - one) / (b - half);
204 alpha_ = two * (one - beta_) / (two * c2_ + L_);
206 state_->stepVec->set(x);
207 state_->stepVec->axpy(-alpha_, *dg);
208 state_->stepVec->axpy(beta_, x);
209 state_->stepVec->axpy(-beta_, *xold);
210 nobj.
prox(*state_->iterateVec, *state_->stepVec, alpha_, tol); state_->nprox++;
211 state_->stepVec->set(*state_->iterateVec);
212 state_->stepVec->axpy(-one,x);
213 state_->snorm = state_->stepVec->norm();
216 strial = sobj.
value(*state_->iterateVec,tol); state_->nsval++;
217 gs = state_->gradientVec->apply(*state_->stepVec);
225 x.
set(*state_->iterateVec);
226 state_->svalue = strial;
227 state_->nvalue = nobj.
value(x,tol); state_->nnval++;
228 state_->value = state_->svalue + state_->nvalue;
229 sobj.
gradient(*state_->gradientVec,x,tol); state_->ngrad++;
230 dg->set(state_->gradientVec->dual());
232 pgstep(*xP,*sP,nobj,x,*dg,t0_,tol);
233 state_->gnorm = sP->norm() / t0_;
236 if (verbosity_ > 0) writeOutput(outStream,writeHeader_);
241 template<
typename Real>
243 std::ios_base::fmtflags osFlags(os.flags());
244 if (verbosity_ > 1) {
245 os << std::string(109,
'-') << std::endl;
246 os <<
"iPiano: Inertial proximal algorithm for nonconvex optimization";
247 os <<
" status output definitions" << std::endl << std::endl;
248 os <<
" iter - Number of iterates (steps taken)" << std::endl;
249 os <<
" value - Objective function value" << std::endl;
250 os <<
" gnorm - Norm of the proximal gradient with parameter lambda" << std::endl;
251 os <<
" snorm - Norm of the step (update to optimization vector)" << std::endl;
252 os <<
" alpha - Inertial gradient parameter" << std::endl;
253 os <<
" beta - Inertial step parameter" << std::endl;
254 os <<
" L - Lipschitz constant estimate" << std::endl;
255 os <<
" #sval - Cumulative number of times the smooth objective function was evaluated" << std::endl;
256 os <<
" #nval - Cumulative number of times the nonsmooth objective function was evaluated" << std::endl;
257 os <<
" #grad - Cumulative number of times the gradient was computed" << std::endl;
258 os <<
" #prox - Cumulative number of times the proximal operator was computed" << std::endl;
259 os << std::string(109,
'-') << std::endl;
263 os << std::setw(6) << std::left <<
"iter";
264 os << std::setw(15) << std::left <<
"value";
265 os << std::setw(15) << std::left <<
"gnorm";
266 os << std::setw(15) << std::left <<
"snorm";
267 os << std::setw(15) << std::left <<
"alpha";
268 os << std::setw(15) << std::left <<
"beta";
269 os << std::setw(15) << std::left <<
"L";
270 os << std::setw(10) << std::left <<
"#sval";
271 os << std::setw(10) << std::left <<
"#nval";
272 os << std::setw(10) << std::left <<
"#grad";
273 os << std::setw(10) << std::left <<
"#nprox";
278 template<
typename Real>
280 std::ios_base::fmtflags osFlags(os.flags());
281 os << std::endl <<
"iPiano: Inertial Proximal Algorithm for Nonconvex Optimization (Type P)" << std::endl;
285 template<
typename Real>
287 std::ios_base::fmtflags osFlags(os.flags());
288 os << std::scientific << std::setprecision(6);
289 if ( state_->iter == 0 ) writeName(os);
290 if ( write_header ) writeHeader(os);
291 if ( state_->iter == 0 ) {
293 os << std::setw(6) << std::left << state_->iter;
294 os << std::setw(15) << std::left << state_->value;
295 os << std::setw(15) << std::left << state_->gnorm;
296 os << std::setw(15) << std::left <<
"---";
297 os << std::setw(15) << std::left <<
"---";
298 os << std::setw(15) << std::left <<
"---";
299 os << std::setw(15) << std::left << L_;
300 os << std::setw(10) << std::left << state_->nsval;
301 os << std::setw(10) << std::left << state_->nnval;
302 os << std::setw(10) << std::left << state_->ngrad;
303 os << std::setw(10) << std::left << state_->nprox;
308 os << std::setw(6) << std::left << state_->iter;
309 os << std::setw(15) << std::left << state_->value;
310 os << std::setw(15) << std::left << state_->gnorm;
311 os << std::setw(15) << std::left << state_->snorm;
312 os << std::setw(15) << std::left << alpha_;
313 os << std::setw(15) << std::left << beta_;
314 os << std::setw(15) << std::left << L_;
315 os << std::setw(10) << std::left << state_->nsval;
316 os << std::setw(10) << std::left << state_->nnval;
317 os << std::setw(10) << std::left << state_->ngrad;
318 os << std::setw(10) << std::left << state_->nprox;
Provides the interface to evaluate objective functions.
iPianoAlgorithm(ParameterList &list)
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)
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
void writeName(std::ostream &os) const override
Print step name.
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
virtual void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
Defines the linear algebra or vector space interface.
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Provides an interface to check status of optimization algorithms.
void writeOutput(std::ostream &os, bool write_header=false) const override
Print iterate status.
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...
virtual void set(const Vector &x)
Set where .
virtual void writeExitStatus(std::ostream &os) const
void initialize(const Vector< Real > &x, const Vector< Real > &g)
void writeHeader(std::ostream &os) const override
Print iterate header.