Options

Petri net programming

The network theory course, available in this book, focuses a lot of attention on stochastic Petri nets that are weakly reversible and have deficiency zero. These are the boring ones: both the rate equation and the master equation have well-behaved stable equilibrium solutions, and any solution approaches one of these equilibria.

Of course, mathematicians are interested in boring situations because we can understand them in detail, and learn to distinguish between the boring situations and the interesting situations.

Since people like David Tanzer and Ken Webb are writing programs that simulate stochastic Petri nets, I think it would be great to simulate some interesting ones.

Personally I believe that the rate equation will be a better starting point for understanding these examples than the master equation. The rate equation is easily simulated in a discrete-time context: at each time there's a certain amount of each species (a floating point number), and at each time step we increment or decrement that amount in a straightforward way. I can make this a lot more precise if anyone wants: first I'll write down the rate equation, which is a differential equation, and then I'll discretize it using the Euler method.

However, it will already be somewhat interesting to study them using the programs you folks already have, as long as we can plot the number of things of each species.

Anyway, here are two examples. I'm writing them out as chemical reaction networks rather than stochastic Petri nets, since it takes less space... but it's the same thing.

Here's one from Feinberg's paper:

A <---> A + A

A + B <---> C <---> B

All the reactions are reversible. This has deficiency 1, and for some choices of the rate constants there are 3 equilibria in the same stoichiometric compatibility class, one of which is unstable. If you don't know the jargon, don't worry: the fun part is that we get an unstable equilibrium.

And here's one that approximately describes the Brusselator, a famous reaction with periodic behavior:

0 <---> A ---> B

A + A + B ---> A + A + A

