You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/R2N.jl
+23-5Lines changed: 23 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ mutable struct R2NSolver{
12
12
xk::V
13
13
∇fk::V
14
14
∇fk⁻::V
15
+
y::V
15
16
mν∇fk::V
16
17
ψ::G
17
18
xkn::V
@@ -40,6 +41,7 @@ function R2NSolver(
40
41
xk =similar(x0)
41
42
∇fk =similar(x0)
42
43
∇fk⁻ =similar(x0)
44
+
y =similar(x0)
43
45
mν∇fk =similar(x0)
44
46
xkn =similar(x0)
45
47
s =similar(x0)
@@ -70,6 +72,7 @@ function R2NSolver(
70
72
xk,
71
73
∇fk,
72
74
∇fk⁻,
75
+
y,
73
76
mν∇fk,
74
77
ψ,
75
78
xkn,
@@ -154,6 +157,12 @@ Notably, you can access, and modify, the following:
154
157
- `stats.solver_specific[:nonsmooth_obj]`: current value of the nonsmooth part of the objective function;
155
158
- `stats.status`: current status of the algorithm. Should be `:unknown` unless the algorithm has attained a stopping criterion. Changing this to anything other than `:unknown` will stop the algorithm, but you should use `:user` to properly indicate the intention;
156
159
- `stats.elapsed_time`: elapsed time in seconds.
160
+
Similarly to the callback, when using a quasi-Newton approximation, two functions, `qn_update_y!(nlp, solver, stats)` and `qn_copy!(nlp, solver, stats)` are called at each update of the approximation.
161
+
Namely, the former computes the `y` vector for which the pair `(s, y)` is pushed into the approximation.
162
+
By default, `y := ∇fk⁻ - ∇fk`.
163
+
The latter allows the user to tell which values should be copied for the next iteration.
164
+
By default, only the gradient is copied: `∇fk⁻ .= ∇fk`.
165
+
This might be useful when using R2N in a constrained optimization context, when the gradient of the Lagrangian function is pushed at each iteration rather than the gradient of the objective function.
0 commit comments