44 #ifndef ROL_MOREAUYOSIDAPENALTYSTEP_H 45 #define ROL_MOREAUYOSIDAPENALTYSTEP_H 54 #include "Teuchos_ParameterList.hpp" 120 template <
class Real>
123 Teuchos::RCP<MoreauYosidaPenalty<Real> >
myPen_;
124 Teuchos::RCP<Algorithm<Real> >
algo_;
125 Teuchos::RCP<Vector<Real> >
x_;
126 Teuchos::RCP<Vector<Real> >
g_;
127 Teuchos::RCP<Vector<Real> >
l_;
144 myPen_->update(x,
true,algo_state.
iter);
146 algo_state.
value = myPen_->value(x, zerotol);
147 con.
value(*(state->constraintVec),x, zerotol);
148 myPen_->gradient(*(state->gradientVec), x, zerotol);
150 state->gradientVec->plus(*g_);
154 x_->axpy(-1.0,(state->gradientVec)->dual());
157 algo_state.
gnorm = x_->norm();
160 algo_state.
gnorm = (state->gradientVec)->norm();
162 algo_state.
cnorm = (state->constraintVec)->norm();
173 :
Step<Real>(), myPen_(Teuchos::null), algo_(Teuchos::null),
174 x_(Teuchos::null), g_(Teuchos::null), l_(Teuchos::null),
175 tau_(10.), print_(false), parlist_(parlist), subproblemIter_(0) {
177 Teuchos::ParameterList& steplist = parlist.sublist(
"Step").sublist(
"Moreau-Yosida Penalty");
179 tau_ = steplist.get(
"Penalty Parameter Growth Factor",10.0);
180 print_ = steplist.sublist(
"Subproblem").get(
"Print History",
false);
182 Real gtol = steplist.sublist(
"Subproblem").get(
"Optimality Tolerance",1.e-8);
183 Real ctol = steplist.sublist(
"Subproblem").get(
"Feasibility Tolerance",1.e-8);
184 Real stol = 1.e-6*std::min(gtol,ctol);
185 int maxit = steplist.sublist(
"Subproblem").get(
"Iteration Limit",1000);
186 parlist_.sublist(
"Status Test").set(
"Gradient Tolerance", gtol);
187 parlist_.sublist(
"Status Test").set(
"Constraint Tolerance", ctol);
188 parlist_.sublist(
"Status Test").set(
"Step Tolerance", stol);
189 parlist_.sublist(
"Status Test").set(
"Iteration Limit", maxit);
199 state->descentVec = x.
clone();
200 state->gradientVec = g.
clone();
201 state->constraintVec = c.
clone();
212 myPen_->updateMultipliers(state->searchSize,x);
214 algo_state.
nfval = 0;
215 algo_state.
ncval = 0;
216 algo_state.
ngrad = 0;
226 algo_ = Teuchos::rcp(
new Algorithm<Real>(
"Composite Step",parlist_,
false));
227 x_->set(x); l_->set(l);
228 algo_->run(*x_,*l_,*myPen_,con,print_);
230 subproblemIter_ = (algo_->getState())->iter;
240 state->descentVec->set(s);
247 myPen_->update(x,
true,algo_state.
iter);
249 state->searchSize *=
tau_;
250 myPen_->updateMultipliers(state->searchSize,x);
253 algo_state.
nfval += myPen_->getNumberFunctionEvaluations() + ((algo_->getState())->nfval);
254 algo_state.
ngrad += myPen_->getNumberGradientEvaluations() + ((algo_->getState())->ngrad);
255 algo_state.
ncval += (algo_->getState())->ncval;
264 std::stringstream hist;
266 hist << std::setw(6) << std::left <<
"iter";
267 hist << std::setw(15) << std::left <<
"fval";
268 hist << std::setw(15) << std::left <<
"cnorm";
269 hist << std::setw(15) << std::left <<
"gnorm";
270 hist << std::setw(15) << std::left <<
"snorm";
271 hist << std::setw(10) << std::left <<
"penalty";
272 hist << std::setw(8) << std::left <<
"#fval";
273 hist << std::setw(8) << std::left <<
"#grad";
274 hist << std::setw(8) << std::left <<
"#cval";
275 hist << std::setw(8) << std::left <<
"subIter";
283 std::stringstream hist;
284 hist <<
"\n" <<
" Moreau-Yosida Penalty solver";
292 std::stringstream hist;
293 hist << std::scientific << std::setprecision(6);
294 if ( algo_state.
iter == 0 ) {
300 if ( algo_state.
iter == 0 ) {
302 hist << std::setw(6) << std::left << algo_state.
iter;
303 hist << std::setw(15) << std::left << algo_state.
value;
304 hist << std::setw(15) << std::left << algo_state.
cnorm;
305 hist << std::setw(15) << std::left << algo_state.
gnorm;
306 hist << std::setw(15) << std::left <<
" ";
307 hist << std::scientific << std::setprecision(2);
308 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
313 hist << std::setw(6) << std::left << algo_state.
iter;
314 hist << std::setw(15) << std::left << algo_state.
value;
315 hist << std::setw(15) << std::left << algo_state.
cnorm;
316 hist << std::setw(15) << std::left << algo_state.
gnorm;
317 hist << std::setw(15) << std::left << algo_state.
snorm;
318 hist << std::scientific << std::setprecision(2);
319 hist << std::setw(10) << std::left << Step<Real>::getStepState()->searchSize;
320 hist << std::scientific << std::setprecision(6);
321 hist << std::setw(8) << std::left << algo_state.
nfval;
322 hist << std::setw(8) << std::left << algo_state.
ngrad;
323 hist << std::setw(8) << std::left << algo_state.
ncval;
Provides the interface to evaluate objective functions.
~MoreauYosidaPenaltyStep()
Teuchos::RCP< Algorithm< Real > > algo_
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 .
std::string printHeader(void) const
Print iterate header.
Provides the interface to compute optimization steps.
Teuchos::RCP< StepState< Real > > getState(void)
Contains definitions of custom data types in ROL.
Teuchos::RCP< Vector< Real > > l_
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Teuchos::RCP< MoreauYosidaPenalty< Real > > myPen_
Implements the computation of optimization steps using Moreau-Yosida regularized bound constraints...
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.
Provides the interface to apply upper and lower bound constraints.
Teuchos::ParameterList parlist_
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).
std::string printName(void) const
Print step name.
Teuchos::RCP< Vector< Real > > lagmultVec
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 .
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
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.
std::string print(AlgorithmState< Real > &algo_state, bool pHeader=false) const
Print iterate status.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
MoreauYosidaPenaltyStep(Teuchos::ParameterList &parlist)
static const double ROL_EPSILON
Platform-dependent machine epsilon.
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.