10 #ifndef ROL_DOUGLASRACHFORDPROJECTION_DEF_H
11 #define ROL_DOUGLASRACHFORDPROJECTION_DEF_H
15 template<
typename Real>
24 DEFAULT_rtol_ (1e-2*std::sqrt(
ROL_EPSILON<Real>())),
25 DEFAULT_maxit_ (10000),
26 DEFAULT_verbosity_ (0),
27 DEFAULT_alpha1_ (0.5),
28 DEFAULT_gamma_ (10.0),
30 atol_ (DEFAULT_atol_),
31 rtol_ (DEFAULT_rtol_),
32 maxit_ (DEFAULT_maxit_),
33 verbosity_ (DEFAULT_verbosity_),
34 alpha1_ (DEFAULT_alpha1_),
35 alpha2_ (1.0-alpha1_),
36 gamma_ (DEFAULT_gamma_),
45 Real tol(std::sqrt(ROL_EPSILON<Real>()));
50 mul_->setScalar(static_cast<Real>(1));
51 con_->applyAdjointJacobian(*
z_,*
mul_,xprim,tol);
58 template<
typename Real>
67 atol_ = list.sublist(
"General").sublist(
"Polyhedral Projection").get(
"Absolute Tolerance",
DEFAULT_atol_);
68 rtol_ = list.sublist(
"General").sublist(
"Polyhedral Projection").get(
"Relative Tolerance",
DEFAULT_rtol_);
69 maxit_ = list.sublist(
"General").sublist(
"Polyhedral Projection").get(
"Iteration Limit",
DEFAULT_maxit_);
71 alpha1_ = list.sublist(
"General").sublist(
"Polyhedral Projection").sublist(
"Douglas-Rachford").get(
"Constraint Weight",
DEFAULT_alpha1_);
73 gamma_ = list.sublist(
"General").sublist(
"Polyhedral Projection").sublist(
"Douglas-Rachford").get(
"Penalty Parameter",
DEFAULT_gamma_);
74 t0_ = list.sublist(
"General").sublist(
"Polyhedral Projection").sublist(
"Douglas-Rachford").get(
"Relaxation Parameter",
DEFAULT_t0_);
77 template<
typename Real>
79 if (con_ == nullPtr) {
83 project_DouglasRachford(x, stream);
87 template<
typename Real>
89 return xprim_->dot(x) + b_;
92 template<
typename Real>
94 Real tol(std::sqrt(ROL_EPSILON<Real>()));
99 template<
typename Real>
105 template<
typename Real>
108 Real rhs = residual_1d(y);
109 Real lam = -rhs/cdot_;
114 Real tol = std::sqrt(ROL_EPSILON<Real>());
115 residual_nd(*res_,y);
116 con_->solveAugmentedSystem(x,*mul_,*z_,*res_,y,tol);
117 x.
scale(static_cast<Real>(-1));
122 template<
typename Real>
124 const Real one(1), two(2), xnorm(x.
norm()), ctol(std::min(atol_,rtol_*xnorm));
126 p_->zero(); q_->zero(); y_->set(x);
127 std::ios_base::fmtflags streamFlags(stream.flags());
128 if (verbosity_ > 2) {
129 stream << std::scientific << std::setprecision(6);
131 stream <<
" Polyhedral Projection using Douglas Rachford Splitting" << std::endl;
133 stream << std::setw(6) << std::left <<
"iter";
134 stream << std::setw(15) << std::left <<
"error";
135 stream << std::setw(15) << std::left <<
"tol";
138 for (
int cnt=0; cnt < maxit_; ++cnt) {
141 tmp_->axpy(alpha1_*gamma_,x);
142 tmp_->scale(one/(alpha1_*gamma_+one));
143 project_con(*p_,*tmp_);
147 tmp_->axpy(-one,*y_);
148 tmp_->axpy(alpha2_*gamma_,x);
149 tmp_->scale(one/(alpha2_*gamma_+one));
150 project_bnd(*q_,*tmp_);
153 tmp_->axpy(-one,*p_);
154 rnorm = tmp_->norm();
155 if (verbosity_ > 2) {
157 stream << std::setw(6) << std::left << cnt;
158 stream << std::setw(15) << std::left << rnorm;
159 stream << std::setw(15) << std::left << ctol;
162 if (rnorm <= ctol)
break;
165 if (verbosity_ > 2) stream << std::endl;
169 stream <<
">>> ROL::PolyhedralProjection::project : Projection may be inaccurate! rnorm = ";
170 stream << rnorm <<
" rtol = " << ctol << std::endl;
172 stream.flags(streamFlags);
void project_DouglasRachford(Vector< Real > &x, std::ostream &stream=std::cout) const
Ptr< Vector< Real > > xprim_
void project_bnd(Vector< Real > &x, const Vector< Real > &y) const
virtual void scale(const Real alpha)=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.
Ptr< Vector< Real > > res_
void project(Vector< Real > &x, std::ostream &stream=std::cout) override
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
DouglasRachfordProjection(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)
Real residual_1d(const Vector< Real > &x) const
Defines the linear algebra or vector space interface.
Ptr< Vector< Real > > tmp_
const Ptr< Constraint< Real > > con_
Ptr< Vector< Real > > mul_
void residual_nd(Vector< Real > &r, const Vector< Real > &y) const
void project_con(Vector< Real > &x, const Vector< Real > &y) const
Provides the interface to apply upper and lower bound constraints.
virtual void set(const Vector &x)
Set where .
virtual Real norm() const =0
Returns where .
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Defines the general constraint operator interface.