|
998 | 998 | @test integ2.ps[p] == 1.0
|
999 | 999 | @test integ2.ps[q] ≈ 2cbrt(3 / 28)
|
1000 | 1000 | end
|
| 1001 | + |
| 1002 | +@testset "Remake problem with no initializeprob" begin |
| 1003 | + @variables x(t) [guess = 1.0] y(t) [guess = 1.0] |
| 1004 | + @parameters p [guess = 1.0] q [guess = 1.0] |
| 1005 | + @mtkbuild sys = ODESystem( |
| 1006 | + [D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p]) |
| 1007 | + prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [p => 1.0]) |
| 1008 | + @test prob.f.initialization_data === nothing |
| 1009 | + prob2 = remake(prob; u0 = [x => 2.0]) |
| 1010 | + @test prob2[x] == 2.0 |
| 1011 | + @test prob2.f.initialization_data === nothing |
| 1012 | + prob3 = remake(prob; u0 = [y => 2.0]) |
| 1013 | + @test prob3.f.initialization_data !== nothing |
| 1014 | + @test init(prob3)[x] ≈ 1.0 |
| 1015 | + prob4 = remake(prob; p = [p => 1.0]) |
| 1016 | + @test prob4.f.initialization_data === nothing |
| 1017 | + prob5 = remake(prob; p = [p => missing, q => 2.0]) |
| 1018 | + @test prob5.f.initialization_data !== nothing |
| 1019 | + @test init(prob5).ps[p] ≈ 1.0 |
| 1020 | +end |
| 1021 | + |
| 1022 | +@testset "Variables provided as symbols" begin |
| 1023 | + @variables x(t) [guess = 1.0] y(t) [guess = 1.0] |
| 1024 | + @parameters p [guess = 1.0] q [guess = 1.0] |
| 1025 | + @mtkbuild sys = ODESystem( |
| 1026 | + [D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p]) |
| 1027 | + prob = ODEProblem(sys, [:x => 1.0], (0.0, 1.0), [p => 1.0]) |
| 1028 | + @test prob.f.initialization_data === nothing |
| 1029 | + prob2 = remake(prob; u0 = [:x => 2.0]) |
| 1030 | + @test prob2.f.initialization_data === nothing |
| 1031 | + prob3 = remake(prob; u0 = [:y => 1.0]) |
| 1032 | + @test prob3.f.initialization_data !== nothing |
| 1033 | + @test init(prob3)[x] ≈ 0.5 |
| 1034 | +end |
0 commit comments