ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
objective
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
"
14
#include "
ROL_PolyhedralProjectionFactory.hpp
"
15
22
23
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
36
TypeBIndicatorObjective
(
const
Ptr<
BoundConstraint<Real>
> &bnd)
37
:
proj_
(makePtr<
PolyhedralProjection
<Real>>(bnd)),
38
isInit_
(true),
tol_
(0) {}
39
40
TypeBIndicatorObjective
(
const
Vector<Real>
&xprim,
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
50
TypeBIndicatorObjective
(
const
Ptr<
PolyhedralProjection<Real>
> &proj)
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
ROL_Objective.hpp
zero
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
Definition
ROL_Objective_SerialSimOpt.hpp:77
ROL_PolyhedralProjectionFactory.hpp
ROL::BoundConstraint
Provides the interface to apply upper and lower bound constraints.
Definition
ROL_BoundConstraint.hpp:39
ROL::Constraint
Defines the general constraint operator interface.
Definition
ROL_Constraint.hpp:52
ROL::PolyhedralProjection
Definition
ROL_PolyhedralProjection.hpp:20
ROL::ROL::Objective::Objective
Objective()
Definition
ROL_Constraint_SerialSimOpt.hpp:53
ROL::TypeBIndicatorObjective::isInit_
bool isInit_
Definition
ROL_TypeBIndicatorObjective.hpp:31
ROL::TypeBIndicatorObjective::res_
const Ptr< Vector< Real > > res_
Definition
ROL_TypeBIndicatorObjective.hpp:30
ROL::TypeBIndicatorObjective::prox
void prox(Vector< Real > &Pv, const Vector< Real > &v, Real t, Real &tol)
Definition
ROL_TypeBIndicatorObjective.hpp:77
ROL::TypeBIndicatorObjective::TypeBIndicatorObjective
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)
Definition
ROL_TypeBIndicatorObjective.hpp:40
ROL::TypeBIndicatorObjective::proj_
const Ptr< PolyhedralProjection< Real > > proj_
Definition
ROL_TypeBIndicatorObjective.hpp:29
ROL::TypeBIndicatorObjective::value
Real value(const Vector< Real > &x, Real &tol)
Definition
ROL_TypeBIndicatorObjective.hpp:65
ROL::TypeBIndicatorObjective::TypeBIndicatorObjective
TypeBIndicatorObjective(const Ptr< PolyhedralProjection< Real > > &proj)
Definition
ROL_TypeBIndicatorObjective.hpp:50
ROL::TypeBIndicatorObjective::initialize
void initialize(const Vector< Real > &x)
Definition
ROL_TypeBIndicatorObjective.hpp:53
ROL::TypeBIndicatorObjective::tol_
Real tol_
Definition
ROL_TypeBIndicatorObjective.hpp:32
ROL::TypeBIndicatorObjective::TypeBIndicatorObjective
TypeBIndicatorObjective(const Ptr< BoundConstraint< Real > > &bnd)
Definition
ROL_TypeBIndicatorObjective.hpp:36
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL::Vector::set
virtual void set(const Vector &x)
Set where .
Definition
ROL_Vector.hpp:176
ROL::Vector::clone
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::ROL_EPSILON
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Definition
ROL_Types.hpp:57
ROL::PolyhedralProjectionFactory
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)
Definition
ROL_PolyhedralProjectionFactory.hpp:102
ROL::ROL_INF
Real ROL_INF(void)
Definition
ROL_Types.hpp:71
Generated by
1.17.0