Code Monkey home page Code Monkey logo

Comments (5)

mehalter avatar mehalter commented on June 16, 2024 1

I believe this has been resolved with a new Catlab feature with cascading_rem_part! and cascading_rem_parts!. This will delete a part of the C-Set and cascade to remove all references to that part as well!

Here is an example:

using AlgebraicPetri
using Catlab.CategoricalAlgebra

# Define a petri net
sir_petri = PetriNet(3, ((1, 2), (2, 2)), (2, 3))

# Delete transitions 1 and 2
cascading_rem_parts!(sir_petri, :T, [1,2])

# Delete state 1
cascading_rem_part!(sir_petri, :S, 1)

from algebraicpetri.jl.

jpfairbanks avatar jpfairbanks commented on June 16, 2024

You can use rem_parts! from the Catlab.CategoricalAlgebra module to delete stuff. Comparing models with homomorphisms from Catlab is also productive. That will give you all the Petri net Homomorphisms between your two models. To compare models you probably actually want to compute a maximumal common submodel, which is a feature that we don't support quite yet.

from algebraicpetri.jl.

anandijain avatar anandijain commented on June 16, 2024

thanks james! ill play around with that. it seems like something like add_inputs! that could have a wrapper function around rem_parts for AlgebraicPetri.

i have been thinking about writing a library that has some syntax for defining and applying rules to graphs (or maybe categories?), which could easily act on petri nets (i think).

for example, the insert_before rule would be {{xs__, y}} -> {{xs, z}, {z, y}} which would match all inneighbors(y), plug them into a new vertex z, then connect z to y, leaving outneighbors(y) unchanged.

then i'd apply_rule(g, rule, vertex) or something to attempt a match + apply on a specific vertex, or apply_rule(g, rule) and apply on all vertices.

one extension of this that would be particularly useful is predicated rules like {{y, xs__}} -> {{y, xs/;P1}, {y, z}, {z, xs/;P2}}
which would allow me to wire based on properties of the matched vertices.

this would allow me to easily describe common model modifications that i may want (ie splitting infected to exposed and infected)

im coming from Graphs.jl, but i get the sense that catlab is the right way to define and express this.

from algebraicpetri.jl.

jpfairbanks avatar jpfairbanks commented on June 16, 2024

You should look at AlgebraicRewriting.jl. @kris-brown and I have a paper about rewriting on generic combinatorial datastructures that is based on some Graph Transformation literature.

from algebraicpetri.jl.

slwu89 avatar slwu89 commented on June 16, 2024

@anandijain you might also find https://github.com/AlgebraicJulia/Structured-Epidemic-Modeling useful, which contains the examples from the paper https://royalsocietypublishing.org/doi/10.1098/rsta.2021.0309. You can build up complex Petri nets from smaller "atomic" building blocks that represent simpler dynamics (e.g. recovery, death, infection).

from algebraicpetri.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.