ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
step
fletcher
ROL_FletcherBase.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_FLETCHERBASE_H
11
#define ROL_FLETCHERBASE_H
12
13
#include "
ROL_Objective.hpp
"
14
#include "
ROL_Constraint.hpp
"
15
#include "
ROL_Vector.hpp
"
16
#include "
ROL_Types.hpp
"
17
#include "ROL_Ptr.hpp"
18
#include "
ROL_KrylovFactory.hpp
"
19
#include "
ROL_PartitionedVector.hpp
"
20
#include <iostream>
21
22
namespace
ROL
{
23
24
template
<
class
Real>
25
class
FletcherBase
:
public
Objective
<Real> {
26
27
protected
:
28
const
Ptr<Objective<Real> >
obj_
;
29
const
Ptr<Constraint<Real> >
con_
;
30
31
Real
penaltyParameter_
;
32
Real
quadPenaltyParameter_
;
33
34
// Evaluation counters
35
int
nfval_
;
36
int
ngval_
;
37
int
ncval_
;
38
39
Real
fPhi_
;
// value of penalty function
40
Ptr<Vector<Real> >
gPhi_
;
// gradient of penalty function
41
42
Ptr<Vector<Real> >
y_
;
// multiplier estimate
43
44
Real
fval_
;
// value of objective function
45
Ptr<Vector<Real> >
g_
;
// gradient of objective value
46
Ptr<Vector<Real> >
c_
;
// constraint value
47
Ptr<Vector<Real> >
scaledc_
;
// penaltyParameter_ * c_
48
Ptr<Vector<Real> >
gL_
;
// gradient of Lagrangian (g - A*y)
49
50
Real
cnorm_
;
// norm of constraint violation
51
52
bool
isValueComputed_
;
53
bool
isGradientComputed_
;
54
bool
isMultiplierComputed_
;
55
bool
isObjValueComputed_
;
56
bool
isObjGradComputed_
;
57
bool
isConValueComputed_
;
58
59
Real
multSolverError_
;
// Error from augmented system solve in value()
60
Real
gradSolveError_
;
// Error from augmented system solve in gradient()
61
62
Real
delta_
;
// regularization parameter
63
64
bool
useInexact_
;
65
66
// For Augmented system solves
67
Ptr<Krylov<Real> >
krylov_
;
68
int
iterKrylov_
;
69
int
flagKrylov_
;
70
Ptr<Vector<Real> >
v1_
;
71
Ptr<Vector<Real> >
v2_
;
72
Ptr<PartitionedVector<Real> >
vv_
;
73
Ptr<Vector<Real> >
b1_
;
74
Ptr<Vector<Real> >
b2_
;
75
Ptr<PartitionedVector<Real> >
bb_
;
76
Ptr<Vector<Real> >
w1_
;
77
Ptr<Vector<Real> >
w2_
;
78
Ptr<PartitionedVector<Real> >
ww_
;
79
80
void
objValue
(
const
Vector<Real>
& x, Real &tol) {
81
if
( !
isObjValueComputed_
) {
82
fval_
=
obj_
->value(x,tol);
nfval_
++;
83
isObjValueComputed_
=
true
;
84
}
85
}
86
87
void
objGrad
(
const
Vector<Real>
& x, Real &tol) {
88
if
( !
isObjGradComputed_
) {
89
obj_
->gradient(*
g_
, x, tol);
ngval_
++;
90
isObjGradComputed_
=
true
;
91
}
92
}
93
94
void
conValue
(
const
Vector<Real>
&x, Real &tol) {
95
if
( !
isConValueComputed_
) {
96
con_
->value(*
c_
,x,tol);
ncval_
++;
97
scaledc_
->set(*
c_
);
98
scaledc_
->scale(
penaltyParameter_
);
99
isConValueComputed_
=
true
;
100
}
101
}
102
103
virtual
void
computeMultipliers
(
const
Vector<Real>
& x, Real tol) {}
104
105
public
:
106
FletcherBase
(
const
ROL::Ptr<
Objective<Real>
> &obj,
107
const
ROL::Ptr<
Constraint<Real>
> &con)
108
:
obj_
(obj),
con_
(con),
nfval_
(0),
ngval_
(0),
ncval_
(0),
fPhi_
(0),
109
isValueComputed_
(false),
isGradientComputed_
(false),
110
isMultiplierComputed_
(false),
isObjValueComputed_
(false),
111
isObjGradComputed_
(false),
isConValueComputed_
(false),
112
multSolverError_
(0),
gradSolveError_
(0),
113
iterKrylov_
(0),
flagKrylov_
(0) {}
114
115
// Accessors
116
const
Ptr<Vector<Real>>
getLagrangianGradient
(
const
Vector<Real>
& x) {
117
// TODO: Figure out reasonable tolerance
118
if
( !
isMultiplierComputed_
) {
119
Real tol =
static_cast<
Real
>
(1e-12);
120
computeMultipliers
(x, tol);
121
}
122
return
gL_
;
123
}
124
125
const
Ptr<Vector<Real>>
getConstraintVec
(
const
Vector<Real>
& x) {
126
Real tol = std::sqrt(
ROL_EPSILON<Real>
());
127
conValue
(x, tol);
128
return
c_
;
129
}
130
131
const
Ptr<Vector<Real>>
getMultiplierVec
(
const
Vector<Real>
& x) {
132
// TODO: Figure out reasonable tolerance
133
if
( !
isMultiplierComputed_
) {
134
Real tol =
static_cast<
Real
>
(1e-12);
135
computeMultipliers
(x, tol);
136
}
137
return
y_
;
138
}
139
140
const
Ptr<Vector<Real>>
getGradient
(
const
Vector<Real>
& x) {
141
if
( !
isGradientComputed_
) {
142
// TODO: Figure out reasonable tolerance
143
Real tol =
static_cast<
Real
>
(1e-12);
144
this->
gradient
(*gPhi_, x, tol);
145
}
146
return
gPhi_
;
147
}
148
149
Real
getObjectiveValue
(
const
Vector<Real>
& x) {
150
Real tol = std::sqrt(
ROL_EPSILON<Real>
());
151
objValue
(x, tol);
152
153
return
fval_
;
154
}
155
156
int
getNumberFunctionEvaluations
()
const
{
157
return
nfval_
;
158
}
159
160
int
getNumberGradientEvaluations
()
const
{
161
return
ngval_
;
162
}
163
164
int
getNumberConstraintEvaluations
()
const
{
165
return
ncval_
;
166
}
167
168
void
setDelta
(Real delta) {
169
delta_
= delta;
170
isValueComputed_
=
false
;
171
isGradientComputed_
=
false
;
172
}
173
174
void
setPenaltyParameter
( Real sigma ) {
175
penaltyParameter_
= sigma;
176
isValueComputed_
=
false
;
177
isGradientComputed_
=
false
;
178
}
179
180
};
// class Fletcher
181
182
}
// namespace ROL
183
184
#include "
ROL_Fletcher.hpp
"
185
#include "
ROL_BoundFletcher.hpp
"
186
187
#endif
ROL_BoundFletcher.hpp
ROL_Constraint.hpp
ROL_Fletcher.hpp
ROL_KrylovFactory.hpp
ROL_Objective.hpp
ROL_PartitionedVector.hpp
ROL_Types.hpp
Contains definitions of custom data types in ROL.
ROL_Vector.hpp
ROL::Constraint
Defines the general constraint operator interface.
Definition
ROL_Constraint.hpp:52
ROL::FletcherBase::fPhi_
Real fPhi_
Definition
ROL_FletcherBase.hpp:39
ROL::FletcherBase::v1_
Ptr< Vector< Real > > v1_
Definition
ROL_FletcherBase.hpp:70
ROL::FletcherBase::computeMultipliers
virtual void computeMultipliers(const Vector< Real > &x, Real tol)
Definition
ROL_FletcherBase.hpp:103
ROL::FletcherBase::b2_
Ptr< Vector< Real > > b2_
Definition
ROL_FletcherBase.hpp:74
ROL::FletcherBase::c_
Ptr< Vector< Real > > c_
Definition
ROL_FletcherBase.hpp:46
ROL::FletcherBase::w1_
Ptr< Vector< Real > > w1_
Definition
ROL_FletcherBase.hpp:76
ROL::FletcherBase::con_
const Ptr< Constraint< Real > > con_
Definition
ROL_FletcherBase.hpp:29
ROL::FletcherBase::conValue
void conValue(const Vector< Real > &x, Real &tol)
Definition
ROL_FletcherBase.hpp:94
ROL::FletcherBase::delta_
Real delta_
Definition
ROL_FletcherBase.hpp:62
ROL::FletcherBase::scaledc_
Ptr< Vector< Real > > scaledc_
Definition
ROL_FletcherBase.hpp:47
ROL::FletcherBase::v2_
Ptr< Vector< Real > > v2_
Definition
ROL_FletcherBase.hpp:71
ROL::FletcherBase::getLagrangianGradient
const Ptr< Vector< Real > > getLagrangianGradient(const Vector< Real > &x)
Definition
ROL_FletcherBase.hpp:116
ROL::FletcherBase::obj_
const Ptr< Objective< Real > > obj_
Definition
ROL_FletcherBase.hpp:28
ROL::FletcherBase::quadPenaltyParameter_
Real quadPenaltyParameter_
Definition
ROL_FletcherBase.hpp:32
ROL::FletcherBase::gPhi_
Ptr< Vector< Real > > gPhi_
Definition
ROL_FletcherBase.hpp:40
ROL::FletcherBase::getNumberConstraintEvaluations
int getNumberConstraintEvaluations() const
Definition
ROL_FletcherBase.hpp:164
ROL::FletcherBase::w2_
Ptr< Vector< Real > > w2_
Definition
ROL_FletcherBase.hpp:77
ROL::FletcherBase::getNumberGradientEvaluations
int getNumberGradientEvaluations() const
Definition
ROL_FletcherBase.hpp:160
ROL::FletcherBase::isMultiplierComputed_
bool isMultiplierComputed_
Definition
ROL_FletcherBase.hpp:54
ROL::FletcherBase::setDelta
void setDelta(Real delta)
Definition
ROL_FletcherBase.hpp:168
ROL::FletcherBase::objGrad
void objGrad(const Vector< Real > &x, Real &tol)
Definition
ROL_FletcherBase.hpp:87
ROL::FletcherBase::isGradientComputed_
bool isGradientComputed_
Definition
ROL_FletcherBase.hpp:53
ROL::FletcherBase::getMultiplierVec
const Ptr< Vector< Real > > getMultiplierVec(const Vector< Real > &x)
Definition
ROL_FletcherBase.hpp:131
ROL::FletcherBase::objValue
void objValue(const Vector< Real > &x, Real &tol)
Definition
ROL_FletcherBase.hpp:80
ROL::FletcherBase::isObjValueComputed_
bool isObjValueComputed_
Definition
ROL_FletcherBase.hpp:55
ROL::FletcherBase::ncval_
int ncval_
Definition
ROL_FletcherBase.hpp:37
ROL::FletcherBase::ngval_
int ngval_
Definition
ROL_FletcherBase.hpp:36
ROL::FletcherBase::g_
Ptr< Vector< Real > > g_
Definition
ROL_FletcherBase.hpp:45
ROL::FletcherBase::y_
Ptr< Vector< Real > > y_
Definition
ROL_FletcherBase.hpp:42
ROL::FletcherBase::getObjectiveValue
Real getObjectiveValue(const Vector< Real > &x)
Definition
ROL_FletcherBase.hpp:149
ROL::FletcherBase::vv_
Ptr< PartitionedVector< Real > > vv_
Definition
ROL_FletcherBase.hpp:72
ROL::FletcherBase::gL_
Ptr< Vector< Real > > gL_
Definition
ROL_FletcherBase.hpp:48
ROL::FletcherBase::iterKrylov_
int iterKrylov_
Definition
ROL_FletcherBase.hpp:68
ROL::FletcherBase::penaltyParameter_
Real penaltyParameter_
Definition
ROL_FletcherBase.hpp:31
ROL::FletcherBase::getGradient
const Ptr< Vector< Real > > getGradient(const Vector< Real > &x)
Definition
ROL_FletcherBase.hpp:140
ROL::FletcherBase::getNumberFunctionEvaluations
int getNumberFunctionEvaluations() const
Definition
ROL_FletcherBase.hpp:156
ROL::FletcherBase::fval_
Real fval_
Definition
ROL_FletcherBase.hpp:44
ROL::FletcherBase::ww_
Ptr< PartitionedVector< Real > > ww_
Definition
ROL_FletcherBase.hpp:78
ROL::FletcherBase::bb_
Ptr< PartitionedVector< Real > > bb_
Definition
ROL_FletcherBase.hpp:75
ROL::FletcherBase::flagKrylov_
int flagKrylov_
Definition
ROL_FletcherBase.hpp:69
ROL::FletcherBase::cnorm_
Real cnorm_
Definition
ROL_FletcherBase.hpp:50
ROL::FletcherBase::krylov_
Ptr< Krylov< Real > > krylov_
Definition
ROL_FletcherBase.hpp:67
ROL::FletcherBase::gradSolveError_
Real gradSolveError_
Definition
ROL_FletcherBase.hpp:60
ROL::FletcherBase::getConstraintVec
const Ptr< Vector< Real > > getConstraintVec(const Vector< Real > &x)
Definition
ROL_FletcherBase.hpp:125
ROL::FletcherBase::useInexact_
bool useInexact_
Definition
ROL_FletcherBase.hpp:64
ROL::FletcherBase::nfval_
int nfval_
Definition
ROL_FletcherBase.hpp:35
ROL::FletcherBase::isValueComputed_
bool isValueComputed_
Definition
ROL_FletcherBase.hpp:52
ROL::FletcherBase::b1_
Ptr< Vector< Real > > b1_
Definition
ROL_FletcherBase.hpp:73
ROL::FletcherBase::setPenaltyParameter
void setPenaltyParameter(Real sigma)
Definition
ROL_FletcherBase.hpp:174
ROL::FletcherBase::isObjGradComputed_
bool isObjGradComputed_
Definition
ROL_FletcherBase.hpp:56
ROL::FletcherBase::isConValueComputed_
bool isConValueComputed_
Definition
ROL_FletcherBase.hpp:57
ROL::FletcherBase::multSolverError_
Real multSolverError_
Definition
ROL_FletcherBase.hpp:59
ROL::FletcherBase::FletcherBase
FletcherBase(const ROL::Ptr< Objective< Real > > &obj, const ROL::Ptr< Constraint< Real > > &con)
Definition
ROL_FletcherBase.hpp:106
ROL::ROL::Objective::gradient
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Definition
ROL_ObjectiveDef.hpp:40
ROL::ROL::Objective::Objective
Objective()
Definition
ROL_Constraint_SerialSimOpt.hpp:53
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::ROL_EPSILON
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Definition
ROL_Types.hpp:57
Generated by
1.17.0