PetriNets

Library to model timed, stochastic Petri nets and state transition diagrams, extended version.

PetriNets.Interfaces PetriNets.Examples PetriNets.Place01 PetriNets.Place10 PetriNets.Place11 PetriNets.Place21 PetriNets.Place12 PetriNets.Place22 PetriNets.Transition PetriNets.Parallel PetriNets.Synchronize PetriNets.Modules PetriNets.ExamplesExtendedPetriNets PetriNets.Extensions

Information



The standard Modelica library contains a sub-library PetriNet for modeling of discrete phenomena with Petri net formalism. It is designed for, and implements, black deterministic priority Petri nets, which are well suited e.g., for control system specification but can have rather limited expressiveness in other problem domains. Such may be in reliability engineering or in investigation of socio-technical aspects of complex technical systems.

Therefore, the Petri net library already available is extended to form a new library ExtendedPetriNet with

  1. transitions allowing for deterministic or stochastic time delays before their firing (using builit-in random number generators BIRNG or custom made ones), and
  2. places capable of containing more than one token,
such that timed, stochastic Petri nets can be modeled.

Several modeling and simulation examples are given to demonstrate the usability of the enhancements - among them - queuing models and models to determine system availability, see the adjoned *.pdf document Petri_Net_Extensions.

For the time being, the extended library is currently structured in a manner that all extensions are clearly seperated from the original Petri net library. Three sub-packages have been added:

  1. Extensions
  2. Modules
  3. ExamplesExtendedPetriNets.
At a later time, the additions could be fully integrated if desired.

Author:
Stefan Fabricius
Swiss Federal Institute of Technology (ETH)
Laboratory for Safety Analysis
Weinbergstrasse 11
8001 Zurich
Switzerland
email: fabricius@lsa.iet.mavt.ethz.ch

Release History and Notes:


Copyright (C) 2002, with the author.

The ExtendedPetriNet library is free software; it can be redistributed and/or modified under the terms of the Modelica license, see the license conditions in the documentation to Modelica.

The library comes with absolutely no warranty. It has been carefully tested, yet, the absence of faults or bugs cannot be guaranteed.

Comments or bug reports are most welcome.


Below listed is the information to the orginal, not extended PetriNet library.

The PetriNets library allows to model discrete components by a special kind of Petri nets with at most one token on a place, as well as by state transition diagrams (which are special kinds of Petri nets). Petri nets and state transition diagrams are "higher level" constructs for the description of switching elements, parallel activities or syncronization. For several kinds of applications it is much easier and clearer to use these components instead of modeling the discrete behaviour directly with the basic language constructs of Modelica ("if" or "when" statements). A typical Petri net is shown in the following figure:

Petri net

A Petri net is defined in the following way:

  1. It consists of a set of places and of a set of transitions. The places are split into start places which are "active" at the start of the simulation and of "normal" places which are "non-active" at the beginning.
  2. Places are connected by transitions, whereby no places and no transitions are directly connected (i.e., a place is connected to a transition which in turn is connected to another place). Any number of start places can be present.
  3. An "active" place is characterized by a "token" placed on the place. In the ModelicaAdditions.PetriNets libray a place is "active" when the public variable "state" of the place is true.
  4. There are several transition elements in the library. Whenever the states of all inputs to the transition elements are active and when the condition of the transition is true then the following actions are performed: The conditionPort connector of a transition element is used to signal via a Boolean signal whether the condition of a transition is true or false. Alternatively, the condition can be provided as an equation to set the public variable condition of the corresponding transition element.
  5. There are several place components in this library (such as Place01, Place10, Place11) which have different number of input and output transition connectors. This is due to the current limitations of the annotations of Modelica, which do not allow to define the graphical location of the elements of a vector of (transition) connectors with unknown length.
  6. If two or more transitions of a place would fire at the same time instant, priorities are used in order that exactly one of them fires. The highest priority has a transition connector of a place with the lowest index (e.g. outTransition1 has a higher priority as outTransition2).

The method used in this library to realize Petri nets in Modelica is described in detail in:

