api.spn

spn_traps(sn, init)

TRP = SPN_TRAPS(SN) TRP = SPN_TRAPS(SN, INIT) All minimal traps of a stochastic Petri net, and which of them m0 marks.

A trap is a non-empty set Q of place levels whose postset is in its preset, Q* <= *Q: every event that takes a token from Q also puts one back, so a marked trap stays marked under every firing. The minimal traps are the minimal siphons of the reversed net and are enumerated by the branch and bound of SPN_SIPHONS, with the same exponential worst case. Inhibitor arcs, firing priorities and immediate precedence are ignored.

– Input SN : a NetworkStruct of a closed model holding Places and Transitions INIT : initial tokens per place level, as in SPN_SIPHONS – Output TRP : struct with fields places (node indices), Q (one 0/1 row per minimal

trap, one column per level, sorted by size then lexicographically), marked (true where m0 puts a token in the trap) and m0

– Reference T. Murata, “Petri nets: properties, analysis and applications”, Proc. IEEE 77(4) (1989) 541-580, Sec. VI-B.

See also SPN_SIPHONS, SPN_PROPERTIES.

spn_tinvariants(sn)

TINV = SPN_TINVARIANTS(SN) Minimal-support semi-positive T-invariants of a stochastic Petri net.

A T-invariant is a non-negative integer right null vector of the incidence matrix, C x = 0: a firing sequence whose event counts are x returns the net to the marking it started from, whenever it can be fired. The minimal-support ones are computed with the Farkas algorithm of SPN_SINVARIANTS run on C’ (one row per event), so they form the same kind of basis: every T-invariant is a non-negative rational combination of them.

Events are the (transition, mode) pairs in node order, levels the (place, class) pairs of SPN_SINVARIANTS. The invariants are STRUCTURAL: inhibitor arcs, firing priorities and the precedence of immediate events over timed ones are ignored, and a T-invariant need not be realisable by a firing sequence from the initial marking.

– Input SN : a NetworkStruct of a closed model holding Places and Transitions – Output TINV : struct with fields transitions and modes (node index and mode index

of each event) and X (one row per invariant, one column per event)

– Reference J. Martinez, M. Silva, “A simple and fast algorithm to obtain all invariants of a generalised Petri net”, Application and Theory of Petri Nets, 1982. T. Murata, “Petri nets: properties, analysis and applications”, Proc. IEEE 77(4) (1989) 541-580, Sec. VII.

See also SPN_SINVARIANTS, SPN_STRUCTPROPS, SPN_PROPERTIES.

spn_structprops(sn)

SP = SPN_STRUCTPROPS(SN) Structural properties of a stochastic Petri net decided from its incidence matrix C = Post - Pre by linear programming, and its net-class membership.

Each LP property is decided per coordinate: the set of levels (or events) that some vector of the cone can make positive is computed with ONE linear program, max sum(t) s.t. 0 <= t <= 1, t <= z, z >= 0 in the cone, whose optimum is unique with t = 1 exactly on the coordinates some cone vector covers. The property holds when every coordinate is covered (a sum of the covering vectors is then strictly positive):

bounded y > 0, y’ C <= 0 structurally bounded: bounded for EVERY

initial marking (boundedlevels: y(p) > 0)

conservative y > 0, y’ C = 0 a positive weighted token sum is conserved

(conservedlevels: covered by a P-invariant)

consistent x > 0, C x = 0 some firing count vector using every event

reproduces the marking (consistentevents: covered by a T-invariant)

repetitive x > 0, C x >= 0 some sequence using every event can be

repeated indefinitely from a large enough marking (repetitiveevents)

Net classes (each requires an ORDINARY net, every arc weight 1; e and e are the input and output levels of event e, p and p the input and output events of level p):

statemachine |*e| = |e*| = 1 for every event markedgraph |*p| = |p*| = 1 for every level freechoice |p*| > 1 implies e = {p} for every e in p efc p* and q* intersect implies p* = q* (extended free choice) asymmetric p* and q* intersect implies p* <= q* or q* <= p*

EVERYTHING HERE IS STRUCTURAL. The incidence matrix cannot see inhibitor arcs, firing priorities, or the precedence of immediate events over timed ones; IGNORED lists those of them the net actually carries (‘inhibitor’, ‘priority’, ‘immediate’). Because they only restrict behaviour, structural boundedness still implies boundedness of the GSPN, but the class-based liveness conclusions of SPN_PROPERTIES do not carry over.

– Input SN : a NetworkStruct of a closed model holding Places and Transitions – Output SP : struct with fields places, transitions, modes, bounded, boundedlevels,

conservative, conservedlevels, consistent, consistentevents, repetitive, repetitiveevents, ordinary, statemachine, markedgraph, freechoice, efc, asymmetric, ignored

– Reference T. Murata, “Petri nets: properties, analysis and applications”, Proc. IEEE 77(4) (1989) 541-580, Secs. II-C and VII. M. Silva, E. Teruel, J.M. Colom, “Linear algebraic and linear programming techniques for the analysis of place/transition net systems”, Lectures on Petri Nets I, LNCS 1491 (1998) 309-373.

See also SPN_SINVARIANTS, SPN_TINVARIANTS, SPN_PROPERTIES.

spn_siphons(sn, init)

SIP = SPN_SIPHONS(SN) SIP = SPN_SIPHONS(SN, INIT) All minimal siphons of a stochastic Petri net, and Commoner’s check that each one contains an initially marked trap.

