# Library Reference

`AlgebraicPetri.AlgebraicPetri`

— ModuleComputing in the category of finite sets and Petri cospans

`AlgebraicPetri.TheoryLabelledPetriNet`

— ConstantACSet definition for a Petri net with labels on transitions and states.

See Catlab.jl documentation for description of the @present syntax.

`AlgebraicPetri.TheoryLabelledReactionNet`

— ConstantACSet definition for a ReactionNet with labels on transitions and states.

See Catlab.jl documentation for description of the @present syntax.

`AlgebraicPetri.TheoryPetriNet`

— ConstantACSet definition for a Petri net.

See Catlab.jl documentation for description of the @present syntax.

`AlgebraicPetri.TheoryReactionNet`

— ConstantACSet definition for a Petri net with rates on transitions and concentrations on states.

See Catlab.jl documentation for description of the @present syntax.

`AlgebraicPetri.LabelledPetriNet`

— MethodLabelledPetriNet(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))`

`AlgebraicPetri.LabelledReactionNet`

— MethodLabelledReactionNet{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))`

`AlgebraicPetri.PetriNet`

— MethodPetriNet(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)`

`AlgebraicPetri.PetriNet`

— MethodPetriNet(tm::TransitionMatrices)

Constructs a PetriNet from its TransitionMatrices representation.

`AlgebraicPetri.ReactionNet`

— MethodReactionNet{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))`

`AlgebraicPetri.TransitionMatrices`

— TypeTransitionMatrices

This data structure stores the transition matrix of an AbstractPetriNet object. This is primarily used for constructing the vectorfield representation of the Petri net.

`AlgebraicPetri.Open`

— MethodOpen(p::AbstractPetriNet, legs...)

Generates on OpenPetriNet with legs bundled as described by `legs`

`AlgebraicPetri.Open`

— MethodOpen(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)

`AlgebraicPetri.Open`

— MethodOpen(n, p::AbstractPetriNet, m)

Generates on OpenPetriNet with two legs, `n`

and `m`

`AlgebraicPetri.add_input!`

— Methodadd_input!(p::AbstractPetriNet,t,s;kw...)

Add an input relationship to the Petri net between the transition `t`

and species `s`

.

Returns the ID of the input relationship

`AlgebraicPetri.add_inputs!`

— Methodadd_inputs!(p::AbstractPetriNet,n,t,s;kw...)

Add input relationships to the Petri net between the transitions `t`

and species `s`

.

Returns the ID of the input relationship

`AlgebraicPetri.add_output!`

— Methodadd_output!(p::AbstractPetriNet,t,s;kw...)

Add an output relationship to the Petri net between the transition `t`

and species `s`

.

Returns the ID of the input relationship

`AlgebraicPetri.add_outputs!`

— Methodadd_outputs!(p::AbstractPetriNet,n,t,s;kw...)

Add output relationships to the Petri net between the transitions `t`

and species `s`

.

Returns the ID of the input relationship

`AlgebraicPetri.add_species!`

— MethodAdd `n`

species to the Petri net. Label and concentration can be provided depending on the kind of Petri net.

Returns the ID of the species

`AlgebraicPetri.add_species!`

— MethodAdd a species to the Petri net. Label and concentration can be provided depending on the kind of Petri net.

Returns the ID of the species

`AlgebraicPetri.add_transition!`

— MethodAdd a transition to the Petri net. Label and rate can be provided depending on the kind of Petri net.

Returns the ID of the transition

`AlgebraicPetri.add_transitions!`

— MethodAdd `n`

transitions to the Petri net. Label and rate can be provided depending on the kind of Petri net.

Returns the ID of the transition

`AlgebraicPetri.concentration`

— MethodConcentration of a ReactionNet

`AlgebraicPetri.concentrations`

— MethodAll concentrations of a ReactionNet

`AlgebraicPetri.inputs`

— MethodInput relationships for a transition

`AlgebraicPetri.ni`

— MethodNumber of input relationships in a Petri net

`AlgebraicPetri.no`

— MethodNumber of output relationships in a Petri net

`AlgebraicPetri.ns`

— MethodNumber of states in a Petri net

`AlgebraicPetri.nt`

— MethodNumber of transitions in a Petri net

`AlgebraicPetri.outputs`

— MethodOutput relationships for a transition

`AlgebraicPetri.rate`

— MethodRate of a RectionNet

`AlgebraicPetri.rates`

— MethodAll rates of a ReactionNet

`AlgebraicPetri.sname`

— MethodName of species

Note that this returns an index if labels are not present in the PetriNet

`AlgebraicPetri.snames`

— MethodNames of species in a Petri net

Note that this returns indices if labels are not present in the PetriNet

`AlgebraicPetri.tname`

— MethodName of transition

Note that this returns an index if labels are not present in the PetriNet

`AlgebraicPetri.tnames`

— MethodNames of transitions in a Petri net

Note that this returns indices if labels are not present in the PetriNet

`AlgebraicPetri.vectorfield`

— Methodvectorfield(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.

`AlgebraicPetri.Epidemiology`

— ModuleSpecific generators and useful tools for constructing epidemiological systems

`AlgebraicPetri.Epidemiology.death`

— ConstantLabelledPetriNet which describes the death process which moves tokens from I to D

`AlgebraicPetri.Epidemiology.exposure`

— ConstantLabelledPetriNet which describes the exposure process where tokens in I "expose" tokens in S, changing them from S to E

`AlgebraicPetri.Epidemiology.illness`

— ConstantLabelledPetriNet which describes the illness process which moves tokens from E to I.

`AlgebraicPetri.Epidemiology.infection`

— ConstantLabelledPetriNet which describes the infection process of tokens in state S by tokens in state I

`AlgebraicPetri.Epidemiology.recovery`

— ConstantLabelledPetriNet which describes the recovery process which moves tokens from I to R

`AlgebraicPetri.Epidemiology.oapply_epi`

— Methodoapply_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]`