@@ -86,6 +86,7 @@ function SolverCore.solve!(
86
86
end
87
87
88
88
iter = 0
89
+ set_iter! (stats, iter)
89
90
ϵd = atol + rtol * norm (dual)
90
91
ϵp = atol
91
92
@@ -94,8 +95,9 @@ function SolverCore.solve!(
94
95
verbose && @info log_row (Any[iter, fx, norm (cx), norm (dual), elapsed_time, ' c' ])
95
96
solved = norm (dual) < ϵd && norm (cx) < ϵp
96
97
tired = neval_obj (nlp) + neval_cons (nlp) > max_eval || elapsed_time > max_time
98
+ user = false
97
99
98
- while ! (solved || tired)
100
+ while ! (solved || tired || user )
99
101
# assume the model returns a dense Hessian in column-major order
100
102
# NB: hess_coord!() only returns values in the lower triangle
101
103
hess_coord! (nlp, x, y, view (hval, 1 : nnzh))
@@ -122,6 +124,9 @@ function SolverCore.solve!(
122
124
Wxy = reshape_array (wval, (nvar + ncon, nvar + ncon))
123
125
Hxy = reshape_array (hval, (nvar, nvar))
124
126
Wxy[1 : nvar, 1 : nvar] .= Hxy
127
+ for i = 1 : nvar
128
+ Wxy[i, i] += sqrt (eps (T))
129
+ end
125
130
if ncon > 0
126
131
Wxy[(nvar + 1 ): (nvar + ncon), 1 : nvar] .= Jx
127
132
end
@@ -146,11 +151,21 @@ function SolverCore.solve!(
146
151
mul! (dual, Jx' , y, one (T), one (T))
147
152
end
148
153
elapsed_time = time () - start_time
149
- solved = norm (dual) < ϵd && norm (cx) < ϵp
154
+ set_time! (stats, elapsed_time)
155
+ presid = norm (cx)
156
+ dresid = norm (dual)
157
+ set_residuals! (stats, presid, dresid)
158
+ solved = dresid < ϵd && presid < ϵp
150
159
tired = neval_obj (nlp) + neval_cons (nlp) > max_eval || elapsed_time > max_time
151
160
152
161
iter += 1
153
162
fx = obj (nlp, x)
163
+ set_iter! (stats, iter)
164
+ set_objective! (stats, fx)
165
+
166
+ callback (nlp, solver, stats)
167
+ user = stats. status == :user
168
+
154
169
verbose && @info log_row (Any[iter, fx, norm (cx), norm (dual), elapsed_time, ' d' ])
155
170
end
156
171
0 commit comments