44#ifndef ROL_TYPEG_MOREAUYOSIDAALGORITHM_DEF_H
45#define ROL_TYPEG_MOREAUYOSIDAALGORITHM_DEF_H
52template<
typename Real>
61 Real ten(10), oem6(1.e-6), oem8(1.e-8), oe8(1e8);
62 ParameterList& steplist = list.sublist(
"Step").sublist(
"Moreau-Yosida Penalty");
63 state_->searchSize = steplist.get(
"Initial Penalty Parameter", ten);
64 maxPenalty_ = steplist.get(
"Maximum Penalty Parameter", oe8);
65 tau_ = steplist.get(
"Penalty Parameter Growth Factor", ten);
68 print_ = steplist.sublist(
"Subproblem").get(
"Print History",
false);
70 Real gtol = steplist.sublist(
"Subproblem").get(
"Optimality Tolerance", oem8);
71 Real ctol = steplist.sublist(
"Subproblem").get(
"Feasibility Tolerance", oem8);
72 int maxit = steplist.sublist(
"Subproblem").get(
"Iteration Limit", 1000);
73 Real stol = oem6*std::min(gtol,ctol);
74 list_.sublist(
"Status Test").set(
"Gradient Tolerance", gtol);
75 list_.sublist(
"Status Test").set(
"Constraint Tolerance", ctol);
76 list_.sublist(
"Status Test").set(
"Step Tolerance", stol);
77 list_.sublist(
"Status Test").set(
"Iteration Limit", maxit);
79 stepname_ = steplist.sublist(
"Subproblem").get(
"Step Type",
"Augmented Lagrangian");
82 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
88template<
typename Real>
98 std::ostream &outStream) {
100 if (
proj_ == nullPtr) {
101 proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
104 proj_->project(x,outStream);
115template<
typename Real>
123 std::ostream &outStream) {
140 state_->gradientVec->plus(dwa);
144 proj_->project(pwa,outStream);
158template<
typename Real>
166 std::ostream &outStream ) {
168 Ptr<Vector<Real>> pwa = x.
clone(), dwa = g.
clone();
173 initialize(x,g,emul,eres,myobj,bnd,econ,*pwa,*dwa,outStream);
174 Ptr<TypeE::Algorithm<Real>> algo;
184 *
proj_->getLinearConstraint(),
185 *
proj_->getMultiplier(),
186 *
proj_->getResidual(),outStream);
187 else algo->run(x,g,myobj,econ,emul,eres,outStream);
189 state_->nfval += algo->getState()->nfval;
190 state_->ngrad += algo->getState()->ngrad;
191 state_->ncval += algo->getState()->ncval;
197 state_->lagmultVec->axpy(-one,emul);
201 state_->iterateVec->set(x);
202 state_->lagmultVec->set(emul);
223template<
typename Real>
225 std::stringstream hist;
227 hist << std::string(109,
'-') << std::endl;
228 hist <<
"Moreau-Yosida Penalty Solver";
229 hist <<
" status output definitions" << std::endl << std::endl;
230 hist <<
" iter - Number of iterates (steps taken)" << std::endl;
231 hist <<
" fval - Objective function value" << std::endl;
232 hist <<
" cnorm - Norm of the constraint" << std::endl;
233 hist <<
" gLnorm - Norm of the gradient of the Lagrangian" << std::endl;
234 hist <<
" ifeas - Infeasibility metric" << std::endl;
235 hist <<
" snorm - Norm of the step (update to optimization vector)" << std::endl;
236 hist <<
" penalty - Penalty parameter for bound constraints" << std::endl;
237 hist <<
" #fval - Cumulative number of times the objective function was evaluated" << std::endl;
238 hist <<
" #grad - Cumulative number of times the gradient was computed" << std::endl;
239 hist <<
" #cval - Cumulative number of times the constraint was evaluated" << std::endl;
240 hist <<
" subiter - Number of subproblem iterations" << std::endl;
241 hist << std::string(109,
'-') << std::endl;
245 hist << std::setw(6) << std::left <<
"iter";
246 hist << std::setw(15) << std::left <<
"fval";
247 hist << std::setw(15) << std::left <<
"cnorm";
248 hist << std::setw(15) << std::left <<
"gLnorm";
249 hist << std::setw(15) << std::left <<
"ifeas";
250 hist << std::setw(15) << std::left <<
"snorm";
251 hist << std::setw(10) << std::left <<
"penalty";
252 hist << std::setw(8) << std::left <<
"#fval";
253 hist << std::setw(8) << std::left <<
"#grad";
254 hist << std::setw(8) << std::left <<
"#cval";
255 hist << std::setw(8) << std::left <<
"subIter";
260template<
typename Real>
262 std::stringstream hist;
263 hist << std::endl <<
"Moreau-Yosida Penalty Solver (Type G, General Constraints)";
265 hist <<
"Subproblem Solver: " <<
stepname_ << std::endl;
269template<
typename Real>
271 std::stringstream hist;
272 hist << std::scientific << std::setprecision(6);
275 if (
state_->iter == 0 ) {
277 hist << std::setw(6) << std::left <<
state_->iter;
278 hist << std::setw(15) << std::left <<
state_->value;
279 hist << std::setw(15) << std::left <<
state_->cnorm;
280 hist << std::setw(15) << std::left <<
gnorm_;
282 hist << std::setw(15) << std::left <<
"---";
283 hist << std::scientific << std::setprecision(2);
284 hist << std::setw(10) << std::left <<
state_->searchSize;
285 hist << std::setw(8) << std::left <<
state_->nfval;
286 hist << std::setw(8) << std::left <<
state_->ngrad;
287 hist << std::setw(8) << std::left <<
state_->ncval;
288 hist << std::setw(8) << std::left <<
"---";
293 hist << std::setw(6) << std::left <<
state_->iter;
294 hist << std::setw(15) << std::left <<
state_->value;
295 hist << std::setw(15) << std::left <<
state_->cnorm;
296 hist << std::setw(15) << std::left <<
gnorm_;
298 hist << std::setw(15) << std::left <<
state_->snorm;
299 hist << std::scientific << std::setprecision(2);
300 hist << std::setw(10) << std::left <<
state_->searchSize;
301 hist << std::scientific << std::setprecision(6);
302 hist << std::setw(8) << std::left <<
state_->nfval;
303 hist << std::setw(8) << std::left <<
state_->ngrad;
304 hist << std::setw(8) << std::left <<
state_->ncval;
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.
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.
MoreauYosidaAlgorithm(ParameterList &list)
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.
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)
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.