ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
constraint
ROL_ScalarLinearConstraint_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_AFFINE_HYPERPLANE_EQUALITY_CONSTRAINT_DEF_H
11
#define ROL_AFFINE_HYPERPLANE_EQUALITY_CONSTRAINT_DEF_H
12
13
namespace
ROL
{
14
15
template
<
typename
Real>
16
ScalarLinearConstraint<Real>::ScalarLinearConstraint
(
const
Ptr<
const
Vector<Real>
> &a,
17
const
Real b)
18
:
a_
(a),
b_
(b) {}
19
20
template
<
typename
Real>
21
void
ScalarLinearConstraint<Real>::value
(
Vector<Real>
&c,
const
Vector<Real>
&x, Real &tol) {
22
SingletonVector<Real>
&cc =
dynamic_cast<
SingletonVector<Real>
&
>
(c);
23
//cc.setValue(a_->dot(x.dual()) - b_);
24
cc.
setValue
(
a_
->apply(x) -
b_
);
25
}
26
27
template
<
typename
Real>
28
void
ScalarLinearConstraint<Real>::applyJacobian
(
Vector<Real>
&jv,
29
const
Vector<Real>
&v,
30
const
Vector<Real>
&x, Real &tol) {
31
SingletonVector<Real>
&jc =
dynamic_cast<
SingletonVector<Real>
&
>
(jv);
32
//jc.setValue(a_->dot(v.dual()));
33
jc.
setValue
(
a_
->apply(v));
34
}
35
36
template
<
typename
Real>
37
void
ScalarLinearConstraint<Real>::applyAdjointJacobian
(
Vector<Real>
&ajv,
38
const
Vector<Real>
&v,
39
const
Vector<Real>
&x, Real &tol) {
40
const
SingletonVector<Real>
& vc =
dynamic_cast<
const
SingletonVector<Real>
&
>
(v);
41
ajv.
set
(*
a_
);
42
ajv.
scale
(vc.
getValue
());
43
}
44
45
template
<
typename
Real>
46
void
ScalarLinearConstraint<Real>::applyAdjointHessian
(
Vector<Real>
&ahuv,
47
const
Vector<Real>
&u,
48
const
Vector<Real>
&v,
49
const
Vector<Real>
&x, Real &tol) {
50
ahuv.
zero
();
51
}
52
53
template
<
typename
Real>
54
std::vector<Real>
ScalarLinearConstraint<Real>::solveAugmentedSystem
(
Vector<Real>
&v1,
55
Vector<Real>
&v2,
56
const
Vector<Real>
&b1,
57
const
Vector<Real>
&b2,
58
const
Vector<Real>
&x, Real &tol) {
59
SingletonVector<Real>
& v2c =
dynamic_cast<
SingletonVector<Real>
&
>
(v2);
60
const
SingletonVector<Real>
& b2c =
dynamic_cast<
const
SingletonVector<Real>
&
>
(b2);
61
62
//v2c.setValue( (a_->dot(b1.dual()) - b2c.getValue() )/a_->dot(*a_) );
63
v2c.
setValue
( (
a_
->apply(b1) - b2c.
getValue
() )/
a_
->dot(*
a_
) );
64
v1.
set
(b1.
dual
());
65
v1.
axpy
(-v2c.
getValue
(),
a_
->dual());
66
67
std::vector<Real> out;
68
return
out;
69
}
70
71
}
// namespace ROL
72
73
#endif
ROL::ScalarLinearConstraint::applyAdjointJacobian
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_ScalarLinearConstraint_Def.hpp:37
ROL::ScalarLinearConstraint::applyAdjointHessian
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_ScalarLinearConstraint_Def.hpp:46
ROL::ScalarLinearConstraint::solveAugmentedSystem
std::vector< Real > solveAugmentedSystem(Vector< Real > &v1, Vector< Real > &v2, const Vector< Real > &b1, const Vector< Real > &b2, const Vector< Real > &x, Real &tol) override
Definition
ROL_ScalarLinearConstraint_Def.hpp:54
ROL::ScalarLinearConstraint::applyJacobian
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_ScalarLinearConstraint_Def.hpp:28
ROL::ScalarLinearConstraint::b_
const Real b_
Affine shift.
Definition
ROL_ScalarLinearConstraint.hpp:49
ROL::ScalarLinearConstraint::value
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Definition
ROL_ScalarLinearConstraint_Def.hpp:21
ROL::ScalarLinearConstraint::a_
const Ptr< const Vector< Real > > a_
Dual vector defining hyperplane.
Definition
ROL_ScalarLinearConstraint.hpp:48
ROL::ScalarLinearConstraint::ScalarLinearConstraint
ScalarLinearConstraint(const Ptr< const Vector< Real > > &a, const Real b)
Definition
ROL_ScalarLinearConstraint_Def.hpp:16
ROL::SingletonVector
Definition
ROL_SingletonVector.hpp:25
ROL::SingletonVector::setValue
void setValue(Real v)
Definition
ROL_SingletonVector.hpp:42
ROL::SingletonVector::getValue
Real getValue() const
Definition
ROL_SingletonVector.hpp:41
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::scale
virtual void scale(const Real alpha)=0
Compute where .
ROL::Vector::dual
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
Definition
ROL_Vector.hpp:193
ROL::Vector::zero
virtual void zero()
Set to zero vector.
Definition
ROL_Vector.hpp:134
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
Generated by
1.17.0