ROL
ROL_BallIndicatorObjective.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_BALLINDICATOROBJECTIVE_H
11 #define ROL_BALLINDICATOROBJECTIVE_H
12 
13 #include "ROL_Objective.hpp"
14 
23 namespace ROL {
24 
25 template<typename Real>
26 class BallIndicatorObjective : public Objective<Real> {
27 private:
28  const Ptr<Vector<Real>> x_, pwa_;
29  const Real rad_;
30 
31 public:
32 
33  BallIndicatorObjective(const Ptr<Vector<Real>> &x, Real rad)
34  : x_(x), pwa_(x->clone()), rad_(rad) {}
35 
36  Real value( const Vector<Real> &x, Real &tol ) {
37  const Real zero(0), one(1);
38  pwa_->set(x); pwa_->axpy(-one,*x_);
39  Real norm = pwa_->norm();
40  return (norm <= rad_) ? zero : ROL_INF<Real>();
41  }
42 
43  void prox( Vector<Real> &Pv, const Vector<Real> &v, Real t, Real &tol){
44  pwa_->set(v); pwa_->axpy(-one,*x_);
45  Real norm = pwa_->norm();
46  if(norm <= rad_) {
47  Pv.set(v);
48  }
49  else {
50  Pv.set(*x_);
51  Pv.axpy(rad_/norm,*pwa_);
52  }
53  }
54 }; // class BallIndicatorObjective
55 
56 } // namespace ROL
57 
58 #endif
BallIndicatorObjective(const Ptr< Vector< Real >> &x, Real rad)
Provides the interface to evaluate objective functions.
void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition: ROL_Vector.hpp:119
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Provides the interface to evaluate the indicator function of norm constraints.
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:175
const Ptr< Vector< Real > > pwa_
Real value(const Vector< Real > &x, Real &tol)
Compute value.