\documentclass[12pt,titlepage]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{color}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{xparse}
\usepackage{hyperref}
%----Macros----------
%
% Unresolved issues:
%
% \righttoleftarrow
% \lefttorightarrow
%
% \color{} with HTML colorspec
% \bgcolor
% \array with options (without options, it's equivalent to the matrix environment)
% Of the standard HTML named colors, white, black, red, green, blue and yellow
% are predefined in the color package. Here are the rest.
\definecolor{aqua}{rgb}{0, 1.0, 1.0}
\definecolor{fuschia}{rgb}{1.0, 0, 1.0}
\definecolor{gray}{rgb}{0.502, 0.502, 0.502}
\definecolor{lime}{rgb}{0, 1.0, 0}
\definecolor{maroon}{rgb}{0.502, 0, 0}
\definecolor{navy}{rgb}{0, 0, 0.502}
\definecolor{olive}{rgb}{0.502, 0.502, 0}
\definecolor{purple}{rgb}{0.502, 0, 0.502}
\definecolor{silver}{rgb}{0.753, 0.753, 0.753}
\definecolor{teal}{rgb}{0, 0.502, 0.502}
% Because of conflicts, \space and \mathop are converted to
% \itexspace and \operatorname during preprocessing.
% itex: \space{ht}{dp}{wd}
%
% Height and baseline depth measurements are in units of tenths of an ex while
% the width is measured in tenths of an em.
\makeatletter
\newdimen\itex@wd%
\newdimen\itex@dp%
\newdimen\itex@thd%
\def\itexspace#1#2#3{\itex@wd=#3em%
\itex@wd=0.1\itex@wd%
\itex@dp=#2ex%
\itex@dp=0.1\itex@dp%
\itex@thd=#1ex%
\itex@thd=0.1\itex@thd%
\advance\itex@thd\the\itex@dp%
\makebox[\the\itex@wd]{\rule[-\the\itex@dp]{0cm}{\the\itex@thd}}}
\makeatother
% \tensor and \multiscript
\makeatletter
\newif\if@sup
\newtoks\@sups
\def\append@sup#1{\edef\act{\noexpand\@sups={\the\@sups #1}}\act}%
\def\reset@sup{\@supfalse\@sups={}}%
\def\mk@scripts#1#2{\if #2/ \if@sup ^{\the\@sups}\fi \else%
\ifx #1_ \if@sup ^{\the\@sups}\reset@sup \fi {}_{#2}%
\else \append@sup#2 \@suptrue \fi%
\expandafter\mk@scripts\fi}
\def\tensor#1#2{\reset@sup#1\mk@scripts#2_/}
\def\multiscripts#1#2#3{\reset@sup{}\mk@scripts#1_/#2%
\reset@sup\mk@scripts#3_/}
\makeatother
% \slash
\makeatletter
\newbox\slashbox \setbox\slashbox=\hbox{$/$}
\def\itex@pslash#1{\setbox\@tempboxa=\hbox{$#1$}
\@tempdima=0.5\wd\slashbox \advance\@tempdima 0.5\wd\@tempboxa
\copy\slashbox \kern-\@tempdima \box\@tempboxa}
\def\slash{\protect\itex@pslash}
\makeatother
% math-mode versions of \rlap, etc
% from Alexander Perlis, "A complement to \smash, \llap, and lap"
% http://math.arizona.edu/~aprl/publications/mathclap/
\def\clap#1{\hbox to 0pt{\hss#1\hss}}
\def\mathllap{\mathpalette\mathllapinternal}
\def\mathrlap{\mathpalette\mathrlapinternal}
\def\mathclap{\mathpalette\mathclapinternal}
\def\mathllapinternal#1#2{\llap{$\mathsurround=0pt#1{#2}$}}
\def\mathrlapinternal#1#2{\rlap{$\mathsurround=0pt#1{#2}$}}
\def\mathclapinternal#1#2{\clap{$\mathsurround=0pt#1{#2}$}}
% Renames \sqrt as \oldsqrt and redefine root to result in \sqrt[#1]{#2}
\let\oldroot\root
\def\root#1#2{\oldroot #1 \of{#2}}
\renewcommand{\sqrt}[2][]{\oldroot #1 \of{#2}}
% Manually declare the txfonts symbolsC font
\DeclareSymbolFont{symbolsC}{U}{txsyc}{m}{n}
\SetSymbolFont{symbolsC}{bold}{U}{txsyc}{bx}{n}
\DeclareFontSubstitution{U}{txsyc}{m}{n}
% Manually declare the stmaryrd font
\DeclareSymbolFont{stmry}{U}{stmry}{m}{n}
\SetSymbolFont{stmry}{bold}{U}{stmry}{b}{n}
% Manually declare the MnSymbolE font
\DeclareFontFamily{OMX}{MnSymbolE}{}
\DeclareSymbolFont{mnomx}{OMX}{MnSymbolE}{m}{n}
\SetSymbolFont{mnomx}{bold}{OMX}{MnSymbolE}{b}{n}
\DeclareFontShape{OMX}{MnSymbolE}{m}{n}{
<-6> MnSymbolE5
<6-7> MnSymbolE6
<7-8> MnSymbolE7
<8-9> MnSymbolE8
<9-10> MnSymbolE9
<10-12> MnSymbolE10
<12-> MnSymbolE12}{}
% Declare specific arrows from txfonts without loading the full package
\makeatletter
\def\re@DeclareMathSymbol#1#2#3#4{%
\let#1=\undefined
\DeclareMathSymbol{#1}{#2}{#3}{#4}}
\re@DeclareMathSymbol{\neArrow}{\mathrel}{symbolsC}{116}
\re@DeclareMathSymbol{\neArr}{\mathrel}{symbolsC}{116}
\re@DeclareMathSymbol{\seArrow}{\mathrel}{symbolsC}{117}
\re@DeclareMathSymbol{\seArr}{\mathrel}{symbolsC}{117}
\re@DeclareMathSymbol{\nwArrow}{\mathrel}{symbolsC}{118}
\re@DeclareMathSymbol{\nwArr}{\mathrel}{symbolsC}{118}
\re@DeclareMathSymbol{\swArrow}{\mathrel}{symbolsC}{119}
\re@DeclareMathSymbol{\swArr}{\mathrel}{symbolsC}{119}
\re@DeclareMathSymbol{\nequiv}{\mathrel}{symbolsC}{46}
\re@DeclareMathSymbol{\Perp}{\mathrel}{symbolsC}{121}
\re@DeclareMathSymbol{\Vbar}{\mathrel}{symbolsC}{121}
\re@DeclareMathSymbol{\sslash}{\mathrel}{stmry}{12}
\re@DeclareMathSymbol{\bigsqcap}{\mathop}{stmry}{"64}
\re@DeclareMathSymbol{\biginterleave}{\mathop}{stmry}{"6}
\re@DeclareMathSymbol{\invamp}{\mathrel}{symbolsC}{77}
\re@DeclareMathSymbol{\parr}{\mathrel}{symbolsC}{77}
\makeatother
% \llangle, \rrangle, \lmoustache and \rmoustache from MnSymbolE
\makeatletter
\def\Decl@Mn@Delim#1#2#3#4{%
\if\relax\noexpand#1%
\let#1\undefined
\fi
\DeclareMathDelimiter{#1}{#2}{#3}{#4}{#3}{#4}}
\def\Decl@Mn@Open#1#2#3{\Decl@Mn@Delim{#1}{\mathopen}{#2}{#3}}
\def\Decl@Mn@Close#1#2#3{\Decl@Mn@Delim{#1}{\mathclose}{#2}{#3}}
\Decl@Mn@Open{\llangle}{mnomx}{'164}
\Decl@Mn@Close{\rrangle}{mnomx}{'171}
\Decl@Mn@Open{\lmoustache}{mnomx}{'245}
\Decl@Mn@Close{\rmoustache}{mnomx}{'244}
\makeatother
% Widecheck
\makeatletter
\DeclareRobustCommand\widecheck[1]{{\mathpalette\@widecheck{#1}}}
\def\@widecheck#1#2{%
\setbox\z@\hbox{\m@th$#1#2$}%
\setbox\tw@\hbox{\m@th$#1%
\widehat{%
\vrule\@width\z@\@height\ht\z@
\vrule\@height\z@\@width\wd\z@}$}%
\dp\tw@-\ht\z@
\@tempdima\ht\z@ \advance\@tempdima2\ht\tw@ \divide\@tempdima\thr@@
\setbox\tw@\hbox{%
\raise\@tempdima\hbox{\scalebox{1}[-1]{\lower\@tempdima\box
\tw@}}}%
{\ooalign{\box\tw@ \cr \box\z@}}}
\makeatother
% \mathraisebox{voffset}[height][depth]{something}
\makeatletter
\NewDocumentCommand\mathraisebox{moom}{%
\IfNoValueTF{#2}{\def\@temp##1##2{\raisebox{#1}{$\m@th##1##2$}}}{%
\IfNoValueTF{#3}{\def\@temp##1##2{\raisebox{#1}[#2]{$\m@th##1##2$}}%
}{\def\@temp##1##2{\raisebox{#1}[#2][#3]{$\m@th##1##2$}}}}%
\mathpalette\@temp{#4}}
\makeatletter
% udots (taken from yhmath)
\makeatletter
\def\udots{\mathinner{\mkern2mu\raise\p@\hbox{.}
\mkern2mu\raise4\p@\hbox{.}\mkern1mu
\raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern1mu}}
\makeatother
%% Fix array
\newcommand{\itexarray}[1]{\begin{matrix}#1\end{matrix}}
%% \itexnum is a noop
\newcommand{\itexnum}[1]{#1}
%% Renaming existing commands
\newcommand{\underoverset}[3]{\underset{#1}{\overset{#2}{#3}}}
\newcommand{\widevec}{\overrightarrow}
\newcommand{\darr}{\downarrow}
\newcommand{\nearr}{\nearrow}
\newcommand{\nwarr}{\nwarrow}
\newcommand{\searr}{\searrow}
\newcommand{\swarr}{\swarrow}
\newcommand{\curvearrowbotright}{\curvearrowright}
\newcommand{\uparr}{\uparrow}
\newcommand{\downuparrow}{\updownarrow}
\newcommand{\duparr}{\updownarrow}
\newcommand{\updarr}{\updownarrow}
\newcommand{\gt}{>}
\newcommand{\lt}{<}
\newcommand{\map}{\mapsto}
\newcommand{\embedsin}{\hookrightarrow}
\newcommand{\Alpha}{A}
\newcommand{\Beta}{B}
\newcommand{\Zeta}{Z}
\newcommand{\Eta}{H}
\newcommand{\Iota}{I}
\newcommand{\Kappa}{K}
\newcommand{\Mu}{M}
\newcommand{\Nu}{N}
\newcommand{\Rho}{P}
\newcommand{\Tau}{T}
\newcommand{\Upsi}{\Upsilon}
\newcommand{\omicron}{o}
\newcommand{\lang}{\langle}
\newcommand{\rang}{\rangle}
\newcommand{\Union}{\bigcup}
\newcommand{\Intersection}{\bigcap}
\newcommand{\Oplus}{\bigoplus}
\newcommand{\Otimes}{\bigotimes}
\newcommand{\Wedge}{\bigwedge}
\newcommand{\Vee}{\bigvee}
\newcommand{\coproduct}{\coprod}
\newcommand{\product}{\prod}
\newcommand{\closure}{\overline}
\newcommand{\integral}{\int}
\newcommand{\doubleintegral}{\iint}
\newcommand{\tripleintegral}{\iiint}
\newcommand{\quadrupleintegral}{\iiiint}
\newcommand{\conint}{\oint}
\newcommand{\contourintegral}{\oint}
\newcommand{\infinity}{\infty}
\newcommand{\bottom}{\bot}
\newcommand{\minusb}{\boxminus}
\newcommand{\plusb}{\boxplus}
\newcommand{\timesb}{\boxtimes}
\newcommand{\intersection}{\cap}
\newcommand{\union}{\cup}
\newcommand{\Del}{\nabla}
\newcommand{\odash}{\circleddash}
\newcommand{\negspace}{\!}
\newcommand{\widebar}{\overline}
\newcommand{\textsize}{\normalsize}
\renewcommand{\scriptsize}{\scriptstyle}
\newcommand{\scriptscriptsize}{\scriptscriptstyle}
\newcommand{\mathfr}{\mathfrak}
\newcommand{\statusline}[2]{#2}
\newcommand{\tooltip}[2]{#2}
\newcommand{\toggle}[2]{#2}
% Theorem Environments
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\newtheorem{prop}{Proposition}
\newtheorem{cor}{Corollary}
\newtheorem*{utheorem}{Theorem}
\newtheorem*{ulemma}{Lemma}
\newtheorem*{uprop}{Proposition}
\newtheorem*{ucor}{Corollary}
\theoremstyle{definition}
\newtheorem{defn}{Definition}
\newtheorem{example}{Example}
\newtheorem*{udefn}{Definition}
\newtheorem*{uexample}{Example}
\theoremstyle{remark}
\newtheorem{remark}{Remark}
\newtheorem{note}{Note}
\newtheorem*{uremark}{Remark}
\newtheorem*{unote}{Note}
%-------------------------------------------------------------------
\begin{document}
%-------------------------------------------------------------------
\section*{Blog - connections: Petri nets and beyond (part 1)}
[[!redirects Blog: connections: Petri nets and beyond (part 1)]]
This page is a [[Blog articles in progress|blog article in progress]], written by [[Ken Webb]]. To see discussions of this article while it is being written, go to the \href{http://forum.azimuthproject.org/discussion/1042/blog-connections-petri-nets-systems-biology-and-beyond}{Azimuth Forum}.
\emph{guest post by \textbf{[[Ken Webb]]}}
I like knowing how things are connected. I hate when I find a new concept, sense that concept is connected to something I already know, but have no idea how to confirm my intuition. The people and writings at the Azimuth Project have introduced me to multiple new things. In this blog I explore one of these, Petri nets, and how they can help build connections to some of the islands in my knowledge.
Unlike many people here, I'm not good at math. Instead I depend on my software development skills. My approach in this blog is to build a simple executable Petri net with software, and then convert it to other formats that can then be processed using tools from other domains. The Petri net example can be viewed as a very non-mathematical \href{http://en.wikipedia.org/wiki/Mind_map}{mind map}, processed by (at least) several Petri net tools, executed by various tools as a system of differential equations, displayed as a \href{http://en.wikipedia.org/wiki/Unified_Modeling_Language}{Unified Modeling Language} (UML) class diagram and as a UML sequence diagram, converted into \href{http://en.wikipedia.org/wiki/SBML}{System Biology Markup Language} (SBML) so it can be processed by numerous other tools from the biology community, and run in a rectangular grid as an \href{http://press.princeton.edu/chapters/s9639.pdf}{agent based model} (ABM). But this initial article restricts itself to building a bridge from Petri nets to differential equations.
Another motivating factor is that I've looked for simple climate models for a long time but haven't found anything satisfactory either online or in books or periodicals. Many use some flavor of differential equations, and I don't know how to build these from scratch and/or have no access to the source code. Much of the information available online seems contradictory or incomplete when you actually get down to trying to put it into a programming language. By simple, I mean something that a generally well-educated person can understand, can interact with, and can even help to build. I've made various attempts to build my own models (see examples \href{http://www.primordion.com/Xholon/jnlp/}{here toward the end of the page} and \href{http://www.primordion.com/Xholon/wb/openwb.php?q=2430118&f=gist.github.com/raw/}{here} ) based on what I've found, but I've been lacking a solid base to start from. Although Petri nets aren't enough, they do appear to provide the base I've been looking for. The rest of this article is about firming up the base in preparation for future climate modeling.
I want to start with a \textbf{qualitative} model that can readily be transformed into something more and more \textbf{quantitative}. I want to think about the \emph{things} in the model before having to consider the actual \emph{numbers} of things. For example, the Simple Climate Model in \href{http://www.azimuthproject.org/azimuth/show/Experiments+in+Petri+nets+-+Results+from+two+different+tools#simple_climate_model_4}{this set of Petri net experiments} is strictly qualitative. All arc weights are 1, so all it does is demonstrate the sorts of things that get moved around. And yet it does convey some of the basic concepts, and it can be extended to be more quantitatively accurate.
\hypertarget{petri_nets_and_reaction_networks}{}\subsubsection*{{Petri nets and reaction networks}}\label{petri_nets_and_reaction_networks}
Petri nets have been well described elsewhere at the Azimuth Project, such as \href{http://www.azimuthproject.org/azimuth/show/Petri+net}{here}, \href{http://math.ucr.edu/home/baez/networks/}{here}, and \href{http://johncarlosbaez.wordpress.com/2012/10/01/petri-net-programming/}{here}. Basically, a Petri net consists of a set of nodes and a set of edges that connect the nodes. The nodes are of two types, \textbf{place} nodes (sometimes called states) and \textbf{transition} nodes. An edge is called an \textbf{arc}. Each place node contains zero or more tokens. Places only connect to transitions, and transitions only connect to places. Transitions act on the tokens in the places they connect to, by moving tokens from input places to output places.
In the following Petri net diagram, the filled rectangles are transitions, the circles are places, and the numbers inside the circles are token quantities. Each transition and place has a unique label. Each arc has an arrow head that shows if it's an input arc (from a place to a transition) or an output arc (from a transition to a place). The arcs are labeled with numbers called weights (1 or 2 in the diagram).
Xholon (a tool we'll get to soon) \href{http://xholon.cvs.sourceforge.net/viewvc/xholon/xholon/src/org/primordion/xholon/io/ef/Xholon2Pnml.java?view=markup}{wrote this out} as a Petri Net Markup Language (PNML) file. The PIPE2 Petri net tool displays it as the following, after some manual moving around of the nodes.
Diagram created by \href{http://pipe2.sourceforge.net/}{PIPE2} from \href{https://gist.github.com/raw/3377668/ReactionNetworkSystem_42_1345649106542_pnml.xml}{Xholon data}.
Reaction networks were independently developed, but are almost exactly the same as Petri nets. These are defined and described in \href{http://math.ucr.edu/home/baez/networks/networks_21.html}{Part 21} of John Baez' network theory course, where they are given a more mathematically precise treatment. Part 21 uses the same Feinberg reaction network that we're using as an example in this article. A reaction network uses the terminology \emph{species} and \emph{reaction} rather than place and transition. A reaction involves two or more of the arcs in the Petri net. An excellent early source of information on reaction networks are \href{http://www.chbmeng.ohio-state.edu/~feinberg/LecturesOnReactionNetworks/}{Martin Feinberg's lectures} where they are called chemical reaction networks (CRN). The following diagram shows Feinberg's first example reaction network, which is the same as the Petri net above. The reaction labelled ξ is the same as transition BE\_AC in the Petri net. It converts one unit of B and one unit of E into one unit of A and one unit of C. The combinations of species B+E and A+C are called \emph{complexes}. In this example, B+E is a \emph{source} complex, and A+C is a \emph{target} complex.
\href{http://www.primordion.com/Xholon/}{Xholon} is a general-purpose Java-based modeling and simulation tool I've written. After being inspired by glowing accounts of Petri nets and reaction networks at the Azimuth Project, I added a \href{http://xholon.cvs.sourceforge.net/viewvc/xholon/xholon/src/org/primordion/xholon/mech/petrinet/}{Petri net and reaction network plug-in} to Xholon. Xholon models are typically specified as \href{http://en.wikipedia.org/wiki/XML}{XML} hierarchical structures, with additional links between nodes. Xholon is pronounced the same as , a very relevant concept from philosophy.
The following is an example of a Petri net specified in Xholon XML format. It's an implementation of the Feinberg Petri net and reaction network described above. There are five places (A B C D E) each with a specified initial number of tokens. There are six transitions (A\_BB BB\_A AC\_D D\_AC D\_BE BE\_AC), each with a displayable symbol (the Greek letters in the reaction network). Each transition has one or more input arcs and output arcs. Each arc has a weight and connects to one place node. The connectors identify the place using an \href{http://www.w3schools.com/xpath/default.asp}{XPath} expression, which provides directions on how to get from the InputArc node to the place node. For example, \emph{ancestor::PetriNet/Places/A} means locate an ancestor node called \emph{PetriNet}, locate a child of that node called \emph{Places}, and then a child of that node called \emph{A}.
\begin{verbatim}
**
****
****
****\end{verbatim}
At this point we have three descriptions of the same thing - a Petri net diagram, a reaction network diagram, and an XML structure.
\hypertarget{kinetics}{}\subsubsection*{{Kinetics}}\label{kinetics}
Note the third line down in the XML:
\begin{verbatim}\end{verbatim}
The XML attribute \emph{kineticsType=``1''} means that the Petri net obeys the traditional rules of a place/transition net. It has \emph{kinetics} type 1. Each time step, each transtion checks its input arcs. If all input arcs have a weight that's greater than 0.0, then the transition fires. When it fires, it decreases the number of tokens in each input place by the amount specified in the corresponding input arc, and it increases the number of tokens in each output place by the amount specified in the corresponding output arc. For example, transition BB\_A will decrease the number of tokens in place B by 2, and will increase the number in A by 1 token.
The XML attribute \emph{p=``1.0''} means that the Petri net does the transitions with 100\% probability. If p=0.0 then nothing will happen. If p=0.5 then the transitions will fire an average of 50\% of the time steps. The same probability p can be set for all transitions as is done here, or each transition can have its own p value.
Xholon also randomizes the firing order of transitions each time step. So even if all transitions fire each time step, AC\_D may fire first in time step 23 while AA\_B may fire first in time step 24.
With kineticsType=1 and p=1.0, the Xholon simulation of the Petri net generates a line graph that looks similar to the following.
With kineticsType=1 and p=0.1666666667, the line graph shows a lot more variabililty. With this p value, there is an average 1 in 6 probability that each of the 6 transitions will fire each time step. So on average only one transition will fire each time step.
Xholon can \href{http://xholon.cvs.sourceforge.net/viewvc/xholon/xholon/src/org/primordion/xholon/mech/petrinet/AnalysisPetriNet.java?revision=1.4&view=markup}{transform the model into Python syntax}, so it can be executed by \href{http://johncarlosbaez.wordpress.com/2012/10/01/petri-net-programming/}{David Tanzer's Petri net software}.
\begin{verbatim}# To run this Petri net (in Ubuntu Linux):
# (1) Save this python script to a .py file, for example pn_test.py .
# (2) Ensure that David Tanzer's petri1.py is in the same directory as this script.
# (3) Open a terminal window.
# (4) Run:
# python pn_test.py
# (5) Or run it while redirecting the output to a CSV file:
# python pn_test.py > pn_test.csv
from petri1 import *
# Petri net - Feinberg Lectures 1.1
A_BB = ("A_BB", [["A"]], [["B",2.0]])
BB_A = ("BB_A", [["B",2.0]], [["A"]])
AC_D = ("AC_D", [["A"], ["C"]], [["D"]])
D_AC = ("D_AC", [["D"]], [["A"], ["C"]])
D_BE = ("D_BE", [["D"]], [["B"], ["E"]])
BE_AC = ("BE_AC", [["B"], ["E"]], [["A"], ["C"]])
petriNet = PetriNet(
["A", "B", "C", "D", "E"], # states
[A_BB, BB_A, AC_D, D_AC, D_BE, BE_AC] # transitions
)
initialLabelling = {"A":140.0, "B":180.0, "C":200.0, "D":25.0, "E":80.0}
steps = 1200
petriNet.RunSimulation(steps, initialLabelling)\end{verbatim}
Running the Python version of the Petri net, and using a different graphing tool, produces a line graph similar to the following. It looks broadly similar to the Xholon line graph with p=0.1666666667 .
A second type of kinetics is called \emph{Mass Action}, and it's typically used with reaction networks. If \emph{kineticsType=``2''} in the XML model, then the Xholon simulation uses mass action kinetics rather than the traditional Petri net place/transition rules. Note that each transition in the XML has a \emph{k} attribute, for example:
\begin{verbatim}\end{verbatim}
The k value is a rate constant that helps determine the rate at which the transition transforms its inputs into its outputs each time step. For example, transition A\_BB runs with a rate constant of 0.0039. Also, each transition fires at a rate that is proportional to the product of its input concentrations. So, to determine the current rate, we multiply the rate constant by the product of the current amounts in all of its input places. We then remove that number of tokens from each of the input places, and add that number of tokens to each of the output places. When a Petri net or reaction network uses rate constants with the transitions, then we refer to it as a \emph{stochastic Petri net} or \emph{stochastic reaction network}. Simulating this model using mass action kinetics, produces a line graph that should be identical to the following.
Why use a k value of 0.0039? Because this is a made-up system, there's no way to determine experimentally what it's value should be. But if I use higher values, then the lines in the graph start to oscillate more and more, or go shooting off to positive or negative infinity. There's no room to explain why that would happen, but perhaps in another blog. It has to do with calculus and finding the right small interval of time to use as a time step.
\hypertarget{from_petri_nets_to_differential_equations}{}\subsubsection*{{From Petri nets to differential equations}}\label{from_petri_nets_to_differential_equations}
Petri nets turn out to be a great starting point for modeling with other formalisms, including some I don't understand very well. For example, a stochastic Petri net (a Petri net where the transtions have rate constants) can be automatically transformed into a system of differential equations. Let's work through exactly what happens when we do this. If you don't know or remember what differential equations are, then think of the following steps as a recipe, or driving instructions (how to get from Petrnet Town to Diffeq City), or maybe as a mathemagical incantation. This is something you can do by hand.
\hypertarget{step_1}{}\paragraph*{{Step 1}}\label{step_1}
Write the name of each place (\textbf{A B C D E} in this model) on a separate line. Then write \textbf{d/dt~} in front of each name, and \textbf{~=~} after it. \textbf{d/dt~} means \emph{rate of change}, so \textbf{d/dt A} is the rate of change of the number of tokens in place A.
\begin{verbatim}d/dt A =
d/dt B =
d/dt C =
d/dt D =
d/dt E = \end{verbatim}
\hypertarget{step_2}{}\paragraph*{{Step 2}}\label{step_2}
For each place, look through all the transitions. When you find an input arc that involves that place, write \textbf{~-} at the end of the line. Write \textbf{~+} for an output arc. For example, \textbf{A} occurs five times in the six transtions, twice as an input and three times as an output. We say that \textbf{A} has five \emph{terms}.
\begin{verbatim}d/dt A = - + - + +
d/dt B = + - + -
d/dt C = - + +
d/dt D = + - -
d/dt E = + -\end{verbatim}
\hypertarget{step_3}{}\paragraph*{{Step 3}}\label{step_3}
Each transition has a rate constant (symbolized as the Greek letters \textbf{α β γ δ ε ξ} in this model). For each term, write the rate constant directly after the \textbf{-} or \textbf{+} symbol. Each rate constant may also be given a numeric value (0.0039 0.0038 0.0037 0.0036 0.0035 0.0034 in this model), but in this process we will use the symbol. If you hate having to write Greek symbols, then write \textbf{alpha beta gamma delta epsilon xi} instead, for example \textbf{d/dt E = +epsilon -xi}.
\begin{verbatim}d/dt A = -α +β -γ +δ +ξ
d/dt B = +α -β +ε -ξ
d/dt C = -γ +δ +ξ
d/dt D = +γ -δ -ε
d/dt E = +ε -ξ\end{verbatim}
\hypertarget{step_4}{}\paragraph*{{Step 4}}\label{step_4}
Each transition has zero or more input arcs, where each arc references a place. For each term, write the names of all the places referenced by input arcs for that transition. If there is just one input arc, write the name of its place after the rate constant symbol. If there are two or more input arcs, write the names of all the places. These will all be multiplied with each other, so it's OK to just write the single-character names of each place with no intervening spaces.
\begin{verbatim}d/dt A = -αA +βBB -γAC +δD +ξBE
d/dt B = +αA -βBB +εD -ξBE
d/dt C = -γAC +δD +ξBE
d/dt D = +γAC -δD -εD
d/dt E = +εD -ξBE\end{verbatim}
\hypertarget{step_5}{}\paragraph*{{Step 5}}\label{step_5}
If an input arc has a weight greater than 1, for example 2, then you can write it in one of two ways. For example, \textbf{BB} or \textbf{B{\tt \symbol{94}}2}, because B times B is the same as B to the power of 2 (B squared). The symbol \textbf{{\tt \symbol{94}}} is often used to mean \emph{to the power of}.
\begin{verbatim}d/dt A = -αA +βB^2 -γAC +δD +ξBE
d/dt B = +αA -βB^2 +εD -ξBE
d/dt C = -γAC +δD +ξBE
d/dt D = +γAC -δD -εD
d/dt E = +εD -ξBE\end{verbatim}
\hypertarget{step_6}{}\paragraph*{{Step 6}}\label{step_6}
This is probably the step that's the least intuitively obvious. I have problems with it. Any term that involves a transition where either the input arcs or output arcs have a weight greater than 1, may need a final adjustment. For example, if we're figuring out the rate of change of B, then any term involving a transition that involves multiple instances of B, will need an adjustment. There are two such terms. Once I really get this, I'll try to write it up in a more meaningful way. For now, the differential equation just works (I think) if we do things this way.
\begin{verbatim}d/dt A = -αA +βB^2 -γAC +δD +ξBE
d/dt B = +2αA -2βB^2 +εD -ξBE
d/dt C = -γAC +δD +ξBE
d/dt D = +γAC -δD -εD
d/dt E = +εD -ξBE\end{verbatim}
So. This is our system of differential equations. The process we've just worked through has been captured as an algorithm in Java, a popular programming language. To see the algorithm, look at the getDifferentialEquations() and getTerm() methods in the \href{http://xholon.cvs.sourceforge.net/viewvc/xholon/xholon/src/org/primordion/xholon/mech/petrinet/crn/AnalysisCRN.java?view=markup}{AnalysisCRN Java class}. Warning: If you're not a programmer, then this may be even scarier than thinking about differential equations for those of us not very math inclined.
What good are differential equations? A simple thing we can do is to format them so they look the way that mathematicians and others expect to see them when displayed on a web page (or in a book). Xholon automatically generated the following using a \LaTeX\xspace format, which the software on this page knows how to deal with.
\begin{displaymath}
\frac{d}{d t} A = -\alpha A +\beta B^2 -\gamma AC +\delta D +\xi BE
\end{displaymath}
\begin{displaymath}
\frac{d}{d t} B = +2\alpha A -2\beta B^2 +\epsilon D -\xi BE
\end{displaymath}
\begin{displaymath}
\frac{d}{d t} C = -\gamma AC +\delta D +\xi BE
\end{displaymath}
\begin{displaymath}
\frac{d}{d t} D = +\gamma AC -\delta D -\epsilon D
\end{displaymath}
\begin{displaymath}
\frac{d}{d t} E = +\epsilon D -\xi BE
\end{displaymath}
Many tools know how to carry out the calculations specified by a system of differential equations. For example, if I write the six differential equations in \href{https://raw.github.com/gist/3666649/ReactionNetworkSystem_0_1346797705635.sbml.m}{this format}, then I can give it to popular software programs such as \href{http://en.wikipedia.org/wiki/MATLAB}{\emph{Matlab}} and \href{http://www.gnu.org/software/octave/}{\emph{GNU Octave}} which will happily turn it into a nice chart showing how each place (A B C D E) changes over time. \emph{GNU Octave} is one of many open-source (free) programs that are compatible with the very successful \emph{Matlab} commercial product that's used in laboratories and universities around the world. The .m file was produced by first \href{http://xholon.cvs.sourceforge.net/viewvc/xholon/xholon/src/org/primordion/xholon/io/ef/Xholon2Sbml4PetriNets.java?view=markup}{transforming the stochastic Petri net} into a Systems Biology Markup Language (SBML) \href{https://raw.github.com/gist/3666649/ReactionNetworkSystem_0_1346797705635.sbml.xml}{formatted file}, and then using a \href{http://www.ebi.ac.uk/compneur-srv/sbml/converters/}{System Biology Format Converter project} (SBFC) tool to convert it to Octave .m format. All of these transformations are done automatically by software.
Diagram created by QtOctave, a GUI for Octave, from \href{https://gist.github.com/raw/3666649/ReactionNetworkSystem_0_1346797705635.sbml.m}{SBFC-generated content}. This line graph should be identical, or nearly so, with the line graph Xholon produced for mass action kinetics.
\hypertarget{run_the_petri_net_using_xholon}{}\subsubsection*{{Run the Petri net using Xholon}}\label{run_the_petri_net_using_xholon}
To run the Petri net (non-stochastic because \emph{kineticsType=``1''} meaning the k values won't be used) model using Xholon, you need Java 1.6 or higher installed on your computer. Click the Launch button.
Select File {\tt \symbol{62}} Open. Drill down to the Model {\tt \symbol{62}} CompositeStructureHierarchy {\tt \symbol{62}} chameleon node. Select the entire on this page (the large grey area). Drag it with your mouse so it's over the chameleon node, and then release the mouse button. Click Refresh. Click Start, and a few seconds later click Pause. Display the line graph by clicking on View {\tt \symbol{62}} xYChart.
The following figure shows some of the relevant features of the Xholon graphical user interface (GUI). The application is called \textbf{Xholon Chameleon} because initially it has only the \textbf{Chameleon} node (chameleon\_0), a chameleon being an animal that can morph into something different. Each node includes an id such as 0 or 41. The \textbf{File} menu at the top includes an Open option. When you drag the Xholon XML from this Azimuth page to the Chameleon node, the entire \textbf{ReactionNetworkSystem} is inserted into the application, as shown here. It has exactly the same structure as the XML. The \textbf{Start}, \textbf{Pause}, and \textbf{Refresh} control nodes are along the top of the GUI. A line graph is displayed if you click on the \textbf{Title:xYChart\_90} node.
All nodes have a context menu that appears when you right-click the node. The figure shows the context menu for the \textbf{AnalysisCRN} node. It includes a \textbf{Special} node-specific submenu that can show various things associated with a reaction network (CRN), for example it can \textbf{Show differential equations} as described in this article. The context menu includes many other useful options, although not all are available with the online version of Xholon. \textbf{Export}, in the context menu for the ReactionNetworkSystem node, will display the system in a variety of text formats including SBML, SBGN, PNML, UML, and mind map (Freemind). It writes the text to the \href{http://sourceforge.net/apps/mediawiki/xholon/index.php?title=Java_Console}{Java Console}. The Special context submenu for the \textbf{AnalysisPetriNet} node includes an option to write out the Petri net in Python format.
The bottom line of the GUI displays summary information about the currently-selected node. The \textbf{inputArc\_85} node of the BE\_AC transition has a reference to the B place node (labelled here as b\_49). This input arc has a weight of 1.0.
To see the Java programming code behind any node in the Xholon application, right-click the node, and select Search Engine {\tt \symbol{62}} Source Code . There are numerous other search engine options as well.
\hypertarget{conclusion}{}\subsubsection*{{Conclusion}}\label{conclusion}
This article has briefly explored Petri nets and reaction networks, which are essentially the same thing. Petri nets are useful on their own, but are also a well-defined relatively-simple starting point for understanding more complex approaches. We have seen how Petri nets can be automatically transformed into systems of differential equations, which, at least to me, are one of those more complex approaches. Future articles in this series will explore additional transformations beyond Petri nets.
category:blog
[[!redirects Connections Petri nets and beyond Part 1]]
\end{document}
**