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
22
23
24namespace ROL {
25
26template<typename Real>
27class TypeBIndicatorObjective : public Objective<Real> {
28private:
29 const Ptr<PolyhedralProjection<Real>> proj_;
30 const Ptr<Vector<Real>> res_;
31 bool isInit_;
32 Real tol_;
33
34public:
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
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
Provides the interface to apply upper and lower bound constraints.
Defines the general constraint operator interface.
void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
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)
const Ptr< PolyhedralProjection< Real > > proj_
Real value(const Vector< Real > &x, Real &tol)
TypeBIndicatorObjective(const Ptr< PolyhedralProjection< Real > > &proj)
void initialize(const Vector< Real > &x)
TypeBIndicatorObjective(const Ptr< BoundConstraint< Real > > &bnd)
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Definition ROL_Types.hpp:57
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)
Real ROL_INF(void)
Definition ROL_Types.hpp:71