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_;
142 Real zerotol = std::sqrt(ROL_EPSILON<Real>());
149 myPen.
gradient(*(state->gradientVec), x, zerotol);
151 state->gradientVec->plus(*g_);
152 gLnorm_ = (state->gradientVec)->norm();
154 con.
value(*(state->constraintVec),x, zerotol);
155 algo_state.
cnorm = (state->constraintVec)->norm();
157 algo_state.
gnorm = std::max(gLnorm_,compViolation_);
173 :
Step<Real>(), algo_(Teuchos::null),
174 x_(Teuchos::null), g_(Teuchos::null), l_(Teuchos::null),
175 tau_(10), print_(false), parlist_(parlist), subproblemIter_(0) {
177 Real ten(10), oem6(1.e-6), oem8(1.e-8);
178 Teuchos::ParameterList& steplist = parlist.sublist(
"Step").sublist(
"Moreau-Yosida Penalty");
180 tau_ = steplist.get(
"Penalty Parameter Growth Factor",ten);
181 print_ = steplist.sublist(
"Subproblem").get(
"Print History",
false);
183 Real gtol = steplist.sublist(
"Subproblem").get(
"Optimality Tolerance",oem8);
184 Real ctol = steplist.sublist(
"Subproblem").get(
"Feasibility Tolerance",oem8);
185 Real stol = oem6*std::min(gtol,ctol);
186 int maxit = steplist.sublist(
"Subproblem").get(
"Iteration Limit",1000);
187 parlist_.sublist(
"Status Test").set(
"Gradient Tolerance", gtol);
188 parlist_.sublist(
"Status Test").set(
"Constraint Tolerance", ctol);
189 parlist_.sublist(
"Status Test").set(
"Step Tolerance", stol);
190 parlist_.sublist(
"Status Test").set(
"Iteration Limit", maxit);
202 state->descentVec = x.
clone();
203 state->gradientVec = g.
clone();
204 state->constraintVec = c.
clone();
216 algo_state.
nfval = 0;
217 algo_state.
ncval = 0;
218 algo_state.
ngrad = 0;
231 algo_ = Teuchos::rcp(
new Algorithm<Real>(
"Composite Step",parlist_,
false));
232 x_->set(x); l_->set(l);
233 algo_->run(*x_,*l_,myPen,con,print_);
235 subproblemIter_ = (algo_->getState())->iter;
247 state->descentVec->set(s);
258 state->searchSize *=
tau_;
262 algo_state.
ncval += (algo_->getState())->ncval;
271 std::stringstream hist;
273 hist << std::setw(6) << std::left <<
"iter";
274 hist << std::setw(15) << std::left <<
"fval";
275 hist << std::setw(15) << std::left <<
"cnorm";
276 hist << std::setw(15) << std::left <<
"gnorm";
277 hist << std::setw(15) << std::left <<
"ifeas";
278 hist << std::setw(15) << std::left <<
"snorm";
279 hist << std::setw(10) << std::left <<
"penalty";
280 hist << std::setw(8) << std::left <<
"#fval";
281 hist << std::setw(8) << std::left <<
"#grad";
282 hist << std::setw(8) << std::left <<
"#cval";
283 hist << std::setw(8) << std::left <<
"subIter";
291 std::stringstream hist;
292 hist <<
"\n" <<
" Moreau-Yosida Penalty solver";
300 std::stringstream hist;
301 hist << std::scientific << std::setprecision(6);
302 if ( algo_state.
iter == 0 ) {
308 if ( algo_state.
iter == 0 ) {
310 hist << std::setw(6) << std::left << algo_state.
iter;
311 hist << std::setw(15) << std::left << algo_state.
value;
312 hist << std::setw(15) << std::left << algo_state.
cnorm;
313 hist << std::setw(15) << std::left <<
gLnorm_;
315 hist << std::setw(15) << std::left <<
" ";
316 hist << std::scientific << std::setprecision(2);
317 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
322 hist << std::setw(6) << std::left << algo_state.
iter;
323 hist << std::setw(15) << std::left << algo_state.
value;
324 hist << std::setw(15) << std::left << algo_state.
cnorm;
325 hist << std::setw(15) << std::left <<
gLnorm_;
327 hist << std::setw(15) << std::left << algo_state.
snorm;
328 hist << std::scientific << std::setprecision(2);
329 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
330 hist << std::scientific << std::setprecision(6);
331 hist << std::setw(8) << std::left << algo_state.
nfval;
332 hist << std::setw(8) << std::left << algo_state.
ngrad;
333 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 is ...
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.
Real testComplementarity(const ROL::Vector< Real > &x)
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.