Class StochPetriNetExamples

java.lang.Object
jline.examples.java.basic.StochPetriNetExamples

public class StochPetriNetExamples extends Object
Stochastic Petri net examples mirroring the example notebooks in stochPetriNet.

This class contains Java implementations that mirror the example notebooks found in jar/src/main/java/jline/examples/java/basic/stochPetriNet/. Each method demonstrates a specific Petri net concept using models from the basic package.

The examples cover: - Basic open and closed Petri net structures - Multiple firing modes and batch processing - Inhibiting conditions and complex token flows - Various stochastic distributions in transitions - Multi-class token systems

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    Main method demonstrating selected Petri net examples.
    static void
     
    static void
    Basic open stochastic Petri net (spn_basic_open.ipynb).
    static void
    Closed Petri net with four places (spn_closed_fourplaces.ipynb).
    static void
    Closed Petri net with two places (spn_closed_twoplaces.ipynb).
    static void
    `spn_colored_gspn.m`: a colored generalized stochastic Petri net.
    static void
    `spn_fluid_dae.m`: fluid (mean-field) analysis of a stochastic Petri net.
    static void
    Competing transitions Petri net (spn_fourmodes.ipynb).
    static void
    Inhibiting transitions Petri net (spn_inhibiting.ipynb).
    static void
    `spn_lpbounds.m`: bound a stochastic Petri net by linear programming.
    static void
    Open Petri net with seven places (spn_open_sevenplaces.ipynb).
    static void
    Pareto-distributed transition firing (spn_pareto_service.ipynb).
    static void
    `spn_productform_nc.m`: solve a stochastic Petri net analytically with NC.
    static void
    `spn_queueing_place.m`: a closed queueing Petri net (QPN) with two queueing places.
    static void
    Batch processing Petri net (spn_twomodes.ipynb).
    static void
    `test_spn_nrm_open.m`: the SSA Next-Reaction-Method path on OPEN nets.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StochPetriNetExamples

      public StochPetriNetExamples()
  • Method Details

    • spn_pareto_service

      public static void spn_pareto_service() throws Exception
      Pareto-distributed transition firing (spn_pareto_service.ipynb).

      Simulation only: the golden holds the JMT row at the reference's seed and run length.

      Throws:
      Exception
    • spn_basic_closed

      public static void spn_basic_closed() throws Exception
      Throws:
      Exception
    • spn_basic_open

      public static void spn_basic_open() throws Exception
      Basic open stochastic Petri net (spn_basic_open.ipynb).

      Shows fundamental open Petri net structure with source, place, transition, and sink.

      Throws:
      Exception
    • spn_twomodes

      public static void spn_twomodes() throws Exception
      Batch processing Petri net (spn_twomodes.ipynb).

      Demonstrates batch token processing where transitions require and produce multiple tokens.

      Throws:
      Exception
    • spn_fourmodes

      public static void spn_fourmodes() throws Exception
      Competing transitions Petri net (spn_fourmodes.ipynb).

      Shows resource competition between transitions requiring different numbers of tokens.

      Throws:
      Exception
    • spn_inhibiting

      public static void spn_inhibiting() throws Exception
      Inhibiting transitions Petri net (spn_inhibiting.ipynb).

      Demonstrates inhibitor arcs that prevent firing when tokens are present in certain places.

      Throws:
      Exception
    • spn_closed_twoplaces

      public static void spn_closed_twoplaces() throws Exception
      Closed Petri net with two places (spn_closed_twoplaces.ipynb).

      Simple closed system demonstrating token circulation between two places with different service rates.

      Throws:
      Exception
    • spn_closed_fourplaces

      public static void spn_closed_fourplaces() throws Exception
      Closed Petri net with four places (spn_closed_fourplaces.ipynb).

      More complex closed system with tokens cycling through four different places using multiple transitions.

      Throws:
      Exception
    • spn_open_sevenplaces

      public static void spn_open_sevenplaces() throws Exception
      Open Petri net with seven places (spn_open_sevenplaces.ipynb).

      Complex open system demonstrating token flow through multiple places with varied routing probabilities.

      Throws:
      Exception
    • spn_productform_nc

      public static void spn_productform_nc() throws Exception
      `spn_productform_nc.m`: solve a stochastic Petri net analytically with NC.

      NC's rec method is the first ANALYTICAL route LINE offers for a Petri net: CTMC builds the explicit generator, SSA and LDES simulate, FLD fluidises. It works in three steps, each with its own reference:

      • Spn_pf decides whether the net has a product form and derives the per-place factors g_l, by complex balance (Coleman-Henderson-Taylor, Perform. Eval. 26(3), 1996);
      • Mdd_rec evaluates G as ONE memoised walk of the decision diagram holding the reachable set (Balsamo-Marin-Stojic, FGCS 111 (2020) 475-490);
      • Spn_metrics reads the mean tokens, the utilisations and the throughputs off masked walks of the same diagram.

      Two nets are solved. The first is a closed cycle, which a queueing network could also express. The second FORKS: Tf consumes one token and produces two, so the marking is not a conserved job population and there is no queueing-network counterpart, which is the limitation the MDD-rec paper opens with.

      Throws:
      Exception - if a solver encounters an error
    • spn_lpbounds

      public static void spn_lpbounds() throws Exception
      `spn_lpbounds.m`: bound a stochastic Petri net by linear programming.

      BA's spnlp family is the first BOUNDING route LINE offers for a Petri net, and it needs neither a generator nor a product form. It relaxes the stationary chain to a MOMENT POLYTOPE (the uniformized evolution equation written for E[X_p], E[X_p^2] and E[X_p1 X_p2], plus behavioural and probabilistic inequalities) and then minimises and maximises each reported measure over it. Every stationary point of the true chain satisfies every row, so the two optima bracket the exact value.

      Reference: Z. Liu, "Performance Analysis of Stochastic Timed Petri Nets Using Linear Programming Approach", IEEE Trans. Software Engineering 24(11), 1998, 1014-1030.

      Throws:
      Exception - if a solver encounters an error
    • spn_queueing_place

      public static void spn_queueing_place() throws Exception
      `spn_queueing_place.m`: a closed queueing Petri net (QPN) with two queueing places.

      A queueing place embeds a scheduling station inside a Petri-net place: an arriving token is served by the place's embedded queue and, on completion, moves to a depository from which the output transitions consume it. A CPU (single-server FCFS) and a think stage (infinite server) here exchange a fixed population of N tokens through two immediate transitions, which is the queueing-Petri-net rendering of a machine-repairman model, so MVA on the equivalent Delay+Queue network cross-validates it exactly.

      Throws:
      Exception - if a solver encounters an error
    • spn_colored_gspn

      public static void spn_colored_gspn() throws Exception
      `spn_colored_gspn.m`: a colored generalized stochastic Petri net.

      A GSPN mixes timed transitions, which fire after a random delay, with immediate ones, which fire as soon as they are enabled and consume no time. It is colored when the tokens carry a type, which in LINE is a job class: a place holds one marking per color and a transition declares one mode per color. Two colors circulate between a buffer and a server; the immediate transition admits a token only into an empty server, through inhibitor arcs on BOTH colors, and the firing weights arbitrate the conflict when both colors are waiting. CTMC eliminates the vanishing markings by stochastic complementation and solves the 8 tangible states exactly; SSA reproduces them by simulation.

      Throws:
      Exception - if a solver encounters an error
    • spn_fluid_dae

      public static void spn_fluid_dae() throws Exception
      `spn_fluid_dae.m`: fluid (mean-field) analysis of a stochastic Petri net.

      A GSPN is a density-dependent Markov population process: the marking is the population, a transition mode is a reaction, and the firing rate lambda*min(enabling degree, servers) is the same min() non-linearity the min-normal closure of FLD exists to smooth. The dae method is the one that can carry it, because a Petri net needs three things stated as EQUATIONS rather than integrated: the P-invariants, which hold to solver tolerance instead of integrator tolerance; the firing FLOW of an immediate transition, an algebraic unknown pinned by the constraint that its input place holds no mass; and a bounded place, a linear inequality on the marking.

      FLD resolves to dae on any model holding a Transition node, so no method has to be named. Unlike every other solver of a Petri net in LINE it also returns a SECOND MOMENT: the marking covariance of the linear noise approximation, on FluidResult.petri.

      Throws:
      Exception - if a solver encounters an error
    • test_spn_nrm_open

      public static void test_spn_nrm_open() throws Exception
      `test_spn_nrm_open.m`: the SSA Next-Reaction-Method path on OPEN nets.

      A Source feeds a Place whose tokens drain through a Transition to a Sink. Before the Source-arrival reaction was added the fed Place stayed empty and the run threw "Deadlock: no transition is enabled".

      Each net asserts that the solver actually ran method nrm (never a silent serial fallback) and that the simulated marking mean and throughput match the analytic M/M/1 result: a Source Exp(lambda) feeding a single-server Transition Exp(mu) is an M/M/1 queue at the Place, with mean tokens rho/(1-rho) and throughput lambda. The canonical net is cross-checked against JMT.

      Throws:
      Exception - if a solver encounters an error
    • main

      public static void main(String[] args) throws Exception
      Main method demonstrating selected Petri net examples.
      Throws:
      Exception