10#ifndef ROL_TYPEB_MOREAUYOSIDAALGORITHM_DEF_HPP
11#define ROL_TYPEB_MOREAUYOSIDAALGORITHM_DEF_HPP
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",
"Trust Region");
51 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
57template<
typename Real>
63 std::ostream &outStream) {
65 if (
proj_ == nullPtr) {
66 proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
78template<
typename Real>
83 std::ostream &outStream) {
100 proj_->project(pwa,outStream);
111template<
typename Real>
116 std::ostream &outStream ) {
118 Ptr<Vector<Real>> pwa = x.
clone();
124 Ptr<TypeU::Algorithm<Real>> algo;
132 if (
hasEcon_) algo->run(x,g,myobj,*
proj_->getLinearConstraint(),
133 *
proj_->getMultiplier(),*
proj_->getResidual(),
135 else algo->run(x,g,myobj,outStream);
144 state_->iterateVec->set(x);
168template<
typename Real>
170 std::ios_base::fmtflags osFlags(os.flags());
172 os << std::string(109,
'-') << std::endl;
173 os <<
"Moreau-Yosida Penalty Solver";
174 os <<
" status output definitions" << std::endl << std::endl;
175 os <<
" iter - Number of iterates (steps taken)" << std::endl;
176 os <<
" fval - Objective function value" << std::endl;
177 os <<
" gnorm - Norm of the gradient" << std::endl;
178 os <<
" ifeas - Infeasibility metric" << std::endl;
179 os <<
" snorm - Norm of the step (update to optimization vector)" << std::endl;
180 os <<
" penalty - Penalty parameter for bound constraints" << std::endl;
181 os <<
" #fval - Cumulative number of times the objective function was evaluated" << std::endl;
182 os <<
" #grad - Cumulative number of times the gradient was computed" << std::endl;
183 os <<
" subiter - Number of subproblem iterations" << std::endl;
184 os << std::string(109,
'-') << std::endl;
188 os << std::setw(6) << std::left <<
"iter";
189 os << std::setw(15) << std::left <<
"fval";
190 os << std::setw(15) << std::left <<
"gnorm";
191 os << std::setw(15) << std::left <<
"ifeas";
192 os << std::setw(15) << std::left <<
"snorm";
193 os << std::setw(10) << std::left <<
"penalty";
194 os << std::setw(8) << std::left <<
"#fval";
195 os << std::setw(8) << std::left <<
"#grad";
196 os << std::setw(8) << std::left <<
"subIter";
201template<
typename Real>
203 std::ios_base::fmtflags osFlags(os.flags());
204 os << std::endl <<
" Moreau-Yosida Penalty Solver";
209template<
typename Real>
211 std::ios_base::fmtflags osFlags(os.flags());
212 os << std::scientific << std::setprecision(6);
215 if (
state_->iter == 0 ) {
217 os << std::setw(6) << std::left <<
state_->iter;
218 os << std::setw(15) << std::left <<
state_->value;
219 os << std::setw(15) << std::left <<
gnorm_;
221 os << std::setw(15) << std::left <<
"---";
222 os << std::scientific << std::setprecision(2);
223 os << std::setw(10) << std::left <<
state_->searchSize;
224 os << std::scientific << std::setprecision(6);
225 os << std::setw(8) << std::left <<
state_->nfval;
226 os << std::setw(8) << std::left <<
state_->ngrad;
227 os << std::setw(8) << std::left <<
"---";
232 os << std::setw(6) << std::left <<
state_->iter;
233 os << std::setw(15) << std::left <<
state_->value;
234 os << std::setw(15) << std::left <<
gnorm_;
236 os << std::setw(15) << std::left <<
state_->snorm;
237 os << std::scientific << std::setprecision(2);
238 os << std::setw(10) << std::left <<
state_->searchSize;
239 os << std::scientific << std::setprecision(6);
240 os << std::setw(8) << std::left <<
state_->nfval;
241 os << std::setw(8) << std::left <<
state_->ngrad;
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
Provides the interface to apply upper and lower bound constraints.
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)
int getNumberGradientEvaluations(void)
Real testComplementarity(const Vector< Real > &x)
int getNumberFunctionEvaluations(void)
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.
Provides an interface to check status of optimization algorithms.
Ptr< PolyhedralProjection< Real > > proj_
void initialize(const Vector< Real > &x, const Vector< Real > &g)
Algorithm()
Constructor, given a step and a status test.
virtual void writeExitStatus(std::ostream &os) const
const Ptr< AlgorithmState< Real > > state_
const Ptr< CombinedStatusTest< Real > > status_
void updateState(const Vector< Real > &x, MoreauYosidaObjective< Real > &myobj, BoundConstraint< Real > &bnd, Vector< Real > &pwa, std::ostream &outStream=std::cout)
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...
MoreauYosidaAlgorithm(ParameterList &list, const Ptr< Secant< Real > > &secant=nullPtr)
void writeName(std::ostream &os) const override
Print step name.
const Ptr< Secant< Real > > secant_
void initialize(Vector< Real > &x, const Vector< Real > &g, MoreauYosidaObjective< Real > &myobj, BoundConstraint< Real > &bnd, Vector< Real > &pwa, std::ostream &outStream=std::cout)
void writeOutput(std::ostream &os, const bool write_header=false) const override
Print iterate status.
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 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< Algorithm< Real > > AlgorithmFactory(ParameterList &parlist, const Ptr< Secant< Real > > &secant=nullPtr)
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.