A siphon is a non-empty set S of place levels whose preset is in its postset, S <= S: every event that puts a token into S also takes one from S, so once S is empty it stays empty. A trap Q is the dual, Q* <= *Q, and once marked stays marked. A siphon that contains a marked trap can never be emptied.

COMMONER’S PROPERTY (every minimal siphon contains a marked trap, hence every siphon does) is decided per minimal siphon S by marking the largest trap inside S. For the underlying ORDINARY net it implies deadlock freedom, for an ordinary asymmetric-choice net liveness, and for an ordinary extended-free-choice net it is equivalent to liveness (SPN_PROPERTIES reports these conclusions). The siphons are structural: inhibitor arcs, firing priorities and immediate precedence are ignored.

The enumeration is a branch and bound over the levels forced in or out of the siphon, with the largest siphon inside the allowed levels as the bound; it is complete and duplicate-free. Each search node costs O(n^3 E) for n levels and E events, but the number of minimal siphons can be exponential in n and deciding whether a minimal siphon contains a given place is NP-complete, so the worst case is exponential.

– Input SN : a NetworkStruct of a closed model holding Places and Transitions INIT : initial tokens per place level, place-major; omitted or [] reads the

marking declared on the Places, and failing that the reference station populations, as SPN_SINVARIANTS does

– Output SIP : struct with fields places (node indices), S (one 0/1 row per minimal

siphon, one column per level, sorted by size then lexicographically), trapped (true where the siphon contains a trap marked in m0), commoner (all of trapped) and m0

– Reference T. Murata, “Petri nets: properties, analysis and applications”, Proc. IEEE 77(4) (1989) 541-580, Sec. VI-B. R. Cordone, L. Ferrarini, L. Piroddi, “Enumeration algorithms for minimal siphons in Petri nets based on place constraints”, IEEE Trans. Systems, Man, and Cybernetics A 35(6) (2005) 844-854.

See also SPN_TRAPS, SPN_PROPERTIES.

spn_reachprops(sn, init, maxstates)

RP = SPN_REACHPROPS(SN) RP = SPN_REACHPROPS(SN, INIT) RP = SPN_REACHPROPS(SN, INIT, MAXSTATES) Behavioural properties of a generalised stochastic Petri net, read off its reachability graph (SPN_REACHGRAPH, which honours inhibitor arcs, firing priorities and the precedence of immediate events).

Verdicts are tri-state, 1 (holds), 0 (fails) or -1 (undetermined, when the graph is not complete):

bounded every level has a finite bound; BOUND gives it per level

(Inf on a level proven unbounded, NaN where undetermined)

deadlockfree no reachable marking enables no event; DEADLOCKS lists the

dead markings found (indices into graph.M), DEADMARKINGS the markings themselves

live per event, L4-live: from every reachable marking the event

can fire again, i.e. it labels an edge inside every bottom strongly connected component of the graph

dead per event, L0-live failure: it never fires from m0 reversible m0 is reachable from every reachable marking: the graph has

a single bottom strongly connected component, holding m0

A truncated graph still settles some verdicts: a dead marking found makes deadlockfree and every live entry 0, and reversible 0 unless it is m0; an event seen firing is not dead.

– Input SN : a NetworkStruct of a closed model holding Places and Transitions INIT : initial tokens per place level, as in SPN_SIPHONS MAXSTATES : maximum number of stored markings (default 100000) – Output RP : struct with fields status, nstates, bounded, bound, deadlockfree,

deadlocks, deadmarkings, live, dead, reversible, nbscc and graph (the SPN_REACHGRAPH result)

– Reference T. Murata, “Petri nets: properties, analysis and applications”, Proc. IEEE 77(4) (1989) 541-580, Secs. IV and V-A.

See also SPN_REACHGRAPH, SPN_PROPERTIES.

spn_reachgraph(sn, init, maxstates)

RG = SPN_REACHGRAPH(SN) RG = SPN_REACHGRAPH(SN, INIT) RG = SPN_REACHGRAPH(SN, INIT, MAXSTATES) Untimed reachability graph of a generalised stochastic Petri net, over the markings of the place levels.

The graph is built breadth-first from m0 under the GSPN firing rules of LINE’s simulator: an event is enabled when every input level holds its pre multiplicity and no inhibitor threshold is reached; when an IMMEDIATE event is enabled only the enabled immediate events of the highest firingprio may fire (the marking is VANISHING), otherwise every enabled TIMED event may. Firing e from m gives m - Pre(:,e) + Post(:,e). Vanishing markings are kept as states of the graph, and TANGIBLE marks the others. Firing weights and rates do not change which markings are reachable and are not used.

Markings are numbered in discovery order: successors are generated in event order, events being the (transition, mode) pairs in node order, so the numbering is the same in every codebase.

TERMINATION. STATUS is

‘complete’ every reachable marking was found; ‘unbounded’ a new marking strictly covers one of its BFS ancestors and

the net is MONOTONE (no inhibitor arc, and no immediate precedence or priority to restrict which enabled event fires), so the covering sequence can be repeated forever: the levels where it grows (UNBOUNDEDLEVELS) are unbounded and the search stops there;

‘cap’ MAXSTATES markings were stored and another was found.

