Skip to content

Commit 6451788

Browse files
committed
add errors
1 parent 2ba3da7 commit 6451788

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,11 @@ function DiffEqBase.ODEProblem{iip, specialize}(sys::AbstractODESystem, u0map =
745745
Consider a BVProblem instead.")
746746
end
747747

748+
if !isempty(get_costs(sys))
749+
error("An ODESystem with costs cannot be solved using a regular ODEProblem.
750+
Solvers for optimal control problems are forthcoming.")
751+
end
752+
748753
f, u0, p = process_SciMLProblem(ODEFunction{iip, specialize}, sys, u0map, parammap;
749754
t = tspan !== nothing ? tspan[1] : tspan,
750755
check_length, warn_initialize_determined, eval_expression, eval_module, kwargs...)
@@ -852,6 +857,11 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
852857
end
853858
!isnothing(callback) && error("BVP solvers do not support callbacks.")
854859

860+
if !isempty(get_costs(sys))
861+
error("An ODESystem with costs cannot be solved using a regular DAEProblem.
862+
Solvers for optimal control problems are forthcoming.")
863+
end
864+
855865
has_alg_eqs(sys) &&
856866
error("The BVProblem constructor currently does not support ODESystems with algebraic equations.") # Remove this when the BVDAE solvers get updated, the codegen should work when it does.
857867

@@ -953,6 +963,11 @@ function DiffEqBase.DAEProblem{iip}(sys::AbstractODESystem, du0map, u0map, tspan
953963
if !iscomplete(sys)
954964
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating a `DAEProblem`")
955965
end
966+
967+
if !isempty(get_costs(sys))
968+
error("An ODESystem with costs cannot be solved using a regular DAEProblem.
969+
Solvers for optimal control problems are forthcoming.")
970+
end
956971
f, du0, u0, p = process_SciMLProblem(DAEFunction{iip}, sys, u0map, parammap;
957972
implicit_dae = true, du0map = du0map, check_length,
958973
t = tspan !== nothing ? tspan[1] : tspan,

0 commit comments

Comments
 (0)