<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Python Library for WfMC-Standard Process-Simulation Specifications</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Claudia Fracca</string-name>
          <email>claudia.fracca@phd.unipd.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Angelica Bianconi</string-name>
          <email>angelica.bianconi@studenti.unipd.it</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Francesca Meneghello</string-name>
          <email>francesca.meneghello.4@studenti.unipd.it</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Massimiliano de Leoni</string-name>
          <email>deleoni@math.unipd.it</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Fabio Asnicar</string-name>
          <email>asnicar@esteco.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Alessandro Turco</string-name>
          <email>turco@esteco.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Process Model</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Notation (BPMN)</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Python.</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>ESTECO SpA</institution>
          ,
          <addr-line>Trieste</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Padua</institution>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2021</year>
      </pub-date>
      <abstract>
        <p>Business process simulation is a flexible technique that allows analysts to compare alternative scenarios and contribute to the analysis and improvement of business processes. This work presents BPSimpy, a business process simulation Python library, to generate a simulation specification file in a standard format that allows seamless integration with diferent simulators. BPSimpy can, e.g., be integrated with libraries for Data and Process Mining, thus bringing together the worlds of mining and business process simulation. For instance, event logs can be used to discover accurate business process simulation models consisting of a business process model and several simulation aspects that parametrize diferent process perspectives, such as the time perspective, the resource perspective, and the decision perspective.</p>
      </abstract>
      <kwd-group>
        <kwd>Business Process Simulation</kwd>
        <kwd>Simulation Model</kwd>
        <kwd>Business Process Simulation Standard (BPSim)</kwd>
        <kwd>Business</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Business process simulation refers to techniques for the simulation of business process behavior