For a non-monotone net covering proves nothing, so only the cap stops an infinite search; SPN_STRUCTPROPS’s structural boundedness is a sufficient condition that holds for the GSPN as well.

A queueing place (scheduling other than INF) is refused: its embedded server is state that the marking does not carry.

– Input SN : a NetworkStruct of a closed model holding Places and Transitions INIT : initial tokens per place level, as in SPN_SIPHONS MAXSTATES : maximum number of stored markings (default 100000) – Output RG : struct with fields places, transitions, modes (the level and event

tables), M (one marking per row), E (one edge per row: from, to, event index), tangible (per marking), status, unboundedlevels (per level) and m0

– Reference T. Murata, “Petri nets: properties, analysis and applications”, Proc. IEEE 77(4) (1989) 541-580, Sec. V-A. B.R. Haverkort, “Performance of Computer Communication Systems: A Model-Based Approach”, Wiley, 1998, Ch. 14.

See also SPN_REACHPROPS, SPN_PROPERTIES.

spn_properties(sn, init, maxstates)

PR = SPN_PROPERTIES(SN) PR = SPN_PROPERTIES(SN, INIT) PR = SPN_PROPERTIES(SN, INIT, MAXSTATES) Structural and behavioural property analysis of a stochastic Petri net in one call: invariants, siphons and traps, the LP structural checks and net classes, the reachability-graph verdicts, and the liveness conclusions that the net class and Commoner’s property license.

STRUCTURAL LIVENESS. With STP = every minimal siphon contains a marked trap (SPN_SIPHONS.commoner), the classical results for ORDINARY nets give

structdeadlockfree = 1 if the net is ordinary and STP holds structlive = 1 if the net is asymmetric choice and STP holds

= 0 if the net is extended free choice and STP fails

and -1 (undetermined) otherwise. They are theorems about the untimed P/T net and are reported only when that net is the GSPN, i.e. IGNORED is empty (no inhibitor arcs, no immediate precedence, no priorities); otherwise both are -1 and the reachability verdicts in REACH are the ones to read.

– Input SN : a NetworkStruct of a closed model holding Places and Transitions INIT : initial tokens per place level, as in SPN_SIPHONS MAXSTATES : maximum number of stored markings (default 100000) – Output PR : struct with fields m0, ignored, sinv (SPN_SINVARIANTS), tinv

(SPN_TINVARIANTS), siphons (SPN_SIPHONS), traps (SPN_TRAPS), struct (SPN_STRUCTPROPS), reach (SPN_REACHPROPS), commoner, structdeadlockfree and structlive

– Reference T. Murata, “Petri nets: properties, analysis and applications”, Proc. IEEE 77(4) (1989) 541-580, Secs. VI and VII. B.R. Haverkort, “Performance of Computer Communication Systems: A Model-Based Approach”, Wiley, 1998, Sec. 14.2.

See also SPN_SINVARIANTS, SPN_TINVARIANTS, SPN_SIPHONS, SPN_TRAPS, SPN_STRUCTPROPS, SPN_REACHPROPS.

spn_ispn_covered(C)

COVERED = SPN_ISPN_COVERED(C) Places of a Petri net covered by a non-negative S-invariant (P-semiflow).

C is the P x T incidence matrix POST - PRE. A semiflow y >= 0, y ~= 0, with y’ C = 0 keeps y’ m constant along every firing, so every place in its support is bounded by y’ m0 / y(p). COVERED(p) is true when some semiflow has y(p) > 0, i.e. when place p is structurally bounded through an invariant; the places left uncovered are the candidates for the unbounded place of an iSPN (SPN_ISPN). The semiflows are generated by Farkas’ algorithm on [C | I], keeping minimal supports only.

See also: spn_ispn(), spn_sinvariants().

spn_sinvariants(sn, init)

INV = SPN_SINVARIANTS(SN) INV = SPN_SINVARIANTS(SN, INIT) Minimal-support S-invariants (P-invariants) of a stochastic Petri net, and the load vector V = S m0.

An S-invariant is a non-negative left null vector of the incidence matrix, U’ C = 0, so U’ m is conserved by every firing. The minimal-support ones form a basis of all of them and are what the convolution algorithm SPN_CONV decomposes the reachability set along; SPN_MDD uses a single positive invariant for a much weaker purpose, to bound each place a priori.

FARKAS’ ALGORITHM, on [C | I]: for each transition column in turn, keep the rows that already annihilate it and add, for every pair of rows of opposite sign in it, the positive combination that cancels it; then drop every row whose support strictly contains another’s, which is what leaves the minimal supports. Rows are kept in integer arithmetic and divided by their gcd, so a multiplicity is never lost to rounding and two invariants that differ only by a positive scale are the same row.

ARC MULTIPLICITIES MUST BE INTEGRAL. A fractional arc has no Petri-net meaning and would make the gcd normalisation and the ILP-free convolution both wrong, so it is refused rather than rounded.

Levels are the (place, class) pairs of SPN_MDD, place-major, so the invariants come out in the coordinates the decision diagram and SPN_CONV both use.

– Input SN : a NetworkStruct holding Places and Transitions INIT : initial tokens per place level, place-major; omitted or [] takes them

from the reference station of each closed class, as SPN_MDD does

– Output INV : struct with fields places (node indices), S (one row per invariant, one

column per place level), V = S m0 and m0

