ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
zoo
testproblems
ROL_HS21.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
#ifndef ROL_HS21_HPP
16
#define ROL_HS21_HPP
17
18
#include "
ROL_StdObjective.hpp
"
19
#include "
ROL_StdConstraint.hpp
"
20
#include "
ROL_StdVector.hpp
"
21
#include "
ROL_TestProblem.hpp
"
22
#include "
ROL_Bounds.hpp
"
23
24
namespace
ROL
{
25
namespace
ZOO
{
26
27
template
<
class
Real>
28
class
Objective_HS21
:
public
StdObjective
<Real> {
29
public
:
30
Real
value
(
const
std::vector<Real> &x, Real &tol ) {
31
const
Real c1(0.1), c2(100);
32
return
c1*x[0]*x[0] + x[1]*x[1] - c2;
33
}
34
35
void
gradient
( std::vector<Real> &g,
const
std::vector<Real> &x, Real &tol ) {
36
const
Real two(2), c1(0.1);
37
g[0] = two*c1*x[0];
38
g[1] = two*x[1];
39
}
40
41
void
hessVec
( std::vector<Real> &hv,
const
std::vector<Real> &v,
const
std::vector<Real> &x, Real &tol ) {
42
const
Real two(2), c1(0.1);
43
hv[0] = two*c1*v[0];
44
hv[1] = two*v[1];
45
}
46
};
// class Objective_HS21
47
48
template
<
class
Real>
49
class
Constraint_HS21
:
public
StdConstraint
<Real> {
50
public
:
51
void
value
( std::vector<Real> &c,
const
std::vector<Real> &x, Real &tol ) {
52
const
Real c1(10);
53
c[0] = c1*x[0] - x[1] - c1;
54
}
55
56
void
applyJacobian
( std::vector<Real> &jv,
const
std::vector<Real> &v,
57
const
std::vector<Real> &x, Real &tol ) {
58
const
Real c1(10);
59
jv[0] = c1*v[0] - v[1];
60
}
61
62
void
applyAdjointJacobian
( std::vector<Real> &ajv,
const
std::vector<Real> &v,
63
const
std::vector<Real> &x, Real &tol ) {
64
const
Real c1(10);
65
ajv[0] = c1*v[0];
66
ajv[1] = -v[0];
67
}
68
69
void
applyAdjointHessian
( std::vector<Real> &ahuv,
const
std::vector<Real> &u,
70
const
std::vector<Real> &v,
const
std::vector<Real> &x, Real &tol ) {
71
ahuv.assign(ahuv.size(),
static_cast<
Real
>
(0));
72
}
73
};
// class Constraint_HS21
74
75
template
<
class
Real>
76
class
getHS21
:
public
TestProblem
<Real> {
77
public
:
78
getHS21
(
void
) {}
79
80
Ptr<Objective<Real> >
getObjective
(
void
)
const
{
81
return
makePtr<Objective_HS21<Real>>();
82
}
83
84
Ptr<Constraint<Real> >
getInequalityConstraint
(
void
)
const
{
85
return
makePtr<Constraint_HS21<Real>>();
86
}
87
88
Ptr<BoundConstraint<Real>>
getBoundConstraint
(
void
)
const
{
89
Ptr<std::vector<Real>> lp = makePtr<std::vector<Real>>(2,2.0);
90
(*lp)[1] =
static_cast<
Real
>
(-50);
91
92
Ptr<Vector<Real>> l = makePtr<StdVector<Real>>(lp);
93
Ptr<Vector<Real>> u = makePtr<StdVector<Real>>(2,50.0);
94
95
return
makePtr<Bounds<Real>>(l,u);
96
}
97
98
Ptr<Vector<Real>>
getInitialGuess
(
void
)
const
{
99
return
makePtr<StdVector<Real>>(2,-1.0);
100
}
101
102
Ptr<Vector<Real>>
getSolution
(
const
int
i = 0 )
const
{
103
Ptr<std::vector<Real> > xp = makePtr<std::vector<Real>>(2,0.0);
104
(*xp)[0] =
static_cast<
Real
>
(2);
105
return
makePtr<StdVector<Real>>(xp);
106
}
107
108
Ptr<Vector<Real>>
getInequalityMultiplier
(
void
)
const
{
109
return
makePtr<StdVector<Real>>(1,0.0);
110
}
111
112
Ptr<BoundConstraint<Real>>
getSlackBoundConstraint
(
void
)
const
{
113
Ptr<Vector<Real>> l = makePtr<StdVector<Real>>(1,0.0);
114
Ptr<Vector<Real>> u = makePtr<StdVector<Real>>(1,
ROL_INF<Real>
());
115
return
makePtr<Bounds<Real>>(l,u);
116
}
117
};
118
119
}
// namespace ZOO
120
}
// namespace ROL
121
122
#endif
// ROL_HS21_HPP
ROL_Bounds.hpp
ROL_StdConstraint.hpp
ROL_StdObjective.hpp
ROL_StdVector.hpp
ROL_TestProblem.hpp
Contains definitions of test objective functions.
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_HS21
Definition
ROL_HS21.hpp:49
ROL::ZOO::Constraint_HS21::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_HS21.hpp:69
ROL::ZOO::Constraint_HS21::value
void value(std::vector< Real > &c, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS21.hpp:51
ROL::ZOO::Constraint_HS21::applyAdjointJacobian
void applyAdjointJacobian(std::vector< Real > &ajv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS21.hpp:62
ROL::ZOO::Constraint_HS21::applyJacobian
void applyJacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS21.hpp:56
ROL::ZOO::Objective_HS21
Definition
ROL_HS21.hpp:28
ROL::ZOO::Objective_HS21::value
Real value(const std::vector< Real > &x, Real &tol)
Definition
ROL_HS21.hpp:30
ROL::ZOO::Objective_HS21::hessVec
void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS21.hpp:41
ROL::ZOO::Objective_HS21::gradient
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
Definition
ROL_HS21.hpp:35
ROL::ZOO::getHS21::getInequalityMultiplier
Ptr< Vector< Real > > getInequalityMultiplier(void) const
Definition
ROL_HS21.hpp:108
ROL::ZOO::getHS21::getSlackBoundConstraint
Ptr< BoundConstraint< Real > > getSlackBoundConstraint(void) const
Definition
ROL_HS21.hpp:112
ROL::ZOO::getHS21::getInitialGuess
Ptr< Vector< Real > > getInitialGuess(void) const
Definition
ROL_HS21.hpp:98
ROL::ZOO::getHS21::getInequalityConstraint
Ptr< Constraint< Real > > getInequalityConstraint(void) const
Definition
ROL_HS21.hpp:84
ROL::ZOO::getHS21::getSolution
Ptr< Vector< Real > > getSolution(const int i=0) const
Definition
ROL_HS21.hpp:102
ROL::ZOO::getHS21::getObjective
Ptr< Objective< Real > > getObjective(void) const
Definition
ROL_HS21.hpp:80
ROL::ZOO::getHS21::getHS21
getHS21(void)
Definition
ROL_HS21.hpp:78
ROL::ZOO::getHS21::getBoundConstraint
Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
Definition
ROL_HS21.hpp:88
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