Skip to content

Commit 4941f47

Browse files
refactor!: require systems to be completed before creating an XProblemExpr
1 parent fdca4e9 commit 4941f47

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,9 @@ struct ODEProblemExpr{iip} end
11381138
function ODEProblemExpr{iip}(sys::AbstractODESystem, u0map, tspan,
11391139
parammap = DiffEqBase.NullParameters(); check_length = true,
11401140
kwargs...) where {iip}
1141+
if !iscomplete(sys)
1142+
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating a `ODEProblemExpr`")
1143+
end
11411144
f, u0, p = process_DEProblem(ODEFunctionExpr{iip}, sys, u0map, parammap; check_length,
11421145
kwargs...)
11431146
linenumbers = get(kwargs, :linenumbers, true)
@@ -1180,6 +1183,9 @@ struct DAEProblemExpr{iip} end
11801183
function DAEProblemExpr{iip}(sys::AbstractODESystem, du0map, u0map, tspan,
11811184
parammap = DiffEqBase.NullParameters(); check_length = true,
11821185
kwargs...) where {iip}
1186+
if !iscomplete(sys)
1187+
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating a `DAEProblemExpr`")
1188+
end
11831189
f, du0, u0, p = process_DEProblem(DAEFunctionExpr{iip}, sys, u0map, parammap;
11841190
implicit_dae = true, du0map = du0map, check_length,
11851191
kwargs...)
@@ -1260,6 +1266,9 @@ function SteadyStateProblemExpr{iip}(sys::AbstractODESystem, u0map,
12601266
parammap = SciMLBase.NullParameters();
12611267
check_length = true,
12621268
kwargs...) where {iip}
1269+
if !iscomplete(sys)
1270+
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating a `SteadyStateProblemExpr`")
1271+
end
12631272
f, u0, p = process_DEProblem(ODEFunctionExpr{iip}, sys, u0map, parammap;
12641273
steady_state = true,
12651274
check_length, kwargs...)

src/systems/diffeqs/sdesystem.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ function SDEProblemExpr{iip}(sys::SDESystem, u0map, tspan,
635635
parammap = DiffEqBase.NullParameters();
636636
sparsenoise = nothing, check_length = true,
637637
kwargs...) where {iip}
638+
if !iscomplete(sys)
639+
error("A completed `SDESystem` is required. Call `complete` or `structural_simplify` on the system before creating an `SDEProblemExpr`")
640+
end
638641
f, u0, p = process_DEProblem(SDEFunctionExpr{iip}, sys, u0map, parammap; check_length,
639642
kwargs...)
640643
linenumbers = get(kwargs, :linenumbers, true)

src/systems/jumps/jumpsystem.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ function DiscreteProblemExpr{iip}(sys::JumpSystem, u0map, tspan::Union{Tuple, No
356356
parammap = DiffEqBase.NullParameters();
357357
use_union = false,
358358
kwargs...) where {iip}
359+
if !iscomplete(sys)
360+
error("A completed `JumpSystem` is required. Call `complete` or `structural_simplify` on the system before creating a `DiscreteProblemExpr`")
361+
end
359362
dvs = unknowns(sys)
360363
ps = parameters(sys)
361364
defs = defaults(sys)

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ function NonlinearProblemExpr{iip}(sys::NonlinearSystem, u0map,
399399
parammap = DiffEqBase.NullParameters();
400400
check_length = true,
401401
kwargs...) where {iip}
402+
if !iscomplete(sys)
403+
error("A completed `NonlinearSystem` is required. Call `complete` or `structural_simplify` on the system before creating a `NonlinearProblemExpr`")
404+
end
402405
f, u0, p = process_NonlinearProblem(NonlinearFunctionExpr{iip}, sys, u0map, parammap;
403406
check_length, kwargs...)
404407
linenumbers = get(kwargs, :linenumbers, true)

src/systems/optimization/optimizationsystem.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0map,
422422
linenumbers = false, parallel = SerialForm(),
423423
use_union = false,
424424
kwargs...) where {iip}
425+
if !iscomplete(sys)
426+
error("A completed `OptimizationSystem` is required. Call `complete` or `structural_simplify` on the system before creating a `OptimizationProblemExpr`")
427+
end
425428
if haskey(kwargs, :lcons) || haskey(kwargs, :ucons)
426429
Base.depwarn("`lcons` and `ucons` are deprecated. Specify constraints directly instead.",
427430
:OptimizationProblem, force = true)

0 commit comments

Comments
 (0)