You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the `ODESystem` has algebraic equations, like `x(t)^2 + y(t)^2`, the resulting
@@ -839,6 +845,7 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
839
845
tspan =get_tspan(sys),
840
846
parammap = DiffEqBase.NullParameters();
841
847
guesses =Dict(),
848
+
allow_cost =false,
842
849
version =nothing, tgrad =false,
843
850
callback =nothing,
844
851
check_length =true,
@@ -852,6 +859,12 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
852
859
end
853
860
!isnothing(callback) &&error("BVP solvers do not support callbacks.")
854
861
862
+
if!isempty(get_costs(sys)) &&!allow_cost
863
+
error("BVProblem will not optimize solutions of ODESystems that have associated cost functions.
864
+
Solvers for optimal control problems are forthcoming. In order to bypass this error (e.g.
865
+
to check the cost of a regular solution), pass `allow_cost` = true into the constructor.")
866
+
end
867
+
855
868
has_alg_eqs(sys) &&
856
869
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.
857
870
@@ -924,7 +937,7 @@ function generate_function_bc(sys::ODESystem, u0, u0_idxs, tspan; kwargs...)
throw(ArgumentError("Time-dependent variable $var is not an unknown of the system.")))
@@ -764,13 +817,42 @@ function process_constraint_system(
764
817
arg isa AbstractFloat ||
765
818
throw(ArgumentError("Invalid argument specified for variable $var. The argument of the variable should be either $iv, a parameter, or a value specifying the time that the constraint holds."))
766
819
767
-
isparameter(arg) &&push!(constraintps, arg)
820
+
isparameter(arg) &&push!(auxps, arg)
768
821
else
769
822
var ∈ sts &&
770
823
@warn"Variable $var has no argument. It will be interpreted as $var($iv), and the constraint will apply to the entire interval."
771
824
end
772
825
end
826
+
end
773
827
774
-
ConstraintsSystem(
775
-
constraints, collect(constraintsts), collect(constraintps); name = consname)
828
+
"""
829
+
Generate a function that takes a solution object and computes the cost function obtained by coalescing the costs vector.
0 commit comments