Browse Source

Fixed petri net size in COEXIST example

pull/30/head
Micah Halter 5 months ago
parent
commit
704959d86d
Signed by: mehalter GPG Key ID: 4224A6EA9A8CAAA8
  1. 15
      examples/covid/coexist/coexist.jl

15
examples/covid/coexist/coexist.jl

@ -15,11 +15,17 @@ using Catlab.Graphics
using Catlab.Programs
using Catlab.Theories
using Catlab.WiringDiagrams
using Catlab.Graphics.Graphviz: run_graphviz
display_uwd(ex) = to_graphviz(ex, box_labels=:name, junction_labels=:variable, edge_attrs=Dict(:len=>"1"));
save_fig(g, fname::AbstractString, format::AbstractString) = begin
open(string(fname, ".", format), "w") do io
run_graphviz(io, g, format=format)
end
end
# Define helper functions for defining the two types of
# reactions in an epidemiology Model. Either a state
# reactions in an epidemiology Model. Either a state
# spontaneously changes, or one state causes another to change
ob(x::Symbol,n::Int) = codom(Open([x], LabelledReactionNet{Number,Int}(x=>n), [x])).ob;
@ -158,7 +164,10 @@ end;
display_uwd(threeNCoexist)
#-
threeNCoexist_algpetri = apex(F_tcx(threeNCoexist))
Graph(threeNCoexist_algpetri)
Graph(threeNCoexist_algpetri);
save_fig(Graph(threeNCoexist_algpetri), "3ncoexist_petri", "svg"); # hide
# ![3-generation COEXIST model petri net](3ncoexist_petri.svg)
# We can JSON to convert this Petri net into an
# easily shareable format
@ -191,4 +200,4 @@ threeNCoexist_algpetri = apex(F_tcx(threeNCoexist));
prob = ODEProblem(vectorfield(threeNCoexist_algpetri),concentrations(threeNCoexist_algpetri),tspan,rates(threeNCoexist_algpetri));
sol = solve(prob,Tsit5());
plot(sol, xlabel="Time", ylabel="Number of people")
plot(sol, xlabel="Time", ylabel="Number of people")
Loading…
Cancel
Save