poniedziałek, 6 sierpnia 2012

Simulation in jBPM (draft)

Recently some work has been started to provide simulation capabilities for jBPM. Simulation in many cases means different things to various people so let me start with context information on what simulation means to me and actually what current simulation component is capable of.

Simulation of business process is targeting business analysts that work on designing processes and optimizing them this is not a developer tool. It brings analitics into the picutre so while modelling the process various scenarios could be evaluated to see what is the best option based on current knowledge. In my eyes it is a way of learing the process and better understanding its design and prepare for the consequences a particular process can introduce. For example if we consider goods return process that will take care of products that were bought but for some reason was returned to the store. There are several steps that needs to be performed to analyze what is the reason of return:
  • it is broken
  • it does not meet customer expectations
  • etc
Depending on the reason various decisions could be taken, from rejecting the return, through sending that for further analysis to verify it is broken up to accepting it and returning funds. Following diagram illustrates sample of such process

We can imagine that this process is prepared for heavy sale period which could be Xmas time. Analyst considers that there could be quite some returns due to it was a duplicated/missed gift and is wondering how to prepare its company to deal with it efficiently. With simulation and just few additional information (input data) provided as some sort of forecast on the expected load and available resources (s)he could identify potential bottlenecks in the organization that will prevent it from gathering profit (working efficiently). To name few of these information:
  • probability of taking a given path on the gateway
  • time spent on executing given activity
  • how many people are available to work on user tasks

Once such information are provided a simulated run through this process is executed and result is gathered and presented to the analyst for inspection. Number of runs can be executed with various input data to exercise "what if" scenarios. Alternative sources of information can exist, for instance analyst can make use of real time data collected by business activity monitoring for processes that are already running on production systems.

With this short introduction we can move on to look into how this is realized by jbpm simulation.

First of all jbpm simulation is divided into two components:
  • path finder
  • simulation engine extension

path finder component is responsible for determining all alternative paths in the process to illustrate how a process can be traversed. This is not only informational but as well input for running simulation. Following image shows the sample process with identified alternative paths and one is visualized on the diagram.


simulation engine extension is (as name suggests) an extension to jbpm engine that allows you to run simulations instead of normal process instance executions. Instead of relying on process data like variable it will traverse the process based on identified paths. So that means that path finder component is responsible for providing input to the simulation engine extension component. This at least is the main use case,it could be used as well to alter the path flow in cases of debugging the simulation.

Simulation engine extension provides core of the simulation dedicated to processes but does not run the simulation itself. For that drools- simulator (some details about it can be found here and here) is employed together with its fluent api that is based on paths and steps that can be positioned in time.

A typical use case would look like this:
  • model process definition
  • determine all alternative paths
  • each alternative path will be a path in drools simulatoin fluent
  • define steps for the path (there could be several steps configured for a drools simulator path that in fact represents simulation instance) on a given time distance
  • add SimulateProcessPathCommand for each step
  • run simulation
To see a running example of such simulation take a look at test case that is part of the jbpm-simulation.

Simulation engine extension while executing simulation will generate events for every simulated activity those events will be stored in simulation repository that could have various capabilities. Personally I prefer one that is backed up with stateful knowledge session and can employ complex event processing  and rules to provide meaningful simulation results.

This is just short heads up on the simulation efforts in jbpm so please leave your comments on what would you like to see supported by this component.

Further details about jbpm-simulation components can be found in jbpm wiki (soon).

3 komentarze:

  1. Hi Maciej,

    What is the maven dependency if we want to use the PathFinder and PathFinderFactory like in the following code?

    https://github.com/mswiderski/jbpm-simulation/blob/master/src/test/java/org/jbpm/simulation/SimulationFluentTest.java

    OdpowiedzUsuń
  2. Thomas, you need to use following:

    org.jbpm
    jbpm-simulation
    1.0.0-SNAPSHOT

    That should bring in all other parts that are required.

    OdpowiedzUsuń