Skip to content

Generalized Stochastic Petri Nets

Marco Paolieri edited this page Mar 15, 2018 · 4 revisions

Model Features

An important subclass of STPNs is that of Generalized Stochastic Petri Nets (GSPNs). This model allows only:

  • Immediate transitions, i.e., with firing time deterministic and equal to 0.
  • Exponential transitions, i.e., with firing time distributed as an exponential random variable with rate λ.

According to the race semantics of GSPNs, immediate transitions have precedence over exponential ones. When multiple immediate transitions are enabled:

  • first, those with maximum priority are selected;
  • then, one of those with maximum priority is selected according to a discrete distribution given by weights. The probability of selecting a specific immediate transition is given by its weight divided by the sum of all the weights of other immediate transitions with maximum priority.

To add an immediate transition, use a deterministic transition feature:

Transition imm = pn.addTransition("start");
imm.addFeature(StochasticTransitionFeature.newDeterministicInstance("0"));

You can pass additional parameters to set the weight of the transition:

// weight is 10
StochasticTransitionFeature.newDeterministicInstance(BigDecimal.ZERO, BigDecimal.TEN);

The weight can even depend on the number of tokens assigned to places by the current marking:

StochasticTransitionFeature.newDeterministicInstance(BigDecimal.ZERO,
    MarkingExpr.from("2 * somePlace", petriNet));

In this case, note that the transition will be disabled if the weight evaluates to zero or to a negative value.

To set the priority of an immediate transition, you can use the Priority feature (the default priority is equal to Integer.MIN_VALUE):

imm.addFeature(new Priority(42));

Exponential transition are created as in STPNs:

Transition exp = pn.addTransition("arrival");
exp.addFeature(StochasticTransitionFeature.newExponentialInstance("2.0"));

The rate λ associated with the transition is fixed (2.0 in the example), but it can decrease with a different clock rate which depends on the current marking. To use marking-dependent rates, pass additional parameters to newExponentialInstance:

StochasticTransitionFeature.newExponentialInstance(new BigDecimal("3.0",
    MarkingExpr.from("p0 / 2.0", petriNet));

If p0 contains 1 token in the current marking, the effective rate will be 3.0 * (1 / 2.0).

Analysis Engines

GSPNSteadyState

The stationary distribution for the underlying CTMC of a GSPN can be computed using the GSPNSteadyState engine. Immediate events are removed by solving absorption probabilities of immediate components that may include cycles. This analysis can be applied to GSPNs with reducible state space and multiple BSCCs. In this case, the stationary probabilities within each BSCC are weighted according to its absorption probability from the initial distribution of the CTMC.

Map<Marking, Double> dist = GSPNSteadyState.builder().build().compute(pn, marking);
for (Marking m : dist.keySet())
    System.out.println("%.6f %s%n", dist.get(m), m);

The available options when building GSPNSteadyState are:

  • epsilon(double): specifies the threshold used to decide whether a probability value should be considered equal to 0.0 in the analysis (1e-9 by default).
  • stopOn(Supplier<StopCriterion>): to stop the analysis on some nodes (never by default).
  • stopOn(MarkingCondition): to use a simple MarkingCondition as stop criterion.

GSPNTransient

The transient probabilities for the underlying CTMC of a GSPN can be computed using the GSPNTransient engine. Immediate events are removed by solving absorption probabilities of immediate components that may include cycles. Transient probabilities are computed using uniformization and the Fox-Glynn algorithm to select Poisson probabilities.

double step = 0.1;
Pair<Map<Marking, Integer>, double[][]> result = GSPNTransient.builder()
    .timePoints(0.0, 10.0, step)
    .build().compute(pn, marking);

Map<Marking, Integer> statePos = result.first();
double[][] probs = result.second();

int markingPos = statePos.get(targetMarking);
for (int t = 0; t < probs.length; t++) {
    double time = t * step;
    Sytem.out.printf("%.1f %.6f", time, probs[t][markingPos]);
}

The available options when building GSPNTransient are:

  • timePoints(double[]): sets the time points for which transient probabilities must be computed.
  • timePoints(start, end, step): sets evenly spaced values as time points for transient probabilities. The distance between points is given by step; the first point is start and the last one is greater or equal to end.
  • error(double): specifies the error allowed in the computation of Poisson probabilities with the Fox-Glynn algorithm (for each time point, 1e-6 by default).
  • epsilon(double): specifies the threshold used to decide whether a probability value should be considered equal to 0.0 in the analysis (1e-9 by default).
  • stopOn(Supplier<StopCriterion>): to stop the analysis on some nodes (never by default).
  • stopOn(MarkingCondition): to use a simple MarkingCondition as stop criterion.