10 #ifndef ROL_DYKSTRAPROJECTION_DEF_H
11 #define ROL_DYKSTRAPROJECTION_DEF_H
15 template<
typename Real>
25 DEFAULT_maxit_ (10000),
26 DEFAULT_verbosity_ (0),
27 atol_ (DEFAULT_atol_),
28 rtol_ (DEFAULT_rtol_),
29 maxit_ (DEFAULT_maxit_),
30 verbosity_ (DEFAULT_verbosity_) {
38 Real tol(std::sqrt(ROL_EPSILON<Real>()));
43 mul_->setScalar(static_cast<Real>(1));
44 con_->applyAdjointJacobian(*
z_,*
mul_,xprim,tol);
51 template<
typename Real>
60 atol_ = list.sublist(
"General").sublist(
"Polyhedral Projection").get(
"Absolute Tolerance",
DEFAULT_atol_);
61 rtol_ = list.sublist(
"General").sublist(
"Polyhedral Projection").get(
"Relative Tolerance",
DEFAULT_rtol_);
62 maxit_ = list.sublist(
"General").sublist(
"Polyhedral Projection").get(
"Iteration Limit",
DEFAULT_maxit_);
66 template<
typename Real>
68 if (con_ == nullPtr) {
72 project_Dykstra(x, stream);
76 template<
typename Real>
78 return xprim_->dot(x) + b_;
81 template<
typename Real>
83 Real tol(std::sqrt(ROL_EPSILON<Real>()));
88 template<
typename Real>
94 template<
typename Real>
97 Real rhs = residual_1d(y);
98 Real lam = -rhs/cdot_;
103 Real tol = std::sqrt(ROL_EPSILON<Real>());
104 residual_nd(*res_,y);
105 con_->solveAugmentedSystem(x,*mul_,*z_,*res_,y,tol);
106 x.
scale(static_cast<Real>(-1));
111 template<
typename Real>
113 const Real one(1), xnorm(x.
norm()), ctol(std::min(atol_,rtol_*xnorm));
114 Real norm1(0), norm2(0), rnorm(0);
115 p_->zero(); q_->zero();
116 std::ios_base::fmtflags streamFlags(stream.flags());
117 if (verbosity_ > 2) {
118 stream << std::scientific << std::setprecision(6);
120 stream <<
" Polyhedral Projection using Dykstra's Algorithm" << std::endl;
122 stream << std::setw(6) << std::left <<
"iter";
123 stream << std::setw(15) << std::left <<
"con norm";
124 stream << std::setw(15) << std::left <<
"bnd norm";
125 stream << std::setw(15) << std::left <<
"error";
126 stream << std::setw(15) << std::left <<
"tol";
129 for (
int cnt=0; cnt < maxit_; ++cnt) {
131 tmp_->set(x); tmp_->plus(*p_);
132 project_con(*y_,*tmp_);
133 p_->set(*tmp_); p_->axpy(-one,*y_);
135 tmp_->set(x); tmp_->axpy(-one,*y_);
136 norm1 = tmp_->norm();
138 tmp_->set(*y_); tmp_->plus(*q_);
139 project_bnd(x,*tmp_);
140 q_->set(*tmp_); q_->axpy(-one,x);
142 tmp_->set(x); tmp_->axpy(-one,*y_);
143 norm2 = tmp_->norm();
147 rnorm = std::sqrt(norm1*norm1 + norm2*norm2);
148 if (verbosity_ > 2) {
150 stream << std::setw(6) << std::left << cnt;
151 stream << std::setw(15) << std::left << norm1;
152 stream << std::setw(15) << std::left << norm2;
153 stream << std::setw(15) << std::left << rnorm;
154 stream << std::setw(15) << std::left << ctol;
157 if (rnorm <= ctol)
break;
159 if (verbosity_ > 2) {
164 stream <<
">>> ROL::PolyhedralProjection::project : Projection may be inaccurate! rnorm = ";
165 stream << rnorm <<
" rtol = " << ctol << std::endl;
167 stream.flags(streamFlags);
Ptr< Vector< Real > > xprim_
virtual void scale(const Real alpha)=0
Compute where .
Real residual_1d(const Vector< Real > &x) const
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual int dimension() const
Return dimension of the vector space.
Ptr< Vector< Real > > res_
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
void project(Vector< Real > &x, std::ostream &stream=std::cout) override
void residual_nd(Vector< Real > &r, const Vector< Real > &y) const
Defines the linear algebra or vector space interface.
Ptr< Vector< Real > > tmp_
void project_con(Vector< Real > &x, const Vector< Real > &y) const
const Ptr< Constraint< Real > > con_
Ptr< Vector< Real > > mul_
void project_bnd(Vector< Real > &x, const Vector< Real > &y) const
Provides the interface to apply upper and lower bound constraints.
DykstraProjection(const Vector< Real > &xprim, const Vector< Real > &xdual, const Ptr< BoundConstraint< Real >> &bnd, const Ptr< Constraint< Real >> &con, const Vector< Real > &mul, const Vector< Real > &res)
virtual void set(const Vector &x)
Set where .
virtual Real norm() const =0
Returns where .
void project_Dykstra(Vector< Real > &x, std::ostream &stream=std::cout) const
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Defines the general constraint operator interface.