44 #ifndef ROL_PRIMALDUALACTIVESETSTEP_H 45 #define ROL_PRIMALDUALACTIVESETSTEP_H 54 #include "Teuchos_ParameterList.hpp" 132 template <
class Real>
156 Teuchos::RCP<Vector<Real> >
x0_;
158 Teuchos::RCP<Vector<Real> >
As_;
160 Teuchos::RCP<Vector<Real> >
res_;
161 Teuchos::RCP<Vector<Real> >
Ag_;
173 const Teuchos::RCP<Objective<Real> >
obj_;
174 const Teuchos::RCP<BoundConstraint<Real> >
bnd_;
175 const Teuchos::RCP<Vector<Real> >
x_;
176 const Teuchos::RCP<Vector<Real> >
xlam_;
177 Teuchos::RCP<Vector<Real> >
v_;
187 const Teuchos::RCP<
Secant<Real> > &secant = Teuchos::null,
188 const bool useSecant =
false )
192 if ( !useSecant || secant == Teuchos::null ) {
211 const Teuchos::RCP<Objective<Real> >
obj_;
212 const Teuchos::RCP<BoundConstraint<Real> >
bnd_;
213 const Teuchos::RCP<Vector<Real> >
x_;
214 const Teuchos::RCP<Vector<Real> >
xlam_;
215 Teuchos::RCP<Vector<Real> >
v_;
225 const Teuchos::RCP<
Secant<Real> > &secant = Teuchos::null,
226 const bool useSecant =
false )
230 if ( !useSecant || secant == Teuchos::null ) {
265 obj.
gradient(*(step_state->gradientVec),x,tol);
267 xtmp_->axpy(-one,(step_state->gradientVec)->dual());
270 return xtmp_->norm();
286 xbnd_(Teuchos::null),
As_(Teuchos::null),
xtmp_(Teuchos::null),
287 res_(Teuchos::null),
Ag_(Teuchos::null),
rtmp_(Teuchos::null),
288 gtmp_(Teuchos::null),
291 Real one(1), oem6(1.e-6), oem8(1.e-8);
293 maxit_ = parlist.sublist(
"Step").sublist(
"Primal Dual Active Set").get(
"Iteration Limit",10);
294 stol_ = parlist.sublist(
"Step").sublist(
"Primal Dual Active Set").get(
"Relative Step Tolerance",oem8);
295 gtol_ = parlist.sublist(
"Step").sublist(
"Primal Dual Active Set").get(
"Relative Gradient Tolerance",oem6);
296 scale_ = parlist.sublist(
"Step").sublist(
"Primal Dual Active Set").get(
"Dual Scaling", one);
298 esec_ =
StringToESecant(parlist.sublist(
"General").sublist(
"Secant").get(
"Type",
"Limited-Memory BFGS"));
299 useSecantHessVec_ = parlist.sublist(
"General").sublist(
"Secant").get(
"Use as Hessian",
false);
300 useSecantPrecond_ = parlist.sublist(
"General").sublist(
"Secant").get(
"Use as Preconditioner",
false);
302 secant_ = SecantFactory<Real>(parlist);
305 krylov_ = KrylovFactory<Real>(parlist);
323 Real zero(0), one(1);
325 step_state->descentVec = s.
clone();
326 step_state->gradientVec = g.
clone();
327 step_state->searchSize = zero;
341 Real tol = std::sqrt(ROL_EPSILON<Real>());
349 lambda_->set((step_state->gradientVec)->dual());
382 Real zero(0), one(1);
385 res_->set(*(step_state->gradientVec));
413 itol_ = std::sqrt(ROL_EPSILON<Real>());
424 rtmp_->set(*(step_state->gradientVec));
427 Ag_->set(*(step_state->gradientVec));
435 if (
rtmp_->norm() > zero ) {
437 Teuchos::RCP<Objective<Real> > obj_ptr = Teuchos::rcpFromRef(obj);
438 Teuchos::RCP<BoundConstraint<Real> > con_ptr = Teuchos::rcpFromRef(con);
439 Teuchos::RCP<LinearOperator<Real> > hessian
440 = Teuchos::rcp(
new HessianPD(obj_ptr,con_ptr,
442 Teuchos::RCP<LinearOperator<Real> > precond
443 = Teuchos::rcp(
new PrecondPD(obj_ptr,con_ptr,
470 res_->set(*(step_state->gradientVec));
519 Real tol = std::sqrt(ROL_EPSILON<Real>());
524 if (
secant_ != Teuchos::null ) {
525 gtmp_->set(*(step_state->gradientVec));
530 if (
secant_ != Teuchos::null ) {
542 std::stringstream hist;
544 hist << std::setw(6) << std::left <<
"iter";
545 hist << std::setw(15) << std::left <<
"value";
546 hist << std::setw(15) << std::left <<
"gnorm";
547 hist << std::setw(15) << std::left <<
"snorm";
548 hist << std::setw(10) << std::left <<
"#fval";
549 hist << std::setw(10) << std::left <<
"#grad";
551 hist << std::setw(10) << std::left <<
"iterPDAS";
552 hist << std::setw(10) << std::left <<
"flagPDAS";
555 hist << std::setw(10) << std::left <<
"iterCR";
556 hist << std::setw(10) << std::left <<
"flagCR";
558 hist << std::setw(10) << std::left <<
"feasible";
569 std::stringstream hist;
570 hist <<
"\nPrimal Dual Active Set Newton's Method\n";
582 std::stringstream hist;
583 hist << std::scientific << std::setprecision(6);
584 if ( algo_state.
iter == 0 ) {
587 if ( print_header ) {
590 if ( algo_state.
iter == 0 ) {
592 hist << std::setw(6) << std::left << algo_state.
iter;
593 hist << std::setw(15) << std::left << algo_state.
value;
594 hist << std::setw(15) << std::left << algo_state.
gnorm;
599 hist << std::setw(6) << std::left << algo_state.
iter;
600 hist << std::setw(15) << std::left << algo_state.
value;
601 hist << std::setw(15) << std::left << algo_state.
gnorm;
602 hist << std::setw(15) << std::left << algo_state.
snorm;
603 hist << std::setw(10) << std::left << algo_state.
nfval;
604 hist << std::setw(10) << std::left << algo_state.
ngrad;
606 hist << std::setw(10) << std::left <<
iter_;
607 hist << std::setw(10) << std::left <<
flag_;
610 hist << std::setw(10) << std::left <<
iterCR_;
611 hist << std::setw(10) << std::left <<
flagCR_;
614 hist << std::setw(10) << std::left <<
"YES";
617 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.
virtual void plus(const Vector &x)=0
Compute , where .
int iter_
PDAS iteration counter.
int iterCR_
CR iteration counter.
const Teuchos::RCP< Vector< Real > > xlam_
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 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, .
const Teuchos::RCP< Secant< Real > > secant_
Defines the linear algebra or vector space interface.
const Teuchos::RCP< BoundConstraint< Real > > bnd_
Teuchos::RCP< Vector< Real > > x0_
Container for initial priaml variables.
std::string printName(void) const
Print step name.
virtual void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -active set.
Teuchos::RCP< Vector< Real > > lambda_
Container for dual variables.
virtual void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the lower -active set.
std::string printHeader(void) const
Print iterate header.
const Teuchos::RCP< Objective< Real > > obj_
int flagCR_
CR termination flag.
int flag_
PDAS termination flag.
State for algorithm class. Will be used for restarts.
const Teuchos::RCP< Objective< Real > > obj_
HessianPD(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< BoundConstraint< Real > > &bnd, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< Vector< Real > > &xlam, const Real eps=0, const Teuchos::RCP< Secant< Real > > &secant=Teuchos::null, const bool useSecant=false)
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
PrecondPD(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< BoundConstraint< Real > > &bnd, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< Vector< Real > > &xlam, const Real eps=0, const Teuchos::RCP< Secant< Real > > &secant=Teuchos::null, const bool useSecant=false)
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
ESecant
Enumeration of secant update algorithms.
const Teuchos::RCP< Vector< Real > > x_
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.
const Teuchos::RCP< Vector< Real > > xlam_
bool feasible_
Flag whether the current iterate is feasible or not.
Provides interface for and implements limited-memory secant operators.
Real computeCriticalityMeasure(Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &con, Real tol)
Compute the gradient-based criticality measure.
virtual void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the upper -active set.
Teuchos::RCP< Vector< Real > > xbnd_
Container for primal variable bounds.
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
Teuchos::RCP< Vector< Real > > v_
Teuchos::RCP< Vector< Real > > v_
const Teuchos::RCP< Secant< Real > > secant_
Teuchos::RCP< Vector< Real > > xlam_
Container for primal plus dual variables.
Provides the interface to apply a linear operator.
virtual void setVectorToLowerBound(Vector< Real > &l)
Set the input vector to the lower bound.
Provides the interface to apply upper and lower bound constraints.
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.
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
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 set(const Vector &x)
Set where .
virtual Real norm() const =0
Returns where .
const Teuchos::RCP< Vector< Real > > x_
Real itol_
Inexact CR tolerance.
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
const Teuchos::RCP< BoundConstraint< Real > > bnd_
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
ESecant esec_
Enum for secant type.
virtual std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
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.
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.
Teuchos::RCP< Vector< Real > > Ag_
Container for gradient projected onto active set.