ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
zoo
testproblems
ROL_HS55.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
14
15
16
#ifndef ROL_HS55_HPP
17
#define ROL_HS55_HPP
18
19
#include "
ROL_StdVector.hpp
"
20
#include "
ROL_TestProblem.hpp
"
21
#include "
ROL_Types.hpp
"
22
#include "
ROL_StdObjective.hpp
"
23
#include "
ROL_StdConstraint.hpp
"
24
#include "
ROL_Bounds.hpp
"
25
26
namespace
ROL
{
27
namespace
ZOO
{
28
34
35
template
<
class
Real>
36
class
Objective_HS55
:
public
StdObjective
<Real> {
37
public
:
38
Real
value
(
const
std::vector<Real> &x, Real &tol ) {
39
const
Real c2(2), c4(4);
40
return
x[0] + c2*x[1] + c4*x[4] + std::exp(x[0]*x[3]);
41
}
42
43
void
gradient
( std::vector<Real> &g,
const
std::vector<Real> &x, Real &tol ) {
44
const
Real c0(0), c1(1), c2(2), c4(4);
45
Real exp03 = std::exp(x[0]*x[3]);
46
g[0] = c1 + x[3]*exp03;
47
g[1] = c2;
48
g[2] = c0;
49
g[3] = x[0]*exp03;
50
g[4] = c4;
51
g[5] = c0;
52
}
53
54
void
hessVec
( std::vector<Real> &hv,
const
std::vector<Real> &v,
const
std::vector<Real> &x, Real &tol ) {
55
const
Real c0(0), c1(1);
56
Real exp03 = std::exp(x[0]*x[3]);
57
hv[0] = x[3]*x[3]*exp03*v[0] + (c1 + x[3]*x[0])*exp03*v[3];
58
hv[1] = c0;
59
hv[2] = c0;
60
hv[3] = (c1 + x[0]*x[3])*exp03*v[0] + x[0]*x[0]*exp03*v[3];
61
hv[4] = c0;
62
hv[5] = c0;
63
}
64
};
65
66
template
<
class
Real>
67
class
Constraint_HS55
:
public
StdConstraint
<Real> {
68
public
:
69
void
value
( std::vector<Real> &c,
const
std::vector<Real> &x, Real &tol ) {
70
const
Real c1(1), c2(2), c3(3), c5(5), c6(6);
71
c[0] = x[0] + c2*x[1] + c5*x[4] - c6;
72
c[1] = x[0] + x[1] + x[2] - c3;
73
c[2] = x[3] + x[4] + x[5] - c2;
74
c[3] = x[0] + x[3] - c1;
75
c[4] = x[1] + x[4] - c2;
76
c[5] = x[2] + x[5] - c2;
77
}
78
79
void
applyJacobian
(std::vector<Real> &jv,
const
std::vector<Real> &v,
80
const
std::vector<Real> &x, Real &tol) {
81
const
Real c2(2), c5(5);
82
jv[0] = v[0] + c2*v[1] + c5*v[4];
83
jv[1] = v[0] + v[1] + v[2];
84
jv[2] = v[3] + v[4] + v[5];
85
jv[3] = v[0] + v[3];
86
jv[4] = v[1] + v[4];
87
jv[5] = v[2] + v[5];
88
}
89
90
void
applyAdjointJacobian
( std::vector<Real> &ajv,
const
std::vector<Real> &v,
91
const
std::vector<Real> &x, Real &tol ) {
92
const
Real c2(2), c5(5);
93
ajv[0] = v[0] + v[1] + v[3];
94
ajv[1] = c2*v[0] + v[1] + v[4];
95
ajv[2] = v[1] + v[5];
96
ajv[3] = v[2] + v[3];
97
ajv[4] = c5*v[0] + v[2] + v[4];
98
ajv[5] = v[2] + v[5];
99
}
100
101
void
applyAdjointHessian
(std::vector<Real> &ahuv,
const
std::vector<Real> &u,
102
const
std::vector<Real> &v,
const
std::vector<Real> &x,
103
Real &tol) {
104
ahuv.assign(ahuv.size(),
static_cast<
Real
>
(0));
105
}
106
};
107
108
template
<
class
Real>
109
class
getHS55
:
public
TestProblem
<Real> {
110
public
:
111
getHS55
(
void
) {}
112
113
Ptr<Objective<Real>>
getObjective
(
void
)
const
{
114
return
ROL::makePtr<Objective_HS55<Real>>();
115
}
116
117
Ptr<Vector<Real>>
getInitialGuess
(
void
)
const
{
118
int
n = 6;
119
ROL::Ptr<std::vector<Real>> xp = ROL::makePtr<std::vector<Real>>(n);
120
(*xp)[0] =
static_cast<
Real
>
(1.0);
121
(*xp)[1] =
static_cast<
Real
>
(2.0);
122
(*xp)[2] =
static_cast<
Real
>
(0.0);
123
(*xp)[3] =
static_cast<
Real
>
(0.0);
124
(*xp)[4] =
static_cast<
Real
>
(0.0);
125
(*xp)[5] =
static_cast<
Real
>
(2.0);
126
return
ROL::makePtr<StdVector<Real>>(xp);
127
}
128
129
Ptr<Vector<Real>>
getSolution
(
const
int
i = 0)
const
{
130
int
n = 6;
131
ROL::Ptr<std::vector<Real>> xp = ROL::makePtr<std::vector<Real>>(n);
132
(*xp)[0] =
static_cast<
Real
>
(0.0);
133
(*xp)[1] =
static_cast<
Real
>
(4.0/3.0);
134
(*xp)[2] =
static_cast<
Real
>
(5.0/3.0);
135
(*xp)[3] =
static_cast<
Real
>
(1.0);
136
(*xp)[4] =
static_cast<
Real
>
(2.0/3.0);
137
(*xp)[5] =
static_cast<
Real
>
(1.0/3.0);
138
return
ROL::makePtr<StdVector<Real>>(xp);
139
}
140
141
Ptr<Constraint<Real>>
getEqualityConstraint
(
void
)
const
{
142
return
ROL::makePtr<Constraint_HS55<Real>>();
143
}
144
145
Ptr<Vector<Real>>
getEqualityMultiplier
(
void
)
const
{
146
int
n = 6;
147
return
ROL::makePtr<StdVector<Real>>(n,0.0);
148
}
149
150
Ptr<BoundConstraint<Real>>
getBoundConstraint
(
void
)
const
{
151
int
n = 6;
152
Ptr<Vector<Real>> l = makePtr<StdVector<Real>>(n,0.0);
153
ROL::Ptr<std::vector<Real>> up = ROL::makePtr<std::vector<Real>>(n,
ROL_INF<Real>
());
154
(*up)[0] =
static_cast<
Real
>
(1);
155
(*up)[3] =
static_cast<
Real
>
(1);
156
Ptr<Vector<Real>> u = makePtr<StdVector<Real>>(up);
157
return
makePtr<Bounds<Real>>(l,u);
158
}
159
};
160
161
}
// End ZOO Namespace
162
}
// End ROL Namespace
163
164
#endif
ROL_Bounds.hpp
ROL_StdConstraint.hpp
ROL_StdObjective.hpp
ROL_StdVector.hpp
ROL_TestProblem.hpp
Contains definitions of test objective functions.
ROL_Types.hpp
Contains definitions of custom data types in ROL.
ROL::StdConstraint
Defines the equality constraint operator interface for StdVectors.
Definition
ROL_StdConstraint.hpp:25
ROL::StdObjective
Specializes the ROL::Objective interface for objective functions that operate on ROL::StdVector's.
Definition
ROL_StdObjective.hpp:26
ROL::TestProblem::TestProblem
TestProblem(void)
Definition
ROL_TestProblem.hpp:28
ROL::ZOO::Constraint_HS55
Definition
ROL_HS55.hpp:67
ROL::ZOO::Constraint_HS55::applyJacobian
void applyJacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS55.hpp:79
ROL::ZOO::Constraint_HS55::applyAdjointHessian
void applyAdjointHessian(std::vector< Real > &ahuv, const std::vector< Real > &u, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS55.hpp:101
ROL::ZOO::Constraint_HS55::value
void value(std::vector< Real > &c, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS55.hpp:69
ROL::ZOO::Constraint_HS55::applyAdjointJacobian
void applyAdjointJacobian(std::vector< Real > &ajv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS55.hpp:90
ROL::ZOO::Objective_HS55
W. Hock and K. Schittkowski 55th test function.
Definition
ROL_HS55.hpp:36
ROL::ZOO::Objective_HS55::hessVec
void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS55.hpp:54
ROL::ZOO::Objective_HS55::gradient
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS55.hpp:43
ROL::ZOO::Objective_HS55::value
Real value(const std::vector< Real > &x, Real &tol)
Definition
ROL_HS55.hpp:38
ROL::ZOO::getHS55::getSolution
Ptr< Vector< Real > > getSolution(const int i=0) const
Definition
ROL_HS55.hpp:129
ROL::ZOO::getHS55::getEqualityConstraint
Ptr< Constraint< Real > > getEqualityConstraint(void) const
Definition
ROL_HS55.hpp:141
ROL::ZOO::getHS55::getBoundConstraint
Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
Definition
ROL_HS55.hpp:150
ROL::ZOO::getHS55::getEqualityMultiplier
Ptr< Vector< Real > > getEqualityMultiplier(void) const
Definition
ROL_HS55.hpp:145
ROL::ZOO::getHS55::getObjective
Ptr< Objective< Real > > getObjective(void) const
Definition
ROL_HS55.hpp:113
ROL::ZOO::getHS55::getInitialGuess
Ptr< Vector< Real > > getInitialGuess(void) const
Definition
ROL_HS55.hpp:117
ROL::ZOO::getHS55::getHS55
getHS55(void)
Definition
ROL_HS55.hpp:111
ROL::ZOO
Definition
ROL_Beale.hpp:26
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::ROL_INF
Real ROL_INF(void)
Definition
ROL_Types.hpp:71
Generated by
1.17.0