44 #ifndef ROL_MOREAUYOSIDAPENALTYSTEP_H 45 #define ROL_MOREAUYOSIDAPENALTYSTEP_H 54 #include "Teuchos_ParameterList.hpp" 120 template <
class Real>
123 Teuchos::RCP<Algorithm<Real> >
algo_;
124 Teuchos::RCP<Vector<Real> >
x_;
125 Teuchos::RCP<Vector<Real> >
g_;
126 Teuchos::RCP<Vector<Real> >
l_;
140 Real zerotol = std::sqrt(ROL_EPSILON<Real>()), one(1);
147 con.
value(*(state->constraintVec),x, zerotol);
148 myPen.
gradient(*(state->gradientVec), x, zerotol);
150 state->gradientVec->plus(*
g_);
154 x_->axpy(-one,(state->gradientVec)->dual());
160 algo_state.
gnorm = (state->gradientVec)->norm();
162 algo_state.
cnorm = (state->constraintVec)->norm();
179 x_(Teuchos::null),
g_(Teuchos::null),
l_(Teuchos::null),
182 Real ten(10), oem6(1.e-6), oem8(1.e-8);
183 Teuchos::ParameterList& steplist = parlist.sublist(
"Step").sublist(
"Moreau-Yosida Penalty");
185 tau_ = steplist.get(
"Penalty Parameter Growth Factor",ten);
186 print_ = steplist.sublist(
"Subproblem").get(
"Print History",
false);
188 Real gtol = steplist.sublist(
"Subproblem").get(
"Optimality Tolerance",oem8);
189 Real ctol = steplist.sublist(
"Subproblem").get(
"Feasibility Tolerance",oem8);
190 Real stol = oem6*std::min(gtol,ctol);
191 int maxit = steplist.sublist(
"Subproblem").get(
"Iteration Limit",1000);
192 parlist_.sublist(
"Status Test").set(
"Gradient Tolerance", gtol);
193 parlist_.sublist(
"Status Test").set(
"Constraint Tolerance", ctol);
194 parlist_.sublist(
"Status Test").set(
"Step Tolerance", stol);
195 parlist_.sublist(
"Status Test").set(
"Iteration Limit", maxit);
207 state->descentVec = x.
clone();
208 state->gradientVec = g.
clone();
209 state->constraintVec = c.
clone();
221 algo_state.
nfval = 0;
222 algo_state.
ncval = 0;
223 algo_state.
ngrad = 0;
237 x_->set(x);
l_->set(l);
252 state->descentVec->set(s);
261 state->searchSize *=
tau_;
267 algo_state.
ncval += (
algo_->getState())->ncval;
276 std::stringstream hist;
278 hist << std::setw(6) << std::left <<
"iter";
279 hist << std::setw(15) << std::left <<
"fval";
280 hist << std::setw(15) << std::left <<
"cnorm";
281 hist << std::setw(15) << std::left <<
"gnorm";
282 hist << std::setw(15) << std::left <<
"snorm";
283 hist << std::setw(10) << std::left <<
"penalty";
284 hist << std::setw(8) << std::left <<
"#fval";
285 hist << std::setw(8) << std::left <<
"#grad";
286 hist << std::setw(8) << std::left <<
"#cval";
287 hist << std::setw(8) << std::left <<
"subIter";
295 std::stringstream hist;
296 hist <<
"\n" <<
" Moreau-Yosida Penalty solver";
304 std::stringstream hist;
305 hist << std::scientific << std::setprecision(6);
306 if ( algo_state.
iter == 0 ) {
312 if ( algo_state.
iter == 0 ) {
314 hist << std::setw(6) << std::left << algo_state.
iter;
315 hist << std::setw(15) << std::left << algo_state.
value;
316 hist << std::setw(15) << std::left << algo_state.
cnorm;
317 hist << std::setw(15) << std::left << algo_state.
gnorm;
318 hist << std::setw(15) << std::left <<
" ";
319 hist << std::scientific << std::setprecision(2);
320 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
325 hist << std::setw(6) << std::left << algo_state.
iter;
326 hist << std::setw(15) << std::left << algo_state.
value;
327 hist << std::setw(15) << std::left << algo_state.
cnorm;
328 hist << std::setw(15) << std::left << algo_state.
gnorm;
329 hist << std::setw(15) << std::left << algo_state.
snorm;
330 hist << std::scientific << std::setprecision(2);
331 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
332 hist << std::scientific << std::setprecision(6);
333 hist << std::setw(8) << std::left << algo_state.
nfval;
334 hist << std::setw(8) << std::left << algo_state.
ngrad;
335 hist << std::setw(8) << std::left << algo_state.
ncval;
Provides the interface to evaluate objective functions.
~MoreauYosidaPenaltyStep()
Teuchos::RCP< Algorithm< Real > > algo_
std::string printName(void) const
Print step name.
Teuchos::RCP< Vector< Real > > x_
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Provides the interface to compute optimization steps.
int getNumberGradientEvaluations(void)
Teuchos::RCP< StepState< Real > > getState(void)
Contains definitions of custom data types in ROL.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Teuchos::RCP< Vector< Real > > l_
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
std::string printHeader(void) const
Print iterate header.
Implements the computation of optimization steps using Moreau-Yosida regularized bound constraints...
void updateMultipliers(Real mu, const ROL::Vector< Real > &x)
std::string print(AlgorithmState< Real > &algo_state, bool pHeader=false) const
Print iterate status.
Defines the linear algebra or vector space interface.
void compute(Vector< Real > &s, const Vector< Real > &x, const Vector< Real > &l, Objective< Real > &obj, EqualityConstraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step (equality and bound constraints).
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 i...
State for algorithm class. Will be used for restarts.
void updateState(const Vector< Real > &x, const Vector< Real > &l, Objective< Real > &obj, EqualityConstraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
bool isActivated(void)
Check if bounds are on.
Defines the equality constraint operator interface.
Teuchos::RCP< Vector< Real > > g_
Provides an interface to run optimization algorithms.
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 gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Provides the interface to apply upper and lower bound constraints.
Teuchos::ParameterList parlist_
int getNumberFunctionEvaluations(void)
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Compute step for bound constraints; here only to satisfy the interface requirements, does nothing, needs refactoring.
void update(Vector< Real > &x, Vector< Real > &l, const Vector< Real > &s, Objective< Real > &obj, EqualityConstraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful (equality and bound constraints).
Teuchos::RCP< Vector< Real > > lagmultVec
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update Moreau-Yosida penalty function.
Teuchos::RCP< Vector< Real > > iterateVec
virtual void set(const Vector &x)
Set where .
virtual Real norm() const =0
Returns where .
virtual void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)=0
Evaluate the constraint operator at .
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Update step, for bound constraints; here only to satisfy the interface requirements, does nothing, needs refactoring.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
MoreauYosidaPenaltyStep(Teuchos::ParameterList &parlist)
void initialize(Vector< Real > &x, const Vector< Real > &g, Vector< Real > &l, const Vector< Real > &c, Objective< Real > &obj, EqualityConstraint< Real > &con, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Initialize step with equality constraint.