diff --git a/Project.toml b/Project.toml index 52eaa80e..3867d2de 100644 --- a/Project.toml +++ b/Project.toml @@ -30,13 +30,13 @@ DataInterpolations = "4, 5, 6, 7, 8" DiffEqBase = "6" DocStringExtensions = "0.7, 0.8, 0.9" MLUtils = "0.3, 0.4" -ModelingToolkit = "9" +ModelingToolkit = "10" +OrdinaryDiffEqTsit5 = "1" Parameters = "0.12" ProgressMeter = "1.6" QuadGK = "2.4" RecipesBase = "1" Reexport = "1.0" -OrdinaryDiffEqTsit5 = "1" SciMLStructures = "1" Setfield = "1" Statistics = "1" diff --git a/docs/Project.toml b/docs/Project.toml index e37b5ae9..a9d8b18d 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -13,7 +13,7 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" DataDrivenDiffEq = "1" Documenter = "1" Literate = "2.14" -ModelingToolkit = "9" +ModelingToolkit = "10" OrdinaryDiffEq = "6" Plots = "1" StableRNGs = "1" diff --git a/docs/src/libs/datadrivensparse/example_04.jl b/docs/src/libs/datadrivensparse/example_04.jl index 48dcbe88..c4567943 100644 --- a/docs/src/libs/datadrivensparse/example_04.jl +++ b/docs/src/libs/datadrivensparse/example_04.jl @@ -29,9 +29,9 @@ using Test #src end end -@mtkbuild sys = Autoregulation() +@mtkcompile sys = Autoregulation() tspan = (0.0, 5.0) -de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan, []) +de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan) de_solution = solve(de_problem, Tsit5(), saveat = 0.005); #md plot(de_solution) diff --git a/src/DataDrivenDiffEq.jl b/src/DataDrivenDiffEq.jl index 8e353f62..ff7e02f0 100644 --- a/src/DataDrivenDiffEq.jl +++ b/src/DataDrivenDiffEq.jl @@ -13,13 +13,13 @@ using Parameters using Setfield @reexport using ModelingToolkit -using ModelingToolkit: AbstractSystem, AbstractTimeDependentSystem +using ModelingToolkit: AbstractSystem using SciMLStructures: SciMLStructures as SS using SymbolicUtils: operation, arguments, iscall, issym using Symbolics using Symbolics: scalarize, variable, value @reexport using ModelingToolkit: unknowns, parameters, independent_variable, observed, - controls, get_iv, get_observed + get_iv, get_observed using Random using QuadGK @@ -67,7 +67,7 @@ const __EMPTY_VECTOR = Vector(undef, 0) # Basis with an indicator for implicit use abstract type AbstractDataDrivenFunction{Bool, Bool} end -abstract type AbstractBasis <: AbstractTimeDependentSystem end +abstract type AbstractBasis <: AbstractSystem end # Collect the DataInterpolations Methods into an Interpolation Type abstract type AbstractInterpolationMethod end @@ -98,7 +98,7 @@ include("./basis/utils.jl") include("./basis/type.jl") export Basis export jacobian, dynamics -export implicit_variables, states +export implicit_variables, states, controls export get_parameter_values, get_parameter_map include("./utils/basis_generators.jl") diff --git a/src/basis/type.jl b/src/basis/type.jl index 7dabbee9..26780572 100644 --- a/src/basis/type.jl +++ b/src/basis/type.jl @@ -263,6 +263,18 @@ function states(b::AbstractBasis) return getfield(b, :unknowns) end +function controls(b::AbstractBasis) + ctrls = getfield(b, :ctrls) + systems = getfield(b, :systems) + isempty(systems) && return ctrls + + ctrls = copy(ctrls) + for sys in systems + append!(ctrls, unknowns(sys, controls(sys))) + end + return ctrls +end + # For internal use is_implicit(b::Basis{X, <:Any}) where {X} = X is_controlled(b::Basis{<:Any, X}) where {X} = X diff --git a/src/problem/type.jl b/src/problem/type.jl index 39244e47..2910fd86 100644 --- a/src/problem/type.jl +++ b/src/problem/type.jl @@ -326,7 +326,7 @@ function ModelingToolkit.observed(p::AbstractDataDrivenProblem, i = :, j = :) isempty(x) ? x : getindex(x, i, j) end -function ModelingToolkit.controls(p::AbstractDataDrivenProblem, i = :, j = :) +function controls(p::AbstractDataDrivenProblem, i = :, j = :) x = getfield(p, :U) isempty(x) ? x : getindex(x, i, j) end diff --git a/test/problem/problem.jl b/test/problem/problem.jl index 2611ce79..687e7055 100644 --- a/test/problem/problem.jl +++ b/test/problem/problem.jl @@ -183,9 +183,9 @@ end end end - @mtkbuild sys = Autoregulation() + @mtkcompile sys = Autoregulation() tspan = (0.0, 5.0) - de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan, []) + de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan) de_solution = solve(de_problem, Tsit5(), saveat = 0.005) prob = DataDrivenProblem(de_solution) @test is_valid(prob)