Professional Documents
Culture Documents
Transformation From Activity Diagrams With Time Properties To Timed Coloured Petri Nets
Transformation From Activity Diagrams With Time Properties To Timed Coloured Petri Nets
Xuling Chang, Linpeng Huang, Jianpeng Hu, Chen Li and Bei Cao
Department of Computer Science and Engineering, Shanghai Jiao Tong University, Shanghai, China
Email: {changxl, lphuang, mikerise, lcroy}@sjtu.edu.cn, caobei.sjtu@gmail.com
Abstract—The activity diagram is widely used for describing the practical usability of our proposed approach, a case study
and understanding workflows, however, it lacks a formal seman- with a GameCapture application is used as an example.
tics and cannot be manipulated by computer. In this paper, we
present a transformation from UML activity diagrams with time The remainder of the paper is organized as follows: Sec-
properties to timed coloured petri nets (TCPNs) in a formal way. tion II discusses the related works of this paper, Section III
We extend the activity diagram with time properties and a formal introduces the activity diagrams briefly, Section IV gives a
model named extended activity hypergraph (EAH) is defined. formal definition with a weak semantics for activity diagrams,
By mapping this formal model to a clocked transition system Section V demonstrates the transformation rules from activity
(CTS), we define a weak semantics for it. A list of transformation diagrams to timed coloured petri nets, and we also discuss the
rules are proposed to show how this can be transformed to a
TCPN model. We partially prove the model equivalence of the
equivalence of activity diagrams and the TCPN models which
two models. Finally, an example of GameCapture application is are transformed under our rules, and finally, in Section VI,
used to validate our approach. an example of GameCapture application to demonstrate the
practical usability of our method is discussed.
Keywords—Activity diagrams, Timed Coloured Petri Nets, Ex-
tended Activity Hypergraph, Model Transformation.
II. R ELATED W ORKS
I. I NTRODUCTION A graphical mapping of an activity diagram onto a coloured
The Unified Modeling Language (UML) [1] is a semi- petri net model is proposed in [9]. The authors do not show
formal language developed by the Object Management Group how they dealt with the analysis of concurrency of the system.
(OMG) [2] to describe the structural and behavioral aspects In [3] a transformation method from UML activity diagrams to
of the complicated software systems. Three categories of stochastic petri nets is proposed. It translates each diagram into
diagrams are defined in UML, i.e, static diagrams, behavioural LGSPN (Labeled Generalized Stochastic Petri Nets) and gains
diagrams and diagrams to organize and manage application a formal semantics for them, then composes these LGSPNs
modules [3]. Activity diagrams is a graphical language which together to gain an analyzable model. In [10] a novel approach
is consisted in behavioral diagrams. This diagram is also used for automatic transformation of SysML activity diagram into
and extended in other modeling languages such as System Timed Petri Net with Energy constraints (ETPN) is proposed.
Modeling Language (SysML) [4], Service Oriented Architec- Model equivalence is not discussed in their works.
ture Modeling Language (SoaML) [5], and a new UML profile In [11] a tool that supports verification of work flow model
dedicated for modeling and analysis of real-time and embedded specified in UML activity diagrams is described. The tool
systems (MARTE) [6]. translates an activity diagram into an input format for model
Timed Coloured Petri Nets (TCPNs) is a language for checker according to a mathematical semantics. In [12] a
modeling and validation of systems in which concurrency, formal verification framework for SysML activity diagrams
communication, and synchronisation play a major role [7]. is proposed. It is based on mapping a composition of SysML
The transformation from UML Activity diagram to TCPN activity diagrams to the input language of the probabilistic
is reasonable for 1) TCPN models are formal and have a symbolic model checker called “PRISM”.
mathematical definition of both its syntax and its semantics To enhance the confidence level of UML activity diagrams,
[8].2) TCPN has a strong ability to describe the real-time the syntax and semantics of UML activity diagrams with
systems with complex loop, concurrency events and data timing constraints are defined in [13]. The authors outline the
parsing behaviors. 3) The model constructed by TCPN can translation of their semantics into PROMELA input language
be verified by several tools available, like CPN tools. of the SPIN model checker.In [14], the authors show mapping
In this paper, we are interested in modeling and evaluating from UML activity diagrams to extended petri nets. However,
system with time properties such as real-time systems. We the authors do not study the semantics equivalence of the two
firstly extend the activity diagram with time properties and models.
define an extended activity hypergraph (EAH). The time prop- Eshuis and Wieringa define two formal semantics of activi-
erty can be added as an annotation. By mapping this EAH ty diagrams (requirement-level semantics and implementation-
model to a clocked transition system, a weak semantics for level semantics) in [15]. The semantics in their work is robust
EAH is defined. Thus we can execute a transformation from but complicated. And the data information is not defined
EAH to a TCPN model which is manipulatable by computer explicitly.
and can be used to verify system properties, i.e, performance
analysis. We use CPN Tools to carry out a simulation with data In this paper, we define the activity diagram with time
collector to analyze performance of the model. To demonstrate properties formally and give a weak semantics for it. The
268
where cnode(t) denotes the corresponding node of timer t. J, D, M, P N, Arcs, T m, P I) , the Extended Activity Hyper-
graph as EAH = (N odes, Events, HyperEdges, Guards,
Definition 4.2: The passage of time is denoted by relation Data, Dura, V ar). The mapping from activity diagrams to
→time . Timers and the master clock is increased by a real activity hypergraphs were discussed in [15]. We add transfor-
number δ. Relation →time is defined as mation rules from activity diagram with time properties and
σ →time σ ⇔ ∃δ ∈ R • δ > 0 data flows to our newly defined extended activity hypergraph.
∧ σ = σ[M C/σ(M C) + δ, t∈σ(RT (C)) t/σ(t) + δ] Rule 4.1: For every f low in EAH, there is a correspond-
∧ ∀t ∈ RT (σ(C)) • σ(t) < dura(t), ing data instance d ∈ Data. Every f low has only one data
type.
where σ[ t∈T t/vart ] represents updating every variable in set
T with vart Rule 4.2: If the successor of init node is in a loop, this
init node is merged with its successor node. Similarly, if the
Definition 4.3: Relation →data denotes the receival of precursor of the f inal node is in a loop, this f inal node is
data. Elements in set ID will be replaced by all the data on merged with its precursor node.
the hyperedge which direct to current node. Then the data in
Rule 4.3: For every object flow in activity diagram, there
ID will be ready to be processed. And the running activity
is a corresponding hyperedge e in EAH. The object node is
will not change.
attached on e as a data instance. We use the first kind of object
σ →data σ ⇔ σ(C) = σ (C) flow to illustrate our rule. A node sequence (ai · oi · ai+1 ) is
used:
∧ σ(M C) = σ (M C) ∧ ∃n ∈ N ode ∀(ai · oi ·ai+1 ) ∈ AD
• n ∈ σ(C) ∧ ∃H = ∅ • H ⊆ HyperEdges ∃e ∈HyperEdges
∧ (∀h ∈ H • n ∈ target(h) ⇒ ⇒ data(e) = oi ;
data(h)={}
Rule 4.4: Every edge entering and leaving an F ork/Join
σ = σ[ID/ data(h)]) node is merged into one hyperedge e. The object nodes passing
h∈H through the F ork/Join node is assigned to e.
Valuation σ[s/Xs] assigns variable Xs to variable s. ∀pn ∈ (F ∪J)∃e ∈ HyperEdges ⇒
Definition 4.4: Relation →var denotes the update of vari- source(e) = start(pn) • target(e) = end(pn)
ables. The variables of the system need to be calculated
before the step is token. We use function cal(v) to denote Rule 4.5: Every Decision/M erge nodes with n incoming
the calculation of variable v. Elements in set C, D, M C does edges or n outgoing edges will be mapped into n hyperedges.
not change. The object nodes passing through the Decision node will
be assigned to each hyperedge which is newly created. The
σ →var σ ⇔ σ(C) = σ (C) ∧ σ(ID) = σ (ID) expressions is assigned to its corresponding hyperedges.
∧ σ(M C) = σ (M C) ∧ ∀t ∈ RT (σ(C)) ∀pn ∈(D ∪ M )∃H ⊆ HyperEdges ⇒
∧ ∀v ∈ V ar • cal(v). (∀n ∈end(pn)∃e ∈ H ⇒ (source(e) = start(pn)
Definition 4.5: Relation →step denotes waking up a sleep- ∧target(e) = n) • pn ∈ D) ∨ (∀n ∈ start(pn)∃e ∈ H ⇒
ing node. A node n can be waked iff the guards on the (source(e) = n ∧ target(e) = end(n)) • pn ∈ J)
hyperedges which direct to n are all satisfied. After data passed
through an activity node, its content, type and amount may Further discussion on rules for mapping activity diagrams
changed. We use function process(ID) to process the current with no data flows can be found in [15] and [17].
data set ID.
σ →step σ ⇔ ∃H ⊆ HyperEdge V. F ROM E XTENDED ACTIVITY H YPER G RAPH TO T IMED
∀h ∈ H ⇒ (source(h) ∈ C • σ guard(h)) C OLOURED P ETRI N ETS
A. Timed Coloured Petri Nets
∧ σ = σ(C/ target(h), ID/process(ID)).
h∈H Timed coloured petri nets (TCPN) are new kind of CPN
models which timing information is added. This makes it
In the initial state, only σ0 is contained in the configuration, possible to evaluate how efficiently a system performs its
C = {σ0 }. The input data set is empty, ID = ∅. Timers in operations. With a TCPN model, performance measures such
set T imer is initialized using set Dura. Other variables are as mean waiting times can be calculated.
initialized appropriately.
B. Transformation Rules
B. From Activity Diagram to Activity Hypergraph We next transform the extended activity hypergraph EAH
In this section we firstly reduced the activity diagram by into TCPN model. A TCPN model contains elements like
mapping elements in the activity diagram into corresponding places, transactions, arcs, expressions, variables and some
elements in the activity hypergraph. We only show rules that functions. We use a to denote the arcs which direct from
we add for mapping activity diagrams with data flows. transitions to places. Similarly, a is used to denote the arcs that
directing from places to transitions. An activity node can be
We consider in the rest of this paper the activity diagram transformed into place or transition as were discussed in [15].
with time properties as T AD = (δInit , F N, AN, At, Obj, F, Here we choose to transform activity nodes into transitions. Let
269
cpnT be the target TCPN model. We use function ma(t) to Rule 5.6: Every one-to-many hyperedge in EAH is trans-
denote the maximum time of transition t and mi(t) to denote formed into a branch structure:
the minimum time, where t ∈ T . The transformation rules are
then listed below:
Rule 5.1: Every data instance has a corresponding color ∀e ∈ HyperEdges • |target(e)| > 1
set in TCPN model. 0
∃(ai · pi · a i · ti · (a0i+1 · p0i+1 · a i+1 , a1i+1
∀d ∈ Data∃c ∈ Σ ⇒ type(d) = c. 1
·p1i+1 · a i+1 , · · · , ani+1 · pni+1 · a i+1 )) ∈ cpnT
n
Rule 5.2: Every node n ∈ N odes in EAH is mapped into ∧(a∗ ∈ A • p∗ ∈ P • t∗ ∈T ) ∧ (data(e) = {}
transition t. If the hyperedge e that directing to n has a guard ⇒ C(p) = type(data(e))) ⇒ guard(e) = {⊥}
function G, a corresponding function is assigned to t. If the
duration of n exists, it is also assigned to t. where a∗ represents all arcs in sequence ai · pi · a i · ti · (a0i+1 ·
0 1
p0i+1 · a i+1 , a1i+1 · p1i+1 · a i+1 , · · · , ani+1 · pni+1 · a i+1 ), so as
n
∀n ∈ N odes∃t ∈ T ∧ (time(n) = {} ⇒
∗ ∗
(G(t) = guard(n)•guard(n) = {⊥}) p and t . This rule is shown in Figure 5.
∧(ma(t) = max(d) • mi(t) = min(d)•
dura(t) = {d} • d = ) C(d)
(d) @+0
Rule 5.3: For the node which is directed from initial
node, a place with time variable is used to form a self loop. C(d)
This rule is aimed at ensuring the correctness of the master
timer in a TCPN model. C(d)
Fig. 4. Rule 5.5: rule for transforming edges. Due to the page limited, we will not give a detailed proof
of the theorem.
270
@[1, 3] [f1=g] @[2, 4]
After After
Begin 1`f1 Copy
Begin Draw
Scene 1`f1 Frame
Scene Indicator F colset F = with f | g timed;
1`f1 F colset E = with e timed;
1`f1 1`f1
@[1, 3] After
Afte colset Flist = list F;
<<DrawRed>> {1} Render
d 1`f1
{1, 3} Copy var flist : Flist;
Draw Red After
Afte Frame @+1 var f1:F;
<<Render>> Frame
ram F
Diamond Game
(f) Render Frame F 1`f1 Draw 1`f1
Logic
g
(f) (f) [H] Indicatorr @+0
@[2, 4] Afte
After 1`f1
(f) Fork1
<<HookJump>> {2, 4} Render
{1, 3} Goto Hooked [G] ram
Frame
<<CopyFrame>> 1 1`e @0.0 1`f1 1`f1 Decision
cision Fork1_2
<<BScene>> Function e Game 1`f1 F
Copy BackBuffer TImer F
Begin Scene {1} Logic @+1 1`f1
(f) Frame e Afte
After @+1
E Hookk
(f) Hook O
Open
Jump
ump 1`f1 1`f1 1`f1
(f) flist f1::flist Jumpp File
F
1`[ ] if f1=f 1`f1
{1} Queue
<<Game>> {2, 4} then 1`f1 After
Afte
<<Openfile>>
Game Logic @+5 else empty Open
Open file to
write 1`flist flist^^[f1] File F
<<Present>> Present if f1=g Fork1_1 1`f1
Draw a Frame (f) @+0 Frame then 1`f1 F @+0
(f) {5} FormQ else empty 1`f1 1`f1
1`f1 Fork2
{12, 16}
<<EScene>> {1, 2} <<Enc>> 1`f1 After
Afte
End Scene Encode Present Fork2_1 Fork2_2
1`f1 F F
<<VPP>> {2, 4} Frame F
@[15, 18] 1`f1 @[12, 16]
Video Processing <<Write>> Prepare
Write File VPP 1`f1 After 1`f1
{15, 18} Enc
F Enc
(f) 1`f1 @[2, 4]
@[1, 2] 1`f1 W it
Write F
(f)
EEnd
d After
Aft File 1`f1
Scene VPP F @+0
<<CloseFile>> 1`f1 After
Afte
CLose File Join Write
1`f1 File F
1`f1
After
Close After
Af
Close
File 1`f1 Join
File F
Fig. 7. Transformation from activity hypergraph to TCPN model : Example of GameCapture Application
VI. C ASE S TUDY: T HE G AME C APTURE A PPLICATION corresponding colour set and variables for a Queue structure
of TCPN model is added. Transformation for hyperedges and
As an example of the our transformation method and nodes is under Rules 5.2, 5.5, 5.6, 5.7. Note that, the guards
its practical usability, we show a GameCapture application. and condition expressions need to be fixed manually according
This program is implemented based on an open-source project to different case. This transformation result is shown on the
TAKSI[19]. right of Figure 7.
In this scenario we assume that the user wants to record
the video when he is playing his favorite game. In order to B. Simulation and Analysis
generate a video, at least 24 frames per second need to be We add a data collector to transition “Present Frame” and
recorded and encoded. For simplicity, we firstly consider using test the data throughput capacity and data transforming speed
a single thread program. However, the performance is poor in of the two TCPN models using CPN Tools. The simulation
SOFTWARE mode. To improve its performance, we consider method is discussed in [7]. We simulate 2000ms to collect
using a Multi-Thread architecture. We reconstruct this model the frame amount and calculate the processing speed. The
into a multi-thread one by executing the VPP (Video Pre- simulation results are as shown in Figures 8 and 9. We can see
processing) module and the Encoder module concurrently. the multi-thread model performs better than the single-thread
model from this simulation result.
A. Model Transformation
We transform the two model (single-thread and multi-
thread) into TCPN models under our transformation rules. We
only show the transformation of multi-thread model and the
271
described in this paper was supported by the National Natural
Science Foundation of China under Grant No. 61232007,
91118004, and the Innovation Program of Shanghai Municipal
Education Commission (No. 13ZZ023).
R EFERENCES
[1] O. Uml, “2.0 superstructure specification,” OMG, Needham, 2004.
[2] O. CORBA, “Object management group,” 1999.
[3] J. P. López-Grao, J. Merseguer, and J. Campos, “From uml activity
diagrams to stochastic petri nets: application to software performance
engineering,” ACM SIGSOFT software engineering notes, vol. 29, no. 1,
Fig. 9. The processing speed of two models models during 2000ms pp. 25–36, 2004.
[4] O. OMG, “Systems modeling language (sysml),” OMG Available Spec-
ification, 2007.
This application is based on an open-source project [5] M. OMG, “Service oriented architecture modeling language (soaml),”
TAKSI[19]. We test these two applications by capturing 2008.
and encoding under different screen resolution: 320 × 240, [6] ——, “Modeling and analysis of real-time and embedded systems,”
640 × 480, 800 × 600, 1024 × 768, 1280 × 720, 1440 × 900, Object Management Group, 2008.
1920 × 1080. We test its ultimate processing speed in Frame [7] K. Jensen, L. M. Kristensen, and L. Wells, “Coloured petri nets and cpn
Per Second. A personal computer (core i7-3630qm processor tools for modelling and validation of concurrent systems,” International
CPU, with 8 GB RAM) is used as experiment platform. The Journal on Software Tools for Technology Transfer, vol. 9, no. 3-4, pp.
213–254, 2007.
experiment results are shown in Figure 10.
[8] K. Jensen, L. M. Kristensen, and L. L. M. Kristensen, Coloured Petri
nets: modelling and validation of concurrent systems. Springer, 2009.
[9] H. T. Jung and S. H. Joo, “Transformation of an activity model
into a colored petri net model,” in Trendz in Information Sciences &
Computing (TISC), 2010. IEEE, 2010, pp. 32–37.
ACKNOWLEDGMENT
We would like to express our special thanks to Rik Eshuis
for his helpful suggestions to improve the paper. The work
272