ROL
ROL_TypeBIndicatorObjective.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_TYPEBINDICATOROBJECTIVE_H
11 #define ROL_TYPEBINDICATOROBJECTIVE_H
12 
13 #include "ROL_Objective.hpp"
15 
24 namespace ROL {
25 
26 template<typename Real>
27 class TypeBIndicatorObjective : public Objective<Real> {
28 private:
29  const Ptr<PolyhedralProjection<Real>> proj_;
30  const Ptr<Vector<Real>> res_;
31  bool isInit_;
32  Real tol_;
33 
34 public:
35 
37  : proj_(makePtr<PolyhedralProjection<Real>>(bnd)),
38  isInit_(true), tol_(0) {}
39 
41  const Vector<Real> &xdual,
42  const Ptr<BoundConstraint<Real>> &bnd,
43  const Ptr<Constraint<Real>> &con,
44  const Vector<Real> &mul,
45  const Vector<Real> &res,
46  ParameterList &list)
47  : proj_(PolyhedralProjectionFactory<Real>(xprim,xdual,bnd,con,mul,res,list)),
48  res_(res.clone()), isInit_(false) {}
49 
51  : proj_(proj), res_(proj->getResidual()->clone()), isInit_(false) {}
52 
53  void initialize(const Vector<Real> &x) {
54  if (!isInit_) {
55  auto xz = x.clone(); xz->zero();
56  Real tol(std::sqrt(ROL_EPSILON<Real>()));
57  tol_ = static_cast<Real>(1e-2)*tol;
58  proj_->getLinearConstraint()->value(*res_,*xz,tol);
59  Real rnorm = res_->norm();
60  if (rnorm > ROL_EPSILON<Real>()) tol_ *= rnorm;
61  isInit_ = true;
62  }
63  }
64 
65  Real value( const Vector<Real> &x, Real &tol ) {
66  initialize(x);
67  const Real zero(0);
68  bool isBndFeasible = proj_->getBoundConstraint()->isFeasible(x);
69  bool isConFeasible = true;
70  if (res_ != nullPtr) {
71  proj_->getLinearConstraint()->value(*res_,x,tol);
72  if (res_->norm() > tol_) isConFeasible = false;
73  }
74  return (isBndFeasible && isConFeasible) ? zero : ROL_INF<Real>();
75  }
76 
77  void prox( Vector<Real> &Pv, const Vector<Real> &v, Real t, Real &tol){
78  Pv.set(v); proj_->project(Pv);
79  }
80 }; // class TypeBIndicatorObjective
81 
82 } // namespace ROL
83 
84 #endif
Provides the interface to evaluate objective functions.
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
void initialize(const Vector< Real > &x)
TypeBIndicatorObjective(const Ptr< PolyhedralProjection< Real >> &proj)
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Ptr< PolyhedralProjection< Real > > PolyhedralProjectionFactory(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, ParameterList &list)
Provides the interface to evaluate the indicator function of linear constraints.
void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
Compute the proximity operator.
TypeBIndicatorObjective(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, ParameterList &list)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
const Ptr< PolyhedralProjection< Real > > proj_
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
TypeBIndicatorObjective(const Ptr< BoundConstraint< Real >> &bnd)
Provides the interface to apply upper and lower bound constraints.
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:175
Defines the general constraint operator interface.