curvature
The quadratic model a trust region minimises.
The optimiser needs three things of it: B v for the predicted reduction and
the Cauchy point, B^-1 g for the Newton step, and an update from a step and
the change in gradient it produced. The dogleg, the accept/reject test and the
radius policy are written against those, so another model can be supplied by
passing model= to TrustRegion.
B0, the model before any curvature pairs, may be a full matrix rather than a
diagonal. It never changes, so it is factorised once at construction and every
later solve is a triangular pair -- O(n^3) once rather than per iteration.
That is what lets a model Hessian contribute its couplings and not merely its
diagonal, and the difference is large: with only the diagonal this model needed
55 calculator calls on a relaxation where a full BFGS needed 51, and with the
couplings it needs 23. Above FULL_MODEL_LIMIT freedoms the starting model is
too large to hold and factorise, so only its diagonal survives.
Keeping B0 fixed and applying the pairs as a correction is also why this is
the only model here. A full BFGS accumulates its updates into the starting
matrix, so a model Hessian is progressively overwritten by the early, noisy
curvature pairs; here it preconditions the whole run, and what gets forgotten
is the stale pairs instead.
The update is Powell-damped, so the model stays positive definite for any curvature pair and the two-loop inverse can be trusted without a fallback.
LimitedMemoryBFGS
The last memory curvature pairs, and a diagonal starting model.
The inverse comes from the usual two-loop recursion. The forward product comes from the compact representation of Byrd, Nocedal and Schnabel,
B = B0 - [B0 S, Y] M^-1 [S^T B0; Y^T],
M = [[S^T B0 S, L], [L^T, -D]]
which is exact rather than an approximation of the stored model, and costs
O(n m + m^3) with m around ten. It is needed because a dogleg wants
g.B.g and p.B.p, not only the Newton step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
number of degrees of freedom |
required |
memory
|
int
|
how many curvature pairs to keep |
DEFAULT_MEMORY
|
diagonal
|
(n,) starting curvature per degree of freedom. The diagonal of a model Hessian goes here, which keeps the part of it that a limited-memory model can carry -- which freedoms are stiff -- while dropping the couplings it cannot. |
None
|
Source code in chmpy/opt/curvature.py
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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
diagonal
property
The diagonal of B0, for a model that has no couplings to offer
quadratic(gradient, step)
solve(vector)
B^-1 v by the two-loop recursion, unwinding through the same B0.
Source code in chmpy/opt/curvature.py
to_dense()
The model as an explicit matrix, by applying it to a basis.
O(n^2 m), so only worth asking for at the sizes where a dense model
would have been an option at all. Used to hand what one stage of a
relaxation learned to the next.
Source code in chmpy/opt/curvature.py
damped_pair(step, gradient_change, model_step, curvature)
Powell's damping: blend y towards Bs until the pair is usable.
Returns (y_hat, y_hat . s), or (None, 0) when no update is safe. The
blend is chosen so that y_hat . s comes out at exactly 0.2 s.Bs > 0,
which keeps the updated model positive definite for any step rather than
only for those with positive curvature. Skipping instead -- which plain
BFGS must do -- throws away precisely the steps a trust region rejects, so
the model that caused a rejection never learns from it.
Source code in chmpy/opt/curvature.py
for_size(n_dof, initial=None, memory=DEFAULT_MEMORY)
Build a curvature model, handling the starting model by size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_dof
|
int
|
number of degrees of freedom |
required |
initial
|
(n, n) starting model, kept whole while it is small enough to factorise once and reduced to its diagonal beyond that |
None
|
|
memory
|
int
|
curvature pairs to keep |
DEFAULT_MEMORY
|
Returns:
| Type | Description |
|---|---|
|
LimitedMemoryBFGS |