Skip to content
Open
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
10 changes: 5 additions & 5 deletions src/cpg_dynam.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Catlab.WiringDiagrams: oapply
using ..DWDDynam
using ...DWDDynam: AbstractInterface, destruct, get_readouts
import ..UWDDynam: nstates, nports, eval_dynamics, euler_approx
import ..DWDDynam: AbstractMachine, ContinuousMachine, DiscreteMachine, DelayMachine,
import ..DWDDynam: Machine, ContinuousMachine, DiscreteMachine, DelayMachine,
ninputs, noutputs
import Catlab.CategoricalAlgebra: migrate!

Expand Down Expand Up @@ -60,7 +60,7 @@ machines `ms`).
Each box of the composition pattern `d` is filled by a machine with the
appropriate type signature. Returns the composite machine.
"""
function oapply(d::OpenCPortGraph, ms::Vector{M}) where {M<:AbstractMachine}
function oapply(d::OpenCPortGraph, ms::Vector{M}) where {M<:Machine}
@assert nparts(d, :Box) == length(ms)
for b in 1:nparts(d, :Box)
@assert fills(ms[b], d, b)
Expand All @@ -86,7 +86,7 @@ function oapply(d::OpenCPortGraph, x::AbstractMachine)
end


function induced_dynamics(d::OpenCPortGraph, ms::Vector{M}, S) where {T, I, M<:AbstractMachine{T, I}}
function induced_dynamics(d::OpenCPortGraph, ms::Vector{M}, S) where {T, I, M<:Machine{T, I}}

function v(u::AbstractVector, xs::AbstractVector, p, t)
states = destruct(S, u)
Expand Down Expand Up @@ -124,7 +124,7 @@ function induced_dynamics(d::OpenCPortGraph, ms::Vector{M}, S) where {T, I, M<:D
end
end

function induced_readout(d::OpenCPortGraph, ms::Vector{M}, S) where {T, I, M<:AbstractMachine{T, I}}
function induced_readout(d::OpenCPortGraph, ms::Vector{M}, S) where {T, I, M<:Machine{T, I}}
function r(u::AbstractVector, p, t::Real)
states = destruct(S, u)
port_readout = get_port_readout(d, ms, states, p, t)
Expand All @@ -141,7 +141,7 @@ function induced_readout(d::OpenCPortGraph, ms::Vector{M}, S) where {T, I, M<:De
end
end

function get_port_readout(d::OpenCPortGraph, ms::Vector{M}, states, args...) where M <: AbstractMachine
function get_port_readout(d::OpenCPortGraph, ms::Vector{M}, states, args...) where M <: Machine
readouts = get_readouts(ms, states, args...)
map(parts(d, :Port)) do port
b = d[:box][port]
Expand Down
30 changes: 15 additions & 15 deletions src/dwd_dynam.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ readout(dynam::AbstractDirectedSystem) = dynam.readout
A directed open dynamical system operating on information fo type `T`.
A machine `m` has type signature (`m.ninputs`, `m.outputs`).
"""
abstract type AbstractMachine{T, InterfaceType, SystemType} end
abstract type AbstractMachine{T} end

interface(m::AbstractMachine) = m.interface
system(m::AbstractMachine) = m.system

input_ports(m::AbstractMachine) = input_ports(interface(m))
output_ports(m::AbstractMachine) = output_ports(interface(m))
ninputs(m::AbstractMachine) = ninputs(interface(m))
noutputs(m::AbstractMachine) = noutputs(interface(m))
nstates(m::AbstractMachine) = nstates(system(m))
dynamics(m::AbstractMachine) = dynamics(system(m))
readout(m::AbstractMachine) = readout(system(m))



struct Machine{T,I,S} <: AbstractMachine{T,I,S}
struct Machine{T,I,S} <: AbstractMachine{T}
interface::I
system::S
end

interface(m::Machine) = m.interface
system(m::Machine) = m.system

input_ports(m::Machine) = input_ports(interface(m))
output_ports(m::Machine) = output_ports(interface(m))
ninputs(m::Machine) = ninputs(interface(m))
noutputs(m::Machine) = noutputs(interface(m))
nstates(m::Machine) = nstates(system(m))
dynamics(m::Machine) = dynamics(system(m))
readout(m::Machine) = readout(system(m))


""" ContinuousMachine{T}(ninputs, nstates, noutputs, f, r)

Expand Down Expand Up @@ -344,7 +344,7 @@ end

### Helper functions for `oapply`

function induced_dynamics(d::WiringDiagram, ms::Vector{M}, S) where {T,I, M<:AbstractMachine{T,I}}
function induced_dynamics(d::WiringDiagram, ms::Vector{M}, S) where {T,I, M<:Machine{T,I}}

function v(u::AbstractVector, xs::AbstractVector, p, t::Real)
states = destruct(S, u) # a list of the states by box
Expand Down Expand Up @@ -384,7 +384,7 @@ function induced_dynamics(d::WiringDiagram, ms::Vector{M}, S) where {T,I, M<:Del
end
end

function induced_readout(d::WiringDiagram, ms::Vector{M}, S) where {T, I, M<:AbstractMachine{T,I}}
function induced_readout(d::WiringDiagram, ms::Vector{M}, S) where {T, I, M<:Machine{T,I}}
function r(u::AbstractVector, p, t)
states = destruct(S, u)
readouts = get_readouts(ms, states, p, t)
Expand Down