– Reference S. Balsamo, A. Marin, I. Stojic, “Computation of the normalising constant for product-form models of distributed systems with synchronisation”, Future Generation Computer Systems 111 (2020) 475-490, Sec. 3.1.

See also SPN_CONV, SPN_MDD.

spn_ispn(pre, post, inh, rate, imm, srv, m0, p0, options)

RES = SPN_ISPN(PRE, POST, INH, RATE, IMM, SRV, M0, P0) RES = SPN_ISPN(PRE, POST, INH, RATE, IMM, SRV, M0, P0, OPTIONS) Steady state of an infinite-state stochastic Petri net (iSPN) whose single unbounded place P0 is the level of a quasi-birth-death process, solved by the matrix-geometric method, after B.R. Haverkort, “Performance of Computer Communication Systems”, Wiley 1998, ch. 17, and B.R. Haverkort, A. Ost, “Steady-state analysis of infinite stochastic Petri nets: comparing the spectral expansion and the matrix-geometric method”, PNPM 1997, 36-45.

The level is the marking of P0 and the phase is the marking of the other (bounded) places. The net is accepted only if it meets the iSPN requirements of Haverkort Sec. 17.2, each checked here and refused with LINE:unsupported:Structure, naming the violated condition, when it fails:

R1 from some level K on, every level has the same set of phase markings

(and the other places are bounded);

R2 every firing, including a timed firing followed by its chain of

immediate firings, moves the level by at most one;

R3 above K the enabling, inhibition and firing rates no longer depend on
the level, so the generator has the QBD form (17.3)

[B00 B01 ] [B10 B11 B12 ] [ … BKK A0 ] [ A2 A1 A0 ] [ A2 A1 .]

with a multi-level boundary 0..K.

K is found by exploring levels 0..KTOP and comparing the blocks: it is the smallest level from which every block in the window is identical, and the window always extends OPTIONS.extra levels past the structural threshold max(PRE(P0,t), INH(P0,t), PRE(P0,t)*min(SRV(t), degree from the other places)) at which the rates provably stop changing with the level.

Immediate transitions are allowed: vanishing markings are eliminated within the explored window, Q = Q_TT + Q_TV (I - P_VV)^{-1} P_VT, before the blocks are read off, and their throughputs come from the expected number of firings along the vanishing chains. A marking in which an immediate transition is enabled is vanishing; immediate transitions then fire with probability proportional to RATE(t) * min(enabling degree, SRV(t)), as in SolverCTMC.

R solves A0 + R A1 + R^2 A2 = 0 (QBD_R_LOGRED, logarithmic reduction), the boundary x_0..x_K solves (17.9) with B_KK + R A2 and the normalisation (17.10), and x_{K+i} = x_K R^i. Every measure is in closed form, with no truncation of the level: for a reward r that is affine in the level above K, r(K+j) = a + (j-1) b for j >= 1,

E[r] = sum_{i<=K} x_i r_i + x_K R N a + x_K R^2 N^2 b, N = (I-R)^{-1},

which gives (17.14) for the mean level and (17.17) for the level-independent rewards.

– Input (P places, T transitions, 1-based indices) PRE : P x T input multiplicities (consumed on firing; enabling needs

m >= PRE(:,t))

POST : P x T output multiplicities INH : P x T inhibitor thresholds (t is disabled when m(p) >= INH(p,t));

Inf for no inhibitor arc. [] means none

RATE : 1 x T firing rate of a timed transition, or weight of an immediate IMM : 1 x T logical, true for an immediate transition. [] means all timed SRV : 1 x T number of servers (Inf for infinite-server). [] means all 1.

A transition with no input place fires at RATE(t)

M0 : P x 1 initial marking P0 : index of the unbounded place OPTIONS: struct, fields (all optional)

extra - levels checked past the structural threshold (default 3, >= 3) maxlevel - largest window explored before refusing (default 200) maxstates - largest number of explored markings (default 2e5) tol - relative tolerance of the block comparisons (default 1e-9) distmax - largest level of the reported level distribution (default:

until the tail mass falls below 1e-12, capped at 1e5)

rewards - cell array of handles r(m) of the P x 1 marking, each affine in

the level above K

qbdmethod - ‘logred’ (default) or ‘successive’ (QBD_R)

– Output, struct with fields

K, L first repeating level, number of phases of a repeating level A0, A1, A2, R level-up, local and level-down blocks, rate matrix B boundary generator over levels 0..K (before adding R A2) x 1 x (K+1) cell, x{i+1} the probability vector of level i levelmarkings 1 x (K+1) cell, P x n_i tangible markings of level i drift [pi A0 1, pi A2 1] of the repeating chain, pi A = 0 spR spectral radius of R meanmarking P x 1 mean marking of every place varlevel variance of the level leveldist 1 x (D+1) probabilities of the level 0..D leveltail probability that the level exceeds D marginal 1 x P cell, marginal{p}(n+1) = Pr{m(p) = n}; for P0 it is

LEVELDIST

tput 1 x T firing rate of every transition (immediate included) reward 1 x numel(OPTIONS.rewards) expected rewards ntangible, nvanishing markings explored in the window

See also: qbd_R_logred(), qbd_R(), spn_metrics(), solver_mam_ispn(), SolverMAM.

spn_pf(model, options)

PF = SPN_PF(MODEL) PF = SPN_PF(MODEL, OPTIONS) Decide whether a stochastic Petri net has a product-form equilibrium distribution and, when it has, return the per-level factors g_l that MDD_REC and SPN_METRICS take as input.

