10#ifndef ROL_TYPEG_MOREAUYOSIDAALGORITHM_DEF_H
11#define ROL_TYPEG_MOREAUYOSIDAALGORITHM_DEF_H
18template<
typename Real>
27 Real ten(10), oem6(1.e-6), oem8(1.e-8), oe8(1e8);
28 ParameterList& steplist = list.sublist(
"Step").sublist(
"Moreau-Yosida Penalty");
29 state_->searchSize = steplist.get(
"Initial Penalty Parameter", ten);
30 maxPenalty_ = steplist.get(
"Maximum Penalty Parameter", oe8);
31 tau_ = steplist.get(
"Penalty Parameter Growth Factor", ten);
34 print_ = steplist.sublist(
"Subproblem").get(
"Print History",
false);
36 Real gtol = steplist.sublist(
"Subproblem").get(
"Optimality Tolerance", oem8);
37 Real ctol = steplist.sublist(
"Subproblem").get(
"Feasibility Tolerance", oem8);
38 int maxit = steplist.sublist(
"Subproblem").get(
"Iteration Limit", 1000);
39 bool reltol = steplist.sublist(
"Subproblem").get(
"Use Relative Tolerances",
true);
40 Real stol = oem6*std::min(gtol,ctol);
41 list_.sublist(
"Status Test").set(
"Gradient Tolerance", gtol);
42 list_.sublist(
"Status Test").set(
"Constraint Tolerance", ctol);
43 list_.sublist(
"Status Test").set(
"Step Tolerance", stol);
44 list_.sublist(
"Status Test").set(
"Iteration Limit", maxit);
45 list_.sublist(
"Status Test").set(
"Use Relative Tolerances", reltol);
47 stepname_ = steplist.sublist(
"Subproblem").get(
"Step Type",
"Augmented Lagrangian");
51 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
57template<
typename Real>
67 std::ostream &outStream) {
69 if (
proj_ == nullPtr) {
70 proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
73 proj_->project(x,outStream);
84template<
typename Real>
92 std::ostream &outStream) {
109 state_->gradientVec->plus(dwa);
113 proj_->project(pwa,outStream);
127template<
typename Real>
135 std::ostream &outStream ) {
137 Ptr<Vector<Real>> pwa = x.
clone(), dwa = g.
clone();
142 initialize(x,g,emul,eres,myobj,bnd,econ,*pwa,*dwa,outStream);
143 Ptr<TypeE::Algorithm<Real>> algo;
153 *
proj_->getLinearConstraint(),
154 *
proj_->getMultiplier(),
155 *
proj_->getResidual(),outStream);
156 else algo->run(x,g,myobj,econ,emul,eres,outStream);
158 state_->nfval += algo->getState()->nfval;
159 state_->ngrad += algo->getState()->ngrad;
160 state_->ncval += algo->getState()->ncval;
166 state_->lagmultVec->axpy(-one,emul);
170 state_->iterateVec->set(x);
171 state_->lagmultVec->set(emul);
190template<
typename Real>
192 std::ios_base::fmtflags osFlags(os.flags());
194 os << std::string(109,
'-') << std::endl;
195 os <<
"Moreau-Yosida Penalty Solver";
196 os <<
" status output definitions" << std::endl << std::endl;
197 os <<
" iter - Number of iterates (steps taken)" << std::endl;
198 os <<
" fval - Objective function value" << std::endl;
199 os <<
" cnorm - Norm of the constraint" << std::endl;
200 os <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
201 os <<
" ifeas - Infeasibility metric" << std::endl;
202 os <<
" snorm - Norm of the step (update to optimization vector)" << std::endl;
203 os <<
" penalty - Penalty parameter for bound constraints" << std::endl;
204 os <<
" #fval - Cumulative number of times the objective function was evaluated" << std::endl;
205 os <<
" #grad - Cumulative number of times the gradient was computed" << std::endl;
206 os <<
" #cval - Cumulative number of times the constraint was evaluated" << std::endl;
207 os <<
" subiter - Number of subproblem iterations" << std::endl;
208 os << std::string(109,
'-') << std::endl;
212 os << std::setw(6) << std::left <<
"iter";
213 os << std::setw(15) << std::left <<
"fval";
214 os << std::setw(15) << std::left <<
"cnorm";
215 os << std::setw(15) << std::left <<
"gLnorm";
216 os << std::setw(15) << std::left <<
"ifeas";
217 os << std::setw(15) << std::left <<
"snorm";
218 os << std::setw(10) << std::left <<
"penalty";
219 os << std::setw(8) << std::left <<
"#fval";
220 os << std::setw(8) << std::left <<
"#grad";
221 os << std::setw(8) << std::left <<
"#cval";
222 os << std::setw(8) << std::left <<
"subIter";
227template<
typename Real>
229 std::ios_base::fmtflags osFlags(os.flags());
230 os << std::endl <<
"Moreau-Yosida Penalty Solver (Type G, General Constraints)";
232 os <<
"Subproblem Solver: " <<
stepname_ << std::endl;
236template<
typename Real>
238 std::ios_base::fmtflags osFlags(os.flags());
239 os << std::scientific << std::setprecision(6);
242 if (
state_->iter == 0 ) {
244 os << std::setw(6) << std::left <<
state_->iter;
245 os << std::setw(15) << std::left <<
state_->value;
246 os << std::setw(15) << std::left <<
state_->cnorm;
247 os << std::setw(15) << std::left <<
gnorm_;
249 os << std::setw(15) << std::left <<
"---";
250 os << std::scientific << std::setprecision(2);
251 os << std::setw(10) << std::left <<
state_->searchSize;
252 os << std::setw(8) << std::left <<
state_->nfval;
253 os << std::setw(8) << std::left <<
state_->ngrad;
254 os << std::setw(8) << std::left <<
state_->ncval;
255 os << std::setw(8) << std::left <<
"---";
260 os << std::setw(6) << std::left <<
state_->iter;
261 os << std::setw(15) << std::left <<
state_->value;
262 os << std::setw(15) << std::left <<
state_->cnorm;
263 os << std::setw(15) << std::left <<
gnorm_;
265 os << std::setw(15) << std::left <<
state_->snorm;
266 os << std::scientific << std::setprecision(2);
267 os << std::setw(10) << std::left <<
state_->searchSize;
268 os << std::scientific << std::setprecision(6);
269 os << std::setw(8) << std::left <<
state_->nfval;
270 os << std::setw(8) << std::left <<
state_->ngrad;
271 os << std::setw(8) << std::left <<
state_->ncval;
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
Provides the interface to apply upper and lower bound constraints.
Provides an interface to check status of optimization algorithms for problems with equality constrain...
Defines the general constraint operator interface.
virtual void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)=0
Evaluate the constraint operator at .
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update constraint function.
virtual void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the adjoint of the the constraint Jacobian at , , to vector .
Provides the interface to evaluate the Moreau-Yosida penalty function.
void getObjectiveGradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Real getObjectiveValue(const Vector< Real > &x, Real &tol)
Real testComplementarity(const Vector< Real > &x)
void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update Moreau-Yosida penalty function.
void updateMultipliers(Real mu, const Vector< Real > &x)
Provides the interface to evaluate objective functions.
Provides interface for and implements limited-memory secant operators.
Algorithm()
Constructor, given a step and a status test.
void initialize(const Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &mul, const Vector< Real > &c)
virtual void writeExitStatus(std::ostream &os) const
const Ptr< CombinedStatusTest< Real > > status_
Ptr< PolyhedralProjection< Real > > proj_
const Ptr< AlgorithmState< Real > > state_
void writeName(std::ostream &os) const override
Print step name.
void initialize(Vector< Real > &x, const Vector< Real > &g, const Vector< Real > &l, const Vector< Real > &c, MoreauYosidaObjective< Real > &myobj, BoundConstraint< Real > &bnd, Constraint< Real > &con, Vector< Real > &pwa, Vector< Real > &dwa, std::ostream &outStream=std::cout)
void updateState(const Vector< Real > &x, const Vector< Real > &l, MoreauYosidaObjective< Real > &myobj, BoundConstraint< Real > &bnd, Constraint< Real > &con, Vector< Real > &pwa, Vector< Real > &dwa, std::ostream &outStream=std::cout)
void writeOutput(std::ostream &os, const bool print_header=false) const override
Print iterate status.
void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, Constraint< Real > &econ, Vector< Real > &emul, const Vector< Real > &eres, std::ostream &outStream=std::cout) override
Run algorithm on general constrained problems (Type-G). This is the primary Type-G interface.
void writeHeader(std::ostream &os) const override
Print iterate header.
const Ptr< Secant< Real > > secant_
MoreauYosidaAlgorithm(ParameterList &list, const Ptr< Secant< Real > > &secant=nullPtr)
Defines the linear algebra or vector space interface.
virtual Real norm() const =0
Returns where .
virtual void set(const Vector &x)
Set where .
virtual void zero()
Set to zero vector.
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Ptr< TypeE::Algorithm< Real > > AlgorithmFactory(ParameterList &parlist, const Ptr< Secant< Real > > &secant=nullPtr)
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.