1%{ @file sn_pn_firing_rates.m
2 % @brief Recovers per-mode transition firing rates of a Petri net from the
5 % @author LINE Development Team
9 % @brief Recovers per-mode transition firing rates from the Place throughputs
12 % The firing rates of a Petri net are not carried by the network structure,
13 % but they are determined by the Place throughputs together with the net
14 % structure. Writing x
for the vector of per-mode firing rates, two families
15 % of equations hold at steady state,
for every Place p and
class k:
17 % departure sum over the modes consuming (p,k) of x, weighted by the
18 % input arc multiplicity when TPUTISTOKENS
is true and
19 % unweighted when it
is false, equals TN(p,k)
20 % balance sum over all modes of x times (produced minus consumed)
23 % The system
is solved in least squares. That
is deliberate: an exact solver
24 % supplies throughputs that satisfy it exactly and the fit
is then the exact
25 % answer, whereas a simulator supplies estimates that satisfy it only up to
26 % sampling error and the least-squares fit
is the right estimator there. A
27 % residual test would reject every simulated run.
31 % [x, consumed, produced, placeNodes] = sn_pn_firing_rates(sn, TN, tputIsTokens)
36 % <tr><th>Name<th>Description
37 % <tr><td>sn<td>Network structure
38 % <tr><td>TN<td>Average throughputs at stations
39 % <tr><td>tputIsTokens<td>True when TN counts tokens, false when it counts firing events
44 % <tr><th>Name<th>Description
45 % <tr><td>x<td>Firing rate per (transition, mode) pair, empty when undetermined
46 % <tr><td>consumed<td>Tokens consumed, indexed (mode, place, class)
47 % <tr><td>produced<td>Tokens produced, indexed (mode, place, class)
48 % <tr><td>placeNodes<td>Node indices of the Places, in the order used above
51function [x, consumed, produced, placeNodes] = sn_pn_firing_rates(sn, TN, tputIsTokens)
58placeNodes = find(sn.nodetype == NodeType.Place);
59transNodes = find(sn.nodetype == NodeType.Transition);
60if isempty(placeNodes) || isempty(transNodes) || isempty(TN)
64% see _kb/04-networkstruct.md (api/sn