@@ -54,6 +54,7 @@ function remake(prob::ODEProblem; f = missing,
54
54
tspan = missing ,
55
55
p = missing ,
56
56
kwargs = missing ,
57
+ interpret_symbolicmap = true ,
57
58
_kwargs... )
58
59
if tspan === missing
59
60
tspan = prob. tspan
@@ -68,14 +69,26 @@ function remake(prob::ODEProblem; f = missing,
68
69
if u0 === missing
69
70
u0 = prob. u0
70
71
end
71
- if (eltype (p) <: Pair && ! isempty (p)) || (eltype (u0) <: Pair && ! isempty (u0)) # one is a non-empty symbolic map
72
- hasproperty (prob. f, :sys ) && hasfield (typeof (prob. f. sys), :ps ) ||
73
- throw (ArgumentError (" This problem does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." *
74
- " Please use `remake` with the `p` keyword argument as a vector of values, paying attention to parameter order." ))
75
- hasproperty (prob. f, :sys ) && hasfield (typeof (prob. f. sys), :states ) ||
76
- throw (ArgumentError (" This problem does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." *
77
- " Please use `remake` with the `u0` keyword argument as a vector of values, paying attention to state order." ))
72
+ isu0symbolic = eltype (u0) <: Pair && ! isempty (u0)
73
+ ispsymbolic = eltype (p) <: Pair && ! isempty (p) && interpret_symbolicmap
74
+ if isu0symbolic && ! has_sys (prob. f)
75
+ throw (ArgumentError (" This problem does not support symbolic maps with" *
76
+ " remake, i.e. it does not have a symbolic origin. Please use `remake`" *
77
+ " with the `u0` keyword argument as a vector of values, paying attention to" *
78
+ " parameter order." ))
79
+ end
80
+ if ispsymbolic && ! has_sys (prob. f)
81
+ throw (ArgumentError (" This problem does not support symbolic maps with " *
82
+ " `remake`, i.e. it does not have a symbolic origin. Please use `remake`" *
83
+ " with the `p` keyword argument as a vector of values (paying attention to" *
84
+ " parameter order) or pass `interpret_symbolicmap = false` as a keyword argument" ))
85
+ end
86
+ if isu0symbolic && ispsymbolic
78
87
p, u0 = process_p_u0_symbolic (prob, p, u0)
88
+ elseif isu0symbolic
89
+ _, u0 = process_p_u0_symbolic (prob, prob. p, u0)
90
+ elseif ispsymbolic
91
+ p, _ = process_p_u0_symbolic (prob, p, prob. u0)
79
92
end
80
93
end
81
94
@@ -262,6 +275,7 @@ function remake(prob::OptimizationProblem;
262
275
ucons = missing ,
263
276
sense = missing ,
264
277
kwargs = missing ,
278
+ interpret_symbolicmap = true ,
265
279
_kwargs... )
266
280
if p === missing && u0 === missing
267
281
p, u0 = prob. p, prob. u0
@@ -272,14 +286,26 @@ function remake(prob::OptimizationProblem;
272
286
if u0 === missing
273
287
u0 = prob. u0
274
288
end
275
- if (eltype (p) <: Pair && ! isempty (p)) || (eltype (u0) <: Pair && ! isempty (u0)) # one is a non-empty symbolic map
276
- hasproperty (prob. f, :sys ) && hasfield (typeof (prob. f. sys), :ps ) ||
277
- throw (ArgumentError (" This problem does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." *
278
- " Please use `remake` with the `p` keyword argument as a vector of values, paying attention to parameter order." ))
279
- hasproperty (prob. f, :sys ) && hasfield (typeof (prob. f. sys), :states ) ||
280
- throw (ArgumentError (" This problem does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." *
281
- " Please use `remake` with the `u0` keyword argument as a vector of values, paying attention to state order." ))
289
+ isu0symbolic = eltype (u0) <: Pair && ! isempty (u0)
290
+ ispsymbolic = eltype (p) <: Pair && ! isempty (p) && interpret_symbolicmap
291
+ if isu0symbolic && ! has_sys (prob. f)
292
+ throw (ArgumentError (" This problem does not support symbolic maps with" *
293
+ " remake, i.e. it does not have a symbolic origin. Please use `remake`" *
294
+ " with the `u0` keyword argument as a vector of values, paying attention to" *
295
+ " parameter order." ))
296
+ end
297
+ if ispsymbolic && ! has_sys (prob. f)
298
+ throw (ArgumentError (" This problem does not support symbolic maps with " *
299
+ " `remake`, i.e. it does not have a symbolic origin. Please use `remake`" *
300
+ " with the `p` keyword argument as a vector of values (paying attention to" *
301
+ " parameter order) or pass `interpret_symbolicmap = false` as a keyword argument" ))
302
+ end
303
+ if isu0symbolic && ispsymbolic
282
304
p, u0 = process_p_u0_symbolic (prob, p, u0)
305
+ elseif isu0symbolic
306
+ _, u0 = process_p_u0_symbolic (prob, prob. p, u0)
307
+ elseif ispsymbolic
308
+ p, _ = process_p_u0_symbolic (prob, p, prob. u0)
283
309
end
284
310
end
285
311
@@ -331,6 +357,7 @@ function remake(prob::NonlinearProblem;
331
357
p = missing ,
332
358
problem_type = missing ,
333
359
kwargs = missing ,
360
+ interpret_symbolicmap = true ,
334
361
_kwargs... )
335
362
if p === missing && u0 === missing
336
363
p, u0 = prob. p, prob. u0
@@ -341,14 +368,26 @@ function remake(prob::NonlinearProblem;
341
368
if u0 === missing
342
369
u0 = prob. u0
343
370
end
344
- if (eltype (p) <: Pair && ! isempty (p)) || (eltype (u0) <: Pair && ! isempty (u0)) # one is a non-empty symbolic map
345
- hasproperty (prob. f, :sys ) && hasfield (typeof (prob. f. sys), :ps ) ||
346
- throw (ArgumentError (" This problem does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." *
347
- " Please use `remake` with the `p` keyword argument as a vector of values, paying attention to parameter order." ))
348
- hasproperty (prob. f, :sys ) && hasfield (typeof (prob. f. sys), :states ) ||
349
- throw (ArgumentError (" This problem does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." *
350
- " Please use `remake` with the `u0` keyword argument as a vector of values, paying attention to state order." ))
371
+ isu0symbolic = eltype (u0) <: Pair && ! isempty (u0)
372
+ ispsymbolic = eltype (p) <: Pair && ! isempty (p) && interpret_symbolicmap
373
+ if isu0symbolic && ! has_sys (prob. f)
374
+ throw (ArgumentError (" This problem does not support symbolic maps with" *
375
+ " remake, i.e. it does not have a symbolic origin. Please use `remke`" *
376
+ " with the `u0` keyword argument as a vector of values, paying attention to" *
377
+ " parameter order." ))
378
+ end
379
+ if ispsymbolic && ! has_sys (prob. f)
380
+ throw (ArgumentError (" This problem does not support symbolic maps with " *
381
+ " `remake`, i.e. it does not have a symbolic origin. Please use `remake`" *
382
+ " with the `p` keyword argument as a vector of values (paying attention to" *
383
+ " parameter order) or pass `interpret_symbolicmap = false` as a keyword argument" ))
384
+ end
385
+ if isu0symbolic && ispsymbolic
351
386
p, u0 = process_p_u0_symbolic (prob, p, u0)
387
+ elseif isu0symbolic
388
+ _, u0 = process_p_u0_symbolic (prob, prob. p, u0)
389
+ elseif ispsymbolic
390
+ p, _ = process_p_u0_symbolic (prob, p, prob. u0)
352
391
end
353
392
end
354
393
0 commit comments