THIS IS THE PART THE MDD-REC PAPER DECLARES OUT OF SCOPE (FGCS Sec. 3.2). Every other function in api/spn/ receives the g_l already formed; this one derives them from the net, which is what lets a solver reach them.

– The theory, in one paragraph Write I(t), O(t) for the input and output vectors of mode t and lambda_t for its rate constant. Henderson-Taylor and Coleman-Henderson-Taylor show that a net whose firing rate has the form

r_t(m) = lambda_t psi(m - I(t)) / psi(m), m >= I(t)

has invariant measure pi(m) = psi(m) prod_l y_l^{m_l} whenever the positive vector y satisfies COMPLEX BALANCE: reading the distinct vectors appearing as some I(t) or O(t) as the COMPLEXES of the net, the flow into every complex must equal the flow out of it,

sum_{t : O(t)=v} lambda_t y^{I(t)} = ( sum_{t : I(t)=v} lambda_t ) y^v.

Two choices of psi are realisable in LINE’s own rate law, and they are the two this function tests for:

psi = 1 r_t = lambda_t, the rate of a SINGLE-SERVER mode.

pi(m) = prod_l y_l^{m_l}, so g_l(k) = y_l^k.

psi = prod_l 1/m_l! r_t = lambda_t prod_l m_l!/(m_l-I_l)!, MASS ACTION,

reached in LINE through Transition.setFiringRateDependence or, for a mode drawing one token from one place, by infinite-server semantics. pi(m) = prod_l y_l^{m_l}/m_l!, so g_l(k) = y_l^k/k!.

Which one holds is not guessed from the model API: the effective rate LINE would use, lambda_t min(enabling degree, servers) g(m), is EVALUATED at every reachable marking and compared against both laws. A net that matches neither under one common psi is refused by name, never approximated.

– Solving for y Complex balance reads A_lambda Psi(y) = 0 with A_lambda the Laplacian of the weighted digraph on complexes and Psi(y)_v = y^v. That Laplacian is the TRANSPOSED GENERATOR of a Markov chain that hops from complex to complex at the rate of the mode joining them, so its kernel on one linkage class is that chain’s stationary distribution and CTMC_SOLVE returns it – strictly positive exactly when the class is strongly connected, which is weak reversibility. With that positive vector kappa in hand y follows from the LINEAR system in x = log y

(v - v0) x = log kappa_v - log kappa_v0, v, v0 in the same linkage class,

solved in minimum norm. Feinberg’s Deficiency Zero Theorem says this system is consistent for every choice of rate constants when the net is weakly reversible and its deficiency c - l - s is zero, which is why those two numbers are reported; but consistency is CHECKED rather than assumed, so a net of positive deficiency whose particular rates still admit a complex-balanced point is accepted on the evidence.

– The gauge, and why the minimum-norm solution is the canonical one Complex balance fixes y only up to y -> y .* exp(u) for any u orthogonal to the stoichiometric subspace S. Such a shift multiplies pi(m) by exp(u’m), which is CONSTANT on one compatibility class, so every reported measure is invariant under it – but the normalising constant G itself is not, it scales by that constant. A gauge must therefore be FIXED, or the four codebases would report four different G on the same net. The one fixed here is x in the row space of the constraint matrix, i.e. the minimum-norm solution, and it is reached in a form that is unique whichever least-squares primitive a codebase carries: solve (rows*rows’)w = rhs and set x = rows’*w. Any two solutions w of that system give the SAME rows’*w, so the answer does not depend on how the rank-deficient solve breaks its tie.

– Input MODEL : a Network holding Places and Transitions OPTIONS : struct, fields

bound - per-place-level token bound, passed to SPN_MDD tol - relative tolerance of the rate-law and complex-balance

checks (default 1e-9)

verbose - print the certificate (default false)

– Output PF : struct with fields

g - 1 x L cell, g{l}(k+1) = g_l(k), ready for MDD_REC y - 1 x L positive vector solving complex balance kind - ‘geometric’ or ‘massaction’, the psi that was found complexes - C x L matrix of the distinct complexes deficiency - c - l - s linkage - number of linkage classes srank - rank of the stoichiometric subspace weaklyreversible - true when every linkage class is strongly connected residual - relative complex-balance residual at y mdds, info - the reachable set and metadata SPN_MDD returned

– Reference J. L. Coleman, W. Henderson, P. G. Taylor, “Product form equilibrium distributions and a convolution algorithm for stochastic Petri nets”, Performance Evaluation 26(3), 1996. M. Feinberg, “Complex balancing in general kinetic systems”, Arch. Rational Mech. Anal. 49, 1972. D. F. Anderson, G. Craciun, T. G. Kurtz, “Product-form stationary distributions for deficiency zero chemical reaction networks”, Bull. Math. Biol. 72, 2010.

See also MDD_REC, SPN_METRICS, SPN_MDD, SPN_CONV.

spn_metrics(mdds, g, info)

MET = SPN_METRICS(MDDS, G_L, INFO) Stationary measures of a product-form stochastic Petri net from the MDD-rec masses.

n(P_j) = sum_k k P(m_j = k) mean tokens u(P_j) = 1 - P(m_j = 0) place utilization u(T_j) = P(e_j >= 1) transition utilization x(T_j) = sum_k min(k, c_j) W(T_j) P(e_j = k) throughput x(P_j) = sum_T I_j(T) x(T) tokens removed per unit time

