44#ifndef ROL_TYPEB_MOREAUYOSIDAALGORITHM_DEF_HPP
45#define ROL_TYPEB_MOREAUYOSIDAALGORITHM_DEF_HPP
52template<
typename Real>
55 tau_(10), print_(false), list_(list), subproblemIter_(0) {
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",
"Trust Region");
82 verbosity_ = list.sublist(
"General").get(
"Output Level", 0);
88template<
typename Real>
94 std::ostream &outStream) {
96 if (proj_ == nullPtr) {
97 proj_ = makePtr<PolyhedralProjection<Real>>(makePtrFromRef(bnd));
105 updateState(x,myobj,bnd,pwa,outStream);
109template<
typename Real>
114 std::ostream &outStream) {
116 Real zerotol = std::sqrt(ROL_EPSILON<Real>());
118 if (state_->iter == 0) {
130 pwa.
axpy(-one,state_->gradientVec->dual());
131 proj_->project(pwa,outStream);
136 state_->gnorm = std::max(gnorm_,compViolation_);
142template<
typename Real>
147 std::ostream &outStream ) {
149 Ptr<Vector<Real>> pwa = x.
clone();
152 x,g,state_->searchSize,updateMultiplier_,
154 initialize(x,g,myobj,bnd,*pwa,outStream);
155 Ptr<TypeU::Algorithm<Real>> algo;
158 if (verbosity_ > 0) writeOutput(outStream,
true);
160 while (status_->check(*state_)) {
162 algo = TypeU::AlgorithmFactory<Real>(list_);
163 if (hasEcon_) algo->run(x,g,myobj,*proj_->getLinearConstraint(),
164 *proj_->getMultiplier(),*proj_->getResidual(),
166 else algo->run(x,g,myobj,outStream);
167 subproblemIter_ = algo->getState()->iter;
170 state_->stepVec->set(x);
171 state_->stepVec->axpy(-one,*state_->iterateVec);
172 state_->snorm = state_->stepVec->norm();
175 state_->iterateVec->set(x);
181 updateState(x,myobj,bnd,*pwa,outStream);
184 if (updatePenalty_) {
185 state_->searchSize *= tau_;
186 state_->searchSize = std::min(state_->searchSize,maxPenalty_);
194 if (verbosity_ > 0) writeOutput(outStream,writeHeader_);
199template<
typename Real>
201 std::stringstream hist;
202 if (verbosity_ > 1) {
203 hist << std::string(109,
'-') << std::endl;
204 hist <<
"Moreau-Yosida Penalty Solver";
205 hist <<
" status output definitions" << std::endl << std::endl;
206 hist <<
" iter - Number of iterates (steps taken)" << std::endl;
207 hist <<
" fval - Objective function value" << std::endl;
208 hist <<
" gnorm - Norm of the gradient" << std::endl;
209 hist <<
" ifeas - Infeasibility metric" << std::endl;
210 hist <<
" snorm - Norm of the step (update to optimization vector)" << std::endl;
211 hist <<
" penalty - Penalty parameter for bound constraints" << std::endl;
212 hist <<
" #fval - Cumulative number of times the objective function was evaluated" << std::endl;
213 hist <<
" #grad - Cumulative number of times the gradient was computed" << std::endl;
214 hist <<
" subiter - Number of subproblem iterations" << std::endl;
215 hist << std::string(109,
'-') << std::endl;
219 hist << std::setw(6) << std::left <<
"iter";
220 hist << std::setw(15) << std::left <<
"fval";
221 hist << std::setw(15) << std::left <<
"gnorm";
222 hist << std::setw(15) << std::left <<
"ifeas";
223 hist << std::setw(15) << std::left <<
"snorm";
224 hist << std::setw(10) << std::left <<
"penalty";
225 hist << std::setw(8) << std::left <<
"#fval";
226 hist << std::setw(8) << std::left <<
"#grad";
227 hist << std::setw(8) << std::left <<
"subIter";
232template<
typename Real>
234 std::stringstream hist;
235 hist << std::endl <<
" Moreau-Yosida Penalty Solver";
240template<
typename Real>
242 std::stringstream hist;
243 hist << std::scientific << std::setprecision(6);
244 if ( state_->iter == 0 ) writeName(os);
245 if ( write_header ) writeHeader(os);
246 if ( state_->iter == 0 ) {
248 hist << std::setw(6) << std::left << state_->iter;
249 hist << std::setw(15) << std::left << state_->value;
250 hist << std::setw(15) << std::left << gnorm_;
251 hist << std::setw(15) << std::left << compViolation_;
252 hist << std::setw(15) << std::left <<
"---";
253 hist << std::scientific << std::setprecision(2);
254 hist << std::setw(10) << std::left << state_->searchSize;
255 hist << std::scientific << std::setprecision(6);
256 hist << std::setw(8) << std::left << state_->nfval;
257 hist << std::setw(8) << std::left << state_->ngrad;
258 hist << std::setw(8) << std::left <<
"---";
263 hist << std::setw(6) << std::left << state_->iter;
264 hist << std::setw(15) << std::left << state_->value;
265 hist << std::setw(15) << std::left << gnorm_;
266 hist << std::setw(15) << std::left << compViolation_;
267 hist << std::setw(15) << std::left << state_->snorm;
268 hist << std::scientific << std::setprecision(2);
269 hist << std::setw(10) << std::left << state_->searchSize;
270 hist << std::scientific << std::setprecision(6);
271 hist << std::setw(8) << std::left << state_->nfval;
272 hist << std::setw(8) << std::left << state_->ngrad;
273 hist << std::setw(8) << std::left << subproblemIter_;
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 an interface to check status of optimization algorithms.
Provides an interface to run bound constrained optimization algorithms.
void initialize(const Vector< Real > &x, const Vector< Real > &g)
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 writeOutput(std::ostream &os, bool write_header=false) const override
Print iterate status.
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)
void writeName(std::ostream &os) const override
Print step name.
void initialize(Vector< Real > &x, const Vector< Real > &g, MoreauYosidaObjective< Real > &myobj, BoundConstraint< Real > &bnd, Vector< Real > &pwa, std::ostream &outStream=std::cout)
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 .