ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
ROL_ReduceLinearConstraint_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_REDUCE_LINEAR_CONSTRAINT_DEF_H
11
#define ROL_REDUCE_LINEAR_CONSTRAINT_DEF_H
12
13
namespace
ROL
{
14
15
template
<
typename
Real>
16
ReduceLinearConstraint<Real>::ReduceLinearConstraint
(
const
Ptr<
Constraint<Real>
> &lcon,
17
const
Ptr<
Vector<Real>
> &x,
18
const
Ptr<
const
Vector<Real>
> &c)
19
:
lcon_
(lcon),
x_
(x),
20
storage_
(makePtr<
VectorController
<Real>>()),
21
nsop_
(makePtr<
NullSpaceOperator
<Real>>(lcon,
x_
,c)) {
22
feasible
(c);
23
}
24
25
template
<
typename
Real>
26
Ptr<Objective<Real>>
ReduceLinearConstraint<Real>::transform
(
const
Ptr<
Objective<Real>
> &obj)
const
{
27
return
makePtr<AffineTransformObjective<Real>>(obj,
nsop_
,
x_
,
storage_
);
28
}
29
30
template
<
typename
Real>
31
Ptr<Constraint<Real>>
ReduceLinearConstraint<Real>::transform
(
const
Ptr<
Constraint<Real>
> &con)
const
{
32
return
makePtr<AffineTransformConstraint<Real>>(con,
nsop_
,
x_
,
storage_
);
33
}
34
35
template
<
typename
Real>
36
Ptr<Constraint<Real>>
ReduceLinearConstraint<Real>::getLinearConstraint
(
void
)
const
{
37
return
lcon_
;
38
}
39
40
template
<
typename
Real>
41
Ptr<const Vector<Real>>
ReduceLinearConstraint<Real>::getFeasibleVector
(
void
)
const
{
42
return
x_
;
43
}
44
45
template
<
typename
Real>
46
void
ReduceLinearConstraint<Real>::project
(
Vector<Real>
&x,
const
Vector<Real>
&y)
const
{
47
Real tol = std::sqrt(
ROL_EPSILON<Real>
());
48
nsop_
->apply(x,y,tol);
49
}
50
51
template
<
typename
Real>
52
void
ReduceLinearConstraint<Real>::project
(
const
Ptr<
Vector<Real>
> &x,
const
Ptr<
const
Vector<Real>
> &y)
const
{
53
project
(*x,*y);
54
}
55
56
template
<
typename
Real>
57
void
ReduceLinearConstraint<Real>::feasible
(
const
Ptr<
const
Vector<Real>
> &c) {
58
Real tol = std::sqrt(
ROL_EPSILON<Real>
());
59
Ptr<Vector<Real>> ran = c->clone();
60
lcon_
->value(*ran,*
x_
,tol);
61
Real cnorm = ran->norm();
62
if
( cnorm >
static_cast<
Real
>
(1e-4)*tol ) {
63
RangeSpaceOperator<Real>
rsop(
lcon_
,
x_
,c);
64
Ptr<Vector<Real>> xzero =
x_
->clone(); xzero->zero();
65
lcon_
->value(*ran,*xzero,tol);
66
ran->scale(
static_cast<
Real
>
(-1));
67
nsop_
->apply(*xzero,*
x_
,tol);
68
rsop.
apply
(*
x_
,*ran,tol);
69
x_
->plus(*xzero);
70
//throw Exception::NotImplemented(">>> ReduceLinearConstraint::feasible : Input x is not feasible!");
71
}
72
}
73
74
}
// namespace ROL
75
76
#endif
ROL::ROL::Constraint
Definition
ROL_Constraint_SerialSimOpt.hpp:52
ROL::ROL::NullSpaceOperator
Definition
ROL_Constraint_SerialSimOpt.hpp:26
ROL::ROL::Objective
Definition
ROL_Constraint_SerialSimOpt.hpp:44
ROL::ROL::RangeSpaceOperator
Definition
ROL_Constraint_SerialSimOpt.hpp:25
ROL::ROL::RangeSpaceOperator::apply
virtual void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
Definition
ROL_Constraint_SerialSimOpt.hpp:50
ROL::ROL::ReduceLinearConstraint::lcon_
const Ptr< Constraint< Real > > lcon_
Definition
ROL_Constraint_SerialSimOpt.hpp:31
ROL::ROL::ReduceLinearConstraint::project
void project(Vector< Real > &x, const Vector< Real > &y) const
Definition
ROL_ReduceLinearConstraint_Def.hpp:46
ROL::ROL::ReduceLinearConstraint::x_
const Ptr< Vector< Real > > x_
Definition
ROL_Constraint_SerialSimOpt.hpp:32
ROL::ROL::ReduceLinearConstraint::nsop_
const Ptr< NullSpaceOperator< Real > > nsop_
Definition
ROL_Constraint_SerialSimOpt.hpp:34
ROL::ROL::ReduceLinearConstraint::storage_
const Ptr< VectorController< Real > > storage_
Definition
ROL_Constraint_SerialSimOpt.hpp:33
ROL::ROL::VectorController
Definition
ROL_Constraint_SerialSimOpt.hpp:21
ROL::ROL::Vector
Definition
ROL_Constraint_SerialSimOpt.hpp:51
ROL::ReduceLinearConstraint::getFeasibleVector
Ptr< const Vector< Real > > getFeasibleVector(void) const
ROL::ReduceLinearConstraint::transform
Ptr< Objective< Real > > transform(const Ptr< Objective< Real > > &obj) const
ROL::ReduceLinearConstraint::ReduceLinearConstraint
ReduceLinearConstraint(const Ptr< Constraint< Real > > &lcon, const Ptr< Vector< Real > > &x, const Ptr< const Vector< Real > > &c)
ROL::ReduceLinearConstraint::feasible
void feasible(const Ptr< const Vector< Real > > &c)
ROL::ReduceLinearConstraint::project
void project(Vector< Real > &x, const Vector< Real > &y) const
ROL::ReduceLinearConstraint::getLinearConstraint
Ptr< Constraint< Real > > getLinearConstraint(void) const
ROL::ROL::ROL_EPSILON
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Definition
ROL_Constraint_SerialSimOpt.hpp:57
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0