Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions docs/src/libs/datadrivensparse/example_04.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions src/DataDrivenDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
12 changes: 12 additions & 0 deletions src/basis/type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/problem/type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/problem/problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading