-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
induced subnet #119
base: main
Are you sure you want to change the base?
induced subnet #119
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/AlgebraicPetri.jl
Outdated
output_places = [subpart(p, output_i, :os) for output_i in output_arcs] | ||
|
||
subnet = T() | ||
copy_parts!(subnet, p, T=t, I=vcat(input_arcs...), O=vcat(output_arcs...), S=union(input_places..., output_places...)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@epatters, this is done with the subpart and incident API. Would you prefer if this used the Topos logic operations? Is not(negation(tt)) equivalent to this formulation?
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 |
c8332c7
to
46f5943
Compare
@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. |
3e26195
to
46f5943
Compare
@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 |
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. |
|
||
function induced_subnet(p::T, t::AbstractVector{Int}) where {T <: AbstractPetriNet} | ||
subnet = Subobject(p, T=t) | ||
return dom(hom(~(¬subnet))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return the Subobject and have the caller call dom if they want just the domain?
We could add overloads for Subobject -> PetriNet so that they can call PetriNet(induced_subnet(g))
if they don't want the morphism?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jpfairbanks those all sound like good ideas, but I don't know how we'd want to implement the overload for PetriNet
to pull the domain subobject out. PetriNet
is a specific type made by calling the @acset_type
macro, it's plausible a user would want to get the domain petri net out of a subobject where the petri nets in question are of a different type, like a labelled petri net. How should the overload work in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would T(p::Subobject{T}) where T<:AbstractPetriNet = dom(p)
work?
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.