ONE DEVIATION FROM THE PAPER’S x(T_j), AND IT IS A GENERALISATION. The paper writes x(T_j) = sum_k k W(T_j) P(e_j = k), which is INFINITE-SERVER firing semantics – every enabling set fires in parallel. LINE’s own rate law is min(enabling degree, nmodeservers) * W(T), so c_j above is the mode’s server count: c_j = 1 recovers single-server semantics, x = W(T) P(e >= 1), and c_j = Inf recovers the paper’s formula exactly. Using the paper’s form for a single-server mode would report a throughput that grows with the token population of a net whose transition can only fire one set at a time.

The measures come out of ONE reachable set and ONE set of g_l, so they are mutually consistent by construction: no per-measure fixed point, no iteration.

– Input MDDS : MDD.toStruct of the reachable set built by SPN_MDD G_L : 1 x K cell of per-level product-form factors g_l(v) INFO : the metadata SPN_MDD returned alongside the diagram – Output MET : struct with fields G, tokens, placeUtil, placeTput, modeUtil,

modeTput and marginal, the per-level P(m_l = k)

– Reference S. Balsamo, A. Marin, I. Stojic, “Computation of the normalising constant for product-form models of distributed systems with synchronisation”, Future Generation Computer Systems 111 (2020) 475-490, Sec. 3.1 and Sec. 5.3.

See also MDD_REC, MDD_REC_MARGINAL, SPN_REC_ENABLED, SPN_MDD.

spn_mdd(model, options)

[MDDS, DESC, INFO] = SPN_MDD(MODEL) [MDDS, DESC, INFO] = SPN_MDD(MODEL, OPTIONS) Decision-diagram reachable set and Kronecker rate descriptor of a stochastic Petri net, so that MDD_MCD can analyse it.

Levels are of two kinds:
place levelsone per (Place, class) pair, holding a token count. A

multiclass net therefore has P*R of them, ordered place-major, so level (p-1)*R+k is class k in place p.

phase levelsone per mode whose firing time has more than one phase,

holding the phase the running server occupies.

The rate structure factorises exactly under single-server firing semantics: a mode fires at a constant rate whenever every input level holds its enabling multiplicity and no inhibitor level has reached its threshold, so

W_l^e[i, i + fire(l) - enab(l)] = 1 for enab(l) <= i < inhib(l)

at every place level. A phase-type mode contributes two event families on its phase level, the internal phase changes D0 (marking unchanged) and the firings D1 (marking moved), each gated by the same per-level enabling indicators. Both are products of per-level terms, which is what Eq. 1 of the paper requires.

– Input MODEL : a Network holding Places and Transitions OPTIONS : struct, fields

bound - per-place-level token bound (scalar or 1 x P*R);

inferred from a place invariant when omitted

phmemory - ‘exact’ (default) or ‘resume’, see the note below descriptor - build the Kronecker rate descriptor (default true).

Pass false for the MDD-rec route, which reads only the reachable set: see the note below

verbose - print the net summary (default false)

– Output MDDS : MDD.toStruct of the reachable set DESC : Kronecker descriptor for MDD_MCD, with fields K, domain, events,

levelkind (1 place, 2 phase) and, when one exists, invariant = struct(‘weights’, w, ‘value’, v) with zero weight on the phase levels

INFOstruct with fields places, placenames, classnames, levelname,

levelkind, modes, init, mdd, phaseof

– Phase-type firing and the memory policy LINE discards a running server’s phase when its mode becomes disabled (State/afterGlobalEvent zeroes the server phases on the disable action), i.e. preemptive repeat. Resetting a mode’s phase is then triggered by a JOINT condition on the place levels, which is not a product of per-level terms and has no Kronecker form. What this descriptor encodes is preemptive resume: a disabled mode’s phase freezes and continues when the mode is re-enabled. The two policies coincide exactly when a mode is never disabled while running, so reachability records, for free, whether any phase-type mode was ever found disabled. OPTIONS.phmemory=’exact’ (the default) errors when one was; ‘resume’ proceeds deliberately with the resume semantics.

– Reachable-set-only mode (OPTIONS.descriptor = false) MDD_REC and SPN_METRICS need the reachable set and the metadata, never the rate descriptor: the product form supplies the rates. So the restrictions below that exist only because a Kronecker form must factorise per level – marking-dependent firing rates and multi-server modes drawing from several places – are lifted, and DESC comes back carrying K, domain, levelkind and the invariant but no events. In exchange the firing times must be EXPONENTIAL: a phase level is a descriptor device, and a product-form marking process is memoryless in the marking alone. Immediate modes stay refused, since a vanishing marking carries no probability and would have to be eliminated from the reachable set first.

– Other restrictions (each is an error, never a silent approximation) No immediate transitions (they make vanishing states, which must be eliminated before a Kronecker rate descriptor exists) and no marking-dependent firing rates. A multi-server mode is accepted only when its enabling touches ONE level, because the enabling degree min_l floor(m(l)/enab(l)) is otherwise not a product of per-level terms.

See also: mdd_mcd(), mdd_descriptor(), mdd_reachset().

spn_lpbnd(sn, options)

