-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhessian_update.jl
More file actions
173 lines (145 loc) · 6.01 KB
/
Copy pathhessian_update.jl
File metadata and controls
173 lines (145 loc) · 6.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
"""
CustomHessian()
User‑provided Hessian function.
The Hessian function should be provided when creating a `FidesProblem`.
See also: [FidesProblem](@ref)
"""
struct CustomHessian
end
"""
BB(; init_hess = nothing}
The Broydens “bad” method as introduced in [1]. This is a rank 1 update strategy that does
not preserve symmetry or positive definiteness.
## Keyword arguments
- `init_hess = nothing`: Initial Hessian for the update scheme. If provided as a `Matrix`,
the given matrix is used; if set to `nothing` (default), the identity matrix is used.
## References
1. Broyden, C. G. (1965). A class of methods for solving nonlinear simultaneous equations.
Mathematics of computation, 19(92), 577-593.
"""
struct BB{T <: Union{Nothing, AbstractMatrix}}
init_hess::T
init_with_hess::Bool
end
function BB(; init_hess::Union{Nothing, AbstractMatrix} = nothing)
init_with_hess = _get_init_with_hess(init_hess)
return BB(init_hess, init_with_hess)
end
"""
SR1(; init_hess = nothing)
The Symmetric Rank 1 update strategy as described in [1]. This is a rank 1 update strategy
that preserves symmetry but does not preserve positive-semidefiniteness.
## Keyword arguments
- `init_hess = nothing`: Initial Hessian for the update scheme. If provided as a `Matrix`,
the given matrix is used; if set to `nothing` (default), the identity matrix is used.
## References
1. Nocedal, Jorge, and Stephen J. Wright, eds. Numerical optimization (Chapter 6.2). New
York, NY: Springer New York, 1999.
"""
struct SR1{T <: Union{Nothing, AbstractMatrix}}
init_hess::T
init_with_hess::Bool
end
function SR1(; init_hess::Union{Nothing, AbstractMatrix} = nothing)
init_with_hess = _get_init_with_hess(init_hess)
return SR1(init_hess, init_with_hess)
end
"""
BG(; init_hess = nothing}
Broydens “good” method as introduced in [1]. This is a rank 1 update strategy that does not
preserve symmetry or positive definiteness.
## Keyword arguments
- `init_hess = nothing`: Initial Hessian for the update scheme. If provided as a `Matrix`,
the given matrix is used; if set to `nothing` (default), the identity matrix is used.
## References
1. Broyden, C. G. (1965). A class of methods for solving nonlinear simultaneous equations.
Mathematics of computation, 19(92), 577-593.
"""
struct BG{T <: Union{Nothing, AbstractMatrix}}
init_hess::T
init_with_hess::Bool
end
function BG(; init_hess::Union{Nothing, AbstractMatrix} = nothing)
init_with_hess = _get_init_with_hess(init_hess)
return BG(init_hess, init_with_hess)
end
"""
BFGS(; init_hess = nothing, enforce_curv_cond::Bool = true)
The Broyden-Fletcher-Goldfarb-Shanno (BFGS) update strategy is a rank-2 update method that
preserves both symmetry and positive-semidefiniteness [1].
## Keyword arguments
- `init_hess = nothing`: Initial Hessian for the update scheme. If provided as a `Matrix`,
the given matrix is used; if set to `nothing` (default), the identity matrix is used.
- `enforce_curv_cond = true`: Whether the update should attempt to preserve positive
definiteness. If `true`, updates from steps that violate the curvature condition are
discarded.
## References
1. Nocedal, Jorge, and Stephen J. Wright, eds. Numerical optimization. New York, NY:
Springer New York, 1999.
"""
struct BFGS{T <: Union{Nothing, AbstractMatrix}}
init_hess::T
enforce_curv_cond::Bool
init_with_hess::Bool
end
function BFGS(;
init_hess::Union{Nothing, AbstractMatrix} = nothing, enforce_curv_cond::Bool = true
)
init_with_hess = _get_init_with_hess(init_hess)
return BFGS(init_hess, enforce_curv_cond, init_with_hess)
end
"""
DFP(; init_hess = nothing, enforce_curv_cond::Bool = true)
The Davidon-Fletcher-Powell update strategy [1]. This is a rank 2 update strategy that
preserves symmetry and positive-semidefiniteness.
## Keyword arguments
- `init_hess = nothing`: Initial Hessian for the update scheme. If provided as a `Matrix`,
the given matrix is used; if set to `nothing` (default), the identity matrix is used.
- `enforce_curv_cond = true`: Whether the update should attempt to preserve positive
definiteness. If `true`, updates from steps that violate the curvature condition are
discarded.
## References
1. Avriel, M. (2003). Nonlinear programming: analysis and methods. Courier Corporation.
"""
struct DFP{T <: Union{Nothing, AbstractMatrix}}
init_hess::T
enforce_curv_cond::Bool
init_with_hess::Bool
end
function DFP(;
init_hess::Union{Nothing, AbstractMatrix} = nothing, enforce_curv_cond::Bool = true
)
init_with_hess = _get_init_with_hess(init_hess)
return DFP(init_hess, enforce_curv_cond, init_with_hess)
end
"""
Broyden(phi; init_hess = nothing, enforce_curv_cond::Bool = true)
The update scheme, as described in [1], which is a generalization of the BFGS/DFP methods
where `phi` controls the convex combination between the two. This rank-2 update strategy
preserves both symmetry and positive-semidefiniteness when `0 ≤ phi ≤ 1`.
## Arguments
- `phi::AbstractFloat`: The convex combination parameter interpolating between BFGS
(`phi=0`) and DFP (`phi=1`).
## Keyword arguments
- `init_hess = nothing`: Initial Hessian for the update scheme. If provided as a `Matrix`,
the given matrix is used; if set to `nothing` (default), the identity matrix is used.
- `enforce_curv_cond = true`: Whether the update should attempt to preserve positive
definiteness. If `true`, updates from steps that violate the curvature condition are
discarded.
## References
1. Nocedal, Jorge, and Stephen J. Wright, eds. Numerical optimization. New York, NY:
Springer New York, 1999.
"""
struct Broyden{T <: Union{Nothing, AbstractMatrix}}
phi::Float64
init_hess::T
enforce_curv_cond::Bool
init_with_hess::Bool
end
function Broyden(
phi::AbstractFloat; init_hess::Union{Nothing, AbstractMatrix} = nothing,
enforce_curv_cond::Bool = true
)
init_with_hess = _get_init_with_hess(init_hess)
return Broyden(phi, init_hess, enforce_curv_cond, init_with_hess)
end