44 #ifndef ROL_MOREAUYOSIDAPENALTYSTEP_H
45 #define ROL_MOREAUYOSIDAPENALTYSTEP_H
53 #include "ROL_ParameterList.hpp"
119 template <
class Real>
123 ROL::Ptr<Vector<Real> >
x_;
124 ROL::Ptr<Vector<Real> >
g_;
125 ROL::Ptr<Vector<Real> >
l_;
126 ROL::Ptr<BoundConstraint<Real> >
bnd_;
147 Real zerotol = std::sqrt(ROL_EPSILON<Real>());
154 myPen.
gradient(*(state->gradientVec), x, zerotol);
156 state->gradientVec->plus(*
g_);
157 gLnorm_ = (state->gradientVec)->norm();
159 con.
value(*(state->constraintVec),x, zerotol);
160 algo_state.
cnorm = (state->constraintVec)->norm();
175 Real zerotol = std::sqrt(ROL_EPSILON<Real>());
181 myPen.
gradient(*(state->gradientVec), x, zerotol);
182 gLnorm_ = (state->gradientVec)->norm();
184 algo_state.
cnorm =
static_cast<Real
>(0);
202 x_(ROL::nullPtr),
g_(ROL::nullPtr),
l_(ROL::nullPtr),
206 Real ten(10), oem6(1.e-6), oem8(1.e-8);
207 ROL::ParameterList& steplist = parlist.sublist(
"Step").sublist(
"Moreau-Yosida Penalty");
209 tau_ = steplist.get(
"Penalty Parameter Growth Factor",ten);
211 print_ = steplist.sublist(
"Subproblem").get(
"Print History",
false);
213 Real gtol = steplist.sublist(
"Subproblem").get(
"Optimality Tolerance",oem8);
214 Real ctol = steplist.sublist(
"Subproblem").get(
"Feasibility Tolerance",oem8);
215 Real stol = oem6*std::min(gtol,ctol);
216 int maxit = steplist.sublist(
"Subproblem").get(
"Iteration Limit",1000);
217 parlist_.sublist(
"Status Test").set(
"Gradient Tolerance", gtol);
218 parlist_.sublist(
"Status Test").set(
"Constraint Tolerance", ctol);
219 parlist_.sublist(
"Status Test").set(
"Step Tolerance", stol);
220 parlist_.sublist(
"Status Test").set(
"Iteration Limit", maxit);
222 stepname_ = steplist.sublist(
"Subproblem").get(
"Step Type",
"Composite Step");
234 state->descentVec = x.
clone();
235 state->gradientVec = g.
clone();
236 state->constraintVec = c.
clone();
246 algo_state.
nfval = 0;
247 algo_state.
ncval = 0;
248 algo_state.
ngrad = 0;
259 state->descentVec = x.
clone();
260 state->gradientVec = g.
clone();
269 algo_state.
nfval = 0;
270 algo_state.
ncval = 0;
271 algo_state.
ngrad = 0;
274 bnd_ = ROL::makePtr<BoundConstraint<Real>>();
287 Ptr<Objective<Real>> penObj;
289 Ptr<Objective<Real>> raw_obj = makePtrFromRef(obj);
290 Ptr<Constraint<Real>> raw_con = makePtrFromRef(con);
292 penObj = makePtr<AugmentedLagrangian<Real>>(raw_obj,raw_con,l,one,x,*(state->constraintVec),
parlist_);
295 Ptr<Objective<Real>> raw_obj = makePtrFromRef(obj);
296 Ptr<Constraint<Real>> raw_con = makePtrFromRef(con);
298 penObj = makePtr<Fletcher<Real>>(raw_obj,raw_con,x,*(state->constraintVec),
parlist_);
301 penObj = makePtrFromRef(obj);
306 x_->set(x);
l_->set(l);
320 algo_ = ROL::makePtr<Algorithm<Real>>(
"Trust Region",
parlist_,
false);
338 state->descentVec->set(s);
350 state->searchSize *=
tau_;
355 algo_state.
ncval += (
algo_->getState())->ncval;
369 state->descentVec->set(s);
379 state->searchSize *=
tau_;
391 std::stringstream hist;
393 hist << std::setw(6) << std::left <<
"iter";
394 hist << std::setw(15) << std::left <<
"fval";
396 hist << std::setw(15) << std::left <<
"cnorm";
398 hist << std::setw(15) << std::left <<
"gnorm";
399 hist << std::setw(15) << std::left <<
"ifeas";
400 hist << std::setw(15) << std::left <<
"snorm";
401 hist << std::setw(10) << std::left <<
"penalty";
402 hist << std::setw(8) << std::left <<
"#fval";
403 hist << std::setw(8) << std::left <<
"#grad";
405 hist << std::setw(8) << std::left <<
"#cval";
407 hist << std::setw(8) << std::left <<
"subIter";
415 std::stringstream hist;
416 hist <<
"\n" <<
" Moreau-Yosida Penalty solver";
424 std::stringstream hist;
425 hist << std::scientific << std::setprecision(6);
426 if ( algo_state.
iter == 0 ) {
432 if ( algo_state.
iter == 0 ) {
434 hist << std::setw(6) << std::left << algo_state.
iter;
435 hist << std::setw(15) << std::left << algo_state.
value;
437 hist << std::setw(15) << std::left << algo_state.
cnorm;
439 hist << std::setw(15) << std::left <<
gLnorm_;
441 hist << std::setw(15) << std::left <<
" ";
442 hist << std::scientific << std::setprecision(2);
443 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
448 hist << std::setw(6) << std::left << algo_state.
iter;
449 hist << std::setw(15) << std::left << algo_state.
value;
451 hist << std::setw(15) << std::left << algo_state.
cnorm;
453 hist << std::setw(15) << std::left <<
gLnorm_;
455 hist << std::setw(15) << std::left << algo_state.
snorm;
456 hist << std::scientific << std::setprecision(2);
457 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
458 hist << std::scientific << std::setprecision(6);
459 hist << std::setw(8) << std::left << algo_state.
nfval;
460 hist << std::setw(8) << std::left << algo_state.
ngrad;
462 hist << std::setw(8) << std::left << algo_state.
ncval;
Provides the interface to evaluate objective functions.
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update constraint functions. x is the optimization variable, flag = true if optimization variable is ...
~MoreauYosidaPenaltyStep()
EStep StringToEStep(std::string s)
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
ROL::Ptr< Vector< Real > > g_
virtual void plus(const Vector &x)=0
Compute , where .
void updateState(const Vector< Real > &x, const Vector< Real > &l, Objective< Real > &obj, Constraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
bool isActivated(void) const
Check if bounds are on.
std::string printHeader(void) const
Print iterate header.
Provides the interface to compute optimization steps.
int getNumberGradientEvaluations(void)
MoreauYosidaPenaltyStep(ROL::ParameterList &parlist)
Contains definitions of custom data types in ROL.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
ROL::Ptr< Vector< Real > > x_
void initialize(Vector< Real > &x, const Vector< Real > &g, Vector< Real > &l, const Vector< Real > &c, Objective< Real > &obj, Constraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Initialize step with equality constraint.
Implements the computation of optimization steps using Moreau-Yosida regularized bound constraints...
void updateMultipliers(Real mu, const ROL::Vector< Real > &x)
Defines the linear algebra or vector space interface.
virtual void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)=0
Evaluate the constraint operator at .
ROL::Ptr< Algorithm< Real > > algo_
ROL::Ptr< BoundConstraint< Real > > bnd_
State for algorithm class. Will be used for restarts.
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, for bound constraints.
ROL::Ptr< StepState< Real > > getState(void)
ROL::ParameterList parlist_
Provides the interface to evaluate the Moreau-Yosida penalty function.
void update(Vector< Real > &x, Vector< Real > &l, const Vector< Real > &s, Objective< Real > &obj, Constraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful (equality and bound constraints).
ROL::Ptr< Vector< Real > > iterateVec
ROL::Ptr< Vector< Real > > l_
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step for bound constraints.
void initialize(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Initialize step without equality constraint.
Provides the interface to apply upper and lower bound constraints.
int getNumberFunctionEvaluations(void)
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 .
std::string printName(void) const
Print step name.
ROL::Ptr< Vector< Real > > lagmultVec
void updateState(const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update Moreau-Yosida penalty function.
virtual void set(const Vector &x)
Set where .
virtual Real norm() const =0
Returns where .
std::string print(AlgorithmState< Real > &algo_state, bool pHeader=false) const
Print iterate status.
EStep
Enumeration of step types.
Real testComplementarity(const ROL::Vector< Real > &x)
Defines the general constraint operator interface.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
void compute(Vector< Real > &s, const Vector< Real > &x, const Vector< Real > &l, Objective< Real > &obj, Constraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step (equality and bound constraints).