ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
constraint
ROL_BinaryConstraint.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_BINARY_CONSTRAINT_H
11
#define ROL_BINARY_CONSTRAINT_H
12
13
#include "
ROL_BoundConstraint.hpp
"
14
#include "
ROL_Constraint.hpp
"
15
23
24
namespace
ROL
{
25
26
template
<
typename
Real>
27
class
BinaryConstraint
:
public
Constraint
<Real> {
28
private
:
29
const
Ptr<const Vector<Real>>
lo_
;
// Lower Bound Vector
30
const
Ptr<const Vector<Real>>
up_
;
// Upper Bound Vector
31
Ptr<Vector<Real>>
d_
;
// Scratch Vector
32
Real
gamma_
;
// Penality parameter
33
34
class
BoundsCheck
:
public
Elementwise::BinaryFunction<Real> {
35
private
:
36
const
int
opt_
;
37
38
public
:
39
BoundsCheck
(
int
option ) :
opt_
(option) {}
40
41
Real
apply
(
const
Real &dl,
const
Real &du )
const
{
42
const
Real
zero
(0), one(1), two(2);
43
if
( dl <
ROL_INF<Real>
() ) {
44
if
( du <
ROL_INF<Real>
() ) {
45
switch
(
opt_
) {
46
case
0:
return
dl*du;
break
;
47
case
1:
return
du-dl;
break
;
48
case
2:
return
-two;
break
;
49
default
:
return
zero
;
break
;
// Should never be called
50
}
51
}
52
else
{
// dl finite, du infinite
53
switch
(
opt_
) {
54
case
0:
return
dl;
break
;
55
case
1:
return
one;
break
;
56
case
2:
return
zero
;
break
;
57
default
:
return
zero
;
break
;
// Should never be called
58
}
59
}
60
}
61
else
{
// dl infinite, du finite
62
if
( du <
ROL_INF<Real>
() ) {
// dl and du infinite
63
switch
(
opt_
) {
64
case
0:
return
du;
break
;
65
case
1:
return
-one;
break
;
66
case
2:
return
zero
;
break
;
67
default
:
return
zero
;
break
;
// Should never be called
68
}
69
}
70
else
{
71
return
zero
;
72
}
73
}
74
}
// apply
75
};
// class BoundsCheck
76
77
public
:
78
79
BinaryConstraint
(
const
ROL::Ptr<
const
Vector<Real>
> &lo,
80
const
ROL::Ptr<
const
Vector<Real>
> &up, Real gamma );
81
BinaryConstraint
(
const
BoundConstraint<Real>
&bnd, Real gamma );
82
BinaryConstraint
(
const
ROL::Ptr<
const
BoundConstraint<Real>
> &bnd, Real gamma );
83
84
void
value
(
Vector<Real>
&c,
const
Vector<Real>
&x, Real &tol)
override
;
85
void
applyJacobian
(
Vector<Real>
&jv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol)
override
;
86
void
applyAdjointJacobian
(
Vector<Real>
&ajv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol)
override
;
87
void
applyAdjointHessian
(
Vector<Real>
&ahuv,
const
Vector<Real>
&u,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol)
override
;
88
89
void
setPenalty
( Real gamma );
90
};
91
92
}
// namespace ROL
93
94
#include "
ROL_BinaryConstraint_Def.hpp
"
95
96
#endif
// ROL_BINARY_CONSTRAINT_H
ROL_BinaryConstraint_Def.hpp
ROL_BoundConstraint.hpp
ROL_Constraint.hpp
zero
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
Definition
ROL_Objective_SerialSimOpt.hpp:77
ROL::BinaryConstraint::BoundsCheck::BoundsCheck
BoundsCheck(int option)
Definition
ROL_BinaryConstraint.hpp:39
ROL::BinaryConstraint::BoundsCheck::opt_
const int opt_
Definition
ROL_BinaryConstraint.hpp:36
ROL::BinaryConstraint::BoundsCheck::apply
Real apply(const Real &dl, const Real &du) const
Definition
ROL_BinaryConstraint.hpp:41
ROL::BinaryConstraint::lo_
const Ptr< const Vector< Real > > lo_
Definition
ROL_BinaryConstraint.hpp:29
ROL::BinaryConstraint::value
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Definition
ROL_BinaryConstraint_Def.hpp:29
ROL::BinaryConstraint::gamma_
Real gamma_
Definition
ROL_BinaryConstraint.hpp:32
ROL::BinaryConstraint::BinaryConstraint
BinaryConstraint(const ROL::Ptr< const Vector< Real > > &lo, const ROL::Ptr< const Vector< Real > > &up, Real gamma)
Definition
ROL_BinaryConstraint_Def.hpp:16
ROL::BinaryConstraint::applyAdjointJacobian
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_BinaryConstraint_Def.hpp:52
ROL::BinaryConstraint::setPenalty
void setPenalty(Real gamma)
Definition
ROL_BinaryConstraint_Def.hpp:70
ROL::BinaryConstraint::applyJacobian
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_BinaryConstraint_Def.hpp:40
ROL::BinaryConstraint::up_
const Ptr< const Vector< Real > > up_
Definition
ROL_BinaryConstraint.hpp:30
ROL::BinaryConstraint::applyAdjointHessian
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_BinaryConstraint_Def.hpp:57
ROL::BinaryConstraint::d_
Ptr< Vector< Real > > d_
Definition
ROL_BinaryConstraint.hpp:31
ROL::BoundConstraint
Provides the interface to apply upper and lower bound constraints.
Definition
ROL_BoundConstraint.hpp:39
ROL::ROL::Constraint::Constraint
Constraint(void)
Definition
ROL_Constraint_SerialSimOpt.hpp:59
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::ROL_INF
Real ROL_INF(void)
Definition
ROL_Types.hpp:71
Generated by
1.17.0