687
687
_pmap = merge (pmap, Dict (p => 1.0 ))
688
688
prob = Problem (sys, u0map, (0.0 , 1.0 ), _pmap)
689
689
@test prob. ps[p] ≈ 1.0
690
- @test prob. f. initialization_data === nothing
690
+ initsys = prob. f. initialization_data. initializeprob. f. sys
691
+ @test is_parameter (initsys, p)
691
692
692
693
# Non-floating point
693
694
@parameters r:: Int s:: Int
696
697
prob = Problem (sys, u0map, (0.0 , 1.0 ), [r => 1 ])
697
698
@test prob. ps[r] == 1
698
699
@test prob. ps[s] == 2
699
- @test prob. f. initialization_data === nothing
700
+ initsys = prob. f. initialization_data. initializeprob. f. sys
701
+ @test is_parameter (initsys, r)
702
+ @test is_parameter (initsys, s)
700
703
701
704
@mtkbuild sys = System (
702
705
[D (x) ~ x + rhss[1 ], p ~ x + y + rhss[2 ]], t; guesses = [p => 0.0 ])
@@ -1180,21 +1183,28 @@ end
1180
1183
@test integ2. ps[q] ≈ 2 cbrt (3 / 28 )
1181
1184
end
1182
1185
1186
+ function test_dummy_initialization_equation (prob, var)
1187
+ initsys = prob. f. initialization_data. initializeprob. f. sys
1188
+ @test isempty (equations (initsys))
1189
+ idx = findfirst (eq -> isequal (var, eq. lhs), observed (initsys))
1190
+ @test idx != = nothing && is_parameter (initsys, observed (initsys)[idx]. rhs)
1191
+ end
1192
+
1183
1193
@testset " Remake problem with no initializeprob" begin
1184
1194
@variables x (t) [guess = 1.0 ] y (t) [guess = 1.0 ]
1185
1195
@parameters p [guess = 1.0 ] q [guess = 1.0 ]
1186
1196
@mtkbuild sys = ODESystem (
1187
1197
[D (x) ~ p * x + q * y, y ~ 2 x], t; parameter_dependencies = [q ~ 2 p])
1188
1198
prob = ODEProblem (sys, [x => 1.0 ], (0.0 , 1.0 ), [p => 1.0 ])
1189
- @test prob. f . initialization_data === nothing
1199
+ test_dummy_initialization_equation ( prob, x)
1190
1200
prob2 = remake (prob; u0 = [x => 2.0 ])
1191
1201
@test prob2[x] == 2.0
1192
- @test prob2. f . initialization_data === nothing
1202
+ test_dummy_initialization_equation ( prob2, x)
1193
1203
prob3 = remake (prob; u0 = [y => 2.0 ])
1194
1204
@test prob3. f. initialization_data != = nothing
1195
1205
@test init (prob3)[x] ≈ 1.0
1196
1206
prob4 = remake (prob; p = [p => 1.0 ])
1197
- @test prob4. f . initialization_data === nothing
1207
+ test_dummy_initialization_equation ( prob4, x)
1198
1208
prob5 = remake (prob; p = [p => missing , q => 2.0 ])
1199
1209
@test prob5. f. initialization_data != = nothing
1200
1210
@test init (prob5). ps[p] ≈ 1.0
@@ -1206,12 +1216,12 @@ end
1206
1216
@mtkbuild sys = ODESystem (
1207
1217
[D (x) ~ p * x + q * y, y ~ 2 x], t; parameter_dependencies = [q ~ 2 p])
1208
1218
prob = ODEProblem (sys, [:x => 1.0 ], (0.0 , 1.0 ), [p => 1.0 ])
1209
- @test prob. f . initialization_data === nothing
1219
+ test_dummy_initialization_equation ( prob, x)
1210
1220
prob2 = remake (prob; u0 = [:x => 2.0 ])
1211
- @test prob2. f. initialization_data === nothing
1212
- prob3 = remake (prob; u0 = [:y => 1.0 ])
1213
- @test prob3. f. initialization_data != = nothing
1221
+ test_dummy_initialization_equation (prob2, x)
1222
+ prob3 = remake (prob; u0 = [:y => 1.0 , :x => nothing ])
1214
1223
@test init (prob3)[x] ≈ 0.5
1224
+ @test SciMLBase. successful_retcode (solve (prob3))
1215
1225
end
1216
1226
1217
1227
@testset " Issue#3246: type promotion with parameter dependent initialization_eqs" begin
0 commit comments