A Petri net describes a system declaratively — places hold state, transitions change it, arcs define the rules. A DDM takes that description and encodes it directly as differential equations. We specify what the relationships are, not how to compute them. Conservation laws come along unchanged: the ODE is dM/dt = C·v(M), so any weighting of places y with y·C = 0 (a P-invariant) has d(y·M)/dt = y·C·v = 0, and the total it weighs stays fixed for the whole run. Capacity limits come along only when they are modeled as a place the transitions draw from, the way the knapsack's capacity is; a capacity declared on a place is not in the equations at all (more on that below).
Each transition gets a flux from mass-action kinetics, and each place changes by the arc-weighted sum of the fluxes around it:
flux(T) = k × M(P1) × M(P2) × ... one factor per input place
dM(p)/dt = Σ w(T→p) × flux(T) − Σ w(p→T) × flux(T)
k is the transition's rate constant, M(P) the marking of an input place, w an arc weight. Each input place enters the flux once, to the first power, whatever its arc weight; the weight only scales how much is drained and produced. That is the law in go-pflow's solver/ode.go (buildVecODEFunction) and in pflow.xyz's browser solver, petri-solver.js, and both set a transition's flux to zero whenever one of its inputs is at or below zero. Textbook chemical mass action raises each concentration to its stoichiometric coefficient instead, so 2A → B would be quadratic in A; the two agree only when every input arc has weight 1, which is the case the figure draws. Tokens become concentrations, firing becomes flux.
| Discrete Simulation | ODE Simulation |
|---|---|
| Track individual events | Track population-level dynamics |
| "Patient 1 arrives at 8:15" | "Patients arrive at rate 10/hour" |
| Slow: must process every event | Fast: solves continuous equations |
| Scales with event count | Scales with equation count |
The ODE has one equation per place, so its size doesn't depend on whether a place holds 10 tokens or 10,000. The equations are differentiable in the rate constants, and go-pflow uses that: its learn package carries forward sensitivities alongside the solve (learn/sensitivity.go) and fits rates to data by gradient (learn/gradopt.go). The tests check those sensitivities against the closed form on a one-place decay and the loss gradients against central finite differences on decay and SIR (learn/sensitivity_test.go). Equilibrium is found by integrating until the marking stops moving (SolveUntilEquilibrium in solver/equilibrium.go). We have no stability analysis to point to: nothing in go-pflow linearizes the ODE around its equilibrium.
pflow.xyz runs DDM in the browser. Draw a net, set initial markings and rate constants, run ODE analysis, and watch token flows evolve. The model exports as JSON-LD.
The knapsack model is the worked case. Each item is a place holding one token, a shared capacity place starts at 15, and each take transition consumes its item and w units of capacity and produces v units of value. Under the first-power rate law every item obeys the same equation, so the relaxation takes every item in one common fraction — 71.4% here, for a value of 35.71 against an integer optimum of 38. The ODE spreads capacity across items rather than choosing among them, and the knapsack post derives the closed form (15·V/W while the total weight W exceeds the capacity) that every one of its numbers follows. Those numbers come from go-pflow's examples/knapsack, which prints them; no test pins them.
Exclusion analysis disables one transition at a time — the knapsack example sets the item's token and rate to zero — and re-runs the ODE to see what the rest of the net does without it. On the knapsack that is five runs (none excluded, then each item), and read through the closed form the table ranks what's left by value density until a subset fits. On that instance it also points at the optimum: dropping item2 is the one exclusion that raises the value, and what's left is the answer. We have not shown that it does so in general. Single exclusions only look at subsets one item smaller, and the knapsack post lists a benchmark against branch-and-bound on larger instances as the worked case still owed.
DDM models aggregate behavior — populations, not individuals. We can't track "Patient 47" through the system. Discrete conditionals ("if X then Y") have no continuous analog at all, because the ODE has no firing instant at which to test one: a read arc, an inhibitor, a declared capacity or a guard is simply ignored by the solver. go-pflow's continuous engine, stochastic.Forecast, therefore refuses a net that leans on any of them (a capacity counts only if some transition feeds that place) rather than plot an answer that leaves them out; Gating() in metamodel/firing.go names which ones a model leans on. Small populations are the other limit. On a net without those constructs the discrete engine's average follows the ODE as the population grows, and stochastic/consistency_test.go pins how closely: on an SIR epidemic the gap must stay under 5% of the population at 1,000 and 2% at 10,000, and shrink between the two. With a handful of tokens the average is the wrong question anyway; what you want is the spread across runs, and the ODE has none. Arc weights above 1 are a third limit: the discrete engine draws weight-many tokens combinatorially while the ODE stays first-order, so the two disagree by design, and the same test file has one (TestConsistencyPreconditionIsHonest) that requires them to.
Inside those limits the ODE is cheap to run and its structure comes straight from the incidence matrix.
This topic is covered in depth in Chapter 3: From Discrete to Continuous of Petri Nets as a Universal Abstraction.
Revised 2026-11-24 against go-pflow's solver, learn and stochastic packages, pflow.xyz's petri-solver.js, the Knapsack Model as revised in October, and book Chapter 3. Nothing was re-run.
Related: Knapsack Model · Sudoku Petri-Net Model · Coffee Shop Model · The Incidence Reduction · Comparing Nets by Their ODE Signatures