ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
constraint
ROL_SlacklessConstraint_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_SLACKLESSCONSTRAINT_DEF_HPP
11
#define ROL_SLACKLESSCONSTRAINT_DEF_HPP
12
13
namespace
ROL
{
14
15
template
<
typename
Real>
16
SlacklessConstraint<Real>::SlacklessConstraint
(
const
Ptr<
Constraint<Real>
> &con ) :
con_
(con) {}
17
18
template
<
typename
Real>
19
void
SlacklessConstraint<Real>::update
(
const
Vector<Real>
&x,
UpdateType
type,
int
iter ) {
20
con_
->update( *
getOpt
(x), type, iter );
21
}
22
23
template
<
typename
Real>
24
void
SlacklessConstraint<Real>::update
(
const
Vector<Real>
&x,
bool
flag,
int
iter ) {
25
con_
->update( *
getOpt
(x), flag, iter );
26
}
27
28
template
<
typename
Real>
29
void
SlacklessConstraint<Real>::value
(
Vector<Real>
&c,
const
Vector<Real>
&x, Real &tol ) {
30
con_
->value( c, *
getOpt
(x), tol );
31
}
32
33
template
<
typename
Real>
34
void
SlacklessConstraint<Real>::applyJacobian
(
Vector<Real>
&jv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
35
con_
->applyJacobian( jv, *
getOpt
(v), *
getOpt
(x), tol );
36
}
37
38
template
<
typename
Real>
39
void
SlacklessConstraint<Real>::applyAdjointJacobian
(
Vector<Real>
&ajv,
const
Vector<Real>
&v,
const
Vector<Real>
&x,
const
Vector<Real>
&dualv, Real &tol ) {
40
zeroSlack
(ajv);
41
con_
->applyAdjointJacobian( *
getOpt
(ajv), v, *
getOpt
(x), dualv, tol );
42
}
43
44
template
<
typename
Real>
45
void
SlacklessConstraint<Real>::applyAdjointHessian
(
Vector<Real>
&ahuv,
const
Vector<Real>
&u,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
46
zeroSlack
(ahuv);
47
con_
->applyAdjointHessian( *
getOpt
(ahuv), u, *
getOpt
(v), *
getOpt
(x), tol );
48
}
49
50
template
<
typename
Real>
51
void
SlacklessConstraint<Real>::setParameter
(
const
std::vector<Real> ¶m) {
52
Constraint<Real>::setParameter
(param);
53
con_
->setParameter(param);
54
}
55
56
template
<
typename
Real>
57
Ptr<Vector<Real>>
SlacklessConstraint<Real>::getOpt
(
Vector<Real>
&xs )
const
{
58
return
dynamic_cast<
PartitionedVector<Real>
&
>
(xs).get(0);
59
}
60
61
template
<
typename
Real>
62
Ptr<const Vector<Real>>
SlacklessConstraint<Real>::getOpt
(
const
Vector<Real>
&xs )
const
{
63
return
dynamic_cast<
const
PartitionedVector<Real>
&
>
(xs).get(0);
64
}
65
66
template
<
typename
Real>
67
void
SlacklessConstraint<Real>::zeroSlack
(
Vector<Real>
&x )
const
{
68
PartitionedVector<Real>
&xpv
69
=
dynamic_cast<
PartitionedVector<Real>
&
>
(x);
70
const
int
nvec =
static_cast<
int
>
(xpv.
numVectors
());
71
for
(
int
i = 1; i < nvec; ++i) {
72
xpv.
get
(i)->zero();
73
}
74
}
75
76
}
// namespace ROL
77
78
#endif
// ROL__SLACKLESSCONSTRAINT_HPP
79
ROL::Constraint::setParameter
virtual void setParameter(const std::vector< Real > ¶m)
Definition
ROL_Constraint.hpp:374
ROL::PartitionedVector
Defines the linear algebra of vector space on a generic partitioned vector.
Definition
ROL_PartitionedVector.hpp:26
ROL::PartitionedVector::get
ROL::Ptr< const Vector< Real > > get(size_type i) const
Definition
ROL_PartitionedVector.hpp:221
ROL::PartitionedVector::numVectors
size_type numVectors() const
Definition
ROL_PartitionedVector.hpp:237
ROL::ROL::Constraint::Constraint
Constraint(void)
Definition
ROL_Constraint_SerialSimOpt.hpp:59
ROL::SlacklessConstraint::applyJacobian
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_SlacklessConstraint_Def.hpp:34
ROL::SlacklessConstraint::setParameter
void setParameter(const std::vector< Real > ¶m) override
Definition
ROL_SlacklessConstraint_Def.hpp:51
ROL::SlacklessConstraint::con_
const Ptr< Constraint< Real > > con_
Definition
ROL_SlacklessConstraint.hpp:27
ROL::SlacklessConstraint::SlacklessConstraint
SlacklessConstraint(const Ptr< Constraint< Real > > &con)
Definition
ROL_SlacklessConstraint_Def.hpp:16
ROL::SlacklessConstraint::value
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Definition
ROL_SlacklessConstraint_Def.hpp:29
ROL::SlacklessConstraint::zeroSlack
void zeroSlack(Vector< Real > &x) const
Definition
ROL_SlacklessConstraint_Def.hpp:67
ROL::SlacklessConstraint::getOpt
Ptr< Vector< Real > > getOpt(Vector< Real > &xs) const
Definition
ROL_SlacklessConstraint_Def.hpp:57
ROL::SlacklessConstraint::applyAdjointHessian
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_SlacklessConstraint_Def.hpp:45
ROL::SlacklessConstraint::applyAdjointJacobian
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &dualv, Real &tol) override
Definition
ROL_SlacklessConstraint_Def.hpp:39
ROL::SlacklessConstraint::update
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Definition
ROL_SlacklessConstraint_Def.hpp:19
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::UpdateType
UpdateType
Definition
ROL_UpdateType.hpp:18
Generated by
1.17.0