|
970 | 970 | @test integ2.ps[p] == 1.0 |
971 | 971 | @test integ2.ps[q] ≈ 2cbrt(3 / 28) |
972 | 972 | end |
| 973 | + |
| 974 | +@testset "Remake problem with no initializeprob" begin |
| 975 | + @variables x(t) [guess = 1.0] y(t) [guess = 1.0] |
| 976 | + @parameters p [guess = 1.0] q [guess = 1.0] |
| 977 | + @mtkbuild sys = ODESystem([D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p]) |
| 978 | + prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [p => 1.0]) |
| 979 | + @test prob.f.initialization_data === nothing |
| 980 | + prob2 = remake(prob; u0 = [x => 2.0]) |
| 981 | + @test prob2[x] == 2.0 |
| 982 | + @test prob2.f.initialization_data === nothing |
| 983 | + prob3 = remake(prob; u0 = [y => 2.0]) |
| 984 | + @test prob3.f.initialization_data !== nothing |
| 985 | + @test init(prob3)[x] ≈ 1.0 |
| 986 | + prob4 = remake(prob; p = [p => 1.0]) |
| 987 | + @test prob4.f.initialization_data === nothing |
| 988 | + prob5 = remake(prob; p = [p => missing, q => 2.0]) |
| 989 | + @test prob5.f.initialization_data !== nothing |
| 990 | + @test init(prob5).ps[p] ≈ 1.0 |
| 991 | +end |
| 992 | + |
| 993 | +@testset "Variables provided as symbols" begin |
| 994 | + @variables x(t) [guess = 1.0] y(t) [guess = 1.0] |
| 995 | + @parameters p [guess = 1.0] q [guess = 1.0] |
| 996 | + @mtkbuild sys = ODESystem([D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p]) |
| 997 | + prob = ODEProblem(sys, [:x => 1.0], (0.0, 1.0), [p => 1.0]) |
| 998 | + @test prob.f.initialization_data === nothing |
| 999 | + prob2 = remake(prob; u0 = [:x => 2.0]) |
| 1000 | + @test prob2.f.initialization_data === nothing |
| 1001 | + prob3 = remake(prob; u0 = [:y => 1.0]) |
| 1002 | + @test prob3.f.initialization_data !== nothing |
| 1003 | + @test init(prob3)[x] ≈ 0.5 |
| 1004 | +end |
0 commit comments