ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
zoo
testproblems
ROL_HS28.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_HS28_HPP
17
#define ROL_HS28_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
25
namespace
ROL
{
26
namespace
ZOO
{
27
33
34
template
<
class
Real>
35
class
Objective_HS28
:
public
StdObjective
<Real> {
36
public
:
37
Real
value
(
const
std::vector<Real> &x, Real &tol ) {
38
const
Real two(2);
39
return
std::pow(x[0]+x[1],two) + std::pow(x[1]+x[2],two);
40
}
41
42
void
gradient
( std::vector<Real> &g,
const
std::vector<Real> &x, Real &tol ) {
43
const
Real two(2);
44
g[0] = two*(x[0]+x[1]);
45
g[1] = two*(x[0]+x[1]) + two*(x[1]+x[2]);
46
g[2] = two*(x[1]+x[2]);
47
}
48
49
void
hessVec
( std::vector<Real> &hv,
const
std::vector<Real> &v,
const
std::vector<Real> &x, Real &tol ) {
50
const
Real two(2);
51
hv[0] = two*v[0] + two*v[1];
52
hv[1] = two*v[0] + two*two*v[1] + two*v[2];
53
hv[2] = two*v[1] + two*v[2];
54
}
55
};
56
57
template
<
class
Real>
58
class
Constraint_HS28
:
public
StdConstraint
<Real> {
59
public
:
60
Constraint_HS28
(
void
) {}
61
62
void
value
( std::vector<Real> &c,
const
std::vector<Real> &x, Real &tol ) {
63
const
Real c1(1), c2(2), c3(3);
64
c[0] = c1*x[0]+c2*x[1]+c3*x[2]-c1;
65
}
66
67
void
applyJacobian
(std::vector<Real> &jv,
const
std::vector<Real> &v,
68
const
std::vector<Real> &x, Real &tol) {
69
const
Real c1(1), c2(2), c3(3);
70
jv[0] = c1*v[0]+c2*v[1]+c3*v[2];
71
}
72
73
void
applyAdjointJacobian
( std::vector<Real> &ajv,
const
std::vector<Real> &v,
74
const
std::vector<Real> &x, Real &tol ) {
75
const
Real c1(1), c2(2), c3(3);
76
ajv[0] = c1*v[0];
77
ajv[1] = c2*v[0];
78
ajv[2] = c3*v[0];
79
}
80
81
void
applyAdjointHessian
(std::vector<Real> &ahuv,
const
std::vector<Real> &u,
82
const
std::vector<Real> &v,
const
std::vector<Real> &x,
83
Real &tol) {
84
ahuv.assign(ahuv.size(),
static_cast<
Real
>
(0));
85
}
86
87
88
};
89
90
template
<
class
Real>
91
class
getHS28
:
public
TestProblem
<Real> {
92
public
:
93
getHS28
(
void
) {}
94
95
Ptr<Objective<Real>>
getObjective
(
void
)
const
{
96
return
ROL::makePtr<Objective_HS28<Real>>();
97
}
98
99
Ptr<Vector<Real>>
getInitialGuess
(
void
)
const
{
100
int
n = 3;
101
ROL::Ptr<std::vector<Real>> xp = ROL::makePtr<std::vector<Real>>(n,0.0);
102
(*xp)[0] =
static_cast<
Real
>
(-4);
103
(*xp)[1] =
static_cast<
Real
>
(1);
104
(*xp)[2] =
static_cast<
Real
>
(1);
105
return
ROL::makePtr<StdVector<Real>>(xp);
106
}
107
108
Ptr<Vector<Real>>
getSolution
(
const
int
i = 0)
const
{
109
int
n = 3;
110
ROL::Ptr<std::vector<Real>> xp = ROL::makePtr<std::vector<Real>>(n,0.0);
111
(*xp)[0] =
static_cast<
Real
>
(0.5);
112
(*xp)[1] =
static_cast<
Real
>
(-0.5);
113
(*xp)[2] =
static_cast<
Real
>
(0.5);
114
return
ROL::makePtr<StdVector<Real>>(xp);
115
}
116
117
Ptr<Constraint<Real>>
getEqualityConstraint
(
void
)
const
{
118
return
ROL::makePtr<Constraint_HS28<Real>>();
119
}
120
121
Ptr<Vector<Real>>
getEqualityMultiplier
(
void
)
const
{
122
int
n = 1;
123
return
ROL::makePtr<StdVector<Real>>(n,0.0);
124
}
125
};
126
127
}
// End ZOO Namespace
128
}
// End ROL Namespace
129
130
#endif
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_HS28::applyJacobian
void applyJacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS28.hpp:67
ROL::ZOO::Constraint_HS28::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_HS28.hpp:81
ROL::ZOO::Constraint_HS28::applyAdjointJacobian
void applyAdjointJacobian(std::vector< Real > &ajv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS28.hpp:73
ROL::ZOO::Constraint_HS28::value
void value(std::vector< Real > &c, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS28.hpp:62
ROL::ZOO::Constraint_HS28::Constraint_HS28
Constraint_HS28(void)
Definition
ROL_HS28.hpp:60
ROL::ZOO::Objective_HS28
W. Hock and K. Schittkowski 28th test function.
Definition
ROL_HS28.hpp:35
ROL::ZOO::Objective_HS28::gradient
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS28.hpp:42
ROL::ZOO::Objective_HS28::value
Real value(const std::vector< Real > &x, Real &tol)
Definition
ROL_HS28.hpp:37
ROL::ZOO::Objective_HS28::hessVec
void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS28.hpp:49
ROL::ZOO::getHS28::getSolution
Ptr< Vector< Real > > getSolution(const int i=0) const
Definition
ROL_HS28.hpp:108
ROL::ZOO::getHS28::getObjective
Ptr< Objective< Real > > getObjective(void) const
Definition
ROL_HS28.hpp:95
ROL::ZOO::getHS28::getEqualityConstraint
Ptr< Constraint< Real > > getEqualityConstraint(void) const
Definition
ROL_HS28.hpp:117
ROL::ZOO::getHS28::getInitialGuess
Ptr< Vector< Real > > getInitialGuess(void) const
Definition
ROL_HS28.hpp:99
ROL::ZOO::getHS28::getEqualityMultiplier
Ptr< Vector< Real > > getEqualityMultiplier(void) const
Definition
ROL_HS28.hpp:121
ROL::ZOO::getHS28::getHS28
getHS28(void)
Definition
ROL_HS28.hpp:93
ROL::ZOO
Definition
ROL_Beale.hpp:26
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0