ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
objective
ROL_SlacklessObjective_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_SLACKLESSOBJECTIVE_DEF_HPP
11
#define ROL_SLACKLESSOBJECTIVE_DEF_HPP
12
13
namespace
ROL
{
14
15
template
<
typename
Real>
16
SlacklessObjective<Real>::SlacklessObjective
(
const
Ptr<
Objective<Real>
> &obj ) :
obj_
(obj) {}
17
18
template
<
typename
Real>
19
Ptr<Objective<Real>>
SlacklessObjective<Real>::getObjective
(
void
)
const
{
20
return
obj_
;
21
}
22
23
template
<
typename
Real>
24
void
SlacklessObjective<Real>::update
(
const
Vector<Real>
&x,
UpdateType
type,
int
iter ) {
25
obj_
->update( *
getOpt
(x), type, iter );
26
}
27
28
template
<
typename
Real>
29
void
SlacklessObjective<Real>::update
(
const
Vector<Real>
&x,
bool
flag,
int
iter ) {
30
obj_
->update( *
getOpt
(x), flag, iter );
31
}
32
33
template
<
typename
Real>
34
Real
SlacklessObjective<Real>::value
(
const
Vector<Real>
&x, Real &tol ) {
35
return
obj_
->value( *
getOpt
(x), tol );
36
}
37
38
template
<
typename
Real>
39
Real
SlacklessObjective<Real>::dirDeriv
(
const
Vector<Real>
&x,
const
Vector<Real>
&d, Real &tol ) {
40
return
obj_
->dirDeriv(*
getOpt
(x),*
getOpt
(d),tol);
41
}
42
43
template
<
typename
Real>
44
void
SlacklessObjective<Real>::gradient
(
Vector<Real>
&g,
const
Vector<Real>
&x, Real &tol ) {
45
zeroSlack
(g);
46
obj_
->gradient(*
getOpt
(g),*
getOpt
(x),tol);
47
}
48
49
template
<
typename
Real>
50
void
SlacklessObjective<Real>::hessVec
(
Vector<Real>
&hv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
51
zeroSlack
(hv);
52
obj_
->hessVec(*
getOpt
(hv),*
getOpt
(v),*
getOpt
(x),tol);
53
}
54
55
template
<
typename
Real>
56
void
SlacklessObjective<Real>::invHessVec
(
Vector<Real>
&ihv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
57
obj_
->invHessVec( *
getOpt
(ihv), *
getOpt
(v), *
getOpt
(x), tol );
58
PartitionedVector<Real>
&Pvp =
dynamic_cast<
PartitionedVector<Real>
&
>
(ihv);
59
const
PartitionedVector<Real>
&vp =
dynamic_cast<
const
PartitionedVector<Real>
&
>
(v);
60
const
int
nvec =
static_cast<
int
>
(vp.
numVectors
());
61
for
(
int
i = 1; i < nvec; ++i) {
62
Pvp.
get
(i)->set(vp.
get
(i)->dual());
63
}
64
}
65
66
template
<
typename
Real>
67
void
SlacklessObjective<Real>::precond
(
Vector<Real>
&Pv,
const
Vector<Real>
&v,
const
Vector<Real>
&x, Real &tol ) {
68
obj_
->precond( *
getOpt
(Pv), *
getOpt
(v), *
getOpt
(x), tol );
69
PartitionedVector<Real>
&Pvp =
dynamic_cast<
PartitionedVector<Real>
&
>
(Pv);
70
const
PartitionedVector<Real>
&vp =
dynamic_cast<
const
PartitionedVector<Real>
&
>
(v);
71
const
int
nvec =
static_cast<
int
>
(vp.
numVectors
());
72
for
(
int
i = 1; i < nvec; ++i) {
73
Pvp.
get
(i)->set(vp.
get
(i)->dual());
74
}
75
}
76
77
template
<
typename
Real>
78
void
SlacklessObjective<Real>::setParameter
(
const
std::vector<Real> ¶m) {
79
Objective<Real>::setParameter
(param);
80
obj_
->setParameter(param);
81
}
82
83
template
<
typename
Real>
84
Ptr<Vector<Real>>
SlacklessObjective<Real>::getOpt
(
Vector<Real>
&xs )
const
{
85
return
dynamic_cast<
PartitionedVector<Real>
&
>
(xs).get(0);
86
}
87
88
template
<
typename
Real>
89
Ptr<const Vector<Real>>
SlacklessObjective<Real>::getOpt
(
const
Vector<Real>
&xs )
const
{
90
return
dynamic_cast<
const
PartitionedVector<Real>
&
>
(xs).get(0);
91
}
92
93
template
<
typename
Real>
94
void
SlacklessObjective<Real>::zeroSlack
(
Vector<Real>
&x )
const
{
95
PartitionedVector<Real>
&xpv
96
=
dynamic_cast<
PartitionedVector<Real>
&
>
(x);
97
const
int
nvec =
static_cast<
int
>
(xpv.
numVectors
());
98
for
(
int
i = 1; i < nvec; ++i) {
99
xpv.
get
(i)->zero();
100
}
101
}
102
103
}
// namespace ROL
104
105
#endif
// ROL__SLACKLESSOBJECTIVE_HPP
106
ROL::Objective::setParameter
virtual void setParameter(const std::vector< Real > ¶m)
Definition
ROL_Objective.hpp:509
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::Objective::Objective
Objective()
Definition
ROL_Constraint_SerialSimOpt.hpp:53
ROL::SlacklessObjective::value
Real value(const Vector< Real > &x, Real &tol) override
Definition
ROL_SlacklessObjective_Def.hpp:34
ROL::SlacklessObjective::SlacklessObjective
SlacklessObjective(const Ptr< Objective< Real > > &obj)
Definition
ROL_SlacklessObjective_Def.hpp:16
ROL::SlacklessObjective::obj_
const Ptr< Objective< Real > > obj_
Definition
ROL_SlacklessObjective.hpp:27
ROL::SlacklessObjective::invHessVec
void invHessVec(Vector< Real > &ihv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_SlacklessObjective_Def.hpp:56
ROL::SlacklessObjective::gradient
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Definition
ROL_SlacklessObjective_Def.hpp:44
ROL::SlacklessObjective::setParameter
void setParameter(const std::vector< Real > ¶m) override
Definition
ROL_SlacklessObjective_Def.hpp:78
ROL::SlacklessObjective::dirDeriv
Real dirDeriv(const Vector< Real > &x, const Vector< Real > &d, Real &tol) override
Definition
ROL_SlacklessObjective_Def.hpp:39
ROL::SlacklessObjective::update
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Definition
ROL_SlacklessObjective_Def.hpp:24
ROL::SlacklessObjective::precond
void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_SlacklessObjective_Def.hpp:67
ROL::SlacklessObjective::getObjective
Ptr< Objective< Real > > getObjective(void) const
Definition
ROL_SlacklessObjective_Def.hpp:19
ROL::SlacklessObjective::getOpt
Ptr< Vector< Real > > getOpt(Vector< Real > &xs) const
Definition
ROL_SlacklessObjective_Def.hpp:84
ROL::SlacklessObjective::zeroSlack
void zeroSlack(Vector< Real > &x) const
Definition
ROL_SlacklessObjective_Def.hpp:94
ROL::SlacklessObjective::hessVec
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Definition
ROL_SlacklessObjective_Def.hpp:50
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