Mosterman P.J., Otter M. and Elmqvist H. (1998):
Modeling Petri-Nets as Local Constraint Equations for Hybrid Systems using Modelica. 1998 Summer Computer Simulation Conference (SCSC'98), Reno, U.S.A., 19.-20. Juli (download from here).

This package is not part of the Modelica standard library, because it is planned to realize a package with only one place and one transition component, once vector connectors with unknown length have better support in Modelica.

Main Author:
Martin Otter
Deutsches Zentrum für Luft und Raumfahrt e.V. (DLR)
Institut für Robotik und Mechatronik
Postfach 1116
D-82230 Wessling
Germany
email: Martin.Otter@dlr.de

Release Notes:


Copyright (C) 2000, DLR.

The ModelicaAdditions.PetriNets package is free software; it can be redistributed and/or modified under the terms of the Modelica license, see the license conditions and the accompanying disclaimer in the documentation of package Modelica in file "Modelica/package.mo".


The extensions to the original are not specifically internally documented at this time. Copyright for extensions with S. Fabricius, ETH Zurich, Switzerland, December 20th, 2001.


PetriNets.Place01 PetriNets.Place01

Place with one output transition

PetriNets.Place01

Parameters

NameDefaultDescription
initialStatefalseInitial value of state

Modelica definition

model Place01 "Place with one output transition"
  parameter Boolean initialState=false "Initial value of state";
  Boolean state(final start=initialState) "State of place";
protected
  Boolean newState(final start=initialState);
public
  PetriNets.Interfaces.FirePortOut outTransition;
equation
  // Set new state for next iteration
  state = pre(newState);
  newState = state and not outTransition.fire;
  
  // Report state to output transition
  outTransition.state = state;
end Place01;

PetriNets.Place10 PetriNets.Place10

Place with one input transition

PetriNets.Place10

Parameters

NameDefaultDescription
initialStatefalseInitial value of state

Modelica definition

model Place10 "Place with one input transition"
  parameter Boolean initialState=false "Initial value of state";
  Boolean state(final start=initialState) "State of place";
protected
  Boolean newState(final start=initialState);
public
  PetriNets.Interfaces.SetPortIn inTransition;
equation
  // Set new state for next iteration
  state = pre(newState);
  newState = inTransition.set or state;
  
  // Report state to input transition
  inTransition.state = state;
end Place10;

PetriNets.Place11 PetriNets.Place11

Place with one input and one output transition

PetriNets.Place11

Parameters

NameDefaultDescription
initialStatefalseInitial value of state

Modelica definition

model Place11 "Place with one input and one output transition"
  parameter Boolean initialState=false "Initial value of state";
  Boolean state(final start=initialState) "State of place";
protected
  Boolean newState(final start=initialState);
public
  PetriNets.Interfaces.SetPortIn inTransition;
  PetriNets.Interfaces.FirePortOut outTransition;
equation
  // Set new state for next iteration
  state = pre(newState);
  newState = inTransition.set or state and not outTransition.fire;
  
  // Report state to input and output transitions
  inTransition.state = state;
  outTransition.state = state;
end Place11;

PetriNets.Place21 PetriNets.Place21

Place with two input and one output transition

PetriNets.Place21

Parameters

NameDefaultDescription
initialStatefalseInitial value of state

Modelica definition

model Place21 "Place with two input and one output transition"
  parameter Boolean initialState=false "Initial value of state";
  Boolean state(final start=initialState) "State of place";
protected
  Boolean newState(final start=initialState);
public
  PetriNets.Interfaces.FirePortOut outTransition;
  PetriNets.Interfaces.SetPortIn inTransition1;
  PetriNets.Interfaces.SetPortIn inTransition2;
equation
  // Set new state for next iteration
  state = pre(newState);
  newState = inTransition1.set or inTransition2.set or state and not
    outTransition.fire;
  
  // Report state to input and output transitions
  inTransition1.state = state;
  inTransition2.state = inTransition1.state or inTransition1.set;
  outTransition.state = state;
end Place21;

PetriNets.Place12 PetriNets.Place12

Place with one input and two output transitions

PetriNets.Place12

Parameters

NameDefaultDescription
initialStatefalseInitial value of state

Modelica definition

model Place12 "Place with one input and two output transitions"
  parameter Boolean initialState=false "Initial value of state";
  Boolean state(final start=initialState) "State of place";
protected
  Boolean newState(final start=initialState);
public
  PetriNets.Interfaces.SetPortIn inTransition;
  PetriNets.Interfaces.FirePortOut outTransition1;
  PetriNets.Interfaces.FirePortOut outTransition2;
equation
  // Set new state for next iteration
  state = pre(newState);
  newState = inTransition.set or state and not (outTransition1.fire or
    outTransition2.fire);
  
  // Report state to input and output transitions
  inTransition.state = state;
  outTransition1.state = state;
  outTransition2.state = outTransition1.state and not outTransition1.fire;
end Place12;

PetriNets.Place22 PetriNets.Place22

Place with two input and two output transitions

PetriNets.Place22

Parameters

NameDefaultDescription
initialStatefalseInitial value of state

Modelica definition

model Place22 "Place with two input and two output transitions"
  parameter Boolean initialState=false "Initial value of state";
  Boolean state(final start=initialState) "State of place";
protected
  Boolean newState(final start=initialState);
public
  PetriNets.Interfaces.FirePortOut outTransition1;
  PetriNets.Interfaces.FirePortOut outTransition2;
  PetriNets.Interfaces.SetPortIn inTransition1;
  PetriNets.Interfaces.SetPortIn inTransition2;
equation
  // Set new state for next iteration
  state = pre(newState);
  newState = inTransition1.set or inTransition2.set or state and not (
    outTransition1.fire or outTransition2.fire);
  
  // Report state to input and output transitions
  inTransition1.state = state;
  inTransition2.state = inTransition1.state or inTransition1.set;
  outTransition1.state = state;
  outTransition2.state = outTransition1.state and not outTransition1.fire;
end Place22;

PetriNets.Transition PetriNets.Transition

Transition with one input and one output connection

PetriNets.Transition

Parameters

NameDefaultDescription
condLabel" "Condition as string (e.g. "x > 0")

Modelica definition

model Transition
  "Transition with one input and one output connection"
  parameter String condLabel=" "
    "Condition as string (e.g. \"x > 0\")";
  Boolean condition;
  Boolean fire;
  PetriNets.Interfaces.FirePortIn inTransition;
  PetriNets.Interfaces.SetPortOut outTransition;
  Modelica.Blocks.Interfaces.BooleanInPort conditionPort(final n=1);
equation
  condition = conditionPort.signal[1];
  fire = condition and inTransition.state and not outTransition.state;
  inTransition.fire = fire;
  outTransition.set = fire;
end Transition;

PetriNets.Parallel PetriNets.Parallel

Transition with one input and two output connections

PetriNets.Parallel

Parameters

NameDefaultDescription
condLabel" "Condition as string (e.g. "x > 0")

Modelica definition

model Parallel "Transition with one input and two output connections"

  parameter String condLabel=" "
    "Condition as string (e.g. \"x > 0\")";
  Boolean fire;
  Boolean condition;
  PetriNets.Interfaces.FirePortIn inTransition;
  PetriNets.Interfaces.SetPortOut outTransition1;
  PetriNets.Interfaces.SetPortOut outTransition2;
  Modelica.Blocks.Interfaces.BooleanInPort conditionPort(final n=1);
equation
  condition = conditionPort.signal[1];
  fire = condition and inTransition.state and not (outTransition1.state or
    outTransition2.state);
  inTransition.fire = fire;
  outTransition1.set = fire;
  outTransition2.set = fire;
end Parallel;

PetriNets.Synchronize PetriNets.Synchronize

Transition with two input and one output connections

PetriNets.Synchronize

Parameters

NameDefaultDescription
condLabel" "Condition as string (e.g. "x > 0")

Modelica definition

model Synchronize
  "Transition with two input and one output connections"
  parameter String condLabel=" "
    "Condition as string (e.g. \"x > 0\")";
  Boolean condition;
  Boolean fire;
  PetriNets.Interfaces.FirePortIn inTransition1;
  PetriNets.Interfaces.FirePortIn inTransition2;
  PetriNets.Interfaces.SetPortOut outTransition;
  Modelica.Blocks.Interfaces.BooleanInPort conditionPort(final n=1);
equation
  condition = conditionPort.signal[1];
  fire = condition and inTransition1.state and inTransition2.state and not
    outTransition.state;
  inTransition1.fire = fire;
  inTransition2.fire = fire;
  outTransition.set = fire;
end Synchronize;

HTML-documentation generated by Dymola Tue Apr 30 22:43:02 2002 .