# Library Reference

AlgebraicPetri.LabelledPetriNetMethod

LabelledPetriNet(n, ts::Vararg{Union{Pair,Tuple}})

Constructs a LabelledPetriNet object with state names as elements of n and labelled transitions described by ts. Transitions are given as transition_name=>((input_states)=>(output_states)).

A LabelledPetriNet modelling the SIR model with 3 states and 2 transitions can be constructed as follows:

LabelledPetriNet([:S, :I, :R], :inf=>((:S,:I)=>(:I,:I)), :rec=>(:I=>:R))
source
AlgebraicPetri.LabelledReactionNetMethod

LabelledReactionNet{R,C}(n, ts::Vararg{Union{Pair,Tuple}}) where {R,C}

Constructs a LabelledReactionNet object with labelled state concentrations as elements of n and labelled transitions described by ts. R is the data type used to store rates and C is the data type used to store concentrations.

Transitions are given as (t_name=>t_rate)=>((input_states)=>(output_states)).

A LabelledReactionNet modelling the SIR model with 3 states and 2 transitions, an initial population of 10 susceptible, 1 infected, 0 recovered and an infection rate of 0.5 and recovery rate of 0.1 can be constructed as follows:

ReactionNet{Float64, Float64}([:S=>10,:I=>1,:R=>0], (:inf=>0.5)=>((1,2)=>(2,2)), (:rec=>0.1)=>(2=>3))
source
AlgebraicPetri.PetriNetMethod

PetriNet(n::Int, ts::Vararg{Union{Pair,Tuple}})

Constructs a PetriNet object with n states and transitions described by ts. Transitions are given as (input_states)=>(output_states).

A PetriNet modelling the SIR model with 3 states and 2 transitions can be constructed as follows:

PetriNet(3, (1,2)=>(2,2), 2=>3)
source
AlgebraicPetri.ReactionNetMethod

ReactionNet{R,C}(n, ts::Vararg{Union{Pair,Tuple}}) where {R,C}

Constructs a ReactionNet object with state concentrations as elements of n and transitions described by ts. R is the data type used to store rates and C is the data type used to store concentrations.

Transitions are given as transition_rate=>((input_states)=>(output_states)).

A ReactionNet modelling the SIR model with 3 states and 2 transitions, an initial population of 10 susceptible, 1 infected, 0 recovered and an infection rate of 0.5 and recovery rate of 0.1 can be constructed as follows:

ReactionNet{Float64, Float64}([10,1,0], 0.5=>((1,2)=>(2,2)), 0.1=>(2=>3))
source
AlgebraicPetri.OpenMethod

Open(p::AbstractPetriNet)

Converts a PetriNet to an OpenPetriNet where each state is exposed as a leg of the cospan. The OpenPetriNet can be composed over an undirected wiring diagram (see this blog post for a description of this compositional tooling)

source
AlgebraicPetri.add_input!Method

Add an input relationship to the Petri net between the transition t and species s.

Returns the ID of the input relationship

source
AlgebraicPetri.add_inputs!Method

Add input relationships to the Petri net between the transitions t and species s.

Returns the ID of the input relationship

source
AlgebraicPetri.add_output!Method

Add an output relationship to the Petri net between the transition t and species s.

Returns the ID of the input relationship

source
AlgebraicPetri.add_outputs!Method

Add output relationships to the Petri net between the transitions t and species s.

Returns the ID of the input relationship

source
AlgebraicPetri.vectorfieldMethod

vectorfield(pn::AbstractPetriNet)

Generates a Julia function which calculates the vectorfield of the Petri net being simulated under the law of mass action.

The resulting function has a signature of the form f!(du, u, p, t) and can be passed to the DifferentialEquations.jl solver package.

source
AlgebraicPetri.Epidemiology.oapply_epiMethod

oapply_epi(ex, args...)

Generates a LabelledPetriNet under a composition pattern described by the undirected wiring diagram ex. This requires that the nodes in ex are only labelled with labels from the following set:

[:infection, :exposure, :illness, :recovery, :death]
source