45#ifndef ROL_DYKSTRAPROJECTION_DEF_H
46#define ROL_DYKSTRAPROJECTION_DEF_H
50template<
typename Real>
78 mul_->setScalar(
static_cast<Real
>(1));
79 con_->applyAdjointJacobian(*
z_,*
mul_,xprim,tol);
86template<
typename Real>
95 atol_ = list.sublist(
"General").sublist(
"Polyhedral Projection").get(
"Absolute Tolerance",
DEFAULT_atol_);
96 rtol_ = list.sublist(
"General").sublist(
"Polyhedral Projection").get(
"Relative Tolerance",
DEFAULT_rtol_);
97 maxit_ = list.sublist(
"General").sublist(
"Polyhedral Projection").get(
"Iteration Limit",
DEFAULT_maxit_);
101template<
typename Real>
103 if (
con_ == nullPtr) {
111template<
typename Real>
116template<
typename Real>
120 con_->value(r,y,tol);
123template<
typename Real>
129template<
typename Real>
133 Real lam = -rhs/
cdot_;
141 x.
scale(
static_cast<Real
>(-1));
146template<
typename Real>
148 const Real one(1), xnorm(x.
norm()), ctol(std::min(
atol_,
rtol_*xnorm));
149 Real norm1(0), norm2(0), rnorm(0);
150 p_->zero();
q_->zero();
151 std::ios_base::fmtflags streamFlags(stream.flags());
153 stream << std::scientific << std::setprecision(6);
155 stream <<
" Polyhedral Projection using Dykstra's Algorithm" << std::endl;
157 stream << std::setw(6) << std::left <<
"iter";
158 stream << std::setw(15) << std::left <<
"con norm";
159 stream << std::setw(15) << std::left <<
"bnd norm";
160 stream << std::setw(15) << std::left <<
"error";
161 stream << std::setw(15) << std::left <<
"tol";
164 for (
int cnt=0; cnt <
maxit_; ++cnt) {
171 norm1 =
tmp_->norm();
178 norm2 =
tmp_->norm();
182 rnorm = std::sqrt(norm1*norm1 + norm2*norm2);
185 stream << std::setw(6) << std::left << cnt;
186 stream << std::setw(15) << std::left << norm1;
187 stream << std::setw(15) << std::left << norm2;
188 stream << std::setw(15) << std::left << rnorm;
189 stream << std::setw(15) << std::left << ctol;
192 if (rnorm <= ctol)
break;
199 stream <<
">>> ROL::PolyhedralProjection::project : Projection may be inaccurate! rnorm = ";
200 stream << rnorm <<
" rtol = " << ctol << std::endl;
202 stream.flags(streamFlags);
Provides the interface to apply upper and lower bound constraints.
Defines the general constraint operator interface.
Real residual_1d(const Vector< Real > &x) const
void residual_nd(Vector< Real > &r, const Vector< Real > &y) const
void project(Vector< Real > &x, std::ostream &stream=std::cout) override
void project_Dykstra(Vector< Real > &x, std::ostream &stream=std::cout) const
Ptr< Vector< Real > > tmp_
void project_con(Vector< Real > &x, const Vector< Real > &y) const
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)
void project_bnd(Vector< Real > &x, const Vector< Real > &y) const
const Ptr< Constraint< Real > > con_
Ptr< Vector< Real > > xprim_
const Ptr< BoundConstraint< Real > > bnd_
Ptr< Vector< Real > > mul_
Ptr< Vector< Real > > res_
PolyhedralProjection(const Ptr< BoundConstraint< Real > > &bnd)
Defines the linear algebra or vector space interface.
virtual Real norm() const =0
Returns where .
virtual void set(const Vector &x)
Set where .
virtual void scale(const Real alpha)=0
Compute where .
virtual void plus(const Vector &x)=0
Compute , where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual int dimension() const
Return dimension of the vector space.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.