44 #ifndef ROL_PRIMALDUALACTIVESETSTEP_H 45 #define ROL_PRIMALDUALACTIVESETSTEP_H 56 #include "Teuchos_ParameterList.hpp" 134 template <
class Real>
139 Teuchos::RCP<PrimalDualPreconditioner<Real> >
precond_;
160 Teuchos::RCP<Vector<Real> >
x0_;
162 Teuchos::RCP<Vector<Real> >
As_;
164 Teuchos::RCP<Vector<Real> >
res_;
165 Teuchos::RCP<Vector<Real> >
Ag_;
189 obj.
gradient(*(step_state->gradientVec),x,tol);
191 xtmp_->axpy(-1.0,(step_state->gradientVec)->dual());
194 return xtmp_->norm();
206 hessian_(Teuchos::null), precond_(Teuchos::null), krylov_(Teuchos::null),
207 iterCR_(0), flagCR_(0), itol_(0.),
208 maxit_(0), iter_(0), flag_(0), stol_(0.), gtol_(0.), scale_(0.),
210 lambda_(Teuchos::null), xlam_(Teuchos::null), x0_(Teuchos::null),
211 xbnd_(Teuchos::null), As_(Teuchos::null), xtmp_(Teuchos::null),
212 res_(Teuchos::null), Ag_(Teuchos::null), rtmp_(Teuchos::null),
213 gtmp_(Teuchos::null),
214 esec_(
SECANT_LBFGS), secant_(Teuchos::null), useSecantPrecond_(false),
215 useSecantHessVec_(false) {
217 maxit_ = parlist.sublist(
"Step").sublist(
"Primal Dual Active Set").get(
"Iteration Limit",10);
218 stol_ = parlist.sublist(
"Step").sublist(
"Primal Dual Active Set").get(
"Relative Step Tolerance",1.e-8);
219 gtol_ = parlist.sublist(
"Step").sublist(
"Primal Dual Active Set").get(
"Relative Gradient Tolerance",1.e-6);
220 scale_ = parlist.sublist(
"Step").sublist(
"Primal Dual Active Set").get(
"Dual Scaling", 1.0);
222 esec_ =
StringToESecant(parlist.sublist(
"General").sublist(
"Secant").get(
"Type",
"Limited-Memory BFGS"));
223 useSecantHessVec_ = parlist.sublist(
"General").sublist(
"Secant").get(
"Use as Hessian",
false);
224 useSecantPrecond_ = parlist.sublist(
"General").sublist(
"Secant").get(
"Use as Preconditioner",
false);
225 if ( useSecantHessVec_ || useSecantPrecond_ ) {
226 secant_ = SecantFactory<Real>(parlist);
229 krylov_ = KrylovFactory<Real>(parlist);
248 step_state->descentVec = s.
clone();
249 step_state->gradientVec = g.
clone();
250 step_state->searchSize = 0.0;
272 lambda_->set((step_state->gradientVec)->dual());
273 lambda_->scale(-1.0);
276 Teuchos::RCP<Objective<Real> > obj_ptr = Teuchos::rcp(&obj,
false);
277 Teuchos::RCP<BoundConstraint<Real> > con_ptr = Teuchos::rcp(&con,
false);
278 hessian_ = Teuchos::rcp(
280 precond_ = Teuchos::rcp(
282 useSecantPrecond_) );
315 res_->set(*(step_state->gradientVec));
316 for ( iter_ = 0; iter_ <
maxit_; iter_++ ) {
321 xlam_->axpy(scale_,*(lambda_));
331 xbnd_->axpy(-1.0,*xtmp_);
338 xbnd_->axpy(-1.0,*xtmp_);
344 if ( useSecantHessVec_ && secant_ != Teuchos::null ) {
345 secant_->applyB(*gtmp_,*As_,x);
348 obj.
hessVec(*gtmp_,*As_,x,itol_);
354 rtmp_->set(*(step_state->gradientVec));
357 Ag_->set(*(step_state->gradientVec));
358 Ag_->axpy(-1.0,*rtmp_);
365 if ( rtmp_->norm() > 0.0 ) {
367 krylov_->run(s,*hessian_,*rtmp_,*precond_,iterCR_,flagCR_);
374 if ( useSecantHessVec_ && secant_ != Teuchos::null ) {
375 secant_->applyB(*rtmp_,s,x);
382 lambda_->set(*rtmp_);
383 lambda_->axpy(-1.0,*gtmp_);
385 lambda_->scale(-1.0);
391 res_->set(*(step_state->gradientVec));
395 xtmp_->axpy(-1.0,res_->dual());
397 xtmp_->axpy(-1.0,*x0_);
404 if ( xtmp_->norm() < gtol_*algo_state.
gnorm ) {
413 if ( iter_ == maxit_ ) {
445 if ( secant_ != Teuchos::null ) {
446 gtmp_->set(*(step_state->gradientVec));
451 if ( secant_ != Teuchos::null ) {
452 secant_->update(*(step_state->gradientVec),*gtmp_,s,algo_state.
snorm,algo_state.
iter+1);
463 std::stringstream hist;
465 hist << std::setw(6) << std::left <<
"iter";
466 hist << std::setw(15) << std::left <<
"value";
467 hist << std::setw(15) << std::left <<
"gnorm";
468 hist << std::setw(15) << std::left <<
"snorm";
469 hist << std::setw(10) << std::left <<
"#fval";
470 hist << std::setw(10) << std::left <<
"#grad";
472 hist << std::setw(10) << std::left <<
"iterPDAS";
473 hist << std::setw(10) << std::left <<
"flagPDAS";
476 hist << std::setw(10) << std::left <<
"iterCR";
477 hist << std::setw(10) << std::left <<
"flagCR";
479 hist << std::setw(10) << std::left <<
"feasible";
490 std::stringstream hist;
491 hist <<
"\nPrimal Dual Active Set Newton's Method\n";
503 std::stringstream hist;
504 hist << std::scientific << std::setprecision(6);
505 if ( algo_state.
iter == 0 ) {
508 if ( print_header ) {
511 if ( algo_state.
iter == 0 ) {
513 hist << std::setw(6) << std::left << algo_state.
iter;
514 hist << std::setw(15) << std::left << algo_state.
value;
515 hist << std::setw(15) << std::left << algo_state.
gnorm;
520 hist << std::setw(6) << std::left << algo_state.
iter;
521 hist << std::setw(15) << std::left << algo_state.
value;
522 hist << std::setw(15) << std::left << algo_state.
gnorm;
523 hist << std::setw(15) << std::left << algo_state.
snorm;
524 hist << std::setw(10) << std::left << algo_state.
nfval;
525 hist << std::setw(10) << std::left << algo_state.
ngrad;
527 hist << std::setw(10) << std::left <<
iter_;
528 hist << std::setw(10) << std::left <<
flag_;
531 hist << std::setw(10) << std::left <<
iterCR_;
532 hist << std::setw(10) << std::left <<
flagCR_;
535 hist << std::setw(10) << std::left <<
"YES";
538 hist << std::setw(10) << std::left <<
"NO";
Teuchos::RCP< Vector< Real > > rtmp_
Container for temporary right hand side storage.
Implements the computation of optimization steps with the Newton primal-dual active set method...
Provides the interface to evaluate objective functions.
Teuchos::RCP< Vector< Real > > As_
Container for step projected onto active set.
std::string printName(void) const
Print step name.
virtual void plus(const Vector &x)=0
Compute , where .
std::string printHeader(void) const
Print iterate header.
int iter_
PDAS iteration counter.
int iterCR_
CR iteration counter.
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Provides the interface to compute optimization steps.
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Teuchos::RCP< StepState< Real > > getState(void)
Contains definitions of custom data types in ROL.
Real neps_
-active set parameter
virtual void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the lower -active set.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Teuchos::RCP< Krylov< Real > > krylov_
ESecant StringToESecant(std::string s)
virtual void setVectorToUpperBound(Vector< Real > &u)
Set the input vector to the upper bound.
Teuchos::RCP< Vector< Real > > gtmp_
Container for temporary gradient storage.
Teuchos::RCP< Secant< Real > > secant_
Secant object.
virtual void zero()
Set to zero vector.
Real scale_
Scale for dual variables in the active set, .
Defines the linear algebra or vector space interface.
Teuchos::RCP< Vector< Real > > x0_
Container for initial priaml variables.
Teuchos::RCP< Vector< Real > > lambda_
Container for dual variables.
int flagCR_
CR termination flag.
int flag_
PDAS termination flag.
State for algorithm class. Will be used for restarts.
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
ESecant
Enumeration of secant update algorithms.
void initialize(Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Initialize step.
virtual void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the upper -active set.
Teuchos::RCP< PrimalDualHessian< Real > > hessian_
bool feasible_
Flag whether the current iterate is feasible or not.
Real computeCriticalityMeasure(Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &con, Real tol)
Compute the gradient-based criticality measure.
Teuchos::RCP< Vector< Real > > xbnd_
Container for primal variable bounds.
Teuchos::RCP< Vector< Real > > xlam_
Container for primal plus dual variables.
virtual void setVectorToLowerBound(Vector< Real > &l)
Set the input vector to the lower bound.
Provides the interface to apply upper and lower bound constraints.
Teuchos::RCP< PrimalDualPreconditioner< Real > > precond_
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Compute step.
Real gtol_
PDAS gradient stopping tolerance.
PrimalDualActiveSetStep(Teuchos::ParameterList &parlist)
Constructor.
Teuchos::RCP< Vector< Real > > xtmp_
Container for temporary primal storage.
Real stol_
PDAS minimum step size stopping tolerance.
Teuchos::RCP< Vector< Real > > iterateVec
virtual void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the -active set.
virtual Real norm() const =0
Returns where .
Real itol_
Inexact CR tolerance.
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
ESecant esec_
Enum for secant type.
virtual bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Update step, if successful.
virtual std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
Teuchos::RCP< Vector< Real > > res_
Container for optimality system residual for quadratic model.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
int maxit_
Maximum number of PDAS iterations.
static const double ROL_EPSILON
Platform-dependent machine epsilon.
Teuchos::RCP< Vector< Real > > Ag_
Container for gradient projected onto active set.