From bbba9c6ec9c9799ea84db42d6f2fefe061f7ac7d Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Fri, 27 Oct 2023 13:09:40 +0530 Subject: [PATCH] feat: update RecursiveArrayTools and SymbolicIndexingInterface compat - Implement SII for solutions, problems, SciMLFunctions, integrators - Solution indexing falls back to AbstractVectorOfArray indexing - remove issymbollike - remove has_static_variable - add new parameter indexing - fix adjoint definitions - Remove syms, paramsyms, indepsym from SciMLFunctions, use SymbolCache in place of f.sys instead --- Project.toml | 4 +- ext/SciMLBaseChainRulesCoreExt.jl | 4 +- ext/SciMLBaseZygoteExt.jl | 9 +- src/ensemble/ensemble_solutions.jl | 20 +- src/integrator_interface.jl | 184 +++---- src/problems/problem_interface.jl | 109 ++-- src/scimlfunctions.jl | 671 +++++++++++------------- src/solutions/ode_solutions.jl | 55 +- src/solutions/optimization_solutions.jl | 12 +- src/solutions/rode_solutions.jl | 2 +- src/solutions/solution_interface.jl | 241 +++------ src/symbolic_utils.jl | 64 +-- src/tabletraits.jl | 8 +- test/downstream/ensemble_zero_length.jl | 2 +- test/downstream/integrator_indexing.jl | 89 ++-- test/downstream/solution_interface.jl | 9 +- test/downstream/symbol_indexing.jl | 22 +- test/existence_functions.jl | 11 +- 18 files changed, 625 insertions(+), 891 deletions(-) diff --git a/Project.toml b/Project.toml index b2e8c4eca..6ef6e125b 100644 --- a/Project.toml +++ b/Project.toml @@ -73,14 +73,14 @@ PyCall = "1.96" PythonCall = "0.9.15" RCall = "0.13.18" RecipesBase = "1.0" -RecursiveArrayTools = "2.38" +RecursiveArrayTools = "3.0" Reexport = "1" RuntimeGeneratedFunctions = "0.5" SciMLOperators = "0.3.7" StaticArrays = "1.7" StaticArraysCore = "1.4" Statistics = "1.9" -SymbolicIndexingInterface = "0.2" +SymbolicIndexingInterface = "0.3" Tables = "1.11" TruncatedStacktraces = "1.4" QuasiMonteCarlo = "0.2.19, 0.3" diff --git a/ext/SciMLBaseChainRulesCoreExt.jl b/ext/SciMLBaseChainRulesCoreExt.jl index 51334f937..5cfd0fbee 100644 --- a/ext/SciMLBaseChainRulesCoreExt.jl +++ b/ext/SciMLBaseChainRulesCoreExt.jl @@ -12,7 +12,7 @@ function ChainRulesCore.rrule(config::ChainRulesCore.RuleConfig{ sym, j::Integer) function ODESolution_getindex_pullback(Δ) - i = issymbollike(sym) ? sym_to_index(sym, VA) : sym + i = symbolic_type(sym) != NotSymbolic() ? sym_to_index(sym, VA) : sym if i === nothing getter = getobserved(VA) grz = rrule_via_ad(config, getter, sym, VA.u[j], VA.prob.p, VA.t[j])[2](Δ) @@ -65,7 +65,7 @@ end function ChainRulesCore.rrule(::typeof(getindex), VA::ODESolution, sym) function ODESolution_getindex_pullback(Δ) - i = issymbollike(sym) ? sym_to_index(sym, VA) : sym + i = symbolic_type(sym) != NotSymbolic() ? sym_to_index(sym, VA) : sym if i === nothing throw(error("AD of purely-symbolic slicing for observed quantities is not yet supported. Work around this by using `A[sym,i]` to access each element sequentially in the function being differentiated.")) else diff --git a/ext/SciMLBaseZygoteExt.jl b/ext/SciMLBaseZygoteExt.jl index c0171f4d4..57d101949 100644 --- a/ext/SciMLBaseZygoteExt.jl +++ b/ext/SciMLBaseZygoteExt.jl @@ -4,9 +4,10 @@ using Zygote using Zygote: @adjoint, pullback import Zygote: literal_getproperty using SciMLBase -using SciMLBase: ODESolution, issymbollike, sym_to_index, remake, +using SciMLBase: ODESolution, sym_to_index, remake, getobserved, build_solution, EnsembleSolution, NonlinearSolution, AbstractTimeseriesSolution +using SymbolicIndexingInterface: symbolic_type, NotSymbolic # This method resolves the ambiguity with the pullback defined in # RecursiveArrayToolsZygoteExt @@ -32,7 +33,7 @@ end @adjoint function getindex(VA::ODESolution, sym, j::Int) function ODESolution_getindex_pullback(Δ) - i = issymbollike(sym) ? sym_to_index(sym, VA) : sym + i = symbolic_type(sym) != NotSymbolic() ? sym_to_index(sym, VA) : sym du, dprob = if i === nothing getter = getobserved(VA) grz = pullback(getter, sym, VA.u[j], VA.prob.p, VA.t[j])[2](Δ) @@ -81,7 +82,7 @@ end for (x, j) in zip(VA.u, 1:length(VA))] (Δ′, nothing) end - VA[i], ODESolution_getindex_pullback + VA[:, i], ODESolution_getindex_pullback end @adjoint function Zygote.literal_getproperty(sim::EnsembleSolution, @@ -91,7 +92,7 @@ end @adjoint function getindex(VA::ODESolution, sym) function ODESolution_getindex_pullback(Δ) - i = issymbollike(sym) ? sym_to_index(sym, VA) : sym + i = symbolic_type(sym) != NotSymbolic() ? sym_to_index(sym, VA) : sym if i === nothing throw(error("Zygote AD of purely-symbolic slicing for observed quantities is not yet supported. Work around this by using `A[sym,i]` to access each element sequentially in the function being differentiated.")) else diff --git a/src/ensemble/ensemble_solutions.jl b/src/ensemble/ensemble_solutions.jl index 5bb198512..07d73172e 100644 --- a/src/ensemble/ensemble_solutions.jl +++ b/src/ensemble/ensemble_solutions.jl @@ -40,9 +40,9 @@ end # Vector of some type which is not an array function EnsembleSolution(sim::T, elapsedTime, converged, stats=nothing) where {T <: AbstractVector{T2} } where {T2 <: - AbstractArray} - EnsembleSolution{eltype(eltype(sim)), ndims(sim[1]) + 1, typeof(sim)}( - sim, + Union{AbstractArray,RecursiveArrayTools.AbstractVectorOfArray}} + EnsembleSolution{eltype(eltype(sim)), ndims(sim[1]) + 1, + typeof(sim)}(sim, elapsedTime, converged, stats) @@ -209,18 +209,8 @@ end end end -Base.@propagate_inbounds function Base.getindex(x::AbstractEnsembleSolution, s, ::Colon) - return [xi[s] for xi in x] -end - -Base.@propagate_inbounds function Base.getindex(x::AbstractEnsembleSolution, - ::Colon, - args::Colon...) - return invoke(getindex, - Tuple{RecursiveArrayTools.AbstractVectorOfArray, Colon, typeof.(args)...}, - x, - :, - args...) +Base.@propagate_inbounds function Base.getindex(x::AbstractEnsembleSolution, ::Union{ScalarSymbolic,ArraySymbolic}, s, ::Colon) + return [xi[s] for xi in x.u] end function (sol::AbstractEnsembleSolution)(args...; kwargs...) diff --git a/src/integrator_interface.jl b/src/integrator_interface.jl index 2cf98f08b..2a62528de 100644 --- a/src/integrator_interface.jl +++ b/src/integrator_interface.jl @@ -345,13 +345,13 @@ function set_u!(integrator::DEIntegrator, sym, val) # So any error checking happens to ensure we actually _can_ set state set_u!(integrator, integrator.u) - if !issymbollike(sym) + if symbolic_type(sym) == NotSymbolic() error("sym must be a symbol") end - i = sym_to_index(sym, integrator) + i = variable_index(integrator, sym) if isnothing(i) - error("sym is not a state variable") + error("$sym is not a state variable") end integrator.u[i] = val @@ -385,27 +385,27 @@ end ### Indexing function getsyms(integrator::DEIntegrator) - if has_syms(integrator.f) - return integrator.f.syms - else - return keys(integrator.u[1]) + syms = variable_symbols(integrator) + if isempty(syms) + syms = keys(integrator.u) end + return syms end function getindepsym(integrator::DEIntegrator) - if has_indepsym(integrator.f) - return integrator.f.indepsym - else + syms = independent_variable_symbols(integrator) + if isempty(syms) return nothing end + return syms end function getparamsyms(integrator::DEIntegrator) - if has_paramsyms(integrator.f) - return integrator.f.paramsyms - else + psyms = parameter_symbols(integrator) + if isempty(psyms) return nothing end + return psyms end function getobserved(integrator::DEIntegrator) @@ -417,58 +417,76 @@ function getobserved(integrator::DEIntegrator) end function sym_to_index(sym, integrator::DEIntegrator) - if has_sys(integrator.f) && is_state_sym(integrator.f.sys, sym) - return state_sym_to_index(integrator.f.sys, sym) + idx = variable_index(integrator, sym) + if idx === nothing + idx = findfirst(isequal(sym), keys(integrator.u)) + end + return idx +end + +# SymbolicIndexingInterface +SymbolicIndexingInterface.symbolic_container(A::DEIntegrator) = A.f +SymbolicIndexingInterface.parameter_values(A::DEIntegrator) = A.p + +function SymbolicIndexingInterface.is_observed(A::DEIntegrator, sym) + return !is_variable(A, sym) && !is_parameter(A, sym) && !is_independent_variable(A, sym) && symbolic_type(sym) == ScalarSymbolic() +end + +function SymbolicIndexingInterface.observed(A::DEIntegrator, sym) + (u, p, t) -> getobserved(A)(sym, u, p, t) +end + +SymbolicIndexingInterface.is_time_dependent(::DEIntegrator) = true + +# TODO make this nontrivial once dynamic state selection works +SymbolicIndexingInterface.constant_structure(::DEIntegrator) = true + +function Base.getproperty(A::DEIntegrator, sym::Symbol) + if sym === :destats && hasfield(typeof(A), :stats) + @warn "destats has been deprecated for stats" + getfield(A, :stats) else - return sym_to_index(sym, getsyms(integrator)) + return getfield(A, sym) end end -Base.@propagate_inbounds function Base.getindex(A::DEIntegrator, - I::Union{Int, AbstractArray{Int}, +Base.@propagate_inbounds function Base.getindex(A::DEIntegrator, ::NotSymbolic, I::Union{Int, AbstractArray{Int}, CartesianIndex, Colon, BitArray, AbstractArray{Bool}}...) - RecursiveArrayTools.VectorOfArray(A.u)[I...] + A.u[I...] +end + +Base.@propagate_inbounds function Base.getindex(A::DEIntegrator, ::ScalarSymbolic, sym) + if is_variable(A, sym) + return A[variable_index(A, sym)] + elseif is_parameter(A, sym) + Base.depwarn("Indexing with parameters is deprecated. Use `getp(sys, $sym)(integrator)` for parameter indexing.", :parameter_getindex) + return getp(A, sym)(A) + elseif is_independent_variable(A, sym) + return A.t + elseif is_observed(A, sym) + return SymbolicIndexingInterface.observed(A, sym)(A.u, A.p, A.t) + else + error("Tried to index integrator with a Symbol that was not found in the system.") + end +end + +Base.@propagate_inbounds function Base.getindex(A::DEIntegrator, ::ArraySymbolic, sym) + return A[collect(sym)] +end + +Base.@propagate_inbounds function Base.getindex(A::DEIntegrator, ::ScalarSymbolic, sym::Union{Tuple,AbstractArray}) + return getindex.((A,), sym) end Base.@propagate_inbounds function Base.getindex(A::DEIntegrator, sym) - if issymbollike(sym) - if sym isa AbstractArray - return A[collect(sym)] - end - i = sym_to_index(sym, A) - elseif all(issymbollike, sym) - return getindex.((A,), sym) - else - i = sym - end + symtype = symbolic_type(sym) + elsymtype = symbolic_type(eltype(sym)) - if i === nothing - if issymbollike(sym) - if has_sys(A.f) && is_indep_sym(A.f.sys, sym) || - Symbol(sym) == getindepsym(A) - return A.t - elseif has_sys(A.f) && is_param_sym(A.f.sys, sym) - return A.p[param_sym_to_index(A.f.sys, sym)] - elseif has_paramsyms(A.f) && Symbol(sym) in getparamsyms(A) - return A.p[findfirst(x -> isequal(x, Symbol(sym)), getparamsyms(A))] - elseif (sym isa Symbol) && has_sys(A.f) && hasproperty(A.f.sys, sym) # Handles input like :X (where X is a state). - return observed(A, getproperty(A.f.sys, sym)) - elseif has_sys(A.f) && (count('₊', String(Symbol(sym))) == 1) && - (count(isequal(Symbol(sym)), - Symbol.(A.f.sys.name, :₊, getparamsyms(A))) == 1) # Handles input like sys.X (where X is a parameter). - return A.p[findfirst(isequal(Symbol(sym)), - Symbol.(A.f.sys.name, :₊, getparamsyms(A)))] - else - return observed(A, sym) - end - else - observed(A, sym) - end - elseif i isa Base.Integer || i isa AbstractRange || i isa AbstractVector{<:Base.Integer} - A[i] + if symtype != NotSymbolic() + return getindex(A, symtype, sym) else - error("Invalid indexing of integrator") + return getindex(A, elsymtype, sym) end end @@ -477,52 +495,24 @@ function observed(A::DEIntegrator, sym) end function Base.setindex!(A::DEIntegrator, val, sym) - if has_sys(A.f) - if issymbollike(sym) - params = getparamsyms(A) - s = Symbol.(states(A.f.sys)) - params = Symbol.(params) - - i = findfirst(isequal(Symbol(sym)), s) - if !isnothing(i) - A.u[i] = val - return A - elseif sym isa Symbol # Handles input like :X. - s_f = Symbol.(getproperty.(states(A.f.sys), :f)) - if count(isequal(Symbol(sym)), s_f) == 1 - i = findfirst(isequal(sym), s_f) - A.u[i] = val - return A - elseif count(isequal(Symbol(sym)), s_f) > 1 - error("The input symbol $(sym) occurs several times among integrator states. Please avoid use Symbol form (:$(sym)).") - end - elseif count('₊', String(Symbol(sym))) == 1 # Handles input like sys.X. - s_names = Symbol.(A.f.sys.name, :₊, s) - if count(isequal(Symbol(sym)), s_names) == 1 - i = findfirst(isequal(Symbol(sym)), s_names) - A.u[i] = val - return A - end - end - - i = findfirst(isequal(Symbol(sym)), params) - if !isnothing(i) - A.p[i] = val - return A - elseif count('₊', String(Symbol(sym))) == 1 # Handles input like sys.X. - p_names = Symbol.(A.f.sys.name, :₊, params) - if count(isequal(Symbol(sym)), p_names) == 1 - i = findfirst(isequal(Symbol(sym)), p_names) - A.p[i] = val - return A - end - end - error("Invalid indexing of integrator: $sym is not a state or parameter, it may be an observed variable.") + has_sys(A.f) || error("Invalid indexing of integrator: Integrator does not support indexing without a system") + if symbolic_type(sym) == ScalarSymbolic() + if is_variable(A, sym) + A.u[variable_index(A, sym)] = val + elseif is_parameter(A, sym) + Base.depwarn("Parameter indexing is deprecated. Use `setp(sys, $sym)(integrator, $val)` to set parameter value.", :parameter_setindex) + setp(A, sym)(A, val) else - error("Invalid indexing of integrator: $sym is not a symbol") + error("Invalid indexing of integrator: $sym is not a state or parameter, it may be an observed variable.") end + return A + elseif symbolic_type(sym) == ArraySymbolic() + setindex!.((A,), val, collect(sym)) + return A else - error("Invalid indexing of integrator: Integrator does not support indexing without a system") + sym isa AbstractArray || error("Invalid indexing of integrator") + setindex!.((A,), val, sym) + return A end end diff --git a/src/problems/problem_interface.jl b/src/problems/problem_interface.jl index aef802a77..f8eb35a6e 100644 --- a/src/problems/problem_interface.jl +++ b/src/problems/problem_interface.jl @@ -1,41 +1,30 @@ -Base.@propagate_inbounds function Base.getindex(prob::AbstractSciMLProblem, sym) - if issymbollike(sym) - if sym isa AbstractArray - return map(s -> prob[s], sym) - end - end +SymbolicIndexingInterface.symbolic_container(prob::AbstractSciMLProblem) = prob.f +SymbolicIndexingInterface.parameter_values(prob::AbstractSciMLProblem) = prob.p - if issymbollike(sym) - if has_sys(prob.f) && is_indep_sym(prob.f.sys, sym) || - Symbol(sym) == getindepsym(prob) +Base.@propagate_inbounds function Base.getindex(prob::AbstractSciMLProblem, sym) + if symbolic_type(sym) == ScalarSymbolic() + if is_variable(prob.f, sym) + return prob.u0[variable_index(prob.f, sym)] + elseif is_parameter(prob.f, sym) + Base.depwarn("Indexing with parameters is deprecated. Use `getp(prob, $sym)(prob)` for parameter indexing.", :parameter_getindex) + return getp(prob, sym)(prob) + elseif is_independent_variable(prob.f, sym) return getindepsym(prob) - elseif has_sys(prob.f) && is_param_sym(prob.f.sys, sym) - return prob.p[param_sym_to_index(prob.f.sys, sym)] - elseif has_paramsyms(prob.f) && Symbol(sym) in getparamsyms(prob) - return prob.p[findfirst(x -> isequal(x, Symbol(sym)), getparamsyms(prob))] - elseif Symbol(sym) in getsyms(prob) - return prob.u0[sym_to_index(sym, prob)] - elseif has_sys(prob.f) && count('₊', String(Symbol(sym))) == 1 # Handles input like sys.X. - s_names = Symbol.(prob.f.sys.name, :₊, getsyms(prob)) - p_names = Symbol.(prob.f.sys.name, :₊, getparamsyms(prob)) - if count(isequal(Symbol(sym)), s_names) == 1 - return prob.u0[findfirst(isequal(Symbol(sym)), s_names)] - elseif count(isequal(Symbol(sym)), p_names) == 1 - return prob.p[findfirst(isequal(Symbol(sym)), p_names)] - end - elseif (sym isa Symbol) && has_sys(prob.f) # Handles input like :X (where X is a state). - s_f = Symbol.(getproperty.(states(prob.f.sys), :f)) - s_count = count(isequal(sym), s_f) - if s_count == 1 - return prob.u0[findfirst(isequal(sym), s_f)] - elseif s_count > 1 - error("Tried to index with a Symbol (:$(sym)) that could represent several different possible states.") + elseif is_observed(prob.f, sym) + obs = SymbolicIndexingInterface.observed(prob.f, sym) + if is_time_dependent(prob.f) + return obs(prob.u0, prob.p, 0.0) + else + return obs(prob.u0, prob.p) end else error("Invalid indexing of problem: $sym is not a state, parameter, or independent variable") end + elseif symbolic_type(sym) == ArraySymbolic() + return map(s -> prob[s], sym) else - error("Invalid indexing of problem: $sym is not a symbol") + sym isa AbstractArray || error("Invalid indexing of problem") + return map(s -> prob[s], sym) end end @@ -43,51 +32,23 @@ function Base.setindex!(prob::AbstractSciMLProblem, args...; kwargs...) ___internal_setindex!(prob::AbstractSciMLProblem, args...; kwargs...) end function ___internal_setindex!(prob::AbstractSciMLProblem, val, sym) - if has_sys(prob.f) - if issymbollike(sym) - params = getparamsyms(prob) - s = Symbol.(states(prob.f.sys)) - params = Symbol.(params) - - i = findfirst(isequal(Symbol(sym)), s) - if !isnothing(i) - prob.u0[i] = val - return prob - elseif sym isa Symbol # Handles input like :X. - s_f = Symbol.(getproperty.(states(prob.f.sys), :f)) - if count(isequal(Symbol(sym)), s_f) == 1 - i = findfirst(isequal(sym), s_f) - prob.u0[i] = val - return prob - elseif count(isequal(Symbol(sym)), s_f) > 1 - error("The input symbol $(sym) occurs several times among problem states. Please avoid use Symbol form (:$(sym)).") - end - elseif count('₊', String(Symbol(sym))) == 1 # Handles input like sys.X. - s_names = Symbol.(prob.f.sys.name, :₊, s) - if count(isequal(Symbol(sym)), s_names) == 1 - i = findfirst(isequal(Symbol(sym)), s_names) - prob.u0[i] = val - return prob - end - end - - i = findfirst(isequal(Symbol(sym)), params) - if !isnothing(i) - prob.p[i] = val - return prob - elseif count('₊', String(Symbol(sym))) == 1 # Handles input like sys.X. - p_names = Symbol.(prob.f.sys.name, :₊, params) - if count(isequal(Symbol(sym)), p_names) == 1 - i = findfirst(isequal(Symbol(sym)), p_names) - prob.p[i] = val - return prob - end - end - error("Invalid indexing of problem: $sym is not a state or parameter, it may be an observed variable.") + has_sys(prob.f) || error("Invalid indexing of problem: Problem does not support indexing without a system") + if symbolic_type(sym) == ScalarSymbolic() + if is_variable(prob.f, sym) + prob.u0[variable_index(prob.f, sym)] = val + elseif is_parameter(prob.f, sym) + Base.depwarn("Indexing with parameters is deprecated. Use `setp(prob, $sym)(prob, $val)` to set parameter value.", :parameter_setindex) + setp(prob, sym)(prob, val) else - error("Invalid indexing of problem: $sym is not a symbol") + error("Invalid indexing of problem: $sym is not a state or parameter, it may be an observed variable.") end + return prob + elseif symbolic_type(sym) == ArraySymbolic() + setindex!.((prob,), val, collect(sym)) + return prob else - error("Invalid indexing of problem: Problem does not support indexing without a system") + sym isa AbstractArray || error("Invalid indexing of problem") + setindex!.((prob,), val, sym) + return prob end end diff --git a/src/scimlfunctions.jl b/src/scimlfunctions.jl index 19e6bd38f..e17c2efef 100644 --- a/src/scimlfunctions.jl +++ b/src/scimlfunctions.jl @@ -230,7 +230,7 @@ $(TYPEDEF) abstract type AbstractODEFunction{iip} <: AbstractDiffEqFunction{iip} end @doc doc""" - ODEFunction{iip,F,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV} <: AbstractODEFunction{iip,specialize} +$(TYPEDEF) A representation of an ODE function `f`, defined by: @@ -255,9 +255,9 @@ ODEFunction{iip,specialize}(f; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -412,8 +412,7 @@ automatically symbolically generating the Jacobian and more from the numerically-defined functions. """ struct ODEFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, WP, TPJ, - S, - S2, S3, O, TCV, + O, TCV, SYS} <: AbstractODEFunction{iip} f::F mass_matrix::TMM @@ -428,9 +427,6 @@ struct ODEFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TW Wfact_t::TWt W_prototype::WP paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -439,7 +435,7 @@ end TruncatedStacktraces.@truncate_stacktrace ODEFunction 1 2 @doc doc""" - SplitFunction{iip,F1,F2,TMM,C,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV} <: AbstractODEFunction{iip,specialize} +$(TYPEDEF) A representation of a split ODE function `f`, defined by: @@ -470,9 +466,9 @@ SplitFunction{iip,specialize}(f1,f2; jac_prototype = __has_jac_prototype(f1) ? f1.jac_prototype : nothing, sparsity = __has_sparsity(f1) ? f1.sparsity : jac_prototype, paramjac = __has_paramjac(f1) ? f1.paramjac : nothing, - syms = __has_syms(f1) ? f1.syms : nothing, - indepsym= __has_indepsym(f1) ? f1.indepsym : nothing, - paramsyms = __has_paramsyms(f1) ? f1.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f1) ? f1.colorvec : nothing, sys = __has_sys(f1) ? f1.sys : nothing) ``` @@ -542,7 +538,7 @@ numerically-defined functions. See `ModelingToolkit.SplitODEProblem` for information on generating the SplitFunction from this symbolic engine. """ struct SplitFunction{iip, specialize, F1, F2, TMM, C, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, - TPJ, S, S2, S3, O, + TPJ, O, TCV, SYS} <: AbstractODEFunction{iip} f1::F1 f2::F2 @@ -558,9 +554,6 @@ struct SplitFunction{iip, specialize, F1, F2, TMM, C, Ta, Tt, TJ, JVP, VJP, JP, Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -569,7 +562,7 @@ end TruncatedStacktraces.@truncate_stacktrace SplitFunction 1 2 @doc doc""" - DynamicalODEFunction{iip,F1,F2,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV} <: AbstractODEFunction{iip,specialize} +$(TYPEDEF) A representation of an ODE function `f`, defined by: @@ -601,9 +594,9 @@ DynamicalODEFunction{iip,specialize}(f1,f2; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -662,7 +655,7 @@ For more details on this argument, see the ODEFunction documentation. The fields of the DynamicalODEFunction type directly match the names of the inputs. """ struct DynamicalODEFunction{iip, specialize, F1, F2, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, - TWt, TPJ, S, S2, S3, + TWt, TPJ, O, TCV, SYS} <: AbstractODEFunction{iip} f1::F1 f2::F2 @@ -677,9 +670,6 @@ struct DynamicalODEFunction{iip, specialize, F1, F2, TMM, Ta, Tt, TJ, JVP, VJP, Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -692,7 +682,7 @@ $(TYPEDEF) abstract type AbstractDDEFunction{iip} <: AbstractDiffEqFunction{iip} end @doc doc""" - DDEFunction{iip,F,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S.S2,S3,O,TCV} <: AbstractDDEFunction{iip,specialize} +$(TYPEDEF) A representation of a DDE function `f`, defined by: @@ -717,9 +707,9 @@ DDEFunction{iip,specialize}(f; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -777,8 +767,7 @@ For more details on this argument, see the ODEFunction documentation. The fields of the DDEFunction type directly match the names of the inputs. """ -struct DDEFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, S, - S2, S3, O, TCV, SYS, +struct DDEFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, O, TCV, SYS, } <: AbstractDDEFunction{iip} f::F @@ -793,9 +782,6 @@ struct DDEFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TW Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -804,7 +790,7 @@ end TruncatedStacktraces.@truncate_stacktrace DDEFunction 1 2 @doc doc""" - DynamicalDDEFunction{iip,F1,F2,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV} <: AbstractDDEFunction{iip,specialize} +$(TYPEDEF) A representation of a DDE function `f`, defined by: @@ -836,9 +822,9 @@ DynamicalDDEFunction{iip,specialize}(f1,f2; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -899,7 +885,7 @@ For more details on this argument, see the ODEFunction documentation. The fields of the DynamicalDDEFunction type directly match the names of the inputs. """ struct DynamicalDDEFunction{iip, specialize, F1, F2, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, - TWt, TPJ, S, S2, S3, + TWt, TPJ, O, TCV, SYS} <: AbstractDDEFunction{iip} f1::F1 f2::F2 @@ -914,9 +900,6 @@ struct DynamicalDDEFunction{iip, specialize, F1, F2, TMM, Ta, Tt, TJ, JVP, VJP, Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -930,7 +913,7 @@ abstract type AbstractDiscreteFunction{iip} <: AbstractDiffEqFunction{iip} end @doc doc""" - DiscreteFunction{iip,F,Ta,S,S2,S3,O} <: AbstractDiscreteFunction{iip,specialize} +$(TYPEDEF) A representation of a discrete dynamical system `f`, defined by: @@ -947,9 +930,9 @@ with respect to time, and more. For all cases, `u0` is the initial condition, ```julia DiscreteFunction{iip,specialize}(f; analytic = __has_analytic(f) ? f.analytic : nothing, - syms = __has_syms(f) ? f.syms : nothing - indepsym = __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing) + syms = nothing + indepsym = nothing, + paramsyms = nothing) ``` Note that only the function `f` itself is required. This function should @@ -982,13 +965,10 @@ For more details on this argument, see the ODEFunction documentation. The fields of the DiscreteFunction type directly match the names of the inputs. """ -struct DiscreteFunction{iip, specialize, F, Ta, S, S2, S3, O, SYS} <: +struct DiscreteFunction{iip, specialize, F, Ta, O, SYS} <: AbstractDiscreteFunction{iip} f::F analytic::Ta - syms::S - indepsym::S2 - paramsyms::S3 observed::O sys::SYS end @@ -996,7 +976,7 @@ end TruncatedStacktraces.@truncate_stacktrace DiscreteFunction 1 2 @doc doc""" - ImplicitDiscreteFunction{iip,F,Ta,S,S2,S3,O} <: AbstractDiscreteFunction{iip,specialize} +$(TYPEDEF) A representation of an discrete dynamical system `f`, defined by: @@ -1017,9 +997,9 @@ dt: the time step ```julia ImplicitDiscreteFunction{iip,specialize}(f; analytic = __has_analytic(f) ? f.analytic : nothing, - syms = __has_syms(f) ? f.syms : nothing - indepsym = __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing) + syms = nothing + indepsym = nothing, + paramsyms = nothing) ``` Note that only the function `f` itself is required. This function should @@ -1052,13 +1032,10 @@ For more details on this argument, see the ODEFunction documentation. The fields of the ImplicitDiscreteFunction type directly match the names of the inputs. """ -struct ImplicitDiscreteFunction{iip, specialize, F, Ta, S, S2, S3, O, SYS} <: +struct ImplicitDiscreteFunction{iip, specialize, F, Ta, O, SYS} <: AbstractDiscreteFunction{iip} f::F analytic::Ta - syms::S - indepsym::S2 - paramsyms::S3 observed::O sys::SYS end @@ -1071,7 +1048,7 @@ $(TYPEDEF) abstract type AbstractSDEFunction{iip} <: AbstractDiffEqFunction{iip} end @doc doc""" - SDEFunction{iip,F,G,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,GG,S,S2,S3,O,TCV} <: AbstractSDEFunction{iip,specialize} +$(TYPEDEF) A representation of an SDE function `f`, defined by: @@ -1097,9 +1074,9 @@ SDEFunction{iip,specialize}(f,g; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -1158,7 +1135,7 @@ For more details on this argument, see the ODEFunction documentation. The fields of the ODEFunction type directly match the names of the inputs. """ struct SDEFunction{iip, specialize, F, G, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, - GG, S, S2, S3, O, + GG, O, TCV, SYS, } <: AbstractSDEFunction{iip} f::F @@ -1175,9 +1152,6 @@ struct SDEFunction{iip, specialize, F, G, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, Wfact_t::TWt paramjac::TPJ ggprime::GG - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -1186,7 +1160,7 @@ end TruncatedStacktraces.@truncate_stacktrace SDEFunction 1 2 @doc doc""" - SplitSDEFunction{iip,F1,F2,G,TMM,C,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV} <: AbstractSDEFunction{iip,specialize} +$(TYPEDEF) A representation of a split SDE function `f`, defined by: @@ -1218,9 +1192,9 @@ SplitSDEFunction{iip,specialize}(f1,f2,g; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -1282,7 +1256,7 @@ The fields of the SplitSDEFunction type directly match the names of the inputs. struct SplitSDEFunction{iip, specialize, F1, F2, G, TMM, C, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, - S, S2, S3, O, TCV, SYS} <: AbstractSDEFunction{iip} + O, TCV, SYS} <: AbstractSDEFunction{iip} f1::F1 f2::F2 g::G @@ -1298,9 +1272,6 @@ struct SplitSDEFunction{iip, specialize, F1, F2, G, TMM, C, Ta, Tt, TJ, JVP, VJP Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -1309,7 +1280,7 @@ end TruncatedStacktraces.@truncate_stacktrace SplitSDEFunction 1 2 @doc doc""" - DynamicalSDEFunction{iip,F1,F2,G,TMM,C,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV} <: AbstractSDEFunction{iip,specialize} +$(TYPEDEF) A representation of an SDE function `f` and `g`, defined by: @@ -1342,9 +1313,9 @@ DynamicalSDEFunction{iip,specialize}(f1,f2; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -1404,7 +1375,7 @@ The fields of the DynamicalSDEFunction type directly match the names of the inpu struct DynamicalSDEFunction{iip, specialize, F1, F2, G, TMM, C, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, - TPJ, S, S2, S3, O, TCV, SYS} <: AbstractSDEFunction{iip} + TPJ, O, TCV, SYS} <: AbstractSDEFunction{iip} # This is a direct copy of the SplitSDEFunction, maybe it's not necessary and the above can be used instead. f1::F1 f2::F2 @@ -1421,9 +1392,6 @@ struct DynamicalSDEFunction{iip, specialize, F1, F2, G, TMM, C, Ta, Tt, TJ, JVP, Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -1437,7 +1405,7 @@ $(TYPEDEF) abstract type AbstractRODEFunction{iip} <: AbstractDiffEqFunction{iip} end @doc doc""" - RODEFunction{iip,F,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV} <: AbstractRODEFunction{iip,specialize} +$(TYPEDEF) A representation of a RODE function `f`, defined by: @@ -1462,9 +1430,9 @@ RODEFunction{iip,specialize}(f; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing, analytic_full = __has_analytic_full(f) ? f.analytic_full : false) @@ -1527,8 +1495,7 @@ For more details on this argument, see the ODEFunction documentation. The fields of the RODEFunction type directly match the names of the inputs. """ -struct RODEFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, S, - S2, S3, O, TCV, SYS, +struct RODEFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, O, TCV, SYS, } <: AbstractRODEFunction{iip} f::F @@ -1543,9 +1510,6 @@ struct RODEFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, T Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -1560,7 +1524,7 @@ $(TYPEDEF) abstract type AbstractDAEFunction{iip} <: AbstractDiffEqFunction{iip} end @doc doc""" - DAEFunction{iip,F,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV} <: AbstractDAEFunction{iip,specialize} +$(TYPEDEF) A representation of an implicit DAE function `f`, defined by: @@ -1582,9 +1546,9 @@ DAEFunction{iip,specialize}(f; vjp = __has_vjp(f) ? f.vjp : nothing, jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -1683,8 +1647,7 @@ See the `modelingtoolkitize` function from automatically symbolically generating the Jacobian and more from the numerically-defined functions. """ -struct DAEFunction{iip, specialize, F, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, S, S2, - S3, O, TCV, +struct DAEFunction{iip, specialize, F, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, O, TCV, SYS} <: AbstractDAEFunction{iip} f::F @@ -1698,9 +1661,6 @@ struct DAEFunction{iip, specialize, F, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TP Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -1714,7 +1674,7 @@ $(TYPEDEF) abstract type AbstractSDDEFunction{iip} <: AbstractDiffEqFunction{iip} end @doc doc""" - SDDEFunction{iip,F,G,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,GG,S,S2,S3,O,TCV} <: AbstractSDDEFunction{iip,specialize} +$(TYPEDEF) A representation of a SDDE function `f`, defined by: @@ -1739,9 +1699,9 @@ SDDEFunction{iip,specialize}(f,g; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing sys = __has_sys(f) ? f.sys : nothing) ``` @@ -1800,7 +1760,7 @@ For more details on this argument, see the ODEFunction documentation. The fields of the DDEFunction type directly match the names of the inputs. """ struct SDDEFunction{iip, specialize, F, G, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, TPJ, - GG, S, S2, S3, O, + GG, O, TCV, SYS} <: AbstractSDDEFunction{iip} f::F g::G @@ -1816,9 +1776,6 @@ struct SDDEFunction{iip, specialize, F, G, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW Wfact_t::TWt paramjac::TPJ ggprime::GG - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV sys::SYS @@ -1832,7 +1789,7 @@ $(TYPEDEF) abstract type AbstractNonlinearFunction{iip} <: AbstractSciMLFunction{iip} end @doc doc""" - NonlinearFunction{iip,F,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,S,S2,O,TCV} <: AbstractNonlinearFunction{iip,specialize} +$(TYPEDEF) A representation of a nonlinear system of equations `f`, defined by: @@ -1855,8 +1812,8 @@ NonlinearFunction{iip, specialize}(f; jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -1905,7 +1862,7 @@ For more details on this argument, see the ODEFunction documentation. The fields of the NonlinearFunction type directly match the names of the inputs. """ struct NonlinearFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, TW, TWt, - TPJ, S, S2, O, TCV, SYS, RP} <: AbstractNonlinearFunction{iip} + TPJ, O, TCV, SYS, RP} <: AbstractNonlinearFunction{iip} f::F mass_matrix::TMM analytic::Ta @@ -1918,8 +1875,6 @@ struct NonlinearFunction{iip, specialize, F, TMM, Ta, Tt, TJ, JVP, VJP, JP, SP, Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - paramsyms::S2 observed::O colorvec::TCV sys::SYS @@ -1934,7 +1889,7 @@ $(TYPEDEF) abstract type AbstractIntervalNonlinearFunction{iip} <: AbstractSciMLFunction{iip} end @doc doc""" - IntervalNonlinearFunction{iip, specialize, F, Ta, S, S2, O, SYS} <: AbstractIntervalNonlinearFunction{iip,specialize} +$(TYPEDEF) A representation of an interval nonlinear system of equations `f`, defined by: @@ -1950,8 +1905,8 @@ interval variable. ```julia IntervalNonlinearFunction{iip, specialize}(f; analytic = __has_analytic(f) ? f.analytic : nothing, - syms = __has_syms(f) ? f.syms : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + paramsyms = nothing, sys = __has_sys(f) ? f.sys : nothing) ``` @@ -1984,12 +1939,10 @@ For more details on this argument, see the ODEFunction documentation. The fields of the IntervalNonlinearFunction type directly match the names of the inputs. """ struct IntervalNonlinearFunction{iip, specialize, F, Ta, - S, S2, O, SYS, + O, SYS, } <: AbstractIntervalNonlinearFunction{iip} f::F analytic::Ta - syms::S - paramsyms::S2 observed::O sys::SYS end @@ -1997,7 +1950,7 @@ end TruncatedStacktraces.@truncate_stacktrace IntervalNonlinearFunction 1 2 """ - OptimizationFunction{iip, AD, F, G, H, HV, C, CJ, CH, HP, CJP, CHP, S, S2, O, EX, CEX, SYS} <: AbstractOptimizationFunction{iip,specialize} +$(TYPEDEF) A representation of an objective function `f`, defined by: @@ -2017,8 +1970,8 @@ OptimizationFunction{iip}(f, adtype::AbstractADType = NoAD(); hess_prototype = nothing, cons_jac_prototype = nothing, cons_hess_prototype = nothing, - syms = __has_syms(f) ? f.syms : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED_NO_TIME, lag_h = nothing, hess_colorvec = __has_colorvec(f) ? f.colorvec : nothing, @@ -2124,7 +2077,7 @@ For more details on this argument, see the ODEFunction documentation. The fields of the OptimizationFunction type directly match the names of the inputs. """ -struct OptimizationFunction{iip, AD, F, G, H, HV, C, CJ, CH, HP, CJP, CHP, S, S2, O, +struct OptimizationFunction{iip, AD, F, G, H, HV, C, CJ, CH, HP, CJP, CHP, O, EX, CEX, SYS, LH, LHP, HCV, CJCV, CHCV, LHCV} <: AbstractOptimizationFunction{iip} f::F @@ -2138,8 +2091,6 @@ struct OptimizationFunction{iip, AD, F, G, H, HV, C, CJ, CH, HP, CJP, CHP, S, S2 hess_prototype::HP cons_jac_prototype::CJP cons_hess_prototype::CHP - syms::S - paramsyms::S2 observed::O expr::EX cons_expr::CEX @@ -2160,7 +2111,7 @@ $(TYPEDEF) abstract type AbstractBVPFunction{iip, twopoint} <: AbstractDiffEqFunction{iip} end @doc doc""" - BVPFunction{iip,F,BF,TMM,Ta,Tt,TJ,BCTJ,JVP,VJP,JP,BCJP,SP,TW,TWt,TPJ,S,S2,S3,O,TCV,BCTCV} <: AbstractBVPFunction{iip,specialize} +$(TYPEDEF) A representation of a BVP function `f`, defined by: @@ -2191,9 +2142,9 @@ BVPFunction{iip,specialize}(f, bc; bcjac_prototype = __has_jac_prototype(bc) ? bc.jac_prototype : nothing, sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym= __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym= nothing, + paramsyms = nothing, colorvec = __has_colorvec(f) ? f.colorvec : nothing, bccolorvec = __has_colorvec(f) ? bc.colorvec : nothing, sys = __has_sys(f) ? f.sys : nothing) @@ -2263,7 +2214,7 @@ For more details on this argument, see the ODEFunction documentation. The fields of the BVPFunction type directly match the names of the inputs. """ struct BVPFunction{iip, specialize, twopoint, F, BF, TMM, Ta, Tt, TJ, BCTJ, JVP, VJP, - JP, BCJP, BCRP, SP, TW, TWt, TPJ, S, S2, S3, O, TCV, BCTCV, + JP, BCJP, BCRP, SP, TW, TWt, TPJ, O, TCV, BCTCV, SYS} <: AbstractBVPFunction{iip, twopoint} f::F bc::BF @@ -2281,9 +2232,6 @@ struct BVPFunction{iip, specialize, twopoint, F, BF, TMM, Ta, Tt, TJ, BCTJ, JVP, Wfact::TW Wfact_t::TWt paramjac::TPJ - syms::S - indepsym::S2 - paramsyms::S3 observed::O colorvec::TCV bccolorvec::BCTCV @@ -2478,10 +2426,9 @@ function ODEFunction{iip, specialize}(f; Wfact_t = __has_Wfact_t(f) ? f.Wfact_t : nothing, W_prototype = __has_W_prototype(f) ? f.W_prototype : nothing, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym = __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f) ? f.colorvec : nothing, @@ -2530,16 +2477,18 @@ function ODEFunction{iip, specialize}(f; _f = prepare_function(f) + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize ODEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, typeof(jac_prototype), typeof(sparsity), Any, Any, typeof(W_prototype), Any, - typeof(syms), typeof(indepsym), typeof(paramsyms), Any, + Any, typeof(_colorvec), typeof(sys)}(_f, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, - Wfact_t, W_prototype, paramjac, syms, indepsym, paramsyms, + Wfact_t, W_prototype, paramjac, observed, _colorvec, sys) elseif specialize === false ODEFunction{iip, FunctionWrapperSpecialize, @@ -2547,11 +2496,11 @@ function ODEFunction{iip, specialize}(f; typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), typeof(Wfact), typeof(Wfact_t), typeof(W_prototype), typeof(paramjac), - typeof(syms), typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(observed), typeof(_colorvec), typeof(sys)}(_f, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, - Wfact_t, W_prototype, paramjac, syms, indepsym, paramsyms, + Wfact_t, W_prototype, paramjac, observed, _colorvec, sys) else ODEFunction{iip, specialize, @@ -2559,11 +2508,11 @@ function ODEFunction{iip, specialize}(f; typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), typeof(Wfact), typeof(Wfact_t), typeof(W_prototype), typeof(paramjac), - typeof(syms), typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(observed), typeof(_colorvec), typeof(sys)}(_f, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, - Wfact_t, W_prototype, paramjac, syms, indepsym, paramsyms, + Wfact_t, W_prototype, paramjac, observed, _colorvec, sys) end end @@ -2580,10 +2529,10 @@ function unwrapped_f(f::ODEFunction, newf = unwrapped_f(f.f)) ODEFunction{isinplace(f), specialization(f), Any, Any, Any, Any, Any, Any, Any, typeof(f.jac_prototype), typeof(f.sparsity), Any, Any, Any, - typeof(f.syms), Any, Any, Any, typeof(f.colorvec), + Any, typeof(f.colorvec), typeof(f.sys)}(newf, f.mass_matrix, f.analytic, f.tgrad, f.jac, f.jvp, f.vjp, f.jac_prototype, f.sparsity, f.Wfact, - f.Wfact_t, f.W_prototype, f.paramjac, f.syms, f.indepsym, f.paramsyms, + f.Wfact_t, f.W_prototype, f.paramjac, f.observed, f.colorvec, f.sys) else ODEFunction{isinplace(f), specialization(f), typeof(newf), typeof(f.mass_matrix), @@ -2591,11 +2540,10 @@ function unwrapped_f(f::ODEFunction, newf = unwrapped_f(f.f)) typeof(f.jac), typeof(f.jvp), typeof(f.vjp), typeof(f.jac_prototype), typeof(f.sparsity), typeof(f.Wfact), typeof(f.Wfact_t), typeof(f.W_prototype), typeof(f.paramjac), - typeof(f.syms), typeof(f.indepsym), typeof(f.paramsyms), typeof(f.observed), typeof(f.colorvec), typeof(f.sys)}(newf, f.mass_matrix, f.analytic, f.tgrad, f.jac, f.jvp, f.vjp, f.jac_prototype, f.sparsity, f.Wfact, - f.Wfact_t, f.W_prototype, f.paramjac, f.syms, f.indepsym, f.paramsyms, + f.Wfact_t, f.W_prototype, f.paramjac, f.observed, f.colorvec, f.sys) end end @@ -2642,9 +2590,9 @@ function ODEFunction{iip}(f::NonlinearFunction) where {iip} jac_prototype = f.jac_prototype, sparsity = f.sparsity, paramjac = f.paramjac, - syms = f.syms, + syms = variable_symbols(f), indepsym = nothing, - paramsyms = f.paramsyms, + paramsyms = parameter_symbols(f), observed = f.observed, colorvec = f.colorvec) end @@ -2693,15 +2641,15 @@ function NonlinearFunction{iip}(f::ODEFunction) where {iip} jac_prototype = f.jac_prototype, sparsity = f.sparsity, paramjac = f.paramjac, - syms = f.syms, - paramsyms = f.paramsyms, + syms = variable_symbols(f), + paramsyms = parameter_symbols(f), observed = f.observed, colorvec = f.colorvec) end @add_kwonly function SplitFunction(f1, f2, mass_matrix, cache, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, paramjac, - syms, indepsym, paramsyms, observed, colorvec, sys) + observed, colorvec, sys) f1 = ODEFunction(f1) f2 = ODEFunction(f2) @@ -2714,12 +2662,9 @@ end typeof(mass_matrix), typeof(cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), typeof(colorvec), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, mass_matrix, cache, analytic, tgrad, jac, jvp, vjp, - jac_prototype, sparsity, Wfact, Wfact_t, paramjac, syms, - indepsym, - paramsyms, observed, colorvec, sys) + jac_prototype, sparsity, Wfact, Wfact_t, paramjac, observed, colorvec, sys) end function SplitFunction{iip, specialize}(f1, f2; mass_matrix = __has_mass_matrix(f1) ? @@ -2740,11 +2685,9 @@ function SplitFunction{iip, specialize}(f1, f2; Wfact_t = __has_Wfact_t(f1) ? f1.Wfact_t : nothing, paramjac = __has_paramjac(f1) ? f1.paramjac : nothing, - syms = __has_syms(f1) ? f1.syms : nothing, - indepsym = __has_indepsym(f1) ? f1.indepsym : - nothing, - paramsyms = __has_paramsyms(f1) ? f1.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f1) ? f1.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f1) ? f1.colorvec : @@ -2752,27 +2695,25 @@ function SplitFunction{iip, specialize}(f1, f2; sys = __has_sys(f1) ? f1.sys : nothing) where {iip, specialize, } + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) if specialize === NoSpecialize SplitFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, - Any, Any, Any, Any, Any, Any}(f1, f2, mass_matrix, _func_cache, + Any, Any, Any}(f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, paramjac, - syms, indepsym, paramsyms, observed, colorvec, sys) else SplitFunction{iip, specialize, typeof(f1), typeof(f2), typeof(mass_matrix), typeof(_func_cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac, jvp, vjp, jac_prototype, - sparsity, Wfact, Wfact_t, paramjac, syms, indepsym, - paramsyms, observed, colorvec, sys) + sparsity, Wfact, Wfact_t, paramjac, observed, colorvec, sys) end end @@ -2785,7 +2726,7 @@ SplitFunction(f::SplitFunction; kwargs...) = f @add_kwonly function DynamicalODEFunction{iip}(f1, f2, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, - Wfact_t, paramjac, syms, indepsym, paramsyms, + Wfact_t, paramjac, observed, colorvec, sys) where {iip} f1 = f1 isa AbstractSciMLOperator ? f1 : ODEFunction(f1) f2 = ODEFunction(f2) @@ -2793,18 +2734,16 @@ SplitFunction(f::SplitFunction; kwargs...) = f if isinplace(f1) != isinplace(f2) throw(NonconformingFunctionsError(["f2"])) end - DynamicalODEFunction{isinplace(f2), FullSpecialize, typeof(f1), typeof(f2), typeof(mass_matrix), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, - paramjac, syms, indepsym, paramsyms, observed, + paramjac, observed, colorvec, sys) end @@ -2826,12 +2765,9 @@ function DynamicalODEFunction{iip, specialize}(f1, f2; nothing, paramjac = __has_paramjac(f1) ? f1.paramjac : nothing, - syms = __has_syms(f1) ? f1.syms : nothing, - indepsym = __has_indepsym(f1) ? f1.indepsym : - nothing, - paramsyms = __has_paramsyms(f1) ? - f1.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f1) ? f1.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f1) ? f1.colorvec : @@ -2840,30 +2776,29 @@ function DynamicalODEFunction{iip, specialize}(f1, f2; iip, specialize, } + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize DynamicalODEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, - Any, Any, Any, Any, Any, Any, Any}(f1, f2, mass_matrix, + Any, Any, Any, Any}(f1, f2, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, paramjac, - syms, indepsym, paramsyms, observed, colorvec, sys) else DynamicalODEFunction{iip, specialize, typeof(f1), typeof(f2), typeof(mass_matrix), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, - Wfact, Wfact_t, paramjac, syms, indepsym, - paramsyms, observed, + Wfact, Wfact_t, paramjac, observed, colorvec, sys) end end @@ -2880,27 +2815,23 @@ DynamicalODEFunction(f::DynamicalODEFunction; kwargs...) = f function DiscreteFunction{iip, specialize}(f; analytic = __has_analytic(f) ? f.analytic : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym = __has_indepsym(f) ? f.indepsym : - nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED, sys = __has_sys(f) ? f.sys : nothing) where {iip, specialize, } _f = prepare_function(f) + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize - DiscreteFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any}(_f, analytic, - syms, indepsym, - parasmsyms, + DiscreteFunction{iip, specialize, Any, Any, Any, Any}(_f, analytic, observed, sys) else DiscreteFunction{iip, specialize, typeof(_f), typeof(analytic), - typeof(syms), typeof(indepsym), typeof(paramsyms), - typeof(observed), typeof(sys)}(_f, analytic, syms, indepsym, - paramsyms, observed, sys) + typeof(observed), typeof(sys)}(_f, analytic, observed, sys) end end @@ -2918,14 +2849,11 @@ function unwrapped_f(f::DiscreteFunction, newf = unwrapped_f(f.f)) if specialize === NoSpecialize DiscreteFunction{isinplace(f), specialize, Any, Any, - Any, Any, Any, Any, Any}(newf, f.analytic, f.syms, f.indepsym, - f.paramsyms, f.observed, f.sys) + Any, Any}(newf, f.analytic, f.observed, f.sys) else DiscreteFunction{isinplace(f), specialize, typeof(newf), typeof(f.analytic), - typeof(f.syms), typeof(f.indepsym), typeof(f.paramsyms), - typeof(f.observed), typeof(f.sys)}(newf, f.analytic, f.syms, - f.indepsym, f.paramsyms, - f.observed, f.sys) + typeof(f.observed), typeof(f.sys)}(newf, f.analytic, + f.observed, f.sys) end end @@ -2933,13 +2861,9 @@ function ImplicitDiscreteFunction{iip, specialize}(f; analytic = __has_analytic(f) ? f.analytic : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym = __has_indepsym(f) ? - f.indepsym : - nothing, - paramsyms = __has_paramsyms(f) ? - f.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED, @@ -2948,19 +2872,15 @@ function ImplicitDiscreteFunction{iip, specialize}(f; specialize, } _f = prepare_function(f) + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize - ImplicitDiscreteFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any}(_f, + ImplicitDiscreteFunction{iip, specialize, Any, Any, Any, Any}(_f, analytic, - syms, - indepsym, - parasmsyms, observed, sys) else - ImplicitDiscreteFunction{iip, specialize, typeof(_f), typeof(analytic), - typeof(syms), typeof(indepsym), typeof(paramsyms), - typeof(observed), typeof(sys)}(_f, analytic, syms, indepsym, - paramsyms, observed, sys) + ImplicitDiscreteFunction{iip, specialize, typeof(_f), typeof(analytic), typeof(observed), typeof(sys)}(_f, analytic, observed, sys) end end @@ -2978,16 +2898,11 @@ function unwrapped_f(f::ImplicitDiscreteFunction, newf = unwrapped_f(f.f)) if specialize === NoSpecialize ImplicitDiscreteFunction{isinplace(f, 6), specialize, Any, Any, - Any, Any, Any, Any, Any}(newf, f.analytic, f.syms, - f.indepsym, - f.paramsyms, f.observed, f.sys) + Any, Any}(newf, f.analytic, f.observed, f.sys) else ImplicitDiscreteFunction{isinplace(f, 6), specialize, typeof(newf), typeof(f.analytic), - typeof(f.syms), typeof(f.indepsym), typeof(f.paramsyms), typeof(f.observed), typeof(f.sys)}(newf, f.analytic, - f.syms, - f.indepsym, f.paramsyms, f.observed, f.sys) end end @@ -3009,10 +2924,9 @@ function SDEFunction{iip, specialize}(f, g; Wfact_t = __has_Wfact_t(f) ? f.Wfact_t : nothing, paramjac = __has_paramjac(f) ? f.paramjac : nothing, ggprime = nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym = __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f) ? f.colorvec : nothing, @@ -3053,32 +2967,29 @@ function SDEFunction{iip, specialize}(f, g; _f = prepare_function(f) _g = prepare_function(g) + + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize SDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, - Any, Any, Any, Any, typeof(syms), typeof(indepsym), typeof(paramsyms), - Any, + Any, Any, Any, Any, Any, typeof(_colorvec), typeof(sys)}(_f, _g, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, - Wfact, Wfact_t, paramjac, ggprime, syms, - indepsym, paramsyms, observed, + Wfact, Wfact_t, paramjac, ggprime, observed, _colorvec, sys) else SDEFunction{iip, specialize, typeof(_f), typeof(_g), typeof(mass_matrix), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), typeof(Wfact), typeof(Wfact_t), - typeof(paramjac), typeof(ggprime), typeof(syms), - typeof(indepsym), typeof(paramsyms), - typeof(observed), typeof(_colorvec), typeof(sys)}(_f, _g, mass_matrix, + typeof(paramjac), typeof(ggprime), typeof(observed), typeof(_colorvec), typeof(sys)}(_f, _g, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, paramjac, ggprime, - syms, indepsym, - paramsyms, observed, _colorvec, sys) end @@ -3090,10 +3001,10 @@ function unwrapped_f(f::SDEFunction, newf = unwrapped_f(f.f), if specialize === NoSpecialize SDEFunction{isinplace(f), specialize, Any, Any, - typeoff(f.mass_matrix), Any, Any, + typeof(f.mass_matrix), Any, Any, Any, Any, Any, typeof(f.jac_prototype), typeof(f.sparsity), Any, Any, - Any, Any, typeof(f.syms), tyepeof(f.indepsym), typeof(f.paramsyms), + Any, Any, typeof(f.observed), typeof(f.colorvec), typeof(f.sys)}(newf, newg, f.mass_matrix, f.analytic, @@ -3105,9 +3016,6 @@ function unwrapped_f(f::SDEFunction, newf = unwrapped_f(f.f), f.Wfact_t, f.paramjac, f.ggprime, - f.syms, - f.indepsym, - f.paramsyms, f.observed, f.colorvec, f.sys) @@ -3116,8 +3024,7 @@ function unwrapped_f(f::SDEFunction, newf = unwrapped_f(f.f), typeof(f.mass_matrix), typeof(f.analytic), typeof(f.tgrad), typeof(f.jac), typeof(f.jvp), typeof(f.vjp), typeof(f.jac_prototype), typeof(f.sparsity), typeof(f.Wfact), typeof(f.Wfact_t), - typeof(f.paramjac), typeof(f.ggprime), typeof(f.syms), - typeof(f.indepsym), typeof(f.paramsyms), + typeof(f.paramjac), typeof(f.ggprime), typeof(f.observed), typeof(f.colorvec), typeof(f.sys)}(newf, newg, f.mass_matrix, f.analytic, @@ -3129,9 +3036,6 @@ function unwrapped_f(f::SDEFunction, newf = unwrapped_f(f.f), f.Wfact_t, f.paramjac, f.ggprime, - f.syms, - f.indepsym, - f.paramsyms, f.observed, f.colorvec, f.sys) @@ -3150,18 +3054,17 @@ SDEFunction(f::SDEFunction; kwargs...) = f @add_kwonly function SplitSDEFunction(f1, f2, g, mass_matrix, cache, analytic, tgrad, jac, jvp, vjp, jac_prototype, Wfact, Wfact_t, paramjac, observed, - syms, indepsym, paramsyms, colorvec, sys) + colorvec, sys) f1 = f1 isa AbstractSciMLOperator ? f1 : SDEFunction(f1) f2 = SDEFunction(f2) + SplitFunction{isinplace(f2), typeof(f1), typeof(f2), typeof(g), typeof(mass_matrix), typeof(cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, mass_matrix, cache, analytic, tgrad, jac, - jac_prototype, Wfact, Wfact_t, paramjac, syms, indepsym, - paramsyms, observed, colorvec, sys) + jac_prototype, Wfact, Wfact_t, paramjac, observed, colorvec, sys) end function SplitSDEFunction{iip, specialize}(f1, f2, g; @@ -3184,11 +3087,9 @@ function SplitSDEFunction{iip, specialize}(f1, f2, g; nothing, paramjac = __has_paramjac(f1) ? f1.paramjac : nothing, - syms = __has_syms(f1) ? f1.syms : nothing, - indepsym = __has_indepsym(f1) ? f1.indepsym : - nothing, - paramsyms = __has_paramsyms(f1) ? f1.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f1) ? f1.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f1) ? f1.colorvec : @@ -3197,15 +3098,16 @@ function SplitSDEFunction{iip, specialize}(f1, f2, g; iip, specialize, } + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize SplitSDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, - Any, Any, Any, Any, Any, Any}(f1, f2, g, mass_matrix, _func_cache, + Any, Any, Any}(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, - Wfact, Wfact_t, paramjac, syms, - indepsym, paramsyms, observed, + Wfact, Wfact_t, paramjac, observed, colorvec, sys) else SplitSDEFunction{iip, specialize, typeof(f1), typeof(f2), typeof(g), @@ -3213,12 +3115,11 @@ function SplitSDEFunction{iip, specialize}(f1, f2, g; typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, - Wfact, Wfact_t, paramjac, syms, indepsym, paramsyms, + Wfact, Wfact_t, paramjac, observed, colorvec, sys) end end @@ -3235,20 +3136,19 @@ SplitSDEFunction(f::SplitSDEFunction; kwargs...) = f @add_kwonly function DynamicalSDEFunction(f1, f2, g, mass_matrix, cache, analytic, tgrad, jac, jvp, vjp, jac_prototype, Wfact, Wfact_t, paramjac, - syms, indepsym, paramsyms, observed, colorvec, + observed, colorvec, sys) f1 = f1 isa AbstractSciMLOperator ? f1 : SDEFunction(f1) f2 = SDEFunction(f2) + DynamicalSDEFunction{isinplace(f2), FullSpecialize, typeof(f1), typeof(f2), typeof(g), typeof(mass_matrix), typeof(cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, g, mass_matrix, cache, analytic, tgrad, - jac, jac_prototype, Wfact, Wfact_t, paramjac, syms, - indepsym, paramsyms, observed, colorvec, sys) + jac, jac_prototype, Wfact, Wfact_t, paramjac, observed, colorvec, sys) end function DynamicalSDEFunction{iip, specialize}(f1, f2, g; @@ -3270,11 +3170,9 @@ function DynamicalSDEFunction{iip, specialize}(f1, f2, g; nothing, paramjac = __has_paramjac(f1) ? f1.paramjac : nothing, - syms = __has_syms(f1) ? f1.syms : nothing, - indepsym = __has_indepsym(f1) ? f1.indepsym : - nothing, - paramsyms = __has_paramsyms(f1) ? - f1.paramsyms : nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f1) ? f1.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f1) ? f1.colorvec : @@ -3283,15 +3181,16 @@ function DynamicalSDEFunction{iip, specialize}(f1, f2, g; iip, specialize, } + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize DynamicalSDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, - Any, Any, Any, Any, Any, Any, Any, Any, Any, + Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any}(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, - Wfact, Wfact_t, paramjac, syms, - indepsym, paramsyms, observed, + Wfact, Wfact_t, paramjac, observed, colorvec, sys) else DynamicalSDEFunction{iip, specialize, typeof(f1), typeof(f2), typeof(g), @@ -3299,13 +3198,11 @@ function DynamicalSDEFunction{iip, specialize}(f1, f2, g; typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, - Wfact, Wfact_t, paramjac, syms, indepsym, - paramsyms, observed, colorvec, sys) + Wfact, Wfact_t, paramjac, observed, colorvec, sys) end end @@ -3334,10 +3231,9 @@ function RODEFunction{iip, specialize}(f; Wfact = __has_Wfact(f) ? f.Wfact : nothing, Wfact_t = __has_Wfact_t(f) ? f.Wfact_t : nothing, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym = __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f) ? f.colorvec : nothing, @@ -3381,18 +3277,19 @@ function RODEFunction{iip, specialize}(f; =# _f = prepare_function(f) + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize RODEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, - typeof(syms), typeof(indepsym), typeof(paramsyms), Any, + Any, typeof(_colorvec), Any}(_f, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, - paramjac, syms, indepsym, - paramsyms, observed, + paramjac, observed, _colorvec, sys, analytic_full) else @@ -3400,11 +3297,11 @@ function RODEFunction{iip, specialize}(f; typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), typeof(Wfact), typeof(Wfact_t), - typeof(paramjac), typeof(syms), typeof(indepsym), typeof(paramsyms), + typeof(paramjac), typeof(observed), typeof(_colorvec), typeof(sys)}(_f, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, - Wfact, Wfact_t, paramjac, syms, indepsym, paramsyms, + Wfact, Wfact_t, paramjac, observed, _colorvec, sys, analytic_full) end end @@ -3432,10 +3329,9 @@ function DAEFunction{iip, specialize}(f; Wfact = __has_Wfact(f) ? f.Wfact : nothing, Wfact_t = __has_Wfact_t(f) ? f.Wfact_t : nothing, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym = __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f) ? f.colorvec : nothing, @@ -3469,26 +3365,26 @@ function DAEFunction{iip, specialize}(f; end _f = prepare_function(f) + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize DAEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, - Any, Any, Any, typeof(syms), - typeof(indepsym), typeof(paramsyms), + Any, Any, Any, Any, typeof(_colorvec), Any}(_f, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, - Wfact, Wfact_t, paramjac, syms, - indepsym, paramsyms, observed, + Wfact, Wfact_t, paramjac, observed, _colorvec, sys) else DAEFunction{iip, specialize, typeof(_f), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), typeof(Wfact), typeof(Wfact_t), - typeof(paramjac), typeof(syms), typeof(indepsym), typeof(paramsyms), + typeof(paramjac), typeof(observed), typeof(_colorvec), typeof(sys)}(_f, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, - paramjac, syms, indepsym, paramsyms, observed, + paramjac, observed, _colorvec, sys) end end @@ -3516,10 +3412,9 @@ function DDEFunction{iip, specialize}(f; Wfact = __has_Wfact(f) ? f.Wfact : nothing, Wfact_t = __has_Wfact_t(f) ? f.Wfact_t : nothing, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym = __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f) ? f.colorvec : nothing, @@ -3558,11 +3453,13 @@ function DDEFunction{iip, specialize}(f; end _f = prepare_function(f) + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize DDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, - Any, typeof(syms), typeof(indepsym), typeof(paramsyms), + Any, Any, typeof(_colorvec), Any}(_f, mass_matrix, analytic, tgrad, @@ -3570,8 +3467,7 @@ function DDEFunction{iip, specialize}(f; jac_prototype, sparsity, Wfact, Wfact_t, - paramjac, syms, - indepsym, paramsyms, + paramjac, observed, _colorvec, sys) else @@ -3579,13 +3475,13 @@ function DDEFunction{iip, specialize}(f; typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), typeof(Wfact), typeof(Wfact_t), - typeof(paramjac), typeof(syms), typeof(indepsym), typeof(paramsyms), + typeof(paramjac), typeof(observed), typeof(_colorvec), typeof(sys)}(_f, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, paramjac, - syms, indepsym, paramsyms, observed, + observed, _colorvec, sys) end end @@ -3601,21 +3497,21 @@ DDEFunction(f::DDEFunction; kwargs...) = f jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, paramjac, - syms, indepsym, paramsyms, observed, + observed, colorvec) where {iip} f1 = f1 isa AbstractSciMLOperator ? f1 : DDEFunction(f1) f2 = DDEFunction(f2) + DynamicalDDEFunction{isinplace(f2), FullSpecialize, typeof(f1), typeof(f2), typeof(mass_matrix), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, - paramjac, syms, indepsym, paramsyms, observed, + paramjac, observed, colorvec, sys) end function DynamicalDDEFunction{iip, specialize}(f1, f2; @@ -3636,11 +3532,9 @@ function DynamicalDDEFunction{iip, specialize}(f1, f2; nothing, paramjac = __has_paramjac(f1) ? f1.paramjac : nothing, - syms = __has_syms(f1) ? f1.syms : nothing, - indepsym = __has_indepsym(f1) ? f1.indepsym : - nothing, - paramsyms = __has_paramsyms(f1) ? - f1.paramsyms : nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f1) ? f1.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f1) ? f1.colorvec : @@ -3649,10 +3543,11 @@ function DynamicalDDEFunction{iip, specialize}(f1, f2; iip, specialize, } + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize DynamicalDDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, - Any, Any, - Any, Any, Any, Any, Any, Any, Any, Any}(f1, f2, mass_matrix, + Any, Any, Any, Any, Any, Any, Any}(f1, f2, mass_matrix, analytic, tgrad, jac, jvp, vjp, @@ -3660,8 +3555,6 @@ function DynamicalDDEFunction{iip, specialize}(f1, f2; sparsity, Wfact, Wfact_t, paramjac, - syms, indepsym, - paramsyms, observed, colorvec, sys) else @@ -3669,13 +3562,11 @@ function DynamicalDDEFunction{iip, specialize}(f1, f2; typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, - Wfact, Wfact_t, paramjac, syms, indepsym, - paramsyms, observed, + Wfact, Wfact_t, paramjac, observed, colorvec, sys) end end @@ -3706,10 +3597,9 @@ function SDDEFunction{iip, specialize}(f, g; Wfact_t = __has_Wfact_t(f) ? f.Wfact_t : nothing, paramjac = __has_paramjac(f) ? f.paramjac : nothing, ggprime = nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym = __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : - nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f) ? f.colorvec : nothing, @@ -3733,11 +3623,13 @@ function SDDEFunction{iip, specialize}(f, g; _f = prepare_function(f) _g = prepare_function(g) + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + if specialize === NoSpecialize SDDEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, - Any, Any, typeof(syms), typeof(indepsym), typeof(paramsyms), + Any, Any, Any, typeof(_colorvec), Any}(_f, _g, mass_matrix, analytic, tgrad, jac, @@ -3747,7 +3639,6 @@ function SDDEFunction{iip, specialize}(f, g; sparsity, Wfact, Wfact_t, paramjac, ggprime, - syms, indepsym, paramsyms, observed, _colorvec, sys) @@ -3756,15 +3647,13 @@ function SDDEFunction{iip, specialize}(f, g; typeof(mass_matrix), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), typeof(Wfact), typeof(Wfact_t), - typeof(paramjac), typeof(ggprime), typeof(syms), typeof(indepsym), - typeof(paramsyms), typeof(observed), + typeof(paramjac), typeof(ggprime), typeof(observed), typeof(_colorvec), typeof(sys)}(_f, _g, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, - paramjac, ggprime, syms, - indepsym, paramsyms, + paramjac, ggprime, observed, _colorvec, sys) end end @@ -3797,9 +3686,8 @@ function NonlinearFunction{iip, specialize}(f; nothing, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : - nothing, + syms = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED_NO_TIME, colorvec = __has_colorvec(f) ? f.colorvec : @@ -3839,34 +3727,34 @@ function NonlinearFunction{iip, specialize}(f; end _f = prepare_function(f) + sys = something(sys, SymbolCache(syms, paramsyms)) + if specialize === NoSpecialize NonlinearFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, - Any, Any, typeof(syms), typeof(paramsyms), Any, + Any, Any, Any, typeof(_colorvec), Any, Any}(_f, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, paramjac, - syms, paramsyms, observed, + observed, _colorvec, sys, resid_prototype) else NonlinearFunction{iip, specialize, typeof(_f), typeof(mass_matrix), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(sparsity), typeof(Wfact), - typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(paramsyms), + typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(_colorvec), typeof(sys), typeof(resid_prototype)}(_f, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, - Wfact_t, paramjac, syms, - paramsyms, + Wfact_t, paramjac, observed, _colorvec, sys, resid_prototype) end end @@ -3884,10 +3772,8 @@ function IntervalNonlinearFunction{iip, specialize}(f; analytic = __has_analytic(f) ? f.analytic : nothing, - syms = __has_syms(f) ? f.syms : nothing, - paramsyms = __has_paramsyms(f) ? - f.paramsyms : - nothing, + syms = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED_NO_TIME, @@ -3896,25 +3782,17 @@ function IntervalNonlinearFunction{iip, specialize}(f; specialize, } _f = prepare_function(f) + sys = something(sys, SymbolCache(syms, paramsyms)) + if specialize === NoSpecialize IntervalNonlinearFunction{iip, specialize, - Any, Any, typeof(syms), typeof(paramsyms), Any, - typeof(_colorvec), Any}(_f, mass_matrix, - analytic, tgrad, jac, - jvp, vjp, - jac_prototype, - sparsity, Wfact, - Wfact_t, paramjac, - syms, paramsyms, observed, - _colorvec, sys) + Any, Any, Any, Any}(_f, analytic, observed, sys) else IntervalNonlinearFunction{iip, specialize, - typeof(_f), typeof(analytic), typeof(syms), - typeof(paramsyms), + typeof(_f), typeof(analytic), typeof(observed), - typeof(sys)}(_f, analytic, syms, - paramsyms, + typeof(sys)}(_f, analytic, observed, sys) end end @@ -3940,8 +3818,8 @@ function OptimizationFunction{iip}(f, adtype::AbstractADType = NoAD(); cons_jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing, cons_hess_prototype = nothing, - syms = __has_syms(f) ? f.syms : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED_NO_TIME, expr = nothing, cons_expr = nothing, @@ -3954,12 +3832,13 @@ function OptimizationFunction{iip}(f, adtype::AbstractADType = NoAD(); nothing, lag_hess_colorvec = nothing) where {iip} isinplace(f, 2; has_two_dispatches = false, isoptimization = true) + sys = something(sys, SymbolCache(syms, paramsyms)) OptimizationFunction{iip, typeof(adtype), typeof(f), typeof(grad), typeof(hess), typeof(hv), typeof(cons), typeof(cons_j), typeof(cons_h), typeof(hess_prototype), typeof(cons_jac_prototype), typeof(cons_hess_prototype), - typeof(syms), typeof(paramsyms), typeof(observed), + typeof(observed), typeof(expr), typeof(cons_expr), typeof(sys), typeof(lag_h), typeof(lag_hess_prototype), typeof(hess_colorvec), typeof(cons_jac_colorvec), typeof(cons_hess_colorvec), @@ -3967,8 +3846,7 @@ function OptimizationFunction{iip}(f, adtype::AbstractADType = NoAD(); }(f, adtype, grad, hess, hv, cons, cons_j, cons_h, hess_prototype, cons_jac_prototype, - cons_hess_prototype, syms, - paramsyms, observed, expr, cons_expr, sys, + cons_hess_prototype, observed, expr, cons_expr, sys, lag_h, lag_hess_prototype, hess_colorvec, cons_jac_colorvec, cons_hess_colorvec, lag_hess_colorvec) end @@ -3988,9 +3866,9 @@ function BVPFunction{iip, specialize, twopoint}(f, bc; Wfact = __has_Wfact(f) ? f.Wfact : nothing, Wfact_t = __has_Wfact_t(f) ? f.Wfact_t : nothing, paramjac = __has_paramjac(f) ? f.paramjac : nothing, - syms = __has_syms(f) ? f.syms : nothing, - indepsym = __has_indepsym(f) ? f.indepsym : nothing, - paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing, + syms = nothing, + indepsym = nothing, + paramsyms = nothing, observed = __has_observed(f) ? f.observed : DEFAULT_OBSERVED, colorvec = __has_colorvec(f) ? f.colorvec : nothing, bccolorvec = __has_colorvec(bc) ? bc.colorvec : nothing, @@ -4098,27 +3976,29 @@ function BVPFunction{iip, specialize, twopoint}(f, bc; _f = prepare_function(f) + sys = something(sys, SymbolCache(syms, paramsyms, indepsym)) + + if specialize === NoSpecialize BVPFunction{iip, specialize, twopoint, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, - Any, typeof(syms), typeof(indepsym), typeof(paramsyms), + Any, Any, typeof(_colorvec), typeof(_bccolorvec), Any}(_f, bc, mass_matrix, analytic, tgrad, jac, bcjac, jvp, vjp, jac_prototype, bcjac_prototype, bcresid_prototype, - sparsity, Wfact, Wfact_t, paramjac, syms, indepsym, paramsyms, observed, + sparsity, Wfact, Wfact_t, paramjac, observed, _colorvec, _bccolorvec, sys) else BVPFunction{iip, specialize, twopoint, typeof(_f), typeof(bc), typeof(mass_matrix), typeof(analytic), typeof(tgrad), typeof(jac), typeof(bcjac), typeof(jvp), typeof(vjp), typeof(jac_prototype), typeof(bcjac_prototype), typeof(bcresid_prototype), typeof(sparsity), - typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(syms), - typeof(indepsym), typeof(paramsyms), typeof(observed), + typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(_colorvec), typeof(_bccolorvec), typeof(sys)}(_f, bc, mass_matrix, analytic, tgrad, jac, bcjac, jvp, vjp, jac_prototype, bcjac_prototype, bcresid_prototype, sparsity, Wfact, Wfact_t, paramjac, - syms, indepsym, paramsyms, observed, + observed, _colorvec, _bccolorvec, sys) end end @@ -4228,9 +4108,27 @@ has_Wfact(f::AbstractSciMLFunction) = __has_Wfact(f) && f.Wfact !== nothing has_Wfact_t(f::AbstractSciMLFunction) = __has_Wfact_t(f) && f.Wfact_t !== nothing has_paramjac(f::AbstractSciMLFunction) = __has_paramjac(f) && f.paramjac !== nothing has_sys(f::AbstractSciMLFunction) = __has_sys(f) && f.sys !== nothing -has_syms(f::AbstractSciMLFunction) = __has_syms(f) && f.syms !== nothing -has_indepsym(f::AbstractSciMLFunction) = __has_indepsym(f) && f.indepsym !== nothing -has_paramsyms(f::AbstractSciMLFunction) = __has_paramsyms(f) && f.paramsyms !== nothing +function has_syms(f::AbstractSciMLFunction) + if __has_syms(f) + f.syms !== nothing + else + !isempty(variable_symbols(f)) + end +end +function has_indepsym(f::AbstractSciMLFunction) + if __has_indepsym(f) + f.indepsym !== nothing + else + !isempty(independent_variable_symbols(f)) + end +end +function has_paramsyms(f::AbstractSciMLFunction) + if __has_paramsyms(f) + f.paramsyms !== nothing + else + !isempty(parameter_symbols(f)) + end +end function has_observed(f::AbstractSciMLFunction) __has_observed(f) && f.observed !== DEFAULT_OBSERVED && f.observed !== nothing end @@ -4318,3 +4216,22 @@ for S in [:ODEFunction end end end + +SymbolicIndexingInterface.symbolic_container(fn::AbstractSciMLFunction) = fn.sys + +function SymbolicIndexingInterface.observed(fn::AbstractSciMLFunction, sym) + if has_observed(fn) + if is_time_dependent(fn) + return (u, p, t) -> fn.observed(sym, u, p, t) + else + return (u, p) -> fn.observed(sym, u, p) + end + end + error("SciMLFunction does not have observed") +end + +function SymbolicIndexingInterface.observed(fn::AbstractSciMLFunction, sym::Symbol) + return SymbolicIndexingInterface.observed(fn, getproperty(fn.sys, sym)) +end + +SymbolicIndexingInterface.constant_structure(::AbstractSciMLFunction) = true \ No newline at end of file diff --git a/src/solutions/ode_solutions.jl b/src/solutions/ode_solutions.jl index b3ba74fe6..33f3d1d8f 100644 --- a/src/solutions/ode_solutions.jl +++ b/src/solutions/ode_solutions.jl @@ -165,83 +165,44 @@ end function (sol::AbstractODESolution)(t::AbstractVector{<:Number}, ::Type{deriv}, idxs::Integer, continuity) where {deriv} A = sol.interp(t, idxs, deriv, sol.prob.p, continuity) - observed = has_observed(sol.prob.f) ? sol.prob.f.observed : DEFAULT_OBSERVED p = hasproperty(sol.prob, :p) ? sol.prob.p : nothing - if has_sys(sol.prob.f) - DiffEqArray{typeof(A).parameters[1:4]..., typeof(sol.prob.f.sys), typeof(observed), - typeof(p)}(A.u, - A.t, - sol.prob.f.sys, - observed, - p) - else - syms = hasproperty(sol.prob.f, :syms) && sol.prob.f.syms !== nothing ? - [sol.prob.f.syms[idxs]] : nothing - DiffEqArray(A.u, A.t, syms, getindepsym(sol), observed, p) - end + return DiffEqArray(A.u, A.t, p, sol) end function (sol::AbstractODESolution)(t::AbstractVector{<:Number}, ::Type{deriv}, idxs::AbstractVector{<:Integer}, continuity) where {deriv} A = sol.interp(t, idxs, deriv, sol.prob.p, continuity) - observed = has_observed(sol.prob.f) ? sol.prob.f.observed : DEFAULT_OBSERVED p = hasproperty(sol.prob, :p) ? sol.prob.p : nothing - if has_sys(sol.prob.f) - DiffEqArray{typeof(A).parameters[1:4]..., typeof(sol.prob.f.sys), typeof(observed), - typeof(p)}(A.u, - A.t, - sol.prob.f.sys, - observed, - p) - else - syms = hasproperty(sol.prob.f, :syms) && sol.prob.f.syms !== nothing ? - sol.prob.f.syms[idxs] : nothing - DiffEqArray(A.u, A.t, syms, getindepsym(sol), observed, p) - end + return DiffEqArray(A.u, A.t, p, sol) end function (sol::AbstractODESolution)(t::Number, ::Type{deriv}, idxs, continuity) where {deriv} - issymbollike(idxs) || error("Incorrect specification of `idxs`") + symbolic_type(idxs) == NotSymbolic() && error("Incorrect specification of `idxs`") augment(sol.interp([t], nothing, deriv, sol.prob.p, continuity), sol)[idxs][1] end function (sol::AbstractODESolution)(t::Number, ::Type{deriv}, idxs::AbstractVector, continuity) where {deriv} - all(issymbollike.(idxs)) || error("Incorrect specification of `idxs`") + all(!isequal(NotSymbolic()), symbolic_type.(idxs)) || error("Incorrect specification of `idxs`") interp_sol = augment(sol.interp([t], nothing, deriv, sol.prob.p, continuity), sol) [first(interp_sol[idx]) for idx in idxs] end function (sol::AbstractODESolution)(t::AbstractVector{<:Number}, ::Type{deriv}, idxs, continuity) where {deriv} - issymbollike(idxs) || error("Incorrect specification of `idxs`") + symbolic_type(idxs) == NotSymbolic() && error("Incorrect specification of `idxs`") interp_sol = augment(sol.interp(t, nothing, deriv, sol.prob.p, continuity), sol) - observed = has_observed(sol.prob.f) ? sol.prob.f.observed : DEFAULT_OBSERVED p = hasproperty(sol.prob, :p) ? sol.prob.p : nothing - if has_sys(sol.prob.f) - return DiffEqArray(interp_sol[idxs], t, [idxs], - independent_variables(sol.prob.f.sys), observed, p) - else - return DiffEqArray(interp_sol[idxs], t, [idxs], getindepsym(sol), observed, p) - end + return DiffEqArray(interp_sol[idxs], t, p, sol) end function (sol::AbstractODESolution)(t::AbstractVector{<:Number}, ::Type{deriv}, idxs::AbstractVector, continuity) where {deriv} - all(issymbollike.(idxs)) || error("Incorrect specification of `idxs`") + all(!isequal(NotSymbolic()), symbolic_type.(idxs)) || error("Incorrect specification of `idxs`") interp_sol = augment(sol.interp(t, nothing, deriv, sol.prob.p, continuity), sol) - observed = has_observed(sol.prob.f) ? sol.prob.f.observed : DEFAULT_OBSERVED p = hasproperty(sol.prob, :p) ? sol.prob.p : nothing - if has_sys(sol.prob.f) - return DiffEqArray([[interp_sol[idx][i] for idx in idxs] for i in 1:length(t)], t, - idxs, - independent_variables(sol.prob.f.sys), observed, p) - else - return DiffEqArray([[interp_sol[idx][i] for idx in idxs] for i in 1:length(t)], t, - idxs, - getindepsym(sol), observed, p) - end + return DiffEqArray([[interp_sol[idx][i] for idx in idxs] for i in 1:length(t)], t, p, sol) end function build_solution(prob::Union{AbstractODEProblem, AbstractDDEProblem}, diff --git a/src/solutions/optimization_solutions.jl b/src/solutions/optimization_solutions.jl index 9f04a5bdd..41b1e212b 100644 --- a/src/solutions/optimization_solutions.jl +++ b/src/solutions/optimization_solutions.jl @@ -87,12 +87,11 @@ end get_p(sol::OptimizationSolution) = sol.cache.p get_observed(sol::OptimizationSolution) = sol.cache.f.observed -get_syms(sol::OptimizationSolution) = sol.cache.f.syms -get_paramsyms(sol::OptimizationSolution) = sol.cache.f.paramsyms - +get_syms(sol::OptimizationSolution) = variable_symbols(sol.cache.f) +get_paramsyms(sol::OptimizationSolution) = parameter_symbols(sol.cache.f) has_observed(sol::OptimizationSolution) = get_observed(sol) !== nothing -has_syms(sol::OptimizationSolution) = get_syms(sol) !== nothing -has_paramsyms(sol::OptimizationSolution) = get_paramsyms(sol) !== nothing +has_syms(sol::OptimizationSolution) = !isempty(variable_symbols(sol.cache.f)) +has_paramsyms(sol::OptimizationSolution) = !isempty(parameter_symbols(sol.cache.f)) function Base.show(io::IO, A::AbstractOptimizationSolution) println(io, string("retcode: ", A.retcode)) @@ -103,6 +102,9 @@ function Base.show(io::IO, A::AbstractOptimizationSolution) return end +SymbolicIndexingInterface.parameter_values(x::AbstractOptimizationSolution) = x.cache.p +SymbolicIndexingInterface.symbolic_container(x::AbstractOptimizationSolution) = x.cache.f + Base.@propagate_inbounds function Base.getproperty(x::AbstractOptimizationSolution, s::Symbol) if s === :minimizer diff --git a/src/solutions/rode_solutions.jl b/src/solutions/rode_solutions.jl index 350c3c823..b6ec13358 100644 --- a/src/solutions/rode_solutions.jl +++ b/src/solutions/rode_solutions.jl @@ -152,7 +152,7 @@ function calculate_solution_errors!(sol::AbstractRODESolution; fill_uanalytic = else for i in 1:length(sol) push!(sol.u_analytic, - f.analytic(sol.prob.u0, sol.prob.p, sol.t[i], sol.W[i])) + f.analytic(sol.prob.u0, sol.prob.p, sol.t[i], sol.W[:, i])) end end end diff --git a/src/solutions/solution_interface.jl b/src/solutions/solution_interface.jl index 04dc0e152..2edb0ddf6 100644 --- a/src/solutions/solution_interface.jl +++ b/src/solutions/solution_interface.jl @@ -23,126 +23,66 @@ end # For augmenting system information to enable symbol based indexing of interpolated solutions function augment(A::DiffEqArray{T, N, Q, B}, sol::AbstractODESolution) where {T, N, Q, B} - observed = has_observed(sol.prob.f) ? sol.prob.f.observed : DEFAULT_OBSERVED p = hasproperty(sol.prob, :p) ? sol.prob.p : nothing - if has_sys(sol.prob.f) - DiffEqArray{T, N, Q, B, typeof(sol.prob.f.sys), typeof(observed), typeof(p)}(A.u, - A.t, - sol.prob.f.sys, - observed, - p) - else - syms = hasproperty(sol.prob.f, :syms) ? sol.prob.f.syms : nothing - DiffEqArray(A.u, A.t, syms, getindepsym(sol), observed, p) - end + return DiffEqArray(A.u, A.t, p, sol) end -# Symbol Handling +# SymbolicIndexingInterface.jl +const AbstractSolution = Union{AbstractTimeseriesSolution,AbstractNoTimeSolution} +SymbolicIndexingInterface.symbolic_container(A::AbstractSolution) = A.prob.f +SymbolicIndexingInterface.parameter_values(A::AbstractSolution) = A.prob.p -# For handling ambiguities -for T in [Int, Colon] - @eval Base.@propagate_inbounds function Base.getindex(A::AbstractTimeseriesSolution, - I::$T) - A.u[I] - end -end -Base.@propagate_inbounds function Base.getindex(A::AbstractTimeseriesSolution, - I::Union{Int, AbstractArray{Int}, - CartesianIndex, Colon, BitArray, - AbstractArray{Bool}}...) - RecursiveArrayTools.VectorOfArray(A.u)[I...] -end -Base.@propagate_inbounds function Base.getindex(A::AbstractTimeseriesSolution, i::Int, - ::Colon) - [A.u[j][i] for j in 1:length(A)] -end -Base.@propagate_inbounds function Base.getindex(A::AbstractTimeseriesSolution, ::Colon, - i::Int) - A.u[i] -end -Base.@propagate_inbounds function Base.getindex(A::AbstractTimeseriesSolution, i::Int, - II::AbstractArray{Int}) - [A.u[j][i] for j in II] +SymbolicIndexingInterface.is_independent_variable(::AbstractNoTimeSolution, sym) = false + +SymbolicIndexingInterface.independent_variable_symbols(::AbstractNoTimeSolution) = [] + +function SymbolicIndexingInterface.is_observed(A::AbstractSolution, sym) + return !is_variable(A, sym) && !is_parameter(A, sym) && !is_independent_variable(A, sym) && symbolic_type(sym) == ScalarSymbolic() end -Base.@propagate_inbounds function Base.getindex(A::AbstractTimeseriesSolution, - ii::CartesianIndex) - ti = Tuple(ii) - i = last(ti) - jj = CartesianIndex(Base.front(ti)) - return A.u[i][jj] + +function SymbolicIndexingInterface.observed(A::AbstractTimeseriesSolution, sym) + (u, p, t) -> getobserved(A)(sym, u, p, t) end -Base.@propagate_inbounds function Base.getindex(A::AbstractTimeseriesSolution, sym) - if issymbollike(sym) - if sym isa AbstractArray - return A[collect(sym)] - end - i = sym_to_index(sym, A) - elseif all(issymbollike, sym) - if has_sys(A.prob.f) && all(Base.Fix1(is_param_sym, A.prob.f.sys), sym) || - !has_sys(A.prob.f) && has_paramsyms(A.prob.f) && - all(in(getparamsyms(A)), Symbol.(sym)) - return getindex.((A,), sym) - else - return [getindex.((A,), sym, i) for i in eachindex(A)] - end - else - i = sym - end +function SymbolicIndexingInterface.observed(A::AbstractNoTimeSolution, sym) + (u, p) -> getobserved(A)(sym, u, p) +end - if i === nothing - if issymbollike(sym) - if has_sys(A.prob.f) && is_indep_sym(A.prob.f.sys, sym) || - Symbol(sym) == getindepsym(A) - return A.t - elseif has_sys(A.prob.f) && is_param_sym(A.prob.f.sys, sym) - return A.prob.p[param_sym_to_index(A.prob.f.sys, sym)] - elseif has_paramsyms(A.prob.f) && Symbol(sym) in getparamsyms(A) - return A.prob.p[findfirst(x -> isequal(x, Symbol(sym)), getparamsyms(A))] - else - if (sym isa Symbol) && has_sys(A.prob.f) - if hasproperty(A.prob.f.sys, sym) - return observed(A, getproperty(A.prob.f.sys, sym), :) - else - error("Tried to index solution with a Symbol that was not found in the system using `getproperty`.") - end - else - return observed(A, sym, :) - end - end - else - observed(A, sym, :) - end - elseif i isa Base.Integer || i isa AbstractRange || i isa AbstractVector{<:Base.Integer} - A[i, :] - else - error("Invalid indexing of solution") +for soltype in [AbstractTimeseriesSolution, AbstractNoTimeSolution] + @eval function SymbolicIndexingInterface.observed(A::$(soltype), sym::Symbol) + has_sys(A.prob.f) || error("Cannot use observed without system") + return SymbolicIndexingInterface.observed(A, getproperty(A.prob.f.sys, sym)) end end -Base.@propagate_inbounds function Base.getindex(A::AbstractTimeseriesSolution, sym, args...) - if issymbollike(sym) - if sym isa AbstractArray - return A[collect(sym), args...] - end - i = sym_to_index(sym, A) - elseif all(issymbollike, sym) - return reduce(vcat, map(s -> A[s, args...]', sym)) - else - i = sym - end +SymbolicIndexingInterface.is_time_dependent(::AbstractTimeseriesSolution) = true - if i === nothing - if issymbollike(sym) && has_sys(A.prob.f) && is_indep_sym(A.prob.f.sys, sym) || - Symbol(sym) == getindepsym(A) - A.t[args...] +SymbolicIndexingInterface.is_time_dependent(::AbstractNoTimeSolution) = false + +# TODO make this nontrivial once dynamic state selection works +SymbolicIndexingInterface.constant_structure(::AbstractSolution) = true + +Base.@propagate_inbounds function Base.getindex(A::AbstractTimeseriesSolution, ::Colon) + return A.u[:] +end + +Base.@propagate_inbounds function Base.getindex(A::AbstractNoTimeSolution, sym) + if symbolic_type(sym) == ScalarSymbolic() + if is_variable(A, sym) + return A[variable_index(A, sym)] + elseif is_parameter(A, sym) + Base.depwarn("Indexing with parameters is deprecated. Use `getp(sys, $sym)(sol)` for parameter indexing.", :parameter_getindex) + return getp(A, sym)(A) + elseif is_observed(A, sym) + return SymbolicIndexingInterface.observed(A, sym)(A.u, A.prob.p) else - observed(A, sym, args...) + error("Tried to index solution with a Symbol that was not found in the system.") end - elseif i isa Base.Integer || i isa AbstractRange || i isa AbstractVector{<:Base.Integer} - A[i, args...] + elseif symbolic_type(sym) == ArraySymbolic() + return A[collect(sym)] else - error("Invalid indexing of solution") + sym isa AbstractArray || error("Invalid indexing of solution") + return getindex.((A,), sym) end end @@ -158,32 +98,6 @@ function observed(A::AbstractTimeseriesSolution, sym, i::Colon) getobserved(A).((sym,), A.u, (A.prob.p,), A.t) end -Base.@propagate_inbounds function Base.getindex(A::AbstractNoTimeSolution, sym) - if issymbollike(sym) - if sym isa AbstractArray - return A[collect(sym)] - end - i = sym_to_index(sym, A) - elseif all(issymbollike, sym) - return reduce(vcat, map(s -> A[s]', sym)) - else - i = sym - end - - if i == nothing - paramsyms = getparamsyms(A) - if issymbollike(sym) && paramsyms !== nothing && Symbol(sym) in paramsyms - get_p(A)[findfirst(x -> isequal(x, Symbol(sym)), paramsyms)] - else - observed(A, sym) - end - elseif i isa Base.Integer || i isa AbstractRange || i isa AbstractVector{<:Base.Integer} - A[i] - else - error("Invalid indexing of solution") - end -end - function observed(A::AbstractNoTimeSolution, sym) getobserved(A)(sym, A.u, A.prob.p) end @@ -275,40 +189,40 @@ DEFAULT_PLOT_FUNC(x, y, z) = (x, y, z) # For v0.5.2 bug seriestype --> :path # Special case labels when idxs = (:x,:y,:z) or (:x) or [:x,:y] ... - if idxs isa Tuple && (issymbollike(idxs[1]) && issymbollike(idxs[2])) - val = issymbollike(int_vars[1][2]) ? String(Symbol(int_vars[1][2])) : + if idxs isa Tuple && (symbolic_type(idxs[1]) != NotSymbolic() && symbolic_type(idxs[2]) != NotSymbolic()) + val = symbolic_type(int_vars[1][2]) != NotSymbolic() ? String(Symbol(int_vars[1][2])) : strs[int_vars[1][2]] xguide --> val - val = issymbollike(int_vars[1][3]) ? String(Symbol(int_vars[1][3])) : + val = symbolic_type(int_vars[1][3]) != NotSymbolic() ? String(Symbol(int_vars[1][3])) : strs[int_vars[1][3]] yguide --> val if length(idxs) > 2 - val = issymbollike(int_vars[1][4]) ? String(Symbol(int_vars[1][4])) : + val = symbolic_type(int_vars[1][4]) != NotSymbolic() ? String(Symbol(int_vars[1][4])) : strs[int_vars[1][4]] zguide --> val end end - if (!any(issymbollike, getindex.(int_vars, 1)) && + if (!any(!isequal(NotSymbolic()), symbolic_type.(getindex.(int_vars, 1))) && getindex.(int_vars, 1) == zeros(length(int_vars))) || - (!any(issymbollike, getindex.(int_vars, 2)) && + (!any(!isequal(NotSymbolic()), symbolic_type.(getindex.(int_vars, 2))) && getindex.(int_vars, 2) == zeros(length(int_vars))) || all(t -> Symbol(t) == getindepsym_defaultt(sol), getindex.(int_vars, 1)) || all(t -> Symbol(t) == getindepsym_defaultt(sol), getindex.(int_vars, 2)) xguide --> "$(getindepsym_defaultt(sol))" end - if length(int_vars[1]) >= 3 && ((!any(issymbollike, getindex.(int_vars, 3)) && + if length(int_vars[1]) >= 3 && ((!any(!isequal(NotSymbolic()), symbolic_type.(getindex.(int_vars, 3))) && getindex.(int_vars, 3) == zeros(length(int_vars))) || all(t -> Symbol(t) == getindepsym_defaultt(sol), getindex.(int_vars, 3))) yguide --> "$(getindepsym_defaultt(sol))" end - if length(int_vars[1]) >= 4 && ((!any(issymbollike, getindex.(int_vars, 4)) && + if length(int_vars[1]) >= 4 && ((!any(!isequal(NotSymbolic()), symbolic_type.(getindex.(int_vars, 4))) && getindex.(int_vars, 4) == zeros(length(int_vars))) || all(t -> Symbol(t) == getindepsym_defaultt(sol), getindex.(int_vars, 4))) zguide --> "$(getindepsym_defaultt(sol))" end - if (!any(issymbollike, getindex.(int_vars, 2)) && + if (!any(!isequal(NotSymbolic()), symbolic_type.(getindex.(int_vars, 2))) && getindex.(int_vars, 2) == zeros(length(int_vars))) || all(t -> Symbol(t) == getindepsym_defaultt(sol), getindex.(int_vars, 2)) if tspan === nothing @@ -449,7 +363,7 @@ function interpret_vars(vars, sol, syms) if var isa Union{Tuple, AbstractArray} #eltype(var) <: Symbol # Some kind of iterable tmp = [] for x in var - if issymbollike(x) + if symbolic_type(x) != NotSymbolic() found = sym_to_index(x, syms) push!(tmp, found == nothing && getindepsym_defaultt(sol) == x ? 0 : @@ -463,15 +377,22 @@ function interpret_vars(vars, sol, syms) else var_int = tmp end - elseif issymbollike(var) + elseif symbolic_type(var) != NotSymbolic() found = sym_to_index(var, syms) if (var isa Symbol) && has_sys(sol.prob.f) - if hasproperty(sol.prob.f.sys, var) - var_int = found == nothing && getindepsym_defaultt(sol) == var ? 0 : - something(found, getproperty(sol.prob.f.sys, var)) + var_int = if found === nothing && getindepsym_defaultt(sol) == var + 0 + elseif found !== nothing + found + elseif is_variable(sol, var) + variable_symbols(sol)[variable_index(sol, var)] + elseif is_parameter(sol, var) + parameter_symbols(sol)[parameter_index(sol, var)] + elseif is_independent_variable(sol, var) + independent_variable_symbols(sol)[1] else error("Tried to index solution with a Symbol that was not found in the system using `getproperty`.") - end + end else var_int = found == nothing && getindepsym_defaultt(sol) == var ? 0 : something(found, var) @@ -490,8 +411,8 @@ function interpret_vars(vars, sol, syms) if vars === nothing # Default: plot all timeseries - if sol[1] isa Union{Tuple, AbstractArray} - vars = collect((DEFAULT_PLOT_FUNC, 0, i) for i in plot_indices(sol[1])) + if sol[:, 1] isa Union{Tuple, AbstractArray} + vars = collect((DEFAULT_PLOT_FUNC, 0, i) for i in plot_indices(sol[:, 1])) else vars = [(DEFAULT_PLOT_FUNC, 0, 1)] end @@ -535,7 +456,7 @@ function interpret_vars(vars, sol, syms) vars = [(DEFAULT_PLOT_FUNC, vars[end - 1], y) for y in vars[end]] else # Both axes are numbers - if vars[1] isa Int || issymbollike(vars[1]) + if vars[1] isa Int || symbolic_type(vars[1]) != NotSymbolic() vars = [tuple(DEFAULT_PLOT_FUNC, vars...)] else vars = [vars] @@ -553,9 +474,9 @@ end function add_labels!(labels, x, dims, sol, strs) lys = [] for j in 3:dims - if !issymbollike(x[j]) && x[j] == 0 + if symbolic_type(x[j]) == NotSymbolic() && x[j] == 0 push!(lys, "$(getindepsym_defaultt(sol)),") - elseif issymbollike(x[j]) + elseif symbolic_type(x[j]) != NotSymbolic() push!(lys, "$(x[j]),") else if strs !== nothing @@ -566,22 +487,22 @@ function add_labels!(labels, x, dims, sol, strs) end end lys[end] = chop(lys[end]) # Take off the last comma - if !issymbollike(x[2]) && x[2] == 0 && dims == 3 + if symbolic_type(x[2]) == NotSymbolic() && x[2] == 0 && dims == 3 # if there are no dependence in syms, then we add "(t)" if strs !== nothing && (x[3] isa Int && endswith(strs[x[3]], r"(.*)")) || - (issymbollike(x[3]) && endswith(string(x[3]), r"(.*)")) + (symbolic_type(x[3]) != NotSymbolic() && endswith(string(x[3]), r"(.*)")) tmp_lab = "$(lys...)" else tmp_lab = "$(lys...)($(getindepsym_defaultt(sol)))" end else - if strs !== nothing && !issymbollike(x[2]) && x[2] != 0 + if strs !== nothing && symbolic_type(x[2]) == NotSymbolic() && x[2] != 0 tmp = strs[x[2]] tmp_lab = "($tmp,$(lys...))" else - if !issymbollike(x[2]) && x[2] == 0 + if symbolic_type(x[2]) == NotSymbolic() && x[2] == 0 tmp_lab = "($(getindepsym_defaultt(sol)),$(lys...))" - elseif issymbollike(x[2]) + elseif symbolic_type(x[2]) != NotSymbolic() tmp_lab = "($(x[2]),$(lys...))" else tmp_lab = "(u$(x[2]),$(lys...))" @@ -627,11 +548,11 @@ function add_analytic_labels!(labels, x, dims, sol, strs) end end -function u_n(timeseries::AbstractArray, n::Int, sol, plott, plot_timeseries) +function u_n(timeseries::Union{AbstractArray,RecursiveArrayTools.AbstractVectorOfArray}, n::Int, sol, plott, plot_timeseries) # Returns the nth variable from the timeseries, t if n == 0 if n == 0 return plott - elseif n == 1 && !(sol[1] isa Union{AbstractArray, ArrayPartition}) + elseif n == 1 && !(sol[:, 1] isa Union{AbstractArray, ArrayPartition}) return timeseries else tmp = Vector{eltype(sol[1])}(undef, length(plot_timeseries)) @@ -642,8 +563,8 @@ function u_n(timeseries::AbstractArray, n::Int, sol, plott, plot_timeseries) end end -function u_n(timeseries::AbstractArray, sym, sol, plott, plot_timeseries) - @assert issymbollike(sym) +function u_n(timeseries::Union{AbstractArray,RecursiveArrayTools.AbstractVectorOfArray}, sym, sol, plott, plot_timeseries) + @assert symbolic_type(sym) != NotSymbolic() if getindepsym_defaultt(sol) == Symbol(sym) return plott else diff --git a/src/symbolic_utils.jl b/src/symbolic_utils.jl index 5a103814a..0cbbc6813 100644 --- a/src/symbolic_utils.jl +++ b/src/symbolic_utils.jl @@ -1,62 +1,55 @@ function getsyms(sol::AbstractSciMLSolution) - if has_syms(sol.prob.f) - return sol.prob.f.syms - else - return keys(sol.u[1]) + syms = variable_symbols(sol) + if isempty(syms) + syms = keys(sol.u[1]) end + return syms end function getsyms(prob::AbstractSciMLProblem) - if has_syms(prob.f) - return prob.f.syms - else - return [] - end + return variable_symbols(prob.f) end function getsyms(sol::AbstractOptimizationSolution) - if has_syms(sol) - return get_syms(sol) - else - return keys(sol.u[1]) + syms = variable_symbols(sol) + if isempty(syms) + syms = keys(sol.u[1]) end + return syms end function getindepsym(prob::AbstractSciMLProblem) - if has_indepsym(prob.f) - return prob.f.indepsym - else + syms = independent_variable_symbols(prob.f) + if isempty(syms) return nothing + else + return syms[1] end end getindepsym(sol::AbstractSciMLSolution) = getindepsym(sol.prob) function getparamsyms(prob::AbstractSciMLProblem) - if has_paramsyms(prob.f) - return prob.f.paramsyms - else + psyms = parameter_symbols(prob.f) + if isempty(psyms) return nothing end + return psyms end getparamsyms(sol) = getparamsyms(sol.prob) function getparamsyms(sol::AbstractOptimizationSolution) - if has_paramsyms(sol) - return get_paramsyms(sol) - else + psyms = parameter_symbols(sol) + if isempty(psyms) return nothing end + return psyms end # Only for compatibility! function getindepsym_defaultt(sol) - if has_indepsym(sol.prob.f) - return sol.prob.f.indepsym - else - return :t - end + return something(getindepsym(sol), :t) end function getobserved(prob::AbstractSciMLProblem) @@ -95,20 +88,13 @@ function cleansym(sym::Symbol) end function sym_to_index(sym, prob::AbstractSciMLProblem) - if has_sys(prob.f) && is_state_sym(prob.f.sys, sym) - return state_sym_to_index(prob.f.sys, sym) - else - return sym_to_index(sym, getsyms(prob)) - end + return variable_index(prob.f, sym) end - function sym_to_index(sym, sol::AbstractSciMLSolution) - if has_sys(sol.prob.f) && is_state_sym(sol.prob.f.sys, sym) - return state_sym_to_index(sol.prob.f.sys, sym) - else - return sym_to_index(sym, getsyms(sol)) + idx = variable_index(sol.prob.f, sym) + if idx === nothing + idx = findfirst(isequal(sym), keys(sol.u[1])) end + return idx end - sym_to_index(sym, syms) = findfirst(isequal(Symbol(sym)), syms) -const issymbollike = RecursiveArrayTools.issymbollike diff --git a/src/tabletraits.jl b/src/tabletraits.jl index a977cc4cd..2566f528f 100644 --- a/src/tabletraits.jl +++ b/src/tabletraits.jl @@ -25,16 +25,18 @@ end function Tables.rows(sol::AbstractTimeseriesSolution) VT = eltype(sol.u) + syms = variable_symbols(sol) if VT <: AbstractArray N = length(sol.u[1]) names = [ :timestamp, - (has_syms(sol.prob.f) ? (sol.prob.f.syms[i] for i in 1:N) : - (Symbol("value", i) for i in 1:N))..., + (isempty(syms) ? (Symbol("value", i) for i in 1:N) : + (syms[i] for i in 1:N))..., ] types = Type[eltype(sol.t), (eltype(sol.u[1]) for i in 1:N)...] else - names = [:timestamp, has_syms(sol.prob.f) ? sol.prob.f.syms[1] : :value] + + names = [:timestamp, isempty(syms) ? :value : syms[1]] types = Type[eltype(sol.t), VT] end return AbstractTimeseriesSolutionRows(names, types, sol.t, sol.u) diff --git a/test/downstream/ensemble_zero_length.jl b/test/downstream/ensemble_zero_length.jl index 917348d56..c32836f13 100644 --- a/test/downstream/ensemble_zero_length.jl +++ b/test/downstream/ensemble_zero_length.jl @@ -7,7 +7,7 @@ ensemble_prob = EnsembleProblem(prob, prob_func = prob_func) sim = solve(ensemble_prob, Tsit5(), EnsembleThreads(), trajectories = 10, save_everystep = false) @test ndims(sim) == 2 -@test length(sim) == 10 +@test length(sim.u) == 10 @test eltype(sim.u) <: ODESolution ts = 0.0:0.1:1.0 diff --git a/test/downstream/integrator_indexing.jl b/test/downstream/integrator_indexing.jl index 6ab155732..f5f180b03 100644 --- a/test/downstream/integrator_indexing.jl +++ b/test/downstream/integrator_indexing.jl @@ -1,4 +1,4 @@ -using ModelingToolkit, OrdinaryDiffEq, RecursiveArrayTools, StochasticDiffEq, Test +using ModelingToolkit, OrdinaryDiffEq, RecursiveArrayTools, StochasticDiffEq, SymbolicIndexingInterface, Test ### Tests on non-layered model (everything should work). ### @@ -18,30 +18,33 @@ tspan = (0.0, 1000000.0) oprob = ODEProblem(population_model, u0, tspan, p) integrator = init(oprob, Rodas4()) -@test integrator[a] == integrator[population_model.a] == integrator[:a] == 2.0 -@test integrator[b] == integrator[population_model.b] == integrator[:b] == 1.0 -@test integrator[c] == integrator[population_model.c] == integrator[:c] == 1.0 -@test integrator[d] == integrator[population_model.d] == integrator[:d] == 1.0 +@test_deprecated integrator[a] +@test_deprecated integrator[population_model.a] +@test_deprecated integrator[:a] +@test getp(oprob, a)(integrator) == getp(oprob, population_model.a)(integrator) == getp(oprob, :a)(integrator) == 2.0 +@test getp(oprob, b)(integrator) == getp(oprob, population_model.b)(integrator) == getp(oprob, :b)(integrator) == 1.0 +@test getp(oprob, c)(integrator) == getp(oprob, population_model.c)(integrator) == getp(oprob, :c)(integrator) == 1.0 +@test getp(oprob, d)(integrator) == getp(oprob, population_model.d)(integrator) == getp(oprob, :d)(integrator) == 1.0 @test integrator[s1] == integrator[population_model.s1] == integrator[:s1] == 2.0 @test integrator[s2] == integrator[population_model.s2] == integrator[:s2] == 1.0 step!(integrator, 100.0, true) -@test integrator[a] == integrator[population_model.a] == integrator[:a] == 2.0 -@test integrator[b] == integrator[population_model.b] == integrator[:b] == 1.0 -@test integrator[c] == integrator[population_model.c] == integrator[:c] == 1.0 -@test integrator[d] == integrator[population_model.d] == integrator[:d] == 1.0 +@test getp(population_model, a)(integrator) == getp(population_model, population_model.a)(integrator) == getp(population_model, :a)(integrator) == 2.0 +@test getp(population_model, b)(integrator) == getp(population_model, population_model.b)(integrator) == getp(population_model, :b)(integrator) == 1.0 +@test getp(population_model, c)(integrator) == getp(population_model, population_model.c)(integrator) == getp(population_model, :c)(integrator) == 1.0 +@test getp(population_model, d)(integrator) == getp(population_model, population_model.d)(integrator) == getp(population_model, :d)(integrator) == 1.0 @test integrator[s1] == integrator[population_model.s1] == integrator[:s1] != 2.0 @test integrator[s2] == integrator[population_model.s2] == integrator[:s2] != 1.0 -integrator[a] = 10.0 -@test integrator[a] == integrator[population_model.a] == integrator[:a] == 10.0 -integrator[population_model.b] = 20.0 -@test integrator[b] == integrator[population_model.b] == integrator[:b] == 20.0 -integrator[c] = 30.0 -@test integrator[c] == integrator[population_model.c] == integrator[:c] == 30.0 +setp(oprob, a)(integrator, 10.0) +@test getp(integrator, a)(integrator) == getp(integrator, population_model.a)(integrator) == getp(integrator, :a)(integrator) == 10.0 +setp(population_model, population_model.b)(integrator, 20.0) +@test getp(integrator, b)(integrator) == getp(integrator, population_model.b)(integrator) == getp(integrator, :b)(integrator) == 20.0 +setp(integrator, c)(integrator, 30.0) +@test getp(integrator, c)(integrator) == getp(integrator, population_model.c)(integrator) == getp(integrator, :c)(integrator) == 30.0 integrator[s1] = 10.0 @test integrator[s1] == integrator[population_model.s1] == integrator[:s1] == 10.0 @@ -59,19 +62,19 @@ integrator = init(sprob, ImplicitEM()) step!(integrator, 100.0, true) -@test integrator[a] == integrator[noisy_population_model.a] == integrator[:a] == 2.0 -@test integrator[b] == integrator[noisy_population_model.b] == integrator[:b] == 1.0 -@test integrator[c] == integrator[noisy_population_model.c] == integrator[:c] == 1.0 -@test integrator[d] == integrator[noisy_population_model.d] == integrator[:d] == 1.0 +@test getp(sprob, a)(integrator) == getp(sprob, noisy_population_model.a)(integrator) == getp(sprob, :a)(integrator) == 2.0 +@test getp(sprob, b)(integrator) == getp(sprob, noisy_population_model.b)(integrator) == getp(sprob, :b)(integrator) == 1.0 +@test getp(sprob, c)(integrator) == getp(sprob, noisy_population_model.c)(integrator) == getp(sprob, :c)(integrator) == 1.0 +@test getp(sprob, d)(integrator) == getp(sprob, noisy_population_model.d)(integrator) == getp(sprob, :d)(integrator) == 1.0 @test integrator[s1] == integrator[noisy_population_model.s1] == integrator[:s1] != 2.0 @test integrator[s2] == integrator[noisy_population_model.s2] == integrator[:s2] != 1.0 -integrator[a] = 10.0 -@test integrator[a] == integrator[noisy_population_model.a] == integrator[:a] == 10.0 -integrator[noisy_population_model.b] = 20.0 -@test integrator[b] == integrator[noisy_population_model.b] == integrator[:b] == 20.0 -integrator[c] = 30.0 -@test integrator[c] == integrator[noisy_population_model.c] == integrator[:c] == 30.0 +setp(integrator, a)(integrator, 10.0) +@test getp(noisy_population_model, a)(integrator) == getp(noisy_population_model, noisy_population_model.a)(integrator) == getp(noisy_population_model, :a)(integrator) == 10.0 +setp(sprob, noisy_population_model.b)(integrator, 20.0) +@test getp(noisy_population_model, b)(integrator) == getp(noisy_population_model, noisy_population_model.b)(integrator) == getp(noisy_population_model, :b)(integrator) == 20.0 +setp(noisy_population_model, c)(integrator, 30.0) +@test getp(noisy_population_model, c)(integrator) == getp(noisy_population_model, noisy_population_model.c)(integrator) == getp(noisy_population_model, :c)(integrator) == 30.0 integrator[s1] = 10.0 @test integrator[s1] == integrator[noisy_population_model.s1] == integrator[:s1] == 10.0 @@ -134,13 +137,13 @@ step!(integrator, 100.0, true) @test integrator[lorenz1.x] isa Real @test integrator[t] isa Real @test integrator[α] isa Real -@test integrator[γ] isa Real -@test integrator[γ] == 2.0 -@test integrator[(lorenz1.σ, lorenz1.ρ)] isa Tuple +@test getp(prob, γ)(integrator) isa Real +@test getp(prob, γ)(integrator) == 2.0 +@test getp(prob, (lorenz1.σ, lorenz1.ρ))(integrator) isa Tuple @test length(integrator[[lorenz1.x, lorenz2.x]]) == 2 -@test integrator[[γ, lorenz1.σ]] isa Vector{Float64} -@test length(integrator[[γ, lorenz1.σ]]) == 2 +@test getp(integrator, [γ, lorenz1.σ])(integrator) isa Vector{Float64} +@test length(getp(integrator, [γ, lorenz1.σ])(integrator)) == 2 @variables q(t)[1:2] = [1.0, 2.0] eqs = [D(q[1]) ~ 2q[1] @@ -175,23 +178,23 @@ integrator2 = init(prob2, Tsit5()) end # Tests various interface methods: -@test_throws Any integrator[σ] -@test in(integrator[lorenz1.σ], integrator.p) -@test in(integrator[lorenz2.σ], integrator.p) -@test_throws Any sol[:σ] +@test_throws Any getp(sys, σ)(integrator) +@test in(getp(sys, lorenz1.σ)(integrator), integrator.p) +@test in(getp(sys, lorenz2.σ)(integrator), integrator.p) +@test_throws Any getp(sol, :σ)(sol) @test_throws Any integrator[x] @test in(integrator[lorenz1.x], integrator.u) @test in(integrator[lorenz2.x], integrator.u) -@test_throws Any sol[:x] - -@test_throws Any integrator[σ]=2.0 -integrator[lorenz1.σ] = 2.0 -@test integrator[lorenz1.σ] == 2.0 -@test integrator[lorenz2.σ] != 2.0 -integrator[lorenz2.σ] = 2.0 -@test integrator[lorenz2.σ] == 2.0 -@test_throws Any sol[:σ] +@test_throws Any getp(sol, :x)(sol) + +@test_throws Any setp(integrator, σ)(integrator, 2.0) +setp(integrator, lorenz1.σ)(integrator, 2.0) +@test getp(integrator, lorenz1.σ)(integrator) == 2.0 +@test getp(integrator, lorenz2.σ)(integrator) != 2.0 +setp(integrator, lorenz2.σ)(integrator, 2.0) +@test getp(integrator, lorenz2.σ)(integrator) == 2.0 +@test_throws Any getp(sol, :σ)(sol) @test_throws Any integrator[x]=2.0 integrator[lorenz1.x] = 2.0 diff --git a/test/downstream/solution_interface.jl b/test/downstream/solution_interface.jl index 11dcc7a14..4e89a968d 100644 --- a/test/downstream/solution_interface.jl +++ b/test/downstream/solution_interface.jl @@ -21,6 +21,9 @@ sol = solve(oprob, Rodas4()) @test sol[s1] == sol[population_model.s1] == sol[:s1] @test sol[s2] == sol[population_model.s2] == sol[:s2] @test sol[s1][end] ≈ 1.0 +@test_deprecated sol[a] +@test_deprecated sol[population_model.a] +@test_deprecated sol[:a] # Tests on SDEProblem noiseeqs = [0.1 * s1, @@ -31,7 +34,9 @@ sol = solve(sprob, ImplicitEM()) @test sol[s1] == sol[noisy_population_model.s1] == sol[:s1] @test sol[s2] == sol[noisy_population_model.s2] == sol[:s2] - +@test_deprecated sol[a] +@test_deprecated sol[noisy_population_model.a] +@test_deprecated sol[:a] ### Tests on layered model (some things should not work). ### @parameters t σ ρ β @@ -74,4 +79,4 @@ sol = solve(prob, Rodas4()) @test_throws ArgumentError sol[x] @test in(sol[lorenz1.x], [getindex.(sol.u, 1) for i in 1:length(states(sol.prob.f.sys))]) -@test_throws ErrorException sol[:x] +@test_throws ArgumentError sol[:x] diff --git a/test/downstream/symbol_indexing.jl b/test/downstream/symbol_indexing.jl index 83a6ec815..f9fc43c23 100644 --- a/test/downstream/symbol_indexing.jl +++ b/test/downstream/symbol_indexing.jl @@ -1,4 +1,4 @@ -using ModelingToolkit, OrdinaryDiffEq, RecursiveArrayTools, Test +using ModelingToolkit, OrdinaryDiffEq, RecursiveArrayTools, SymbolicIndexingInterface, Test using Optimization, OptimizationOptimJL @parameters t σ ρ β @@ -53,9 +53,9 @@ sol = solve(prob, Rodas4()) @test sol[a, 1:5] isa AbstractVector @test sol[a, [1, 2, 3]] isa AbstractVector -@test sol[1] isa AbstractVector -@test sol[1:2] isa AbstractArray -@test sol[[1, 2]] isa AbstractArray +@test sol[:, 1] isa AbstractVector +@test sol[:, 1:2] isa AbstractDiffEqArray +@test sol[:, [1, 2]] isa AbstractDiffEqArray @test sol[lorenz1.x] isa Vector @test sol[lorenz1.x, 2] isa Float64 @@ -67,9 +67,9 @@ sol = solve(prob, Rodas4()) @test sol[α] isa Vector @test sol[α, 3] isa Float64 @test length(sol[α, 5:10]) == 6 -@test sol[γ] isa Real -@test sol[γ] == 2.0 -@test sol[(lorenz1.σ, lorenz1.ρ)] isa Tuple +@test getp(prob, γ)(sol) isa Real +@test getp(prob, γ)(sol) == 2.0 +@test getp(prob, (lorenz1.σ, lorenz1.ρ))(sol) isa Tuple @test sol[[lorenz1.x, lorenz2.x]] isa Vector{Vector{Float64}} @test length(sol[[lorenz1.x, lorenz2.x]]) == length(sol) @@ -132,7 +132,7 @@ sol4 = sol(0.1, idxs = [lorenz1.x, lorenz2.x]) @test sol4 isa Vector @test length(sol4) == 2 @test first(sol4) isa Real -@test sol(0.1, idxs = [lorenz1.x, 1]) isa Vector{Real} +@test sol(0.1, idxs = [lorenz1.x, 1]) isa Vector{<:Real} sol5 = sol(0.0:1.0:10.0, idxs = lorenz1.x) @test sol5.u isa Vector @@ -201,7 +201,7 @@ D = Differential(t) @named fol = ODESystem([D(x) ~ (1 - x) / tau]) prob = ODEProblem(fol, [x => 0.0], (0.0, 10.0), [tau => 3.0]) sol = solve(prob, Tsit5()) -@test sol[tau] == 3 +@test getp(fol, tau)(sol) == 3 @testset "OptimizationSolution" begin @variables begin @@ -219,6 +219,6 @@ sol = solve(prob, Tsit5()) sol = solve(prob, GradientDescent()) @test sol[x]≈1 atol=1e-3 @test sol[y]≈1 atol=1e-3 - @test sol[a] ≈ 1 - @test sol[b] ≈ 100 + @test getp(sys, a)(sol) ≈ 1 + @test getp(sys, b)(sol) ≈ 100 end diff --git a/test/existence_functions.jl b/test/existence_functions.jl index 9c959fc99..f95fed731 100644 --- a/test/existence_functions.jl +++ b/test/existence_functions.jl @@ -1,8 +1,8 @@ using Test, SciMLBase using SciMLBase: __has_jac, __has_tgrad, __has_Wfact, __has_Wfact_t, - __has_paramjac, __has_syms, __has_analytic, __has_colorvec, has_jac, + __has_paramjac, __has_analytic, __has_colorvec, has_jac, has_tgrad, - has_Wfact, has_Wfact_t, has_paramjac, has_syms, has_analytic, has_colorvec, + has_Wfact, has_Wfact_t, has_paramjac, has_analytic, has_colorvec, AbstractDiffEqFunction struct Foo <: AbstractDiffEqFunction{false} @@ -11,19 +11,17 @@ struct Foo <: AbstractDiffEqFunction{false} Wfact::Any Wfact_t::Any paramjac::Any - syms::Any analytic::Any colorvec::Any end -f = Foo(1, 1, 1, 1, 1, 1, 1, 1) +f = Foo(1, 1, 1, 1, 1, 1, 1) @test __has_jac(f) @test __has_tgrad(f) @test __has_Wfact(f) @test __has_Wfact_t(f) @test __has_paramjac(f) -@test __has_syms(f) @test __has_analytic(f) @test __has_colorvec(f) @@ -32,7 +30,6 @@ f = Foo(1, 1, 1, 1, 1, 1, 1, 1) @test has_Wfact(f) @test has_Wfact_t(f) @test has_paramjac(f) -@test has_syms(f) @test has_analytic(f) @test has_colorvec(f) @@ -50,7 +47,6 @@ f2 = Foo2(1, 1, nothing, nothing) @test __has_Wfact(f2) @test __has_Wfact_t(f2) @test !__has_paramjac(f2) -@test !__has_syms(f2) @test !__has_analytic(f2) @test !__has_colorvec(f2) @@ -59,6 +55,5 @@ f2 = Foo2(1, 1, nothing, nothing) @test !has_Wfact(f2) @test !has_Wfact_t(f2) @test !has_paramjac(f2) -@test !has_syms(f2) @test !has_analytic(f2) @test !has_colorvec(f2)