55
55
maxtime
56
56
retcode:: ReturnCode.T
57
57
force_stop:: Bool
58
+ maxiters:: Int
59
+ end
60
+
61
+ function Base. show (io:: IO ,
62
+ cache:: NonlinearSolvePolyAlgorithmCache{pType, N} ) where {pType, N}
63
+ problem_kind = ifelse (pType == :NLS , " NonlinearProblem" , " NonlinearLeastSquaresProblem" )
64
+ println (io, " NonlinearSolvePolyAlgorithmCache for $(problem_kind) with $(N) algorithms" )
65
+ best_alg = ifelse (cache. best == - 1 , " nothing" , cache. best)
66
+ println (io, " Best algorithm: $(best_alg) " )
67
+ println (io, " Current algorithm: $(cache. current) " )
68
+ println (io, " nsteps: $(cache. nsteps) " )
69
+ println (io, " retcode: $(cache. retcode) " )
70
+ __show_cache (io, cache. caches[cache. current], 0 )
58
71
end
59
72
60
73
function reinit_cache! (cache:: NonlinearSolvePolyAlgorithmCache , args... ; kwargs... )
@@ -68,11 +81,11 @@ for (probType, pType) in ((:NonlinearProblem, :NLS), (:NonlinearLeastSquaresProb
68
81
algType = NonlinearSolvePolyAlgorithm{pType}
69
82
@eval begin
70
83
function SciMLBase. __init (prob:: $probType , alg:: $algType{N} , args... ;
71
- maxtime = nothing , kwargs... ) where {N}
84
+ maxtime = nothing , maxiters = 1000 , kwargs... ) where {N}
72
85
return NonlinearSolvePolyAlgorithmCache {isinplace(prob), N, maxtime !== nothing} (
73
86
map (solver -> SciMLBase. __init (prob, solver, args... ; maxtime, kwargs... ),
74
87
alg. algs), alg, - 1 , 1 , 0 , 0.0 , maxtime,
75
- ReturnCode. Default, false )
88
+ ReturnCode. Default, false , maxiters )
76
89
end
77
90
end
78
91
end
124
137
return Expr (:block , calls... )
125
138
end
126
139
127
- @generated function __step! (
128
- cache :: NonlinearSolvePolyAlgorithmCache{iip, N} , args ... ; kwargs... ) where {iip, N}
140
+ @generated function __step! (cache :: NonlinearSolvePolyAlgorithmCache{iip, N} , args ... ;
141
+ kwargs... ) where {iip, N}
129
142
calls = []
130
143
cache_syms = [gensym (" cache" ) for i in 1 : N]
131
144
for i in 1 : N
134
147
$ (cache_syms[i]) = cache. caches[$ (i)]
135
148
if $ (i) == cache. current
136
149
__step! ($ (cache_syms[i]), args... ; kwargs... )
150
+ $ (cache_syms[i]). nsteps += 1
137
151
if ! not_terminated ($ (cache_syms[i]))
138
152
if SciMLBase. successful_retcode ($ (cache_syms[i]). retcode)
139
153
cache. best = $ (i)
157
171
cache. force_stop = true
158
172
return
159
173
end
160
- end
161
- )
174
+ end )
162
175
163
176
return Expr (:block , calls... )
164
177
end
0 commit comments