The 0 means `nothing'. In this example the deficiency is 1. It has a periodic solution and an unstable equilibrium where all the species are present in a positive amount. So, the fun is periodic behavior: the amount of the various species cycle around as time passes.

Comments

  • 1.

    I now see that Ken Webb has programmed up lots of interesting reaction networks ($\simeq$ Petri nets) on his Azimuth page!

    If I were smart enough to run these programs, I would. I probably am, given enough time. But I'm a bit impatient, so my idea of running a program is clicking a big fat button that says RUN. I get a little put off when I read:

    To view the model source code (XML), with notes and instructions, click on the link. To run the model, select File –> Open in the Xholon Chameleon tool, and then drag the link to the Xholon Chameleon window.

    To run the simulation, read the model notes and instructions, especially starting with step (4).

    But I would gladly overcome this barrier if I thought that at the end of the day, I could put something on my website (or ideally the Azimuth Blog) that contained a big fat button that said RUN, which other idiots like myself could simply press to run the program.

    Comment Source:I now see that Ken Webb has programmed up lots of interesting reaction networks ($\simeq$ Petri nets) on his [[Ken Web|Azimuth page]]! <img src = "http://math.ucr.edu/home/baez/emoticons/love.gif" alt = ""/> If I were smart enough to run these programs, I would. I probably _am_, given enough time. But I'm a bit impatient, so my idea of running a program is clicking a big fat button that says **RUN**. I get a little put off when I read: > To view the model source code (XML), with notes and instructions, click on the link. To run the model, select File –> Open in the Xholon Chameleon tool, and then drag the link to the Xholon Chameleon window. > To run the simulation, read the model notes and instructions, especially starting with step (4). But I would gladly overcome this barrier if I thought that at the end of the day, I could put something on my website (or ideally the Azimuth Blog) that contained a big fat button that said **RUN**, which other idiots like myself could simply press to run the program.
  • 2.

    I understand John's comment about wanting a "big fat button that says RUN". I've been thinking about it and may be able to do something soon. But there are several reasons why it's not easy to do.

    I'm using Java which works online in a number of ways - as a Java applet, using Java JNLP technology, or running it on a server. The easiest approach is to take the desktop software I've written, put it on my server, and run it using JNLP which downloads everything and runs it on your computer. I'm gradually updating my base Java code so everything will run without the Java runtime system complaining about security violations. Even then you have to go through several steps.

    The software I write is intended to be collaborative and open-ended, and only incidentally may have a predefined beginning and end. It's a feature that you can start with a general-purpose core and drag in various independently-produced parts at runtime. For example, if I write a simple climate model that includes a Sun object, someone else can write some code to simulate the effect of sunspots. While running the software I could scan a library of parts, drag in someone else's sunspot module, and watch for sinusoidal activity in an output line graph. This already works, but it's hard to make it easy to use.

    I've tested some concepts with a Java applet that uses the same Java code I use with my Petri net examples. When you click on Start app, a bunch of people and cats start roaming randomly through an empty space. A menu gives you some predefined choices, or you can write your own structures and programming code in an editor on the page. It has Pause and Unpause buttons instead of a Run button. It's like a game, so you do have to read the brief (and somewhat cryptic) game and console help information. Things you can do include: build houses and cat traps, add new cat behaviors, add zombies, termites and other beasts, get the cats to draw graphs for you, and so on. There's more information at my Collaborative Apps site.

    For now I've just parked those Petri net and CRN examples as links from my Azimuth page. They're mostly learning exercises for me, and I've added some cryptic documentation on how to run them, mostly for my own benefit. When I have time I would like to find the best way to make them more accessible to other people.

    Comment Source:I understand John's comment about wanting a "big fat button that says RUN". I've been thinking about it and may be able to do something soon. But there are several reasons why it's not easy to do. I'm using Java which works online in a number of ways - as a Java applet, using Java JNLP technology, or running it on a server. The easiest approach is to take the desktop software I've written, put it on my server, and run it using JNLP which downloads everything and runs it on your computer. I'm gradually updating my base Java code so everything will run without the Java runtime system complaining about security violations. Even then you have to go through several steps. The software I write is intended to be collaborative and open-ended, and only incidentally may have a predefined beginning and end. It's a feature that you can start with a general-purpose core and drag in various independently-produced parts at runtime. For example, if I write a simple climate model that includes a Sun object, someone else can write some code to simulate the effect of sunspots. While running the software I could scan a library of parts, drag in someone else's sunspot module, and watch for sinusoidal activity in an output line graph. This already works, but it's hard to make it easy to use. I've tested some concepts with a [Java applet](http://www.primordion.com/Xholon/pulpcore/Bestiary/index.html) that uses the same Java code I use with my Petri net examples. When you click on _Start app_, a bunch of people and cats start roaming randomly through an empty space. A menu gives you some predefined choices, or you can write your own structures and programming code in an editor on the page. It has Pause and Unpause buttons instead of a Run button. It's like a game, so you do have to read the brief (and somewhat cryptic) game and console help information. Things you can do include: build houses and cat traps, add new cat behaviors, add zombies, termites and other beasts, get the cats to draw graphs for you, and so on. There's more information at my [Collaborative Apps](http://primordion.com/collabapp/) site. For now I've just parked those [Petri net and CRN examples](http://www.azimuthproject.org/azimuth/show/Ken+Webb) as links from my Azimuth page. They're mostly learning exercises for me, and I've added some cryptic documentation on how to run them, mostly for my own benefit. When I have time I would like to find the best way to make them more accessible to other people.
  • 3.

    One solution for running code would be to use the Azimuth web server in conjunction with custom HTML pages. This would work for Java, Python and other languages, for applications that straight-forwardly turn inputs into outputs.

    This could for example be used with the Blog - connections: Petri nets and beyond (part 1) article I'm writing. The server would be given the XML specification of the model, and would return a line graph, or the model in Python format, or the model in PNML format, or the model in SBML format, or whatever.

    For Dave Tanzer's python tool, the server could be given a Petri net in Python format, and the Python program would return the generated data, or a line graph.

    Comment Source:One solution for running code would be to use the [Azimuth web server](http://forum.azimuthproject.org/discussion/1020/2/an-azimuth-web-server/#Item_15) in conjunction with custom HTML pages. This would work for Java, Python and other languages, for applications that straight-forwardly turn inputs into outputs. This could for example be used with the [Blog - connections: Petri nets and beyond (part 1)](http://www.azimuthproject.org/azimuth/show/Blog+-+connections%3A+Petri+nets+and+beyond+%28part+1%29) article I'm writing. The server would be given the XML specification of the model, and would return a line graph, or the model in Python format, or the model in PNML format, or the model in SBML format, or whatever. For [Dave Tanzer's python tool](http://johncarlosbaez.wordpress.com/2012/10/01/petri-net-programming/), the server could be given a Petri net in Python format, and the Python program would return the generated data, or a line graph.
  • 4.
    edited October 2012

    That's great Ken. With John's spec for an Azimuth web server I think there might be some concensus that we want to produce interactive models on the Azimuth blog written in any of several languages.

    I'd be very pleased if we can get any of your models to run on the prototype.

    Atm I'm working on the glue for Html, JS, Snap and Haskell FFI to call some Fortran code. I hope to start writing some tests in a week or so.

    I need to chose some canonical Azimuth set of javascript libraries. For Allan, Glyn and Tim's bistablity javascript code we followed Allan and chose jxgraph for the sliders.

    I've been using jquery a bit; it's very popular but I have no preferences. Do you have any requirements or preferences for any javascript libs you might use?

    Wrt UI stuff (which I abhor) I'm just playing with Blaze-Html which generates Html pages programmatically.

    Here's the template for an example index.html page.

     numbers :: Int -> Html 
     numbers n = docTypeHtml $ do>     H.head $ do
        H.title "Natural numbers"
       body $ do
         p "A list of natural numbers:"
         ul $ forM_ [1 .. n] (li . toHtml)
    

    Glyn and I have been working on the assumption that we'll use programatically-generated JSON, which is what the Snap web server tends to use (althought it's a convenience not a mandate).

    Comment Source:That's great Ken. With John's spec for an Azimuth web server I think there might be some concensus that we want to produce interactive models on the Azimuth blog written in any of several languages. I'd be very pleased if we can get any of your models to run on the prototype. Atm I'm working on the glue for Html, JS, Snap and Haskell [FFI]() to call some Fortran code. I hope to start writing some tests in a week or so. I need to chose some canonical Azimuth set of javascript libraries. For Allan, Glyn and Tim's bistablity javascript code we followed Allan and chose jxgraph for the sliders. I've been using jquery a bit; it's very popular but I have no preferences. Do you have any requirements or preferences for any javascript libs you might use? Wrt UI stuff (which I abhor) I'm just playing with [Blaze-Html](http://jaspervdj.be/blaze/tutorial.html) which generates Html pages programmatically. Here's the template for an example index.html page. numbers :: Int -> Html numbers n = docTypeHtml $ do> H.head $ do H.title "Natural numbers" body $ do p "A list of natural numbers:" ul $ forM_ [1 .. n] (li . toHtml) Glyn and I have been working on the assumption that we'll use programatically-generated JSON, which is what the Snap web server tends to use (althought it's a convenience not a mandate).
Sign In or Register to comment.