Upload
rexkarz
View
214
Download
0
Embed Size (px)
Citation preview
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
1/225
Petri Net Modelling UsingConstraints
Michael J. Sanders
School of Computer Science and Software Engineering
Faculty of Information Technology
Monash University
March 2004
Thesis submitted for the degree of
Master of Information Technology (Research)
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
2/225
Declaration:
This thesis contains no material which has been accepted for the
award of any other degree or diploma in any university or other
institution. To the best of my knowledge and belief, the thesis
contains no material previously published or written by another
person, except where due reference is made in the text of the
thesis.
Michael J. Sanders
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
3/225
Acknowledgements
The author wishes to sincerely thank Professor Jim Breen and Doctor Ken Parker for
their support and feedback throughout the duration of this research. Special thanks
are due to Professor Breen for facilitating and encouraging my role in the research to
begin with.
Thanks are also due to IBM and IBM Global Services in Australia for their support
and for the opportunity to experience the patent submission process.
Above all, I would like to thank my dear wife Ros for her tolerance and understanding.
Mick Sanders, Melbourne, March 2004.
i
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
4/225
Contents
1 Introduction 1
1.1 Problem Statement and Aim . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Research Approach and Outline . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Contributions of the Thesis . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Notes on the Terminology Used in this Thesis . . . . . . . . . . . . . . 5
1.5 Copyright and Patent Restrictions . . . . . . . . . . . . . . . . . . . . . 5
2 Multi-sets 6
2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Formal Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 New Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3 Petri Nets and Net Unfolding 12
3.1 Place/Transition Nets . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 High-Level Petri Nets . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.1 Predicate/Transition nets . . . . . . . . . . . . . . . . . . . . . 17
3.2.2 Coloured Petri nets . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.3 Extensions to High-Level Petri Nets . . . . . . . . . . . . . . . . . . . . 20
3.3.1 Timed tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3.2 Inhibitor and equality arcs . . . . . . . . . . . . . . . . . . . . . 21
3.4 High Level Petri Net Unfolding . . . . . . . . . . . . . . . . . . . . . . 23
3.4.1 Finite place colour set . . . . . . . . . . . . . . . . . . . . . . . 25
ii
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
5/225
3.4.2 Finite place colour set - restricted firing . . . . . . . . . . . . . 25
3.4.3 Infinite place colour set - unrestricted firing . . . . . . . . . . . 27
3.4.4 Infinite place colour set - restricted firing . . . . . . . . . . . . . 28
3.4.5 Multi-set arc expressions . . . . . . . . . . . . . . . . . . . . . . 29
3.4.6 Partially unfolding high-level nets to other high-level nets . . 29
3.5 Formulating High-Level Petri Net Firing Rules . . . . . . . . . . . . . . 30
3.5.1 Required definitions . . . . . . . . . . . . . . . . . . . . . . . . 30
3.5.2 Constraint-free arcs . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.5.3 Unary constrained arcs . . . . . . . . . . . . . . . . . . . . . . . 34
3.5.4 Binary constrained arcs . . . . . . . . . . . . . . . . . . . . . . 35
3.5.5 K-ary constrained arcs . . . . . . . . . . . . . . . . . . . . . . . 36
3.6 Unfolding and Combinatorial Search . . . . . . . . . . . . . . . . . . . 37
3.7 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4 The Constraint Satisfaction Problem 39
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.1.1 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.2 The Binary Constraint Satisfaction Problem . . . . . . . . . . . . . . . 40
4.3 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.4 Systematic Search Methods . . . . . . . . . . . . . . . . . . . . . . . . 44
4.4.1 Generate-and-Test (GT) . . . . . . . . . . . . . . . . . . . . . . 45
4.4.2 Chronological Backtracking (BT) . . . . . . . . . . . . . . . . . 45
4.5 Consistency and Techniques . . . . . . . . . . . . . . . . . . . . . . . . 49
4.5.1 Node consistency (NC) techniques . . . . . . . . . . . . . . . . . 50
4.5.2 Arc consistency (AC) techniques . . . . . . . . . . . . . . . . . 51
4.6 Constraint Propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.6.1 Forward Checking (FC and MFC) . . . . . . . . . . . . . . . . . 57
4.6.2 Full Look Ahead (LA) . . . . . . . . . . . . . . . . . . . . . . . 60
4.7 Intelligent Backtracking . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.7.1 Backmarking (BM) . . . . . . . . . . . . . . . . . . . . . . . . . 62
iii
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
6/225
4.7.2 Backjumping (BJ) . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.7.3 Conflict-Directed Backjumping (CBJ) . . . . . . . . . . . . . . . 70
4.8 Combining Propagation with Smart Backtracking . . . . . . . . . . . . 73
4.8.1 Forward Checking with Conflict-Directed BackJumping (FC-CBJ) 73
4.9 K-ary Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.9.1 Dual transformation . . . . . . . . . . . . . . . . . . . . . . . . 75
4.9.2 Hidden transformation . . . . . . . . . . . . . . . . . . . . . . . 76
4.9.3 Direct solution by search . . . . . . . . . . . . . . . . . . . . . . 78
4.10 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
5 Representing High-Level Petri Nets as Constraint Satisfaction Prob-
lems 84
5.1 Required Definitions and Approach . . . . . . . . . . . . . . . . . . . . 85
5.2 Petri Nets and Conventional CSPs . . . . . . . . . . . . . . . . . . . . 86
5.3 CSP Representation Limitations . . . . . . . . . . . . . . . . . . . . . . 87
5.3.1 Resource consistency . . . . . . . . . . . . . . . . . . . . . . . . 88
5.3.2 Arc unfolding . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.4 Resource Allocation Problems and CSPs . . . . . . . . . . . . . . . . . 90
5.5 Definition of Resource CSPs . . . . . . . . . . . . . . . . . . . . . . . . 95
5.5.1 Unary Resource Constraints . . . . . . . . . . . . . . . . . . . . 95
5.5.2 Binary Resource Constraints . . . . . . . . . . . . . . . . . . . . 96
5.5.3 Value-Resource Consistency . . . . . . . . . . . . . . . . . . . . 98
5.6 Solving Resource CSPs . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
5.6.1 Node consistency . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.6.2 Forward Checking . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.6.3 Conflict-Directed Backjumping . . . . . . . . . . . . . . . . . . 100
5.6.4 Introduction to the FC-CBJ-M algorithm . . . . . . . . . . . . . 101
5.7 Listings for Algorithm FC-CBJ-M . . . . . . . . . . . . . . . . . . . . . 102
5.8 Solution of a General Resource Problem . . . . . . . . . . . . . . . . . 108
5.8.1 Problem statement . . . . . . . . . . . . . . . . . . . . . . . . . 109
iv
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
7/225
5.8.2 Problem solution . . . . . . . . . . . . . . . . . . . . . . . . . . 111
5.9 Limitations of FC-CBJ-M and a Proposal . . . . . . . . . . . . . . . . 114
5.10 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
6 Run-time Library and Compiler 120
6.1 Run-time Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . 121
6.2 Token and Place Representation . . . . . . . . . . . . . . . . . . . . . . 121
6.2.1 Multi-set structure within Places . . . . . . . . . . . . . . . . . 123
6.2.2 Token specialisation through inheritance . . . . . . . . . . . . . 124
6.2.3 Place/Token class structure and relationships . . . . . . . . . . 125
6.2.4 Timed tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
6.2.5 Place/Transition class relationship . . . . . . . . . . . . . . . . 126
6.3 Transition and Arc Representation . . . . . . . . . . . . . . . . . . . . 127
6.4 Net Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
6.5 Transition Occurrence and Constraints . . . . . . . . . . . . . . . . . . 129
6.5.1 Concurrency, interleaving and fairness . . . . . . . . . . . . . . 130
6.5.2 Overview of transition evaluation . . . . . . . . . . . . . . . . . 132
6.5.3 Evaluation of inhibitor and equality arcs . . . . . . . . . . . . . 134
6.5.4 Transition firing token removal and addition . . . . . . . . . 136
6.6 Compiler Language and Implementation . . . . . . . . . . . . . . . . . 137
6.6.1 OCELOT Grammar . . . . . . . . . . . . . . . . . . . . . . . . 137
6.6.2 An example the Dining Philosophers . . . . . . . . . . . . . . 137
6.6.3 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
6.7 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
7 OCELOT Examples 148
7.1 The Eight Queens Problem . . . . . . . . . . . . . . . . . . . . . . . . . 148
7.2 The Crypto Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
7.3 A Timed Token Example . . . . . . . . . . . . . . . . . . . . . . . . . . 154
7.4 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
v
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
8/225
8 Conclusions 157
A OCELOT EBNF Grammar 169
B OCELOT Run-time Source Code 175
B.1 Support.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
B.2 Support.cpp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
vi
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
9/225
List of Figures
2.1 A simple multi-set and its base set . . . . . . . . . . . . . . . . . . . . 7
2.2 Two-dimensional representation of a multi-set . . . . . . . . . . . . . 8
2.3 Multi-set subtraction in a 2D context . . . . . . . . . . . . . . . . . . 10
3.1 The (partial) Dining Philosophers P/T net . . . . . . . . . . . . . . . . 14
3.2 The Dining Philosophers high-level Petri net . . . . . . . . . . . . . . . 16
3.3 An example of inhibitor and equality arcs . . . . . . . . . . . . . . . . 22
3.4 Unfolding of a finite place Colour Set . . . . . . . . . . . . . . . . . . . 25
3.5 Unfolding of a constrained finite place Colour Set . . . . . . . . . . . . 26
3.6 Unfolding of an arc-constrained finite place Colour Set . . . . . . . . . 27
3.7 Unfolding of an infinite place Colour Set . . . . . . . . . . . . . . . . . 27
3.8 Unfolding of a constrained infinite place Colour Set . . . . . . . . . . . 28
3.9 Unfolding of multi-set arcs . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.10 Partial unfolding of a guard expression . . . . . . . . . . . . . . . . . . 30
3.11 Unary value constraints over arc/guard expressions . . . . . . . . . . . 35
3.12 Binary value constraints over arc/guard expressions . . . . . . . . . . . 36
3.13 K-ary value constraints over arc/guard expressions . . . . . . . . . . . 37
4.1 The Map Colouring Problem . . . . . . . . . . . . . . . . . . . . . . . . 41
4.2 The map problem as a network of relations . . . . . . . . . . . . . . . . 42
4.3 The Map Colouring binary constraints . . . . . . . . . . . . . . . . . . 43
4.4 Two backtracking solutions to the Map Colouring Problem . . . . . . . 46
4.5 Thrashing and redundant checking in backtracking . . . . . . . . . . 47
4.6 The map colouring problem with a unary constraint . . . . . . . . . . . 48
vii
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
10/225
4.7 An illustration of Backmarking . . . . . . . . . . . . . . . . . . . . . . 63
4.8 A non-binary constraint problem . . . . . . . . . . . . . . . . . . . . . 75
4.9 Dual transformation of the non-binary problem . . . . . . . . . . . . . 76
4.10 Hidden transformation of the non-binary problem . . . . . . . . . . . . 77
4.11 A simple k-ary constraint with interleaved variables . . . . . . . . . . . 79
4.12 Interleaved k-ary constraints . . . . . . . . . . . . . . . . . . . . . . . . 81
4.13 Interleaved k-ary graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
5.1 A value CSP as a PN transition-place group . . . . . . . . . . . . . . . 86
5.2 CSP with tuples and implicit constraints . . . . . . . . . . . . . . . . . 87
5.3 Net showing resource and value constraints . . . . . . . . . . . . . . . . 88
5.4 The net of figure 5.3 arc-unfolded . . . . . . . . . . . . . . . . . . . . . 90
5.5 A trivial resource problem as a Petri net . . . . . . . . . . . . . . . . . 91
5.6 Resource constraint graph for the trivial problem . . . . . . . . . . . . 94
5.7 Filtered domain views for resource-constrained variables . . . . . . . . 99
5.8 Forward Checking for resource consistency . . . . . . . . . . . . . . . . 100
5.9 Application of search techniques to the problem . . . . . . . . . . . . . 102
5.10 Staff supply for the resource problem . . . . . . . . . . . . . . . . . . . 109
5.11 Petri net for the staff resource problem . . . . . . . . . . . . . . . . . . 110
5.12 Constraint graph for the staff resource problem . . . . . . . . . . . . . 112
5.13 Solution graph for the staff resource problem . . . . . . . . . . . . . . . 113
5.14 Resource problem with generic multi-set demand . . . . . . . . . . . . 115
6.1 UML class diagram of main OCELOT run-time classes . . . . . . . . . 122
6.2 UML diagram relationship summary . . . . . . . . . . . . . . . . . . . 123
6.3 Place representation of a multi-set . . . . . . . . . . . . . . . . . . . . . 123
6.4 An example net with resource and value constraints . . . . . . . . . . . 128
6.5 Object structure for the example of figure 6.4 . . . . . . . . . . . . . . 129
6.6 An example of a binary constraint on an inhibitor arc . . . . . . . . . . 135
6.7 The Dining Philosophers example . . . . . . . . . . . . . . . . . . . . . 138
viii
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
11/225
7.1 One solution to the 8 Queens Problem . . . . . . . . . . . . . . . . . . 149
7.2 The 8 Queens Problem as a high-level Petri net . . . . . . . . . . . . . 150
7.3 The Crypto Problem as a high-level Petri net . . . . . . . . . . . . . . 152
7.4 A timed token example . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
ix
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
12/225
Chapter 1
Introduction
1.1 Problem Statement and Aim
Petri nets have traditionally been used for system modelling and verification, due to
their intuitive graphical representation and strong mathematical basis, and a large
body of literature exists to support such usage. Until very recently far less research
had been done, however, on the translation of declarative Petri net models to exe-
cutable imperative code. This remains the case particularly for high-level Petri net
formalisms. A considerable number of Petri net simulation and analysis tools exist in
either commercial or academic form, for example CPN/Tools [3], LOOPN++[41] and
PROD[39]. The body of literature discussing in detail the techniques of translation
into executable models, and the challenges faced in achieving it, is however small.
Simulation and dynamic (reachability) analysis of a high-level Petri net is dependent
upon the unfolding of the net. Because of their representational power even simple
high-level Petri nets may unfold to elementary nets of high complexity. Unfolding a net
corresponds to a translation from first order predicate logic to propositional logic, and
therefore facilitates implementation in a simple (third generation) imperative program-
ming language such as C. Achieving this unfolding is non-trivial because it ultimately
requires the combinatorial exploration of related value domains (in the form of place
markings). Some advanced high-level Petri net formalisms, for example Coloured Petri
1
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
13/225
Nets [37], are based on functions over multi-sets and may be described using variations
of functional languages such as ML [47]. Recent research has focused on algorithms
to improve the efficiency of unfolding using functional and algebraic methods, for ex-
ample [44] and [50]. Given the requirement in the unfolding process for state-space
exploration of value domains, it is perhaps surprising that Artificial Intelligence ap-
proaches such as constraint programming have not been prominently promoted as an
approach to unfolding. In particular the Constraint Satisfaction Problem (CSP) is an
established problem representation that has well-studied associated search techniques.
Although it has been recognised for some time that Petri nets can be used to represent
the Constraint Satisfaction Problem [11][57], to the authors knowledge no one has pre-
viously investigated the application of advanced CSP search techniques to the unfolding
problem. This constitutes a gap in the literature for both the CSP and Petri net for-
malisms, and the absence of a possible avenue of investigation for unfolding techniques.
The aim of this thesis, and its related publications, is to address this gap by inves-
tigating the applicability of Constraint Satisfaction Problem search techniques to the
unfolding of high-level Petri nets. Furthermore its goal is to demonstrate a working,
and reasonably efficient, implementation of the resultant techniques in a Petri net
context.
1.2 Research Approach and Outline
To achieve its aim, the thesis builds upon research into Petri nets and multi-set CSPs
originally published by the author in [61], [62] and [63]. It commences with a formal re-
view of multi-sets, an essential mathematical construct for the study of high-level Petri
nets (chapter 2). This chapter also introduces a simple new definition by the author
for elementary multi-sets. The thesis follows this in chapter 3 with a brief review and
definition of Place/Transition and high-level Petri nets, before presenting a detailed
investigation by the author into the firing rules for high-level Petri nets and their rela-
tionship to unary, binary and k-ary constraints over the net arc and guard expressions.
2
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
14/225
The thesis then provides a formal introduction to, and literature review for, the binary
Constraint Satisfaction Problem (CSP), including the established approaches and al-
gorithms developed for its solution (chapter 4). This chapter is intended to provide a
comprehensive understanding of the CSP as well as to clearly identify the benefits and
limitations of commonly applied techniques and algorithms. The chapter additionally
defines and discusses the solution of non-binary (k-ary) constraints, since chapter 3
shows that these will be encountered in any Petri net simulation environment. A novel
approach to k-ary constraint representation and solution, developed by the author, is
presented here. The thesis then presents the results of the authors investigation into
the applicability of binary and non-binary CSPs to the representation and unfolding
of high-level Petri nets (chapter 5). The unsuitability of conventional CSPs for this
purpose is identified and demonstrated here. This chapter then introduces and defines
the authors new multi-set-based constraint problem representation termed resource
value constraints and an algorithm, FC-CBJ-M, to solve it. The derivation of this
algorithm from the established CSP algorithms of chapter 4 is shown. The application
of the new representation, and the associated algorithm, to Petri net unfolding as well
as to many resource allocation problems is discussed. Examples of the latter problems
are presented to demonstrate the algorithms utility. The thesis continues in chap-
ter 6 by presenting details of the authors practical implementation of the preceding
research, a tool-set called OCELOT (a recursive definition for: OCELOT Continually
Expands, Leading to an Over-size Thesis). OCELOT is a simple high-level Petri net
modelling tool. Its distinguishing characteristic is that it translates programs written
in its high-level net language directly into imperative C++ source code, which is thenlinked with a run-time library. The library implements the FC-CBJ-M algorithm, and
the generated C++ source may be either modified directly for real-world applications,
or linked to external code through a defined mechanism. The thesis achieves its goal
in chapter 7 by introducing several high-level Petri net examples, illustrating how the
OCELOT tool-set represents them as both a constraint representation and as an im-
perative language artifact, and presenting measurements of OCELOT unfolding speed.
The author concludes this research in chapter 8 by examining how the findings of the
3
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
15/225
preceding chapters have contributed to the aim of the thesis, and summarising these
results. Gaps in the research and avenues for possible further research are identified.
Appendices A and B present, respectively, generated C++ code for the examples of
chapter 7, the EBNF grammar for the OCELOT compiler and the C++ listings for
the run-time library of OCELOT.
1.3 Contributions of the Thesis
As noted in the preceding section, key elements of this research have been published
in the following refereed papers [61][62][63]:
M. J. Sanders, Constraint programming with object-oriented Petri nets, in Pro-
ceedings of the 1998 International Conference on Systems, Man, and Cybernetics,
volume 1, (San Diego, CA, USA), pp. 289294, IEEE, October 1998.
M. J. Sanders, Constraint satisfaction over shared multi-set value domains,
in Proceedings of the 6th Pacific Rim International Conference on Artificial In-
telligence (PRICAI 2000), (R. Mizoguchi and J. Slaney, eds.), Lecture Notesin Artificial Intelligence 1886, p. 796, Melbourne, Australia: SpringerVerlag,
AugustSeptember 2000.
M. J. Sanders, Efficient computation of enabled transitions in high-level Petri
nets, in Proceedings of the 2000 International Conference on Systems, Man, and
Cybernetics, (Nashville, TN, USA), pp. 31533158, IEEE, October 2000.
The latter two publications present the authors work on multi-set constraint satisfac-
tion and the FC-CBJ-M algorithm. The thesis additionally contributes to the liter-
ature the definitions for elementary multi-sets (chapter 2), the relationship between
high-level Petri net arc and guard expression and constraints (chapter 3), the k-ary
back-jumping approach to non-binary constraints (chapter 4), the concept ofresource
value constraints and the FC-CBJ-M algorithm (chapter 5) and some techniques used
in the OCELOT compiler and run-time library (chapter 6).
4
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
16/225
The authors employer, IBM Global Services, has funded the filing of a US patent
application on behalf of IBM Corporation, of Armonk, New York. This patent appli-
cation covers aspects of the resourcevalue constraint representation of problems and
the application of the FC-CBJ-M algorithm to the solution of such problems. This
patent is currently pending.
1.4 Notes on the Terminology Used in this Thesis
Petri nets and the Constraint Satisfaction Problem (CSP) are both graph-based for-
malisms and as a consequence they share some terminology, such as nodes, arcs and
paths. This is a potential source of confusion and where necessary the author has iden-
tified areas of possible confusion (refer to subsection 4.1.1).
Where not explicitly identified otherwise the graph terminology should be assumed
to refer to Petri nets and not CSPs.
1.5 Copyright and Patent Restrictions
Certain aspects of the research into resourcevalue constraints and the FC-CBJ-M
algorithm are covered by US and international patent law while the above-mentioned
patent is pending and, should the patent be granted, afterward. It is requested that
any party wishing to make commercial use of, or distribute, this research contact the
author beforehand.
5
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
17/225
Chapter 2
Multi-sets
In this chapter the author presents a definition and discussion of multi-sets. A sep-
arate chapter is devoted to this topic because of the critical importance of multi-set
theory, both to the understanding of high-level Petri nets and to the application of
the new constraint satisfaction techniques the author later presents for the simulation
and analysis of such nets. Section 2.1 gives an informal overview of multi-sets, while
section 2.2 presents a formal definition of them. Finally section 2.3 introduces new
definitions and concepts crucial to the authors work.
2.1 Overview
Multi-sets have a basis in set theory. Informally, a multi-set, or bag, is a set of values
over some domain where there are one or more instances of each value. Where there
is exactly one instance of each value the multi-set is also a set. Multi-sets are thus
always defined over a base set. For example, figure 2.1 shows a multi-set over a set
of colours (a) and its corresponding base set (b). The multi-set shown is denoted by:
3`red+ 2`green+ 1`blue, where the notation 3 red is pronounced as three-prime-red.
6
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
18/225
R
R
RG
GR B
B
(a) multiset (b) base set
G
Figure 2.1: A simple multi-set and its base set
2.2 Formal DefinitionThe formal definitions presented below are based on those of Jensen[37].
A multi-set m is a function m [D N] over the non-empty base set D, where
N is the set of non-negative integers and [D N] is the set of all functions from D
to N. The set D is the base set over which m is defined.
The integer function m(e) N is the number of instances of the element e D .
Element e is said to belong to m (that is, e m) iff m(e) = 0 (that is, e D). In
the case where m(e) is unity for all e D , the multi-set m is identical to the set D
over which it is defined. The set of non-negative integers {m(e) | s D} is termed
the coefficients of m and the integer m(e) is termed the coefficient of e . Each empty
multi-set (where all coefficients are zero) is denoted by the common empty multi-set .
Multi-sets are usually denoted by the shorthand notation m(e1) e1 + + m(en) en ;
for example, as already noted the multi-set of figure 2.1(a) would be denoted by
3 red+ 2 green+ 1 blue . Elements with coefficients of zero are omitted for clarity,
and the optional notation e shall be equivalent to the notation 1`e (that is, denoting
elements whose coefficient is one).
7
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
19/225
For illustration we will use simple multi-sets with a base set constrained to a fi-
thesetN
domain (integers < 10) domain (integers < 10)
setmembership 43 + 34 + 25 + 17{3, 4, 5, 7}
base set multiset
Figure 2.2: Two-dimensional representation of a multi-set
nite set of integers. The relationship between a multi-set and its base set is shown
in figure 2.2, which illustrates the two-dimensional aspect of multi-sets due to each
element in the domain having a coefficient. This two-dimensional view of multi-sets
will prove important to the theoretical approach of this thesis and its tool-set imple-
mentation.
Formally, a multi-set m can be represented as a sum over its base set D :
m =
eD m(e) e
The following relations are defined over multi-sets:
8
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
20/225
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
21/225
thesetN
multiset m2
43 + 34 + 25 + 17
multiset m2
43 + 34 + 25 + 17
23 + 34 + 15 + 17
multiset m1
multiset m2
23 + 15
multiset m1
23 + 34 + 15 + 16 + 17
domain (integers < 10)
domain (integers < 10)
(subtraction not possible)
(b)(a)
domain (integers < 10)
domain (integers < 10) domain (integers < 10)
the
setN
the
setN
thesetN
thesetN
Figure 2.3: Multi-set subtraction in a 2D context
2.3 New Definitions
This chapter concludes with the introduction of two new definitions related to multi-
sets. For a multi-set m with a base set D, a BaseSet function S is defined over m:
S(m) = D.
For any multi-set this function generates the base set. Finally we introduce and define
the concept of an elementary multi-set. These multi-sets consist of a single element,
10
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
22/225
that is for an elementary multi-set the base set is a singleton:
|S()| = 1.
A multi-set m = m1 e1 + . . . + mn en is therefore elementary iff n = 1. The minimum
number of elementary multi-sets within m is given by n and the maximum number is
given by |m|. For example, given a multi-set m = 2`x + 3 y the minimal split ofm into
elementary multi-sets is:
m = 1 + 2 where 1 = 2 x and 2 = 3 y.
The maximal split of m into elementary multi-sets is:
m = 1 + . . . + 5 where 1 = x, 2 = x, 3 = y, . . . , 5 = y.
The reduction of a multi-set into its component elementary multi-sets is defined as
a result of multi-set addition, discussed earlier in this chapter.
2.4 Chapter Summary
In this chapter the author has reviewed basic multi-set theory and operations, and in-
troduced the concept of an elementary multi-set. The two-dimensional representation
of a multi-set presented here will prove important when the author discusses multi-set
constraint satisfaction problems in chapter 5. In the next chapter the author reviews
elementary and high-level Petri net properties before presenting an investigation into
net unfolding rules.
11
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
23/225
Chapter 3
Petri Nets and Net Unfolding
In this chapter the author provides a brief overview of simple Place/Transition Petri
nets and of high-level Petri nets. This is followed by a detailed discussion of the
unfolding of high-level nets and of their transition firing rules. Section 3.1 briefly
reviews Place/Transition Petri nets, then section 3.2 reviews high-level Petri nets in
the form of both Predicate Transition (PrT) nets and Coloured Petri nets (CPNs),
and some of their extensions. Section 3.4 then discusses how high-level Petri nets may
be unfolded to elementary Petri nets, and shows how this unfolding corresponds to a
solution of individual transition bindings. It is also noted that the unfolding is itself
a NP-complete combinatorial search problem. In section 3.5 the author formulates a
set of high-level Petri net firing rules as constraint problems, and shows how these rules
restrict the bindings that must be considered during unfolding. Section 3.6 concludes
this chapter by proposing the Constraint Satisfaction Problem (CSP) as a possible
model for Petri net unfoldings.
3.1 Place/Transition Nets
Petri nets [56] are a mathematical modelling tool. In this section the author introduces
one of the simplest form of Petri nets, Place/Transition nets (P/T Nets), and the term
Petri nets is used in this section to refer to these.
12
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
24/225
A Petri net is a digraph. There are two types of nodes in the graph, places (rep-
resented by circles) and transitions (represented by bars). The directed graph edges
are known as arcs. Places and transitions may be connected via input arcs from places
to transitions, and output arcs from transitions to places. Places contain tokens; these
have no explicit value associated with them, and in the nets considered here places
may contain any finite number (0 . . . n) of tokens. The overall state of the system (the
number of tokens in each place) is known as the marking of the net. The marking
represents the state of the system, while transitions represent activities that may oc-
cur in the system. Arcs have a cardinality (default of 1) associated with them, and
a transition is enabled if the number of tokens in each of its input places equals or
exceeds the cardinality of the associated input arc. If enabled a transition may fire,
in which case it removes from each input place the number of tokens specified by the
corresponding input arc, and adds to each output place the number of tokens specified
by each output arc.
Any number of enabled transitions may fire in parallel (or in any sequence). This
execution of a Petri net is known as playing the token game. A net that has one
or more transitions capable of firing is said to be live. Conversely, one with no en-
abled transition is dead. Figure 3.1 shows a P/T net representing the famous Dining
Philosophers Problem, where any of five philosophers attempt to move from a think-
ing state to a dining state by picking up the forks on each side of them (only one
philosophers transitions and arcs have been shown). Only two non-adjacent philoso-
phers may eat at the same time, and the problem is an example of parallel competitionfor resources, without deadlock.
Place markings in P/T nets can be regarded in terms of propositional logic, for example
in figure 3.1 the presence of a token in a philosophers thinking place means it is
true that this philosopher is thinking. This view of P/T nets is important when the
unfolding of high-level Petri nets is examined later. P/T nets are a powerful represen-
tational tool, however even the simplest problems can result in very large, complex nets.
13
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
25/225
forks
eat think
thinkingeating
Figure 3.1: The (partial) Dining Philosophers P/T net
Comprehensive introductions to Petri nets are given in Peterson [55] and Reiss [60]. Thefollowing definition of a Petri net is based on that of both Murata [51] and Jensen [37]:
A Petri net is a 5-tuple (P, T, A, E,I) where:
P = {p1, p2, . . . , pm} is a finite set of places,
T = {t1, t2, . . . , tn} is a finite set of transitions,
A (P T)
(T P) is a set of arcs,
E [A {1, 2, . . . , j}] is an arc expression function (arc cardinality),
I [P {0, 1, . . . , k}] is the initial marking of the net,
P T= and T P = .
14
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
26/225
Because of the inherent parallel nature of Petri nets they are ideal for modelling and
analysing parallel, concurrent and/or distributed systems. Their graphical nature al-
lows them to demonstrate causality, and they have a strong theoretical basis for anal-
ysis, both static (invariants, using matrix-based methods) and dynamic (reach-
ability, using graph-based methods). When devising a tool to model and execute
Petri nets a primary need is to consider dynamic behaviour of nets; this includes the
firing rules and the reachability graph. The author next introduces a more concise
representation, generically known as the high-level Petri net.
3.2 High-Level Petri NetsEven the simple example of figure 3.1 demonstrates that the modelling power of P/T
nets is limited. Complex problems result in very large P/T nets, and human readabil-
ity and mapping of causality (advantages of the graphical Petri net model) are often
lost. The propositional logic of these nets results in two undesirable outcomes:
1. The state of the system is widely distributed and hard to visualise, and there is
no functional grouping of sub-states. In the philosopher problem the modeler is
only interested in the status of the five forks and the status of their corresponding
philosophers. Instead the P/T net contains many typeless sub-states.
2. As a consequence of their distributed state P/T nets may contain structurally-
repeated functional chunks. For example, in the net of figure 3.1 the eat/think
activity and status of each philosopher is individually modeled.
A high-level Petri net is a generic term for nets that share the following characteristics:
Tokens are typed. For the nets considered here each place holds tokens represent-
ing any arbitrary value of a specific type (that is, types cannot be mixed within
a place). Token types may be basic scalars, such as integers or strings, through
to n-tuples of other types.
Places contain a multi-set of tokens, that is there may be multiple instances of
any token value.
15
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
27/225
Input arcs may be annotated with an expression that specifies not only cardi-
nality, but also a restriction on what values are prerequisites for the transition
firing and a mapping to local (transition scope only) variables. Output arcs may
have expressions that specify both cardinality and operations over local transition
variables.
Transitions may be annotated with a guard expression that restricts the con-
ditions for transition firing. This expression is formulated over a set of local
transition variables.
0+1+2+3+4
(i + 1) MOD 5
ii
j
i
i i
i[j = (i+1) MOD 5]
Eat Think
Thinking
Forks
Eating
0+1+2+3+4
Figure 3.2: The Dining Philosophers high-level Petri net
Figure 6.7 shows the Dining Philosopher problem of figure 3.1 modeled as a high-level
Petri net. This net is very readable because it directly models the three sub-states of the
problem, namely: the presence and identity of forks on the table, the philosophers who
are thinking, and those who are eating. Furthermore the action components of the
net are not replicated, and only one eat and one think transition are required. Note
that the scope of arc variables is local to their associated transition, so that variable i
16
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
28/225
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
29/225
3.2.2 Coloured Petri nets
Coloured Petri Nets (CPNs) [35][34][37] arose from the difficulty in performing invari-
ant analysis on PrT nets. These difficulties arise from the complexity of binding arc
and guard expression variables to values. CPNs overcome this problem by providing a
dual representation: expression-based and function-based. In the function-based rep-
resentation the relationship between variable binding and transition enabling is defined
in terms of functions over multi-sets. For dynamic (reachability) analysis and simula-
tion only the expression-based representation is required, and CPNs look (and behave)
similarly to PrT nets.
Jensen [34] formally defines a Coloured Petri net as a tuple CP N = (, P, T, A,N, C, G, E,I)
where:
is a finite set of colour sets, or types, which determine what values
and functions may be used in tokens and expressions. Colour sets may
themselves be infinite (for example, the set of all integers).
P is a finite set of places.
T is a finite set of transitions.
A is a finite set of arcs, where P
T = P
A = T
A = . Note
that P, T and A must be finite to avoid the possibility of infinite arcs.
N is a node function, N [A P T
T P]. It maps every
arc into a pair of nodes where the first is the source and the second is
the destination. The function must be from a place to a transition, or
vice-versa.
18
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
30/225
C is a colour function, C [P ], that maps each place to a colour
set. Every token in the place must have a value of that colour set, or
type.
G is a guard function, defined from T into expressions, where t T :
[TYPE(G(t)) = BOOLEAN
TYPE(VAR(G(t))) ]. The guard
expression is a boolean function and all variables in it must be of a type
from the set of colour sets.
E is an arc expression, defined from A into expressions, where a
A : [TYPE(E(a)) = C(p)ms
TYPE(VAR(E(a))) ]. Note that
p is the place of N(a). The arc expression must be a multi-set over the
colour set of the associated place.
I is an initialisation function, defined from P into closed (that is, con-
stant) expressions, where p P : [TYPE(I(p)) = C(p)ms]. Each
place may be initialised, or marked, with a multi-set of tokens from
its associated colour set. The marking of each place is finite, therefore
so is the initial marking.
Jensen also introduces the following notations for the arcs and variables associated
with a transition t T:
A(t) = {a A | N (a) P {t}
{t} P }. This defines all input
and output arcs for a transition t.
VAR(t) = {v | v VAR(G(t))
a A(t) : v VAR(E(a))}.
This defines all variables associated with a transition t.
19
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
31/225
Jensen has further defined hierarchical CPNs, which may be used to reduce net com-
plexity in a similar way to the use of functions and modules in high-level programming
languages. Such nets may be flattened to a non-hierarchical form and this thesis
deals only with non-hierarchical CPNs.
Investigation of the firing rules and unfoldings of CPNs requires the presentation of
Jensens definitions of bindings, token elements and binding elements respectively.
For a transition t T a binding b is a function over VAR(t) where
v VAR(t) : b(v) TYPE(v)
G(t)b. All variables must be
bound to a value of the appropriate type and all guard expressions must
be satisfied for the bound values. B(t) is the set of all bindings for t.
For a transition t T a token element is a pair (p,c) where p P is
an input place oft and c C(p). TE is the set of all token elements.
A binding element is a pair (t, b) where t T is a transition and
b B(t). BE is the set of all binding elements.
3.3 Extensions to High-Level Petri Nets
Several extension mechanisms have been proposed and implemented for high-level Petri
nets. In general these mechanisms have been proposed to increase the representational
power of Petri nets, however some limit or even preclude formal proof techniques. In
this section the author briefly discusses three common extensions to high-level Petri
nets, the timed tokens of CPNs and arc extensions in the form of inhibitor and equal-
ity arcs. These extensions are introduced here because they are implemented in the
OCELOT tool-set presented later (chapter 6).
20
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
32/225
3.3.1 Timed tokens
When simulating systems using Petri nets it is useful to be able to examine the effect
of delays or finite response times, since these are usually a significant element of real
systems. Jensen enhanced CPNs, with the addition of a global clock and an optionally
present token time stamp, to define Timed CPNs [36]. If a time stamp is assigned
to a token this defines the earliest time at which the token may by used as part of a
binding evaluation; each token is invisible until its time arrives, when it is said to be
colour enabled. Since multiple tokens may be involved in a binding element the latter
is said to be ready iff the current (global clock) time is greater than or equal to the
time stamps of all removed tokens.
In net simulation, all enabled transitions are fired at a particular time instant. If
and when the net is deadlocked the global clock may be advanced to the next token
time stamp, at which time bindings are re-evaluated. Jensen shows that any Timed
CPN may be transformed into a conventional CPN by simply discarding the timing
information in markings and expressions. In the OCELOT tool-set the global clock is
implemented in real-time such that the clock advances, second-by-second, until the
next set of timed tokens are ready. Although this real-time behaviour is not required
for CPN simulation, it allows for the modelling and/or actual control of real systems,
by providing a timing function.
3.3.2 Inhibitor and equality arcs
A limitation of CPNs and high-level nets in general is that they have no inherent zero
test, for example a transition cannot be enabled by the absence of tokens matching
the input arc (or guard) expressions. Such functionality would contradict the definition
of CPN binding elements presented above. Genrich and Lautenbach [28] have shown
that high-level Petri nets with infinite colour sets (types) are equivalent to first order
logic, since such nets can unfold to infinite P/T nets, and are therefore Turing com-
plete. Zero tests can therefore be simulated by the use of complex colour sets and/or
21
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
33/225
complementary place markings. Nets with finite unfoldings are however not Turing
complete. Inhibitor arcs provide this functionality to Petri nets by requiring that the
bound arc expression is not contained in the marking of the associated place.
Equality arcs further facilitate modelling with Petri nets. They require the place mark-
ing to be equal to the bound arc expression. The latter may be empty in which case
the place marking must also be empty for the transition to fire. Figure 6.6 shows an
example Petri net where the value bound to the expression x of input arc 1 must not
be present in the marking of P3 (due to inhibitor arc 3), ruling out the token value 1.
The equality arc 2 requires the marking of P2 to be a single token, while the transition
guard expression requires the arc expression y to be bound to a value also present in
the marking of P1. The only valid solution is x = 3, y = 3.
(arc 3)
0+1+51+2+3 3
P3P2P1
x x
[x = y]
T1
y
(arc 1)
(arc 2)
Figure 3.3: An example of inhibitor and equality arcs
Arc extensions, including inhibitor and equality arcs, have been proposed and studied
by many, for example in [40][13][8][7]. Inhibitor and equality arcs prove very useful
in modelling but may prevent formal invariant analysis of net properties. Lakos and
Christensen [40] propose an automatic complementation of inhibitor arcs and places
to allow reduction to a normal high-level Petri net (and therefore to a P/T net). In-
hibitor and equality arcs do not prevent analysis of reachability and are included in the
22
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
34/225
OCELOT tool-set. The discussion of unfolding that follows is restricted to unextended
high-level Petri nets; the impact of arc extensions on net unfolding is left until the
discussion of the OCELOT tool-set in chapter 6, where the author also presents some
examples of their use.
3.4 High Level Petri Net Unfolding
In order to be able to model, and perform dynamic (reachability) analysis on, high-
level Petri nets it is essential to formulate rules for the firing of transitions. To see how
high-level Petri net transition firing conditions might be determined, the unfolding
of such Petri nets must first be examined. The first step is to review the relationship
between high-level nets and P/T nets.
In the previous section it was noted that P/T nets can be viewed in terms of propo-
sitional logic, and high-level nets in terms of first-order predicate logic. This section
now shows how all high-level nets can be represented in terms of P/T nets. Jensen[37]
formally defines the equivalence between non-hierarchical CPNs and P/T nets as fol-
lows, with reference to the P/T net definitions of section 3.1.
For a non-hierarchical Coloured Petri net CP N = (, P, T, A,N, C, G, E,I) the equiv-
alent P/T net is PT N = (P, T , A, E,I) where:
P = T E.
For each token element in the CPN there is a corresponding place in the P/T net.
Every token value in the CPN is replaced by a unique place allowing distinction
between the values. For a CPN token colour c the corresponding P/T place is
referred to as (p,c). Because CPN place markings are finite the corresponding
number of P/T places is also finite (as required by their definition).
T = BE.
For each binding element (finite, since CPN markings are finite) in the CPN there
23
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
35/225
is a corresponding transition in the P/T net. Therefore each CPN transition is
split into however many bindings satisfy both the arc and guard expressions. For
a CPN binding b for transition t the corresponding P/T net transition is referred
to as (t, b).
A = {((p,c), (t, b)) P T | (E(p,t)b)(c) = 0}
{((t, b), (p,c)) T P | (E(t, p)b)(c) = 0}.
If, in the CPN, an occurrence of transition t with the binding b removes one or
more tokens of colour c from place p, then there is an arc from the P/T net place
(p,c) to the transition (t, b). Similarly for the CPN occurrence of t with b adding
one or more tokens to p, there is an arc from P/T net transition (t, b) to place
(p,c).
((p,c), (t, b)) A
(P T ) : E ((p,c), (t, b)) = (E(p,t)b)(c).
((t, b), (p,c)) A
(T P) : E ((t, b), (p,c)) = (E(t, p)b)(c).
This defines equivalence of arc expression arity. The number of tokens with colour
c, removed in the CPN from place p by transition t with the binding b, is the same
as the number of tokens removed in the P/T net from place (p,c) by transition(t, b). Similarly the number of c tokens added to the CPN place p by t with
binding b is equal to the number of P/T net tokens added to (p,c) by (t, b).
(p,c) P : I (p,c) = (I(p))(c).
The number of tokens of colour c in the initial marking of CPN place p gives the
number of tokens in the corresponding P/T net place (p,c).
The examples to be presented here illustrate the relationship graphically. These ex-
amples consider very simple nets consisting of a single transition having one or more
input places. The basic Petri net rules for the Token Game show that each individ-
ual transition, its complete set of input arcs, input places and their markings, can be
unfolded in isolation. The unfolding of the complete high-level Petri net will be the
union of all such (disjoint) unfoldings. Such restricted single-transition nets shall be
formally defined in a later chapter.
24
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
36/225
3.4.1 Finite place colour set
In this case the colour set, or type, of the places is restricted to a finite set of values,
namely an enumerated data type (for example, the values RED, GREEN and BLUE).
In the example of figure 3.4 there is no transition guard expression, nor do any of the
arc expressions constrain the possible variable bindings, so the presence of a token of
any colour in the place marking will enable the transition. The high-level nets places
and single transition unfold to an elementary P/T net. The elementary nets places
represent each possible token colour (or proposition that the value or colour is present
in the high-level places marking), while each transition corresponds to a binding ele-
ment, or enabled firing, of the high-level transition.
Because the high-level place type has a finite set of values (and hence binding el-
1_GREEN1_RED 1_BLUE
2_GREEN2_RED 2_BLUE
T1
x y
P1 P2GREEN+ BLUE+
RED+RED+
Figure 3.4: Unfolding of a finite place Colour Set
ements), so there are a finite number of corresponding P/T places and transitions,
determined by the Cartesian product of the places markings.
3.4.2 Finite place colour set - restricted firing
In the example of figure 3.5 the transition guard expression constrains the values that
arc variable x may take (not GREEN). The unfolding is now a subset of the Cartesian
product of the places markings. Any tokens with colour outside the constrained set
25
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
37/225
cannot be part of any binding element; their presence in the place marking constitutes
dead weight since, once part of the place marking, they can never participate further
in the token game (assuming they cannot be bound through other transitions input
arcs). Intuitively it is easy to see that if such tokens are added to the place marking,
other than by the initial marking, then the place invariant for the high-level net is vio-
lated. The firing rules, or Token Game, of P/T nets dictate that enabled transitions
1_GREEN1_RED 1_BLUE
2_GREEN2_RED 2_BLUE
T1
x y
P1 P2GREEN+ BLUE+
RED+RED+
[ x != GREEN ]
Figure 3.5: Unfolding of a constrained finite place Colour Set
not in conflict may fire simultaneously. This corresponds to the required behaviour of
high-level nets, where enabled binding elements not in conflict may fire simultaneously
[37].
The example of figure 3.6 shows an additional constraint on the enabled bindings.
The two input arcs are annotated with the same variable x; this imposes the constraint
that a token with the same colour must be present in both input places for a binding
to be enabled. This constraint is a conjunction with that enforced by the transition
guard expression and in the example acts to restrict binding of x to a colour of RED
for the given marking. Note that simple arc expressions such as this behave as a fold-
ing of guard expressions; the same constraint could be achieved more verbosely in the
example of figure 3.5 by enhancing the guard expression to read x != GREEN AND x
== y . The effect of arc and guard expressions is explored more fully in section 3.5.
26
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
38/225
1_GREEN1_RED 1_BLUE
2_GREEN2_RED 2_BLUE
T1
x x
P1 P2GREEN+ BLUE+
RED+RED+
[ x != GREEN ]
Figure 3.6: Unfolding of an arc-constrained finite place Colour Set
3.4.3 Infinite place colour set - unrestricted firing
In this case the colour set, or type, of the place is infinite. In figure 3.7 the token colour
set is the Cartesian product of an infinite number of strings and an infinite number of
integers. The transition firing is unconstrained by either guard or arc expressions, so
the net consisting of the place and transition would potentially unfold to an infinite
set of P/T places (representing each of the possible stringinteger values possible in
the original place marking) and transitions (representing all possible binding elements).
P/T nets must by definition contain a finite number of nodes. Because the marking
P1
+
+
+
T1
Figure 3.7: Unfolding of an infinite place Colour Set
27
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
39/225
of a high-level place must be finite (that is, a finite number of tokens), the unfolding of
all enabled binding elements will also be finite and equal to the number of tokens. The
unfolding can therefore be regarded as a dynamic P/T net of just the enabled binding
elements. The unfolded net structure therefore changes as the high-level net markings
change.
3.4.4 Infinite place colour set - restricted firing
The author now examines the case where the place colour set is infinite, but the set
of binding elements is constrained by any or all of the arc expressions and a guard
expression. In the example of figure 3.8 the place marking contains tokens of anycolour from the Cartesian stringinteger product. Only those tokens whose colour
P1
+
+
+
T1
[ y > 0 AND y < 4 ]
Figure 3.8: Unfolding of a constrained infinite place Colour Set
corresponds to the product of the very small sets ({OK} and {1, 2, 3} can be part
of any binding elements. The unfolded P/T net would potentially contain an infinite
number of places, but only three transitions corresponding to the above firing rule.
Because of the finite high-level net marking the number of corresponding P/T places is
however also finite. As with the example of figure 3.5, any tokens with colour outside
the constrained set cannot be part of any binding element.
28
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
40/225
3.4.5 Multi-set arc expressions
It is worth briefly discussing unfolding where multi-set arc expressions are involved.
The requirement of an arc expression for a particular quantity of a token colour does
not affect the unfolding to P/T places and transitions; the arc expression requirements
are reflected in the unfolded P/T net. At this stage it is important only to note that the
3RED +
3GREENP1
T1
3x + 2y
RED GREEN
32
32
Figure 3.9: Unfolding of multi-set arcs
multi-set arc expressions remain orthogonal to token colour across the net unfolding.
This fact is important to the methods presented later in this thesis.
3.4.6 Partially unfolding high-level nets to other high-level
nets
The enormous expressive power of Coloured Petri nets allows for arbitrarily complex arc
and guard expressions, allowing compression of complex functional behaviour into
a small number of places and transitions. Such nets may often be unfolded to larger,
but simpler, Coloured nets as shown in the example of figure 3.10 where disjunction in
the guard expression may be alternatively expressed as concurrent transition binding.
Partial unfolding is important because it means that Petri net tools that may not be
able to support complex functional arc and/or guard expressions lose only expressive-
ness, rather than representational capability.
29
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
41/225
y
P1 P2P1
23 + 5 +
7 + 39
3 + 26 +
38 + 9
23 + 5 +
7 + 39
3 + 26 +
38 + 9
T1
[ (x < 4 OR x > 8) AND x = y ]
P2
yx
T2
y
[ x > 8 AND x = y ]
T1
x
[ x < 4 AND x = y ]
x
Figure 3.10: Partial unfolding of a guard expression
3.5 Formulating High-Level Petri Net Firing Rules
In the previous section the author showed that net unfolding may be constrained by
both arc expressions and guard expressions. This section first explores exactly how
these expressions constrain unfolding. It then presents a formulation of high-level
Petri net firing rules in terms of constraints over high-level Petri net arc structures,
and arc expressions and guard expressions. As before the definitions deal with simple
nets consisting of a single transition, its input arcs, input places and their markings.
3.5.1 Required definitions
The Finite-Domain Constraint Satisfaction Problem will be comprehensively defined
in the next chapter, but at this point a generic constraint problem CP may be brieflydefine as:
30
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
42/225
CP is a pair (V, C) where:
V = {v1, v2, . . . , vn} is a finite set of variables.
C = {c1, c2, . . . , cn} is a finite set of constraints on subsets of V.
Constraint cvi,vj ,vk restricts the possible values that its associated vari-
ables vi, vj, vk may simultaneously take.
C(v1) is the set of all constraints associated with variable v1.
An important issue is that transition firing rules cannot be expressed simply in terms
of variables. Arc expressions may not involve unique, or indeed any, variables. For
example, figure 3.6 illustrates a net where both arcs constrain each other by sharing
the same expression. This section will also show examples where the arc expressions
are closed, that is, they evaluate to a constant value. Furthermore, arc expressions
may take the form of multi-sets over tuples corresponding to their places colour set.
Constraints are therefore treated as existing on, or between, arc expressions rather
than variables.
The following definitions for transition enabling have been adapted from Jensens def-
initions for CP Nets [37]. P(t) is the set of input places for a transition t T, G(t)
is the guard expression list for transition t, A(p,t) is the set of input arcs from place
p P to t, and M(p) is the marking of a place p. Then the set Ainp of all input arcs
for transition t is given by:
Ainp(t) = {a A | p P(t) : a A(p,t)}
31
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
43/225
Note that, as with Jensens original definitions, multiple arcs are allowed from an input
place to a transition; this allows the separation of complex multi-set arc expressions into
a sum of simpler, possibly elementary, multi-set expressions (refer to chapter 2). An
arbitrary, but fixed, order < is applied to these arcs a0, a1, . . . , an such that ai < ai+1.
A binding b for transition t is valid if:
p P(t) :
aA(p,t) E(a)b M(p)
G(t)b
Where E(a) is the set of arc expressions for a.
Informally, each input place must contain a multi-set marking the sum of all in-
put arc expressions from that place to the transition. Furthermore, bound values of
arc expressions must satisfy the guard expression. The transition t is said to be en-
abled in marking M for the binding b; the set Bval(M, t) B(t) is the set of all valid
bindings for the marking. Note that V ar(E(a)) is the set of variables for arc a and
V ar(G(t)) is the set of variables for the transition guard expression list. It will shortly
be shown that, as stated earlier, a constraint problem may exist even without any arc
variables, that is, all arc expressions are closed and V ar(E(Ainp)) = . The concept
of variable ownership by an arc is now defined. It corresponds to the first arc in
whose expression the variable appears. O(a) is defined from A into V ar, such that:
O(ai) = {v V ar(E(ai)) | aj < ai : v / V ar(E(aj))}
Each arc expression E(a) is defined to be an ordered multi-set of sub-expressions
{e0, e1, . . . , en} representing the expressions tuple form, where e0, e1, . . . , en are to-
ken field expressions, of the same type as the corresponding colour set field, each of
which may be either a constant (closed) expression or a single variable (CP Nets allow
unrestricted arc expressions, but these are difficult to implement in practice).
32
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
44/225
The constraint problem CP for a transition t, is now redefined such that:
V = {ei(ax), ej(ay), . . . , ek(az)} where:
ax, ay, . . . , az Ainp(t)
ei(ax), ej(ax), . . . , ek(ax) V ar(E(ax))
cei(ax),ej(ay),...,ek(az) restricts the values that may be bound to its associated arc
expressions ei(ax), ej(ay), . . . , ek(az).
C(E(ai)) is the set of all constraints associated with the expression for
arc ai.
Four distinct conditions where the value of binding elements is constrained by arc
and guard expressions can now be defined. This section shows how each of these
constraints is associated with one or more arc expressions. These constraints apply
only to the value or colour of tokens, and not to the coefficients or quantity of multi-set
arc expressions. The relationship between value constraints and multi-set expression
coefficients is discussed in chapter 5.
3.5.2 Constraint-free arcs
An arc anc has no constraints if all tuple-fields of its arc expression are not closed and
consist only of unique variables, which do not appear in any other arc expressions or
the guard expression; the arc is enabled simply by the presence of an adequate number
of tokens (as required by the expressions multi-set coefficients) in the place marking:
33
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
45/225
V ar(E(anc))
V ar(E(Ainp \ {anc})) =
V ar(E(anc))
V ar(G(t)) =
E(anc) = V ar(E(anc))
In this case the generic problem CP has a null constraint set C(E(anc)) = for arc
anc.
3.5.3 Unary constrained arcs
An arc auc has one or more unary constraints if all tuple-fields of its arc expression
consist of either:
Unique variables which do not appear in any other arc expressions, but at least
one of which appears in a guard sub-expression involving only constants or vari-
ables from the same arc.
Constant (closed) expressions.
Such an arc is constrained only by its own expressions:
V ar(E(auc))
V ar(E(Ainp \ {auc})) =
[ ( e E(auc) : V ar(e) = ) ( g G(t) : V ar(g) V ar(E(auc))) ]
[ g G(t) : V ar(g) V ar(E(auc))
V ar(g)
V ar(E(auc)) = ]
In this case the generic problem CP defines the constraint set as:
C(E(auc)) = {ce1(auc), ce2(auc), . . . , cen(auc)} where e1, e2, . . . , en E(auc).
Figure 3.11 illustrates both of these unary constraint situations. The closed arc ex-
pression for the left arc constrains the choice of bindings, while the guard expression
achieves a similar effect for the right arc and variable x in its expression.
34
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
46/225
T1
[x = 5]
P2P1
x5
Figure 3.11: Unary value constraints over arc/guard expressions
3.5.4 Binary constrained arcs
A binary constraint exists between a pair of arcs ai, aj when either:
A tuple-field consisting of the same variable appears in the arc expressions of
both arcs.
A guard sub-expression contains variables from the arc expressions of both arcs
but no other arcs.
One arcs binding is constrained against the bindings already made for the other arc.
If one arc owns the variable(s) involved in the constraint (and from the earlier def-
inition, one must) then it is said the arc constrains the other arc; conversely, the
non-owning arc is constrained by the other:
V ar(E(ai))
V ar(E(aj)) =
[ g G(t) : V ar(g)
V ar(E(ai)) =
V ar(g)
V ar(E(aj)) =
V ar(g) V ar(E(ai)) V ar(E(aj)) ]
In this case, for the generic problem CP:
ce1(ai),e2(aj) C(E(ai)) and ce1(ai),e2(aj) C(E(aj))
35
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
47/225
Figure 3.12 illustrates both of these binary constraint situations. The arc expression
for the two left-most arcs constrains the choice of bindings for variable x such that the
same token colour must be bound from P1 and P2, while the guard expression achieves
a similar effect for the two right-most arcs and variables y and z in its expression.
P1
y zx
arc ordering (L to R)
P4P3P2
[y = z]
T1
x
Figure 3.12: Binary value constraints over arc/guard expressions
3.5.5 K-ary constrained arcs
A K-ary constraint (K > 2) exists between multiple arcs ai . . . an where an arcs
binding is constrained against multiple arcs by one or more tuple-field expressions
in its arc expression. Unlike a binary constraint, no arc owns all variables in the
constraining expression. Such constraints can only arise through a guard sub-expressioncontaining variables from all the constrained arcs:
g G(t) : V ar(g)
{ V ar(E(ai)), . . . , V ar(E(an)) } =
In this case, for the generic problem CP:
ce1(ai),e2(aj),...,en(am) C(E(ai)) and . . . ce1(ai),e2(aj),...,en(am) C(E(an))
36
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
48/225
Figure 3.13 illustrates a K-ary constraint situation. The guard expression enforces
a 3-ary constraint on the variables x, y and z in the arc expressions of all three arcs.
[x + y = z]
P1 P2 P3
z
arc ordering (L to R)
T1
xy
Figure 3.13: K-ary value constraints over arc/guard expressions
3.6 Unfolding and Combinatorial Search
The examples presented in this chapter illustrate that unfolding even simple high-level
Petri nets may result in a combinatorial explosion in the number of net nodes. Cor-
respondingly, a combinatorial exploration of high-level net place markings is required
in order to completely determine net unfolding. Although net markings must be finite,
combinatorial search is exponential and NP-hard.
The formulation of high-level Petri net transition firing rules shows that arc and guard
expressions constrain the potentially large number of bindings to be considered. Ap-
proaches that utilise these constraints may reduce the search effort. The class of prob-
lems known as Constraint Satisfaction Problems (CSPs) involves combinatorial search
and has resulted in some potentially useful techniques for problem reduction. The
relationship of high-level Petri nets and CSPs will be examined shortly (in chapter 5),
37
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
49/225
once CSPs have been formally introduced in the following chapter.
3.7 Chapter Summary
In this chapter elementary P/T nets and high-level Petri nets have been introduced, in
the form of both Predicate-Transition nets and Coloured Petri nets. It has been shown
how all high-level nets can be unfolded to elementary nets, allowing both analysis and
modelling of such nets. The unfolding process will be an NP-complete combinatorial
search problem. In the following chapters the author will examine how high-level
net unfoldings might be determined algorithmically, using straightforward imperative
algorithms. The approach to be taken is to examine the possibility of reducing the
search effort by representing binding calculations as Constraint Satisfaction Problems
(CSPs), and these, along with techniques for their solution, are introduced next.
38
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
50/225
Chapter 4
The Constraint Satisfaction
Problem
4.1 Introduction
In this chapter the author introduces, in section 4.2, the binary Constraint Satisfaction
Problem (CSP) with an example. Section 4.3 formally defines the binary CSP and
discusses properties of binary and unary constraints, and in section 4.4 basic search
techniques for solving these problems are introduced. The limitations of these tech-
niques are then illustrated, then section 4.5 reviews in detail the concept of consistency
while examining some of the consistency-enforcement techniques that may be applied.
Section 4.6 discusses the concept ofconstraint propagation as a key solution technique,
and illustrates it with two important algorithms. This is followed with a discussion of
an important alternative technique, intelligent backtracking(section 4.7), which is illus-
trated with three well-known algorithms for its application. Section 4.8 then discusses
the combination of these two key techniques, and presents the algorithm of choice
for further investigation. In section 4.9 attention is turned to non-binary constraints.
The author briefly introduces them, discusses their representation in the form of bi-
nary constraints, and their solution. Finally the author presents a new technique that
may be applied to potentially improve search efficiency for all non-binary constraint
satisfaction problems, before presenting a chapter summary in section 4.10.
39
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
51/225
4.1.1 Terminology
Both Petri nets and CSPs have a basis in graph theory and, as a result, there is an
overlap in terminology between the two fields. In particular the following CSP terms
may be confused with their rather different Petri net synonyms, and for this reason
will be emphasized and their context made clear in this and subsequent chapters:
node
arc
path
The definition of these CSP terms will be presented in this chapter.
4.2 The Binary Constraint Satisfaction Problem
A binary constraint satisfaction problem (CSP) consists of a set of variables, each with
its own domain of values from which an assignment to the variable must be made. It is
important to note that in CSPs the domain of each variable is finite. This distinguishes
CSPs from the Constraint Solving paradigm where domains are typically infinite, for
example the set of all integers. A variable, together with its domain, is known as a
node. An assignment to a variable of one of its domain values is known as a labelling.
One or more of the variables is constrained by the values assigned to one or more of
the other variables. Some variables may not be constrained at all. A constraint on
assignment values between two variables is known as a binary constraint, or arc. A
solution consists of an assignment of values to all variables such that no constraints are
violated. Solving a CSP may require finding just one solution or the set of all possible
solutions.
This overview begins with an example. A well known binary constraint satisfaction
problem is the Map Colouring Problem, an instance of which is shown in figure 4.1.
The problem is to assign a colour from the domain {red, green, blue} to each state and
40
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
52/225
TAS
NSW
ACT
VIC
WA
NT
SA
QLD
Figure 4.1: The Map Colouring Problem
territory of Australia, with the overall constraint that each state and territory must
be a different colour to all adjacent neighbours. In this example the states represent
the problems variables and the three colours represent each variables domains, which
happen to be identical in this case. Figure 4.2 shows the same problem in the form of
a network of relations consisting of nodes and arcs which makes explicit the problem
domains and constraints. Before discussing the solutions to this example, a formal
definition of the binary CSP must be presented.
4.3 Definitions
The following definition for the binary CSP is based on one of the earliest, that of
Montanari [49]. The definition is enhanced here to explicitly include unary constraints,
which restrict the value that may be assigned to a variable without reference to any
other variables. The problem of figure 4.2 contains no unary constraints. Note that
41
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
53/225
blue
red, green,
blue
red, green,
blue
red, green,
blue
red, green,
blue
red, green,
blue
red, green,
blue
red, green,
blue
red, green,
WA
TAS
NSW
ACT
NT
VIC
SA
QLD
!=
!=!=
!=!=
!=
!=
!=
!=
!=
!=
Figure 4.2: The map problem as a network of relations
unary constraints are generally treated as being implicit in the binary constraint prob-
lem, however they are explicitly defined here due to their importance in Petri net
representation (see chapter 3).
A binary constraint satisfaction problem (V, D,U, B) consists of a set V of n vari-
ables {v1, . . . , vn} , a set D of n respective value domains {D1, . . . , Dn} , a set U of
n respective unary value constraints or relations {U1, . . . , U n} over each domain where
Ui Di , and a set B of binary value constraints or relations Bij between variables vi
and vj .
It will be shown later that, if evaluated first, unary constraints act to reduce the
domain of their variables through the elimination of inconsistent values. As a conse-
quence Bij is a subset of the product of the unary relations on the respective domains,
42
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
54/225
that is, Bij Ui Uj .
Both figure 4.1 and figure 4.3 show constraint graphs for the map problem. The
are "not equals"
WA
NT
SA
QLD
ACT
VIC
TAS
NSW
All constraints
Figure 4.3: The Map Colouring binary constraints
graph of figure 4.3 is more useful in that it presents an ordering (an arbitrary vertical
one representing the states and territories from West to East) of the variables, allowinga systematic ordered evaluation of the effect of the constraints on differing variable
assignments. It also reveals potentially useful information about the problem; for ex-
ample it shows that South Australia (SA) is the most heavily constrained variable,
with five other variables constraining its assignment. Conversely the least constrained
variable is Tasmania (TAS). In the following discussion a top-down order of assignment
of variables will be assumed, that is WA will be assigned first.
43
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
55/225
Several properties of constraints can be formulated, based on the observations of
Bartak [2]:
1. Non-unary constraints are never independent; they share variables in the prob-
lem.
2. Non-unary constraints always specify partial information; only unary constraints
specify the value (or set of values) of their variables.
3. Constraints are non-directional; a constraint on two variables x and y infers a
constraint on x given an assignment to y, and vice-versa.
4. Constraints are declarative; they specify a relationship between variables without
defining how that relationship should be enforced.
5. Constraints are additive; the order of constraint application does not affect the
conjunction of constraints or the set of all possible solutions (although it will be
shown that it may affect the efficiency of finding these solutions).
Properties 3 and 5 imply that the constraint graph of figure 4.3 may be re-orderedwith no effect on the overall problem solution (although the efficiency of the solution
may change). Each CSP is a combinatorial problem where the set of solutions is itself
a subset of the Cartesian product of all variable domains.
4.4 Systematic Search Methods
All CSPs have finite domains and therefore all solutions can be found by systematic
searching of all possible variable-value assignments. Although some CSPs are trivial to
solve, overall they are NP-complete [24] and there is no guarantee of finding a solution
in polynomial time. Two simple systematic search methods for solving CSPs are now
examined, and the limitations of these methods identified.
44
8/14/2019 Thesis - Petri Net Modelling Using Constraints - Michael Sanders 2004
56/225
4.4.1 Generate-and-Test (GT)
This is the most basic algorithm and involves the systematic generation of each possible
assignment of variable values, followed by a test of all constraints. Therefore in the
example given it requires 38 sets of assignments, each requiring up to 8 constraint
evaluations to determine if the assignment is a valid solution. This algorithm is highly
inefficient and makes no use of any properties of the constraint problem that might
reduce the search effort.
4.4.2 Chronological Backtracking (BT)
This search technique, often known simply as backtracking [29][9], is almost always
more efficient (usually dramatically so) than Generate-And-Test. Backtracking oper-
ates by applying a fixed variable evaluation order, then extending a partial solution by
assigning a value to the next variable and checking all constraints on that assignment.
If any of these constraints fail the algorithm backtracks to the previously assigned vari-
able (the partial solution) and attempts a new assignment from the untried domain
values. When the partial solution is extended to all variables then a solution is found.
Figure 4.4 illustrates two backtracking solutions to the map problem given the orde