Skip to content

Commit

Permalink
refactor!: require systems to be completed before creating an `XPro…
Browse files Browse the repository at this point in the history
…blemExpr`
  • Loading branch information
AayushSabharwal committed Jan 29, 2024
1 parent e9ddf8a commit 039a45d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/systems/diffeqs/abstractodesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,9 @@ struct ODEProblemExpr{iip} end
function ODEProblemExpr{iip}(sys::AbstractODESystem, u0map, tspan,
parammap = DiffEqBase.NullParameters(); check_length = true,
kwargs...) where {iip}
if !iscomplete(sys)
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating a `ODEProblemExpr`")
end
f, u0, p = process_DEProblem(ODEFunctionExpr{iip}, sys, u0map, parammap; check_length,
kwargs...)
linenumbers = get(kwargs, :linenumbers, true)
Expand Down Expand Up @@ -1242,6 +1245,9 @@ struct DAEProblemExpr{iip} end
function DAEProblemExpr{iip}(sys::AbstractODESystem, du0map, u0map, tspan,
parammap = DiffEqBase.NullParameters(); check_length = true,
kwargs...) where {iip}
if !iscomplete(sys)
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating a `DAEProblemExpr`")
end
f, du0, u0, p = process_DEProblem(DAEFunctionExpr{iip}, sys, u0map, parammap;
implicit_dae = true, du0map = du0map, check_length,
kwargs...)
Expand Down Expand Up @@ -1322,6 +1328,9 @@ function SteadyStateProblemExpr{iip}(sys::AbstractODESystem, u0map,
parammap = SciMLBase.NullParameters();
check_length = true,
kwargs...) where {iip}
if !iscomplete(sys)
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating a `SteadyStateProblemExpr`")
end
f, u0, p = process_DEProblem(ODEFunctionExpr{iip}, sys, u0map, parammap;
steady_state = true,
check_length, kwargs...)
Expand Down
3 changes: 3 additions & 0 deletions src/systems/diffeqs/sdesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ function SDEProblemExpr{iip}(sys::SDESystem, u0map, tspan,
parammap = DiffEqBase.NullParameters();
sparsenoise = nothing, check_length = true,
kwargs...) where {iip}
if !iscomplete(sys)
error("A completed `SDESystem` is required. Call `complete` or `structural_simplify` on the system before creating an `SDEProblemExpr`")
end
f, u0, p = process_DEProblem(SDEFunctionExpr{iip}, sys, u0map, parammap; check_length,
kwargs...)
linenumbers = get(kwargs, :linenumbers, true)
Expand Down
3 changes: 3 additions & 0 deletions src/systems/discrete_system/discrete_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ function DiscreteProblemExpr{iip}(sys::DiscreteSystem, u0map, tspan,
parammap = DiffEqBase.NullParameters();
check_length = true,
kwargs...) where {iip}
if !iscomplete(sys)
error("A completed `DiscreteSystem` is required. Call `complete` or `structural_simplify` on the system before creating a `DiscreteProblemExpr`")
end
f, u0, p = process_DiscreteProblem(DiscreteFunctionExpr{iip}, sys, u0map, parammap;
check_length, kwargs...)
linenumbers = get(kwargs, :linenumbers, true)
Expand Down
3 changes: 3 additions & 0 deletions src/systems/jumps/jumpsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ function DiscreteProblemExpr{iip}(sys::JumpSystem, u0map, tspan::Union{Tuple, No
parammap = DiffEqBase.NullParameters();
use_union = false,
kwargs...) where {iip}
if !iscomplete(sys)
error("A completed `JumpSystem` is required. Call `complete` or `structural_simplify` on the system before creating a `DiscreteProblemExpr`")
end
dvs = states(sys)
ps = parameters(sys)
defs = defaults(sys)
Expand Down
3 changes: 3 additions & 0 deletions src/systems/nonlinear/nonlinearsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ function NonlinearProblemExpr{iip}(sys::NonlinearSystem, u0map,
parammap = DiffEqBase.NullParameters();
check_length = true,
kwargs...) where {iip}
if !iscomplete(sys)
error("A completed `NonlinearSystem` is required. Call `complete` or `structural_simplify` on the system before creating a `NonlinearProblemExpr`")
end
f, u0, p = process_NonlinearProblem(NonlinearFunctionExpr{iip}, sys, u0map, parammap;
check_length, kwargs...)
linenumbers = get(kwargs, :linenumbers, true)
Expand Down
3 changes: 3 additions & 0 deletions src/systems/optimization/optimizationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0map,
linenumbers = false, parallel = SerialForm(),
use_union = false,
kwargs...) where {iip}
if !iscomplete(sys)
error("A completed `OptimizationSystem` is required. Call `complete` or `structural_simplify` on the system before creating a `OptimizationProblemExpr`")
end
if haskey(kwargs, :lcons) || haskey(kwargs, :ucons)
Base.depwarn("`lcons` and `ucons` are deprecated. Specify constraints directly instead.",
:OptimizationProblem, force = true)
Expand Down

0 comments on commit 039a45d

Please sign in to comment.