ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
constraint
ROL_BinaryConstraint_Def.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_DEF_H
11
#define ROL_BINARY_CONSTRAINT_DEF_H
12
13
namespace
ROL
{
14
15
template
<
typename
Real>
16
BinaryConstraint<Real>::BinaryConstraint
(
const
ROL::Ptr<
const
Vector<Real>
> &lo,
17
const
ROL::Ptr<
const
Vector<Real>
> &up, Real gamma ) :
18
lo_
(lo),
up_
(up),
d_
(
lo_
->clone()),
gamma_
(gamma) {}
19
20
template
<
typename
Real>
21
BinaryConstraint<Real>::BinaryConstraint
(
const
BoundConstraint<Real>
&bnd, Real gamma ) :
22
BinaryConstraint
( bnd.getLowerBound(), bnd.getUpperBound(), gamma ) {}
23
24
template
<
typename
Real>
25
BinaryConstraint<Real>::BinaryConstraint
(
const
ROL::Ptr<
const
BoundConstraint<Real>
> &bnd, Real gamma ) :
26
BinaryConstraint
( bnd->getLowerBound(), bnd->getUpperBound(), gamma ) {}
27
28
template
<
typename
Real>
29
void
BinaryConstraint<Real>::value
(
Vector<Real>
&c,
const
Vector<Real>
&x, Real &tol) {
30
const
Real one(1);
31
c.
set
( x );
32
c.
axpy
( -one, *
lo_
);
// c = x-l
33
d_
->set( *
up_
);
34
d_
->axpy( -one, x );
// d = u-x
35
c.
applyBinary
(
BoundsCheck
(0), *
d_
);
36
c.
scale
(
gamma_
);
37
}
38
39
template
<
typename
Real>
40
void
BinaryConstraint<Real>::applyJacobian
(
Vector<Real>
&jv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol) {
41
const
Real one(1);
42
jv.
set
( x );
43
jv.
axpy
( -one, *
lo_
);
44
d_
->set( *
up_
);
45
d_
->axpy( -one, x );
46
jv.
applyBinary
(
BoundsCheck
(1), *
d_
);
47
jv.
applyBinary
( Elementwise::Multiply<Real>(), v );
48
jv.
scale
(
gamma_
);
49
}
50
51
template
<
typename
Real>
52
void
BinaryConstraint<Real>::applyAdjointJacobian
(
Vector<Real>
&ajv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol) {
53
applyJacobian
(ajv,v,x,tol);
54
}
55
56
template
<
typename
Real>
57
void
BinaryConstraint<Real>::applyAdjointHessian
(
Vector<Real>
&ahuv,
const
Vector<Real>
&u,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol) {
58
const
Real one(1);
59
ahuv.
set
( x );
60
ahuv.
axpy
( -one, *
lo_
);
61
d_
->set( *
up_
);
62
d_
->axpy( -one, x );
63
ahuv.
applyBinary
(
BoundsCheck
(2), *
d_
);
64
ahuv.
applyBinary
( Elementwise::Multiply<Real>(), v );
65
ahuv.
applyBinary
( Elementwise::Multiply<Real>(), u );
66
ahuv.
scale
(
gamma_
);
67
}
68
69
template
<
typename
Real>
70
void
BinaryConstraint<Real>::setPenalty
( Real gamma ) {
71
gamma_
= gamma;
72
}
73
74
}
// namespace ROL
75
76
#endif
// ROL_BINARY_CONSTRAINT_DEF_H
ROL::BinaryConstraint::BoundsCheck
Definition
ROL_BinaryConstraint.hpp:34
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::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::applyBinary
virtual void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector &x)
Definition
ROL_Vector.hpp:215
ROL::Vector::scale
virtual void scale(const Real alpha)=0
Compute where .
ROL::Vector::axpy
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition
ROL_Vector.hpp:120
ROL
Definition
ROL_ElementwiseVector.hpp:27
applyJacobian
void applyJacobian(ROL::Vector< Real > &jv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &sol)
Definition
step/interiorpoint/test_02.cpp:118
Generated by
1.17.0