BND = SPN_LPBND(SN) BND = SPN_LPBND(SN, OPTIONS) Linear-programming bounds on the mean marking and the throughputs of a stochastic timed Petri net.

The stationary chain is relaxed to a MOMENT POLYTOPE: the uniformized evolution equation is written for E[X_p], E[X_p^2] and E[X_p1 X_p2], which gives linear equalities among the mean marking x, the enabling probabilities q and the products y(p,t) = E[X_p e_t]; behavioural and probabilistic inequalities are added on top; and every reported measure is then obtained by minimising and maximising its linear form over that polytope. Any stationary point of the true chain satisfies every row, so the two optima BRACKET the exact value whatever the polytope leaves out.

This is the Petri-net sibling of the QRF bounds in SolverBA: same technique, a different index space, and a LINEAR objective, so there is no stationary point to escape from and the answer is a property of the model alone.

VARIABLES, over place levels l = 1..L and modes e = 1..E:

x(l) E[X_l], mean tokens >= 0 q(e) P(mode e enabled) in [0,1] th(e) throughput of mode e >= 0 u(e) state-equation firing counts >= 0 y(l,e) E[X_l e_e] >= 0 (Markovian only)

u is EXISTENTIAL and is not reported: E[X] is a convex combination of reachable markings, each of which is m0 + C h for some nonnegative integer h, so the mean satisfies m0 + C u for some nonnegative real u. It is not a mean firing count and has no steady-state value.

LEVELS ARE (place, class) PAIRS, PLACE-MAJOR, level (pp-1)*R + k, the same coordinates SPN_MDD, SPN_SINVARIANTS and SPN_CONV use. MODES are (transition, mode) pairs in node order. Both index spaces are returned in BND.

THE TOKEN COUNTS CREATED BY A FIRING ARE DETERMINISTIC IN LINE, which removes a whole branch of the reference: it allows sigma_{t,p}(n) to be random and splits the covariance family into an independent case (its eq. 7) and a selective one (its eq. 8). SETFIRINGOUTCOME takes an integer weight, so E[sigma^2] = sigma^2 and E[sigma_p1 sigma_p2] = sigma_p1 sigma_p2 hold exactly and eq. (7) is the correct form. Eq. (8) has no LINE model behind it and is deliberately absent.

– Input SN : a NetworkStruct holding Places and Transitions OPTIONS : struct, all fields optional

markovian true (default) uses the second-moment, covariance and Little’s

law families, which need exponential firing times; false drops them and the whole y block, leaving the operational bound, which needs only a mean firing time and so admits any phase-type law. A law that is not phase-type at all is refused by both: SN carries such a mode as its own parameter list rather than a (D0,D1) pair, and no mean can be read off it without a per-distribution table

assumelive false (default). true adds the two liveness rows, which are

valid only on a live net; see the note below

init initial tokens per place level, place-major; omitted reads the

declared marking through State.initialOccupancy

tol LP feasibility slack added to the inequality sides, default 0 verbose print the polytope size

– Output BND : struct with fields

places place node indices, in level order levelname 1 x L cell, “Place.Class” modes 1 x E struct array with fields trans, mode, enab, inhib,

fire, rate

tokens 2 x L, row 1 the minimum and row 2 the maximum of x(l) placeTput 2 x L, bracket on sum_e pi_e(l) mu_e q(e), tokens removed

from level l per unit time

modeTput 2 x E, bracket on th(e) modeUtil 2 x E, bracket on q(e) bound 1 x L, the a priori per-level bound B_l read off the

P-invariants, Inf where none constrains the level

nplacelevels, nclasses, markovian, nvars, nrows

LIVENESS IS OFF BY DEFAULT, AND THAT IS DELIBERATE. The reference’s two liveness rows (sum_t q_t >= 1 and x_p <= sum_t y_{p,t}) hold only on a live net, and liveness is not something this function can cheaply certify – an inhibitor arc alone is enough to deadlock a net that looks well formed. A bound that silently assumed it would be wrong rather than loose on exactly the models where a bound is most wanted, so the rows are available under OPTIONS.assumelive and absent otherwise.

WHAT THE ROWS ARE WORTH, MEASURED. They are the whole of the lower side. On the reference’s own Table 2 (its Fig. 2b production line, five rate vectors) ASSUMELIVE reproduces its published l.b. column to four decimals – 1.1653 against 1.165, 1.8288 against 1.829, 1.5814 against 1.581, 1.3592 against 1.359, 1.3497 against 1.350 – while without them the Markovian lower bound collapses onto the OPERATIONAL one (0.9302, 1.4815, 1.1111, 1.1110 against that column’s 0.930, 1.481, 1.111, 1.111) on four of the five. The upper side needs neither row and matches the published u.b.2 either way.

– Reference Z. Liu, “Performance Analysis of Stochastic Timed Petri Nets Using Linear Programming Approach”, IEEE Trans. Software Engineering 24(11), 1998, 1014-1030. The constraint families are its Table 1, p. 1022; the bracket statement is its Theorem 3, p. 1021.

See also SPN_SINVARIANTS, SPN_METRICS, SPN_MDD, SOLVER_BA_SPNLP_ANALYZER.

spn_conv(S, V, g)

G = SPN_CONV(S, V, G_L) G = SPN_CONV(INV, G_L) Normalising constant of an S-invariant reachable product-form stochastic Petri net, by convolution over the invariant load vector.

