Skip to content

Generalized System struct #614

Open
Open
@shashi

Description

@shashi
struct JumpSystem{U <: ArrayPartition} <: AbstractSystem
    eqs::U
    iv::Variable
    states::Vector{Variable}
    ps::Vector{Variable}
    pins::Vector{Variable}
    observed::Vector{Equation}
    name::Symbol
    systems::Vector{JumpSystem}
end
struct NonlinearSystem <: AbstractSystem
    eqs::Vector{Equation}
    states::Vector{Variable}
    ps::Vector{Variable}
    pins::Vector{Variable}
    observed::Vector{Equation}
    name::Symbol
    systems::Vector{NonlinearSystem}
end
struct OptimizationSystem <: AbstractSystem
    op::Operation
    states::Vector{Variable}
    ps::Vector{Variable}
    pins::Vector{Variable}
    observed::Vector{Equation}
    name::Symbol
    systems::Vector{OptimizationSystem}
end
struct ReactionSystem <: AbstractSystem
    eqs::Vector{Reaction}
    iv::Variable
    states::Vector{Variable}
    ps::Vector{Variable}
    pins::Vector{Variable}
    observed::Vector{Equation}
    name::Symbol
    systems::Vector{ReactionSystem}
end
struct ODESystem <: AbstractODESystem
    eqs::Vector{Equation}
    iv::Variable
    states::Vector{Variable}
    ps::Vector{Variable}
    pins::Vector{Variable}
    observed::Vector{Equation}
    tgrad::RefValue{Vector{Expression}}
    jac::RefValue{Any}
    Wfact::RefValue{Matrix{Expression}}
    Wfact_t::RefValue{Matrix{Expression}}
    name::Symbol
    systems::Vector{ODESystem}
end
struct SDESystem <: AbstractODESystem
    eqs::Vector{Equation}
    noiseeqs::AbstractArray{Operation}
    iv::Variable
    states::Vector{Variable}
    ps::Vector{Variable}
    pins::Vector{Variable}
    observed::Vector{Equation}
    tgrad::RefValue{Vector{Expression}}
    jac::RefValue{Matrix{Expression}}
    Wfact::RefValue{Matrix{Expression}}
    Wfact_t::RefValue{Matrix{Expression}}
    name::Symbol
    systems::Vector{SDESystem}
end

Should probably be combined to

struct System{T}
    systemparams::T
    eqs::Vector
    iv::Operation
    states::Vector
    ps::Vector
    pins::Vector
    observed::Vector
    cache::Dict
    name::Symbol
end
# interface, possibly memoized in `cache`
equations(s::System, states=states(s))
states(s::System) # should return OrderedSet.
parameters(s::System)
pins(s::System)
observed(s::System, states=states(s))

A big reason is right now it's so hard to generically build a system back. (e.g. you'd have to write flatten for every system type, even though it would have the exact same code.)

Any objections?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions