AlgebraicPetri.jl
AlgebraicPetri.jl copied to clipboard
induced subnet
Sometimes when dealing with big petri nets it's useful to grab the "induced subnet", that is, given some transition(s) we grab the net consisting of the transition(s), and the arcs and places incident to them. The name comes from the induced_subgraph
method in Catlab.BasicGraphs.
It think there is a much slicker way to do this with the logic of subobjects.
https://blog.algebraicjulia.org/post/2021/09/cset-graphs-4/#using-the-logic-of-subgraphs
if A is the Petri net with only the transitions in tt, then
\neg(\tilde(A))
is the induced sub-petri-net that you want.
If there's a slicker way to do it, let's just abandon the more complex approach and do that. I'll read the blog post tonight.
@jpfairbanks not sure if I'm using the subobject interface wrong, I'm not getting the subnet I expected (i.e. the one with 2 places and 1 transition)
julia> sir_petri = PetriNet(3, ((1, 2), (2, 2)), (2, 3))
PetriNet with elements T = 1:2, S = 1:3, I = 1:3, O = 1:3
┌───┬────┬────┐
│ I │ it │ is │
├───┼────┼────┤
│ 1 │ 1 │ 1 │
│ 2 │ 1 │ 2 │
│ 3 │ 2 │ 2 │
└───┴────┴────┘
┌───┬────┬────┐
│ O │ ot │ os │
├───┼────┼────┤
│ 1 │ 1 │ 2 │
│ 2 │ 1 │ 2 │
│ 3 │ 2 │ 3 │
└───┴────┴────┘
julia> dom(hom(¬(~Subobject(sir_petri, T=[1]))))
PetriNet with elements T = 1:0, S = 1:0, I = 1:0, O = 1:0
@mehalter I think I've addressed (finally) James' comments locally but I'm not sure how to best pull the updates from main on AlgJulia into this branch on my fork. Can you help give me some advice? I've already messed it up twice and reverted.
@slwu89 sure, have you pushed these local changes here? Could you push it here building on these changes and then I can help you out with the rebase. Or, does this PR already contain the new changes to address the requests?
Thanks @mehalter, I ended up just rebasing this branch onto main to grab the latest changes. This branch was made pre Catlab v0.15 so it had the old using
for each module. I'll go ahead and make changes to address @jpfairbanks's comments from here, which will take a bit more time. Using the subobject interface in lieu of the "imperative" interface is giving some errors on certain types of nets, so I'll need to look into that when I have time.
Awesome @slwu89 ! One recommendation is you should reword the first commit since it's not actually doing a rebase. It's adding the initial implementation of induced subnet
Whoops, thanks. Still not gittin it.