With S the minimal-support S-invariant matrix and V = S m0 the load vector, the reachability set of an S-INVARIANT REACHABLE net is exactly {m >= 0 : S m = V}, and conditioning on the marking of one place partitions it (Lemma 5.1 of the MDD-rec paper). Writing G_j(W) for the mass of the markings supported on the first j places with S m = W,

G_0(W) = [W == 0], G_j(W) = sum_i g_j(i) G_{j-1}(W - i S_j),

and G = G_n(V). On a net whose only invariant is “the tokens are conserved” this is Buzen’s convolution for a closed queueing network, one place per station.

NO ILP IS SOLVED. Coleman-Henderson-Taylor obtain the marking set M_p(P’,W) from the feasibility of an integer program so that the sum skips the terms that contribute nothing. Here the sum simply runs over i whose residual W - i S_j stays non-negative and the recursion returns zero on an infeasible residual, which gives the same value: the ILP is an optimisation of the enumeration, not part of the definition. Memoising on (j, W) keeps the walk over the reachable residuals rather than over all of them.

S-INVARIANT REACHABILITY IS NOT CHECKED, and cannot be cheaply: no algorithm is known that decides it without generating the reachability set. On a net that fails it, {m : S m = V} is strictly larger than the reachable set and this returns a normalising constant over unreachable markings too, which is why MDD_REC – which walks the reachable set itself – is the general algorithm and this one the special case. Compare the two on a new net before trusting this one on it.

– Input S : S(i,p), the minimal-support S-invariants, one row per invariant; or the

struct SPN_SINVARIANTS returned, in which case V holds the factors

V : the load vector S m0, one entry per invariant G_L : 1 x n cell, G_L{p}(i+1) is g_p(i), the product-form factor of i tokens

in place level p; its length bounds the marking of that level

– Output G : the normalising constant

– Reference J. Coleman, W. Henderson, P. Taylor, “Product form equilibrium distributions and a convolution algorithm for stochastic Petri nets”, Performance Evaluation 26(3), 1996, 159-180; the point of comparison for MDD-rec in S. Balsamo, A. Marin, I. Stojic, Future Generation Computer Systems 111 (2020) 475-490, Sec. 5.1.

See also MDD_REC, SPN_SINVARIANTS, SPN_MDD.

spn_bench_mdd(OPTIONS)

OUT = SPN_BENCH_MDD() OUT = SPN_BENCH_MDD(OPTIONS) Cost profile of the decision-diagram aggregation on a SCALABLE stochastic Petri net, the flexible-manufacturing-system (FMS) family of G. Ciardo, K. Trivedi, “A decomposition approach for stochastic reward net models”, Perform. Eval. 18(1), 1993, which is the standard scaling benchmark for decision-diagram state-space methods.

The net has three machine lines, one job class each, that take a part from a common pool, process it and return it, plus an assembly stage that consumes one finished part of every class at once. The reachable set grows steeply in the part count N while the number of levels stays fixed, which is the regime the aggregation is built for: |S| grows polynomially of degree 3R in N and sum_k |M_k| does not.

– Input OPTIONS : struct, fields

parts - vector of part counts to sweep (default 1:5) maxstates- skip a row whose exact solve would exceed this many

states (default 200000); the aggregation still runs

verbose - print the table as it is produced (default true)

– Output OUT : struct array, one entry per part count, with fields parts, nstates,

levels, sumMk, compression, iters, t_reach, t_solve, noAggregation and, when the exact solve was run, t_exact and maxerr

– Remarks The exact reference is the explicit generator assembled through MDD/index, which is why MAXSTATES gates it: the aggregation is the cheap side and the point of the benchmark is to watch the two diverge.

See also: spn_mdd(), mdd_mcd(), mdd_bench_mcd().

spn_rec_enabled(mdds, g, mde, nplacelevels)

EN = SPN_REC_ENABLED(MDDS, G_L, MDE, NPLACELEVELS) Enabling-degree distribution of one mode of a product-form stochastic Petri net, by the masked MDD-rec recursion.

The enabling degree of a mode in marking m is

e(m) = min_{l : I_l > 0} floor(m_l / I_l),

zero when any inhibitor threshold is met. P(e >= k) is therefore the mass of the marking subset in which EVERY input level holds at least k*I_l tokens and no inhibitor fires, which is a per-level restriction and so exactly what MDD_REC_MASKED computes: the paper’s second modified recurrence is the same walk under a different mask, not a second algorithm.

– Input MDDS : MDD.toStruct of the reachable set built by SPN_MDD G_L : 1 x K cell of per-level product-form factors MDE : one entry of INFO.modes as returned by SPN_MDD NPLACELEVELS : how many leading levels are place levels – Output EN : struct with fields

ge - ge(k+1) is the mass of {e >= k}; ge(1) is the whole set eq - eq(k+1) is the mass of {e == k}, i.e. ge(k+1)-ge(k+2) maxDegree - the largest enabling degree the place bounds permit, E_j

The masses are UNNORMALISED, as in the paper; divide by G from MDD_REC for probabilities. SPN_METRICS does that and turns them into the transition measures.

– Reference S. Balsamo, A. Marin, I. Stojic, “Computation of the normalising constant for product-form models of distributed systems with synchronisation”, Future Generation Computer Systems 111 (2020) 475-490, Sec. 5.3.

See also MDD_REC_MASKED, SPN_METRICS, SPN_MDD.