ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
step
interiorpoint
ROL_InteriorPoint.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_INTERIORPOINT_H
11
#define ROL_INTERIORPOINT_H
12
13
#include "
ROL_Objective.hpp
"
14
#include "
ROL_BoundConstraint.hpp
"
15
#include "
ROL_ObjectiveFromBoundConstraint.hpp
"
16
17
namespace
ROL
{
18
19
namespace
InteriorPoint
{
20
25
template
<
class
Real>
26
class
PenalizedObjective
:
public
ROL::Objective
<Real> {
27
private
:
28
typedef
typename
PartitionedVector<Real>::size_type
size_type
;
29
30
ROL::Ptr<Objective<Real> >
obj_
;
31
ROL::Ptr<Objective<Real> >
barrier_
;
32
ROL::Ptr<Vector<Real> >
x_
;
33
ROL::Ptr<Vector<Real> >
g_
;
34
ROL::Ptr<Vector<Real> >
scratch_
;
35
36
Real
mu_
;
37
Real
fval_
;
38
Real
gnorm_
;
39
int
nfval_
;
40
int
ngval_
;
41
42
public
:
43
44
PenalizedObjective
(
const
ROL::Ptr<
Objective<Real>
> &obj,
45
const
ROL::Ptr<
BoundConstraint<Real>
> &bnd,
46
const
Vector<Real>
&x,
47
ROL::ParameterList &parlist)
48
:
obj_
(obj),
x_
(
ROL
::nullPtr),
g_
(
ROL
::nullPtr),
scratch_
(
ROL
::nullPtr),
49
fval_
(0),
gnorm_
(0),
nfval_
(0),
ngval_
(0) {
50
ROL::ParameterList& IPlist = parlist.sublist(
"Step"
).sublist(
"Interior Point"
);
51
barrier_
= ROL::makePtr<ObjectiveFromBoundConstraint<Real>>(*bnd,IPlist);
52
x_
= x.
clone
();
53
g_
= x.
dual
().clone();
54
scratch_
= x.
dual
().clone();
55
mu_
= IPlist.get(
"Initial Barrier Parameter"
,1.0);
56
}
57
58
void
updatePenalty
( Real mu ) {
59
mu_
= mu;
60
}
61
62
int
getNumberFunctionEvaluations
(
void
) {
63
return
nfval_
;
64
}
65
66
int
getNumberGradientEvaluations
(
void
) {
67
return
ngval_
;
68
}
69
70
void
reset
(
void
) {
71
nfval_
= 0;
nfval_
= 0;
72
}
73
74
void
update
(
const
Vector<Real>
&x,
bool
flag =
true
,
int
iter = -1 ) {
75
// Update original objective and bound penalty
76
obj_
->update(x,flag,iter);
77
barrier_
->update(x,flag,iter);
78
}
79
80
Real
value
(
const
Vector<Real>
&x, Real &tol ) {
81
// Compute original objective value and bound penalty value
82
fval_
=
obj_
->value(x,tol);
83
Real val =
fval_
;
84
Real bval =
barrier_
->value(x,tol);
85
val +=
mu_
*bval;
86
87
++
nfval_
;
88
return
val;
89
}
90
91
Real
getObjectiveValue
(
void
) {
92
return
fval_
;
93
}
94
95
void
gradient
(
Vector<Real>
&g,
const
Vector<Real>
&x, Real &tol ) {
96
// Compute gradient of objective and bound penalty
97
obj_
->gradient(g,x,tol);
98
barrier_
->gradient(*
scratch_
,x,tol);
99
scratch_
->scale(
mu_
);
100
g.
plus
(*
scratch_
);
101
102
g_
->set(g);
103
gnorm_
= g.
norm
();
104
++
ngval_
;
105
}
106
107
void
getObjectiveGradient
(
Vector<Real>
&g ) {
108
g.
set
(*
g_
);
109
}
110
111
Real
getGradientNorm
() {
112
return
gnorm_
;
113
}
114
115
void
hessVec
(
Vector<Real>
&hv,
const
Vector<Real>
&v,
116
const
Vector<Real>
&x, Real &tol ) {
117
// Compute hessvec of objective and bound penalty
118
obj_
->hessVec(hv, v, x, tol);
119
barrier_
->hessVec(*
scratch_
,v,x,tol);
120
scratch_
->scale(
mu_
);
121
hv.
plus
(*
scratch_
);
122
}
123
124
};
// class InteriorPointObjective
125
126
}
// namespace InteriorPoint
127
}
// namespace ROL
128
129
#endif
ROL_BoundConstraint.hpp
ROL_ObjectiveFromBoundConstraint.hpp
ROL_Objective.hpp
ROL::BoundConstraint
Provides the interface to apply upper and lower bound constraints.
Definition
ROL_BoundConstraint.hpp:39
ROL::InteriorPoint::PenalizedObjective::reset
void reset(void)
Definition
ROL_InteriorPoint.hpp:70
ROL::InteriorPoint::PenalizedObjective::getGradientNorm
Real getGradientNorm()
Definition
ROL_InteriorPoint.hpp:111
ROL::InteriorPoint::PenalizedObjective::mu_
Real mu_
Definition
ROL_InteriorPoint.hpp:36
ROL::InteriorPoint::PenalizedObjective::hessVec
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Definition
ROL_InteriorPoint.hpp:115
ROL::InteriorPoint::PenalizedObjective::updatePenalty
void updatePenalty(Real mu)
Definition
ROL_InteriorPoint.hpp:58
ROL::InteriorPoint::PenalizedObjective::gradient
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Definition
ROL_InteriorPoint.hpp:95
ROL::InteriorPoint::PenalizedObjective::update
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Definition
ROL_InteriorPoint.hpp:74
ROL::InteriorPoint::PenalizedObjective::ngval_
int ngval_
Definition
ROL_InteriorPoint.hpp:40
ROL::InteriorPoint::PenalizedObjective::fval_
Real fval_
Definition
ROL_InteriorPoint.hpp:37
ROL::InteriorPoint::PenalizedObjective::getObjectiveValue
Real getObjectiveValue(void)
Definition
ROL_InteriorPoint.hpp:91
ROL::InteriorPoint::PenalizedObjective::obj_
ROL::Ptr< Objective< Real > > obj_
Definition
ROL_InteriorPoint.hpp:30
ROL::InteriorPoint::PenalizedObjective::getObjectiveGradient
void getObjectiveGradient(Vector< Real > &g)
Definition
ROL_InteriorPoint.hpp:107
ROL::InteriorPoint::PenalizedObjective::g_
ROL::Ptr< Vector< Real > > g_
Definition
ROL_InteriorPoint.hpp:33
ROL::InteriorPoint::PenalizedObjective::size_type
PartitionedVector< Real >::size_type size_type
Definition
ROL_InteriorPoint.hpp:28
ROL::InteriorPoint::PenalizedObjective::scratch_
ROL::Ptr< Vector< Real > > scratch_
Definition
ROL_InteriorPoint.hpp:34
ROL::InteriorPoint::PenalizedObjective::getNumberGradientEvaluations
int getNumberGradientEvaluations(void)
Definition
ROL_InteriorPoint.hpp:66
ROL::InteriorPoint::PenalizedObjective::x_
ROL::Ptr< Vector< Real > > x_
Definition
ROL_InteriorPoint.hpp:32
ROL::InteriorPoint::PenalizedObjective::getNumberFunctionEvaluations
int getNumberFunctionEvaluations(void)
Definition
ROL_InteriorPoint.hpp:62
ROL::InteriorPoint::PenalizedObjective::value
Real value(const Vector< Real > &x, Real &tol)
Definition
ROL_InteriorPoint.hpp:80
ROL::InteriorPoint::PenalizedObjective::PenalizedObjective
PenalizedObjective(const ROL::Ptr< Objective< Real > > &obj, const ROL::Ptr< BoundConstraint< Real > > &bnd, const Vector< Real > &x, ROL::ParameterList &parlist)
Definition
ROL_InteriorPoint.hpp:44
ROL::InteriorPoint::PenalizedObjective::barrier_
ROL::Ptr< Objective< Real > > barrier_
Definition
ROL_InteriorPoint.hpp:31
ROL::InteriorPoint::PenalizedObjective::nfval_
int nfval_
Definition
ROL_InteriorPoint.hpp:39
ROL::InteriorPoint::PenalizedObjective::gnorm_
Real gnorm_
Definition
ROL_InteriorPoint.hpp:38
ROL::PartitionedVector::size_type
std::vector< PV >::size_type size_type
Definition
ROL_PartitionedVector.hpp:38
ROL::ROL::Objective
Definition
ROL_Constraint_SerialSimOpt.hpp:44
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::Vector::norm
virtual Real norm() const =0
Returns where .
ROL::Vector::set
virtual void set(const Vector &x)
Set where .
Definition
ROL_Vector.hpp:176
ROL::Vector::dual
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
Definition
ROL_Vector.hpp:193
ROL::Vector::plus
virtual void plus(const Vector &x)=0
Compute , where .
ROL::Vector::clone
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
ROL::InteriorPoint
Definition
ROL_InteriorPoint.hpp:19
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0