on the basis of a simulation model consisting of a business process model extended with additional
information for the definition of the diferent run-time
simulation aspects: case arrival rate, task
durations, routing probabilities, resource allocation and utilization, etc. Simulation provides
a flexible approach to analyse and improve business processes [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. The main idea of business
process simulation is to generate a set of possible execution traces of a process, leveraging on
the information a simulation model. The resulting execution traces allow companies to monitor
the eficiency of their internal processes and to determine the critical aspects like bottlenecks,
wastes, and over-and under-utilization of resources, and to verify the consequences of proposed
process modifications before putting them in production. Through simulation experiments,
various ‘what-if’ questions can be answered, and redesigning alternatives can be compared
with respect to some key performance indicators.
      </p>
      <p>
        Typically, a business process simulation requires, as a first step, to extract a business process
model from the process information (e.g. process documentation, stakeholders interviews,
observational data, process data, event logs, etc.) such as a BPMN model [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] that covers the
control-flow perspective (i.e. the ordering of activities) and may be enhanced with other
perspectives, such as time, resource, and decision perspective [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. The model is further extended
by the definition of run-time simulation aspects, i.e. simulation parameters. The appropriate
setup of these simulation aspects is often based on insights from process documentation, expert
interviews and observations of the real process. These insights may be however inaccurate or,
even, incorrect: they are indeed based on subjective opinions of process stakeholders and on the
supposed process executions. It then follows that any conclusions drawn from these simulation
results can be misleading or erroneous. Consequently, they can yield negative efects when the
process is redesigned according to those conclusions. To analyze the actual process and not the
supposed one, business process simulation should be merged with data and process mining:
the simulation model should be derived from the actual objective facts recorded in the process
event data, instead that from the subjective personal opinions [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
      <p>This paper reports on BPSimpy, a business process simulation Python library to
programmatically generate business simulation files. This way, one can write Python code that leverages on
data- and/or process-mining libraries to obtain simulation models that accurately reflect the
reality. In fact, the choice of Python is driven by the fact that this language is already equipped
with libraries for process mining (e.g. PM4Py1), machine learning, data science (e.g. Pandas,
Numpy, Scipy, Tensorflow, Keras, etc.), and more.</p>
      <p>One of the strongest points of BPSimpy is the ability to generate simulation models compliant
with the Business Process Simulation Specification (BPSim), a standard format by the Workflow
1 import BPSimpy
2 example = BPSimpy . BPSim ( `BPMN . xml ' )
3 s c e n a r i o = example . a d d S c e n a r i o ( i d = ` S1 ' , name= ` P i z z a shop ' )
4 s t a r t = s c e n a r i o . g e t E l e m e n t P a r a m e t e r s ( example . getIdByName ( ` S t a r t ' ) )
5 s t a r t . a d d I n t e r T r i g g e r T i m e r ( v a l u e = d a t e t i m e . t i m e d e l t a ( minutes = 5 ) )
6 r e c e i v e O r d e r = s c e n a r i o . g e t E l e m e n t P a r a m e t e r s ( example . getIdByName ( ` R e c e i v e Orde r ' ) )
7 r e c e i v e O r d e r . a d d P r o p e r t y ( name= ` n o O f P i z z a s ' , n a m e D i s t r i b u t i o n = ` P o i s s o n D i s t r i b u t i o n ' ,
mean = 4 )
8 r e c e i v e O r d e r . a d d P r o c e s s i n g T i m e ( n a m e D i s t r i b u t i o n = ` T r u n c a t e d N o r m a l D i s t r i b u t i o n ' , min=0 ,
max=10 , mean =2 , s t a n d a r d D e v i a t i o n = 1 )
9 r e c e i v e O r d e r . addWaitTime ( v a l u e = d a t e t i m e . t i m e d e l t a ( minutes = 1 ) )
10 bake = s c e n a r i o . g e t E l e m e n t P a r a m e t e r s ( example . getIdByName ( ` Bake P i z z a ' ) )
11 bake . a d d P r o c e s s i n g T i m e ( e x p r e s s i o n = ` ` bpsim : g e t P r o p e r t y ( ` n o O f P i z z a s ' ) ∗ 7 ' )
12 bake . addWaitTime ( n a m e D i s t r i b u t i o n = ` T r u n c a t e d N o r m a l D i s t r i b u t i o n ' , min=0 , max=100 , mean
=5 , s t a n d a r d D e v i a t i o n = 2 )
13 d e l i v e r y P i z z a = s c e n a r i o . g e t E l e m e n t P a r a m e t e r s ( example . getIdByName ( ` D e l i v e r y P i z z a ' ) )
14 d e l i v e r y P i z z a . a d d P r o c e s s i n g T i m e ( n a m e D i s t r i b u t i o n = ` T r u n c a t e d N o r m a l D i s t r i b u t i o n ' , min=0 ,
max=120 , mean =10 , s t a n d a r d D e v i a t i o n = 8 )
15 d e l i v e r y P i z z a . addWaitTime ( v a l u e = d a t e t i m e . t i m e d e l t a ( minutes = 5 ) )
16 YesSeq = s c e n a r i o . g e t E l e m e n t P a r a m e t e r s ( example . getIdByName ( ` yes ' ) )
17 YesSeq . a d d P r o b a b i l i t y ( v a l u e = 0 . 0 2 )
18 NoSeq= s c e n a r i o . g e t E l e m e n t P a r a m e t e r s ( example . getIdByName ( ` no ' ) )
19 NoSeq . a d d P r o b a b i l i t y ( v a l u e = 0 . 9 8 )
20 O r d e r C o l l e c t o r = g e t E l e m e n t P a r a m e t e r s ( example . getIdByName ( ` Order C o l l e c t o r ' ) )
21 O r d e r C o l l e c t o r . a d d Q u a n t i t y ( v a l u e = 1 )
22 PizzaMaker = g e t E l e m e n t P a r a m e t e r s ( example . getIdByName ( ` P i z z a Maker ' ) )
23 PizzaMaker . a d d Q u a n t i t y ( v a l u e = 3 )
24 DeliveryMan = g e t E l e m e n t P a r a m e t e r s ( example . getIdByName ( ` D e l i v e r y Man ' ) )
25 DeliveryMan . a d d Q u a n t i t y ( v a l u e = 3 )
26 r e c e i v e O r d e r . a d d S e l e c t i o n ( e x p r e s s i o n = ` ` bpsim : g e t R e s o u r c e ( ` O r d e r C o l l e c t o r ' , 1 ) ” )
27 bake . a d d S e l e c t i o n ( e x p r e s s i o n = ` ` bpsim : g e t R e s o u r c e ( ` PizzaMaker ' , 1 ) ” )
28 d e l i v e r y P i z z a . a d d S e l e c t i o n ( e x p r e s s i o n = ` ` bpsim : g e t R e s o u r c e ( ` DeliveryMan ' , 1 ) ” )</p>
      <p>
        Management Coalition (WfMC) [
        <xref ref-type="bibr" rid="ref5 ref6">5</xref>
        ]. This enables a seamless integration with diferent simulation
software products, such as Lanner 2 and Sparx3.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. BPSimpy Library</title>
      <p>The BPSimpy library takes a BPMN process model and the simulation parameters as input and
generates a BPSim simulation model. The BPSim simulation model is organized in simulation
scenarios. A simulation scenario specifies the initial conditions at the beginning of the situation
and the diferent simulation parameters, necessary to set up a simulation run. Simulation
parameters are also attached to the elements of the BPMN process model (events, tasks, gateways,
sequences, etc.) to configure their simulation-time behavior. BPSimpy supports simulation
parameters related to the various process perspectives: time, control, resources, cost, priority,
and data. The definition of process’ data objects is done via a set of process properties.</p>
      <p>We describe the functionalities of the BPSimpy library through the example in Fig. 1. The
2https://www.lanner.com/en-us/technology/l-sim-bpmn-simulation-engine.html
3https://sparxsystems.com/products/ea/trial/request.html
diferent elements of the BPMN model are associated with some simulation parameters related
to the perspectives on time, resources and control. Note how the example defines waiting times
independently of the availability of resources: often, process tasks are not started as soon as
they are enabled and resources are available, because resources work on multiple processes,
take working breaks, execute duties that leave no trails in event logs, and other practical factors.</p>
      <p>Fig. 2 shows the Python code to implement this simulation scenario. After importing the
BPSimpy library (line 1), we call the constructor of a BPSim object passing the BPMN
specification file (line 2). The next step is to create a scenario ( method a d d s c e n a r i o ( ) , line 3). Once
the scenario is created, the simulation parameters are associated to the diferent elements of
the BPMN model, such as tasks, events, sequences, etc. The method g e t E l e m e n t P a r a m e t e r s ( i d )
(line 4,6,10,...) returns an handle object to invoke the methods to associate the parameters to
the BPMN element with a given i d . If this is not known the method g e t I d B y N a m e ( n a m e ) (line
4) allows one to retrieve it by the element name. Line 5 associates a control parameter to the
start event: the interTriggerTimer, which models the case arrival rate. Line 7 sets a property
parameter, that models the attribute ‘noOfPizzas’ for the first task Receive Order. In line 17 and 19
the routing probabilities for the XOR gateway are added through the method a d d P r o b a b i l i t y ( ) .
Lines 22 to 30 associate the quantity of resources to each roles (method a d d Q u a n t i t y ( ) ). Each
task is linked to the corresponding role that resources need to be able to play to perform it
(method a d d S e l e c t i o n ( ) ).</p>
      <p>
        Note how BPSim’s simulation parameters are typed according to their nature and necessary
configuration, which our library BPSimpy fully supports: constants, distributions , enumerations,
and XPATH 1.0 expressions (see the BPMSim guide for details [
        <xref ref-type="bibr" rid="ref5 ref6">5</xref>
        ]). Our library allows setting
up these parameters invoking methods of the same name. Calendars are also supported(cf.
Section 3). It is also possible to request to a specific process model element a result request
attribute to have in the output, e.g. the resulting processing time of a specific process task or
the number of times a task is performed, (see [
        <xref ref-type="bibr" rid="ref5 ref6">5</xref>
        ] for the applicability).
      </p>
    </sec>
    <sec id="sec-3">
      <title>3. A Case Study</title>
      <p>This section reports a case study of a real business process. The event log is taken from the
Second International Business Process Intelligence Challenge (BPI2012).4 The event log refers
to an application process for a personal loan or overdraft within a global financing organization.
The event log is a merger of three intertwined sub processes and we decided to showcase on an
individual subprocess (subprocess A). We leveraged on the Pm4Py library and other statistic
libraries in Python to first mine a fitting, precise BPMN process model and later complement
with the other simulation parameters, namely: (i) the probability distribution function of the
inter arrival rate, considering the case-arrival calendar from 8am to 11pm; (ii) the branching
probabilities for each XOR split in the process model; (iii) the probability distributions of the
processing time of every model task; (iv) the set of roles with the resources belonging to each;
(v) the working calendar hours for each role, and (vi) the mapping of each activity a to each role
that resources must play to be able to perform a. Once we discovered the BPMN process model
and the simulation parameters, we employed our BPSimpy library to write a BPSim simulation
4https://www.win.tue.nl/bpi/doku.php?id=2012:challenge
ifle. As last step, this file was given as input to the Lanner simulator (L-sim) to carry out the
simulation. L-sim returns a zip file as output that contains the simulated event log and a file with
the simulation statistics of interests. The result-request configuration was employed through
our library to analyze the performance the queue length and the waiting time for each task.
This analysis can be useful to individuate process improvements. Note that the generation of an
event-log file in XES format is supported by the Lanner simulator through a so-called vendor
extension, a concept supported by the BPSim and configurable via our BPMSimpy library.</p>
      <p>Further information on the case study is available in the library Github repository.5 The
repository also contains a tutorial based on a Jupiter Notebook on Google Colab that presents
the case study along with a screencast demonstrating the usage of the BPSimpy library. This
way, the Github repository incorporates a collaborative system where users can download and
use the BPSimpy library, report problems and contribute to the code.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion</title>
      <p>This paper reports on BPSimpy, a mature Python library that allows for programmatically
creating business process simulation models in BPSim, a WfMC standard supported by multiple
simulators. The library and the underneath standard supports several simulation parameters to
enhance incorporate information related to time, control, resources and decision. The library
is meant to enable the integration of the Process- and Data-Mining worlds to create accurate
simulation models. These models enables monitoring processes, determining such critical
aspects as resource over- and under-use, bottlenecks, cost and time wasting, to provide actionable
insights to enable for a subsequent process improvement.</p>
      <p>Acknowledgement. This research work is partly supported by the Department of Mathematics of
University of Padua through the SID/BIRD 2020 project “Deep Graph Memory Networks”.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M.</given-names>
            <surname>Dumas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. La</given-names>
            <surname>Rosa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Mendling</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H. A.</given-names>
            <surname>Reijers</surname>
          </string-name>
          , Fundamentals of Business Process Management, 2nd ed., Springer Publishing Company, Incorporated,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>BPMN</surname>
          </string-name>
          <year>2013</year>
          : ISO/IEC International Standard 19510:
          <string-name>
            <surname>Information Technology - Object Management Group Business Process Model</surname>
          </string-name>
          and Notation,
          <string-name>
            <surname>Document Number</surname>
            <given-names>ISO</given-names>
          </string-name>
          /IEC 19510:
          <string-name>
            <surname>2013(E)</surname>
          </string-name>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>W. M. P. van der Aalst</surname>
          </string-name>
          , Process Mining: Data Science in Action, 2nd ed., Springer Publishing Company, Incorporated,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>N.</given-names>
            <surname>Martin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Depaire</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Caris</surname>
          </string-name>
          ,
          <article-title>The use of process mining in business process simulation model construction</article-title>
          ,
          <source>Business &amp; Information Systems Engineering</source>
          (
          <year>2016</year>
          )
          <fpage>73</fpage>
          -
          <lpage>87</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>BPSim</given-names>
            <surname>2013: Workflow Management Coalition: BPSim- Business Process Simulation Speciifcation</surname>
          </string-name>
          ,
          <source>Document Number WFMC -BPSWG-2012-1</source>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>5The Github Repository of BPSimpy - https://github.com/claudiafracca/BPSimpyLibrary.git</mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>