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
23namespace ROL {
24
25template<typename Real>
26class BallIndicatorObjective : public Objective<Real> {
27private:
28 const Ptr<Vector<Real>> x_, pwa_;
29 const Real rad_;
30
31public:
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
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Provides the interface to evaluate the indicator function of norm constraints.
void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
Compute the proximity operator.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
BallIndicatorObjective(const Ptr< Vector< Real > > &x, Real rad)
Provides the interface to evaluate objective functions.
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .