Composed Open Population SIRV Model
using StockFlow
using StockFlow.Syntax
using Catlab
using Catlab.CategoricalAlgebra
using LabelledArrays
using OrdinaryDiffEq
using Plots
using Catlab.Graphics
using Catlab.Programs
using Catlab.Theories
using Catlab.WiringDiagrams
sir = @stock_and_flow begin
:stocks
S
I
R
:parameters
rbirth
cbeta
rrecovery
rdeath
:dynamic_variables
v_inf₁ = I / N
v_inf₂ = v_inf₁ * cbeta
v_inf₃ = v_inf₂ * S
:flows
CLOUD => f_birth(rbirth * N) => S
S => f_inf(v_inf₃) => I
I => f_rec(rrecovery * I) => R
S => f_deathS(S * rdeath) => CLOUD
I => f_deathI(I * rdeath) => CLOUD
R => f_deathR(R * rdeath) => CLOUD
:sums
N = [I, R, S]
end
GraphF(sir)
svi = @stock_and_flow begin
:stocks
S
V
I
:parameters
rvaccine
rdeath
lambda
evaccine_complement # 1.0 - evaccine
:dynamic_variables
v_vacV = evaccine_complement * V
v_infV = v_vacV * lambda
:flows
S => f_vacc(S * rvaccine) => V
V => f_deathV(V * rdeath) => CLOUD
V => f_infV(v_infV) => I
:sums
N = [V, I, S]
end
GraphF(svi)
Define the UWD-algebra
sirv_uwd = @relation (S,I) begin
seir(S,I)
svi(S,I)
end;
display_uwd(sirv_uwd)
Define a foot of the structured multicospan
footS=foot(:S, :N, :S=>:N)
GraphF(footS;schema="C0")
Define a foot of the structured multicospan
footI=foot(:I, :N, :I=>:N)
GraphF(footI;schema="C0")
Open sir and svi stock and flow diagram with the feet defined before
open_sir=Open(sir, footS, footI)
open_svi=Open(svi, footS, footI)
Catlab.CategoricalAlgebra.StructuredCospans.StructuredCospan{Catlab.CategoricalAlgebra.StructuredCospans.DiscreteACSet{StockAndFlow0, StockAndFlowF}, Catlab.CategoricalAlgebra.FreeDiagrams.Multicospan{StockAndFlowF, Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}, StaticArraysCore.SVector{2, Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}}}, StaticArraysCore.SVector{2, StockAndFlow0}}(Catlab.CategoricalAlgebra.FreeDiagrams.Multicospan{StockAndFlowF, Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}, StaticArraysCore.SVector{2, Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}}}(StockAndFlowF:
S = 1:3
SV = 1:1
LS = 1:3
F = 1:3
I = 1:2
O = 1:3
V = 1:4
LV = 1:3
LSV = 1:0
P = 1:4
LVV = 1:1
LPV = 1:4
Name = 1:0
Op = 1:0
Position = 1:0
lss : LS → S = [1, 2, 3]
lssv : LS → SV = [1, 1, 1]
ifn : I → F = [1, 3]
is : I → S = [2, 3]
ofn : O → F = [1, 2, 3]
os : O → S = [1, 2, 2]
fv : F → V = [3, 4, 2]
lvs : LV → S = [2, 1, 2]
lvv : LV → V = [1, 3, 4]
lsvsv : LSV → SV = Int64[]
lsvv : LSV → V = Int64[]
lvsrc : LVV → V = [1]
lvtgt : LVV → V = [2]
lpvp : LPV → P = [4, 3, 1, 2]
lpvv : LPV → V = [1, 2, 3, 4]
sname : S → Name = [:S, :V, :I]
svname : SV → Name = [:N]
fname : F → Name = [:f_vacc, :f_deathV, :f_infV]
vname : V → Name = [:v_vacV, :v_infV, Symbol("##v_f_vacc#630"), Symbol("##v_f_deathV#631")]
pname : P → Name = [:rvaccine, :rdeath, :lambda, :evaccine_complement]
vop : V → Op = [:*, :*, :*, :*]
lvsposition : LV → Position = Int8[2, 1, 1]
lsvsvposition : LSV → Position = Int8[]
lvsrcposition : LVV → Position = Int8[1]
lpvpposition : LPV → Position = Int8[1, 2, 2, 2], Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}[ACSetTransformation((S = FinFunction([1], 1, 3), SV = FinFunction([1], 1, 1), LS = FinFunction([1], 1, 3), F = FinFunction(Int64[], 0, 3), I = FinFunction(Int64[], 0, 2), O = FinFunction(Int64[], 0, 3), V = FinFunction(Int64[], 0, 4), LV = FinFunction(Int64[], 0, 3), LSV = FinFunction(Int64[], 0, 0), P = FinFunction(Int64[], 0, 4), LVV = FinFunction(Int64[], 0, 1), LPV = FinFunction(Int64[], 0, 4), Name = Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Symbol}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Symbol})), FinSet(0)), Op = Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Symbol}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Symbol})), FinSet(0)), Position = Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Int8}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Int8})), FinSet(0))), StockAndFlowF {S:1, SV:1, LS:1, F:0, I:0, O:0, V:0, LV:0, LSV:0, P:0, LVV:0, LPV:0, Name:0, Op:0, Position:0}, StockAndFlowF {S:3, SV:1, LS:3, F:3, I:2, O:3, V:4, LV:3, LSV:0, P:4, LVV:1, LPV:4, Name:0, Op:0, Position:0}), ACSetTransformation((S = FinFunction([3], 1, 3), SV = FinFunction([1], 1, 1), LS = FinFunction([3], 1, 3), F = FinFunction(Int64[], 0, 3), I = FinFunction(Int64[], 0, 2), O = FinFunction(Int64[], 0, 3), V = FinFunction(Int64[], 0, 4), LV = FinFunction(Int64[], 0, 3), LSV = FinFunction(Int64[], 0, 0), P = FinFunction(Int64[], 0, 4), LVV = FinFunction(Int64[], 0, 1), LPV = FinFunction(Int64[], 0, 4), Name = Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Symbol}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Symbol})), FinSet(0)), Op = Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Symbol}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Symbol})), FinSet(0)), Position = Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Int8}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Int8})), FinSet(0))), StockAndFlowF {S:1, SV:1, LS:1, F:0, I:0, O:0, V:0, LV:0, LSV:0, P:0, LVV:0, LPV:0, Name:0, Op:0, Position:0}, StockAndFlowF {S:3, SV:1, LS:3, F:3, I:2, O:3, V:4, LV:3, LSV:0, P:4, LVV:1, LPV:4, Name:0, Op:0, Position:0})]), StockAndFlow0[StockAndFlow0:
S = 1:1
SV = 1:1
LS = 1:1
Name = 1:0
lss : LS → S = [1]
lssv : LS → SV = [1]
sname : S → Name = [:S]
svname : SV → Name = [:N], StockAndFlow0:
S = 1:1
SV = 1:1
LS = 1:1
Name = 1:0
lss : LS → S = [1]
lssv : LS → SV = [1]
sname : S → Name = [:I]
svname : SV → Name = [:N]])
Compose those two models according the UWD-algebra
open_sirv = oapply(sirv_uwd, [open_sir, open_svi])
Catlab.CategoricalAlgebra.StructuredCospans.StructuredMulticospan{Catlab.CategoricalAlgebra.StructuredCospans.DiscreteACSet{StockAndFlow0, StockAndFlowF}, Catlab.CategoricalAlgebra.FreeDiagrams.Multicospan{StockAndFlowF, Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}, Vector{Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}}}, Vector{Union{Nothing, StockAndFlow0}}}(Catlab.CategoricalAlgebra.FreeDiagrams.Multicospan{StockAndFlowF, Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}, Vector{Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}}}(StockAndFlowF:
S = 1:4
SV = 1:1
LS = 1:4
F = 1:9
I = 1:5
O = 1:8
V = 1:12
LV = 1:9
LSV = 1:2
P = 1:8
LVV = 1:3
LPV = 1:10
Name = 1:0
Op = 1:0
Position = 1:0
lss : LS → S = [1, 2, 3, 4]
lssv : LS → SV = [1, 1, 1, 1]
ifn : I → F = [1, 2, 3, 7, 9]
is : I → S = [1, 2, 3, 4, 2]
ofn : O → F = [2, 4, 3, 5, 6, 7, 8, 9]
os : O → S = [1, 1, 2, 2, 3, 1, 4, 4]
fv : F → V = [4, 3, 5, 6, 7, 8, 11, 12, 10]
lvs : LV → S = [2, 1, 2, 1, 2, 3, 4, 1, 4]
lvv : LV → V = [1, 3, 5, 6, 7, 8, 9, 11, 12]
lsvsv : LSV → SV = [1, 1]
lsvv : LSV → V = [1, 4]
lvsrc : LVV → V = [1, 2, 9]
lvtgt : LVV → V = [2, 3, 10]
lpvp : LPV → P = [2, 1, 3, 4, 4, 4, 8, 7, 5, 6]
lpvv : LPV → V = [2, 4, 5, 6, 7, 8, 9, 10, 11, 12]
sname : S → Name = [:S, :I, :R, :V]
svname : SV → Name = [:N]
fname : F → Name = [:f_birth, :f_inf, :f_rec, :f_deathS, :f_deathI, :f_deathR, :f_vacc, :f_deathV, :f_infV]
vname : V → Name = [:v_inf₁, :v_inf₂, :v_inf₃, Symbol("##v_f_birth#625"), Symbol("##v_f_rec#626"), Symbol("##v_f_deathS#627"), Symbol("##v_f_deathI#628"), Symbol("##v_f_deathR#629"), :v_vacV, :v_infV, Symbol("##v_f_vacc#630"), Symbol("##v_f_deathV#631")]
pname : P → Name = [:rbirth, :cbeta, :rrecovery, :rdeath, :rvaccine, :rdeath, :lambda, :evaccine_complement]
vop : V → Op = [:/, :*, :*, :*, :*, :*, :*, :*, :*, :*, :*, :*]
lvsposition : LV → Position = Int8[1, 2, 2, 1, 1, 1, 2, 1, 1]
lsvsvposition : LSV → Position = Int8[2, 2]
lvsrcposition : LVV → Position = Int8[1, 1, 1]
lpvpposition : LPV → Position = Int8[2, 1, 1, 2, 2, 2, 1, 2, 2, 2], Catlab.CategoricalAlgebra.CSets.StructTightACSetTransformation{ACSets.Schemas.TypeLevelBasicSchema{Symbol, Tuple{:S, :SV, :LS, :F, :I, :O, :V, :LV, :LSV, :P, :LVV, :LPV}, Tuple{(:lss, :LS, :S), (:lssv, :LS, :SV), (:ifn, :I, :F), (:is, :I, :S), (:ofn, :O, :F), (:os, :O, :S), (:fv, :F, :V), (:lvs, :LV, :S), (:lvv, :LV, :V), (:lsvsv, :LSV, :SV), (:lsvv, :LSV, :V), (:lvsrc, :LVV, :V), (:lvtgt, :LVV, :V), (:lpvp, :LPV, :P), (:lpvv, :LPV, :V)}, Tuple{:Name, :Op, :Position}, Tuple{(:sname, :S, :Name), (:svname, :SV, :Name), (:fname, :F, :Name), (:vname, :V, :Name), (:pname, :P, :Name), (:vop, :V, :Op), (:lvsposition, :LV, :Position), (:lsvsvposition, :LSV, :Position), (:lvsrcposition, :LVV, :Position), (:lpvpposition, :LPV, :Position)}, Tuple{}}, @NamedTuple{S::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, SV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LS::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, F::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, I::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, O::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, V::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LSV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, P::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LVV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, LPV::Catlab.CategoricalAlgebra.FinSets.FinDomFunctionVector{Int64, Vector{Int64}, Catlab.CategoricalAlgebra.FinSets.FinSetInt}, Name::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Op::Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}, Position::Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}}, StockAndFlowF, StockAndFlowF}[ACSetTransformation((S = FinFunction([1], 1, 4), SV = FinFunction([1], 1, 1), LS = FinFunction([1], 1, 4), F = FinFunction(Int64[], 0, 9), I = FinFunction(Int64[], 0, 5), O = FinFunction(Int64[], 0, 8), V = FinFunction(Int64[], 0, 12), LV = FinFunction(Int64[], 0, 9), LSV = FinFunction(Int64[], 0, 2), P = FinFunction(Int64[], 0, 8), LVV = FinFunction(Int64[], 0, 3), LPV = FinFunction(Int64[], 0, 10), Name = Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Symbol}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Symbol})), FinSet(0)), Op = Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Symbol}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Symbol})), FinSet(0)), Position = Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Int8}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Int8})), FinSet(0))), StockAndFlowF {S:1, SV:1, LS:1, F:0, I:0, O:0, V:0, LV:0, LSV:0, P:0, LVV:0, LPV:0, Name:0, Op:0, Position:0}, StockAndFlowF {S:4, SV:1, LS:4, F:9, I:5, O:8, V:12, LV:9, LSV:2, P:8, LVV:3, LPV:10, Name:0, Op:0, Position:0}), ACSetTransformation((S = FinFunction([2], 1, 4), SV = FinFunction([1], 1, 1), LS = FinFunction([2], 1, 4), F = FinFunction(Int64[], 0, 9), I = FinFunction(Int64[], 0, 5), O = FinFunction(Int64[], 0, 8), V = FinFunction(Int64[], 0, 12), LV = FinFunction(Int64[], 0, 9), LSV = FinFunction(Int64[], 0, 2), P = FinFunction(Int64[], 0, 8), LVV = FinFunction(Int64[], 0, 3), LPV = FinFunction(Int64[], 0, 10), Name = Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Symbol}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Symbol})), FinSet(0)), Op = Catlab.CategoricalAlgebra.FinSets.VarFunction{Symbol}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Symbol}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Symbol})), FinSet(0)), Position = Catlab.CategoricalAlgebra.FinSets.VarFunction{Int8}(FinDomFunction(Union{ACSets.ColumnImplementations.AttrVar, Int8}[], FinSet(0), TypeSet(Union{ACSets.ColumnImplementations.AttrVar, Int8})), FinSet(0))), StockAndFlowF {S:1, SV:1, LS:1, F:0, I:0, O:0, V:0, LV:0, LSV:0, P:0, LVV:0, LPV:0, Name:0, Op:0, Position:0}, StockAndFlowF {S:4, SV:1, LS:4, F:9, I:5, O:8, V:12, LV:9, LSV:2, P:8, LVV:3, LPV:10, Name:0, Op:0, Position:0})]), Union{Nothing, StockAndFlow0}[StockAndFlow0:
S = 1:1
SV = 1:1
LS = 1:1
Name = 1:0
lss : LS → S = [1]
lssv : LS → SV = [1]
sname : S → Name = [:S]
svname : SV → Name = [:N], StockAndFlow0:
S = 1:1
SV = 1:1
LS = 1:1
Name = 1:0
lss : LS → S = [1]
lssv : LS → SV = [1]
sname : S → Name = [:I]
svname : SV → Name = [:N]])
The composed stock and flow diagram is the apex of the composed open stock and flow diagram
sirv = apex(open_sirv)
GraphF(sirv)
L = @stock_and_flow begin
:stocks
V
I
:parameters
lambda
cbeta
evaccine_complement
:dynamic_variables
v_inf₁ = I / N
v_inf₂ = v_inf₁ * cbeta
v_vacV = evaccine_complement * V
v_infV = v_vacV * lambda
:flows
V => f_infV(v_infV) => I
:sums
N = [V, I]
end;
GraphF(L)
I = @stock_and_flow begin
:stocks
V
I
:parameters
cbeta
evaccine_complement
:dynamic_variables
v_inf₁ = I / N
v_inf₂ = v_inf₁ * cbeta
v_vacV = evaccine_complement * V
v_infV = *(v_vacV)
:flows
V => f_infV(v_infV) => I
:sums
N = [V, I]
end;
GraphF(I)
R = @stock_and_flow begin
:stocks
V
I
:parameters
cbeta
evaccine_complement
:dynamic_variables
v_inf₁ = I / N
v_inf₂ = v_inf₁ * cbeta
v_vacV = evaccine_complement * V
v_infV = v_vacV * v_inf₂
:flows
V => f_infV(v_infV) => I
:sums
N = [V, I]
end;
GraphF(R)
using AlgebraicRewriting
using AlgebraicRewriting: rewrite
const hom = Catlab.CategoricalAlgebra.homomorphism
rule = Rule(hom(I,L), hom(I,R))
sirv_rewritten = rewrite(rule, sirv)
GraphF(sirv_rewritten)
define values of constant parameters
p = LVector(
cbeta=0.1, rbirth=0.001, rdeath=0.001, rrecovery=0.05, # for model sir
rvaccine=0.01, evaccine=0.3, evaccine_complement = 0.7 # for model svi
)
7-element LabelledArrays.LArray{Float64, 1, Vector{Float64}, (:cbeta, :rbirth, :rdeath, :rrecovery, :rvaccine, :evaccine, :evaccine_complement)}:
:cbeta => 0.1
:rbirth => 0.001
:rdeath => 0.001
:rrecovery => 0.05
:rvaccine => 0.01
:evaccine => 0.3
:evaccine_complement => 0.7
define initial values for stocks
u0 = LVector(
S=990.0, I=10.0, R=0.0, V=0.0
)
prob_sirv = ODEProblem(vectorfield(sirv_rewritten),u0,(0.0,100.0),p);
sol_sirv = solve(prob_sirv,Tsit5(),abstol=1e-8);
plot(sol_sirv)
to have the figures plotted fix to the wider of the cells
HTML("""
<style>
.output_svg div{
width: 100% !important;
height: 100% !important;
}
</style>
""")