generated from AlgebraicJulia/AlgebraicTemplate.jl
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kris Brown
committed
May 14, 2024
1 parent
22086e0
commit 4dfa651
Showing
10 changed files
with
478 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,7 @@ Manifest.toml | |
.DS_Store | ||
.vscode | ||
.ipynb_checkpoints | ||
|
||
cache/ | ||
|
||
figures/SIRSDiscretetrajectory.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# # Petri Net rewriting | ||
# | ||
# First we want to load our package with `using` | ||
|
||
using AlgebraicABMs | ||
using Catlab, AlgebraicPetri # for declaring model building blocks | ||
using Distributions # for defining hazard rates | ||
|
||
# ## Schema | ||
# | ||
# We create a regular grid | ||
|
||
@present SchLife(FreeSchema) begin | ||
Cell::Ob | ||
(N,E,W,S)::Hom(Cell,Cell) | ||
Life::Ob | ||
live::Hom(Life,Cell) | ||
end | ||
|
||
# We define a network of cells | ||
|
||
@present SchLifeGraph <: SchSymmetricGraph begin | ||
Life::Ob | ||
live::Hom(Life,V) | ||
end | ||
|
||
@acset_type Life(SchLifeGraph) <: AbstractSymmetricGraph | ||
|
||
function living_neighbors(n::Int; alive=false) | ||
X = Life(1) | ||
alive && add_part!(X, :Live, live=1) | ||
for _ in 1:n | ||
v = add_part!(X, :V) | ||
add_part!(X, :Life, live=v) | ||
add_edge!(X, v, 1) | ||
end | ||
X | ||
end | ||
|
||
living_neighbors(2) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.