ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
algorithm
TypeU
trustregion
ROL_DogLeg_U.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_DOGLEG_U_H
11
#define ROL_DOGLEG_U_H
12
16
17
#include "
ROL_TrustRegion_U.hpp
"
18
#include "
ROL_Types.hpp
"
19
20
namespace
ROL
{
21
22
template
<
class
Real>
23
class
DogLeg_U
:
public
TrustRegion_U
<Real> {
24
private
:
25
26
Ptr<Vector<Real>>
primal_
,
dual_
;
27
28
public
:
29
30
// Constructor
31
DogLeg_U
() {}
32
33
void
initialize
(
const
Vector<Real>
&x,
const
Vector<Real>
&g) {
34
primal_
= x.
clone
();
35
dual_
= g.
clone
();
36
}
37
38
void
solve
(
Vector<Real>
&s,
39
Real &snorm,
40
Real &pRed,
41
int
&iflag,
42
int
&iter,
43
const
Real del,
44
TrustRegionModel_U<Real>
&model ) {
45
Real tol = std::sqrt(
ROL_EPSILON<Real>
());
46
const
Real
zero
(0), half(0.5), one(1), two(2);
47
iter = 0;
48
// Set s to be the gradient
49
s.
set
(model.
getGradient
()->dual());
50
// Compute (quasi-)Newton step
51
model.
invHessVec
(*
primal_
,*model.
getGradient
(),s,tol);
52
Real sNnorm =
primal_
->norm();
53
Real gsN = -
primal_
->dot(s);
54
// Check if (quasi-)Newton step is feasible
55
if
( gsN >=
zero
) {
56
// Use the Cauchy point
57
model.
hessVec
(*
dual_
,s,s,tol);
58
Real gnorm = s.
norm
();
59
Real gnorm2 = gnorm*gnorm;
60
//Real gBg = dual_->dot(s.dual());
61
Real gBg =
dual_
->apply(s);
62
Real alpha = gnorm2/gBg;
63
if
( alpha*gnorm >= del || gBg <=
zero
) {
64
alpha = del/gnorm;
65
}
66
s.
scale
(-alpha);
67
snorm = alpha*gnorm;
68
iflag = 2;
69
pRed = alpha*(gnorm2 - half*alpha*gBg);
70
}
71
else
{
72
// Approximately solve trust region subproblem using double dogleg curve
73
if
(sNnorm <= del) {
// Use the (quasi-)Newton step
74
s.
set
(*
primal_
);
75
s.
scale
(-one);
76
snorm = sNnorm;
77
pRed = -half*gsN;
78
iflag = 0;
79
}
80
else
{
// The (quasi-)Newton step is outside of trust region
81
model.
hessVec
(*
dual_
,s,s,tol);
82
Real alpha =
zero
;
83
Real beta =
zero
;
84
Real gnorm = s.
norm
();
85
Real gnorm2 = gnorm*gnorm;
86
//Real gBg = dual_->dot(s.dual());
87
Real gBg =
dual_
->apply(s);
88
Real gamma = gnorm2/gBg;
89
if
( gamma*gnorm >= del || gBg <=
zero
) {
90
// Use Cauchy point
91
alpha =
zero
;
92
beta = del/gnorm;
93
s.
scale
(-beta);
94
snorm = del;
95
iflag = 2;
96
}
97
else
{
98
// Use a convex combination of Cauchy point and (quasi-)Newton step
99
Real a = sNnorm*sNnorm + two*gamma*gsN + gamma*gamma*gnorm2;
100
Real b = -gamma*gsN - gamma*gamma*gnorm2;
101
Real c = gamma*gamma*gnorm2 - del*del;
102
alpha = (-b + std::sqrt(b*b - a*c))/a;
103
beta = gamma*(one-alpha);
104
s.
scale
(-beta);
105
s.
axpy
(-alpha,*
primal_
);
106
snorm = del;
107
iflag = 1;
108
}
109
pRed = (alpha*(half*alpha-one)*gsN - half*beta*beta*gBg + beta*(one-alpha)*gnorm2);
110
}
111
}
112
}
113
};
114
115
}
// namespace ROL
116
117
#endif
zero
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
Definition
ROL_Objective_SerialSimOpt.hpp:77
ROL_TrustRegion_U.hpp
ROL_Types.hpp
Contains definitions of custom data types in ROL.
ROL::DogLeg_U::primal_
Ptr< Vector< Real > > primal_
Definition
ROL_DogLeg_U.hpp:26
ROL::DogLeg_U::DogLeg_U
DogLeg_U()
Definition
ROL_DogLeg_U.hpp:31
ROL::DogLeg_U::initialize
void initialize(const Vector< Real > &x, const Vector< Real > &g)
Definition
ROL_DogLeg_U.hpp:33
ROL::DogLeg_U::solve
void solve(Vector< Real > &s, Real &snorm, Real &pRed, int &iflag, int &iter, const Real del, TrustRegionModel_U< Real > &model)
Definition
ROL_DogLeg_U.hpp:38
ROL::DogLeg_U::dual_
Ptr< Vector< Real > > dual_
Definition
ROL_DogLeg_U.hpp:26
ROL::TrustRegionModel_U
Provides the interface to evaluate trust-region model functions.
Definition
ROL_TrustRegionModel_U.hpp:32
ROL::TrustRegionModel_U::hessVec
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &s, Real &tol) override
Definition
ROL_TrustRegionModel_U.hpp:150
ROL::TrustRegionModel_U::invHessVec
virtual void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &s, Real &tol) override
Definition
ROL_TrustRegionModel_U.hpp:154
ROL::TrustRegionModel_U::getGradient
virtual const Ptr< const Vector< Real > > getGradient(void) const
Definition
ROL_TrustRegionModel_U.hpp:168
ROL::TrustRegion_U
Provides interface for and implements trust-region subproblem solvers.
Definition
ROL_TrustRegion_U.hpp:23
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::scale
virtual void scale(const Real alpha)=0
Compute where .
ROL::Vector::clone
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
ROL::Vector::axpy
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition
ROL_Vector.hpp:120
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