Prev Next

Fibonacci Number Generator with Link Event

A Link Event is a mechanism for connecting two sections of a Process. Link Events can be used:

  • To create looping scenarios, as generic 'Go To' objects within the Process level
  • To avoid long Sequence Flow lines; paired Link Events can be used as 'off-page' connectors for printing a Process across multiple pages

The use of Link Events is limited to a single Process level (that is, they cannot link a parent Process with a sub-Process).

There can be multiple source Link Events, but there can only be one target Link Event.

  • The target Link Event marker is unfilled, to 'catch' from the source link
  • The source Link Event marker is filled to 'throw' to the target link

When the EABPSim Execution Engine is running the simulation, the source-target Link Events are paired by element NAME, so they cannot be empty.

Create BPMN Model

  • Create a StartEvent S1
  • Add a Sequence Flow to a target abstractTask Activity element next=first+second (open the 'Properties' dialog and set the 'Type' field to 'abstractTask')
  • Add a Sequence Flow to a target abstractTask Activity element first=second
  • Add a Sequence Flow to a target abstractTask Activity element second=next
  • Add a Sequence Flow to a target abstractTask Activity element n++
  • Add a Sequence Flow to a target exclusive Gateway element loopNode (on the instant menu, select 'Exclusive')
  • Add a Sequence Flow to each of these target elements:
         -  A Throwing Link Intermediate Event element SetNext (open the 'Properties' dialog and set the
            'Type' field to 'Throwing > Link') and
         -  An End Event element E1
  • Create a Catching Link Intermediate Event element SetNext (open the 'Properties' dialog and set the 'Type' field to 'Catching > Link')
  • Add a Sequence Flow to the target element next=first+second

Configure BPSim

We will use Property Parameters to define how the sequence flow forms a loop during which a Fibonacci Number will be generated. The loop mechanism is implemented via the pair of Link Events.

Open the Configure BPSim window ('Simulate > BPSim > Manage > Open BPSim Manager')

Task

Action

Element: S1

In the element type list on the left, expand the Start Event group and click on S1.

Click on the 'Control Tab' and on the 'New Parameter' drop-down arrow; select 'TriggerCount'.

In the 'Value' field type '1'.

Click on the 'Properties' tab

Overtype the New Property text to create these properties:

  • N - and type '10' in the 'Value' field as the total number of Fibonacci Numbers to be generated
  • first - and type '1' in the 'Value' field
  • second - and type '1' in the 'Value' field
  • n - and type '0' in the 'Value' field as the nth new Fibonacci Number

Element: next=first+second

In the element type list, expand the Activity group and click on next=first+second.

Click on the 'Properties' tab and overtype the New Property text with 'next '.

In the 'Value' field, click on the button, click on the 'Expression' tab and type the expression '{first}+{second}'.

Click on the OK button.

Element: first=second

In the element type list, in the Activity group click on first=second.

Click on the 'Properties' tab and overtype the New Property text with 'first '.

In the 'Value' field, click on the button, click on the 'Expression' tab and type the expression '{second}'.

Click on the OK button.

Element: second=next

In the element type list, in the Activity group click on second=next.

Click on the 'Properties' tab and overtype the New Property text with 'second'.

In the 'Value' field, click on the button, click on the 'Expression' tab and type the expression '{next}'.

Click on the OK button.

Element: n++

In the element type list, in the Activity group click on n++.

Click on the 'Properties' tab and overtype the New Property text with 'n'.

In the 'Value' field, click on the button, click on the 'Expression' tab and type the expression '{n}+1'.

Click on the OK button.

Conditions of Gateway

In the element type list, expand the Gateway group and the LoopNode element and click on SetNext.

Click on the 'Control' tab and on the 'New Parameter' drop-down arrow, and select 'Condition'.

In the 'Value' field, click on the button, click on the 'Expression' tab and type the expression '{n} <={N}'.

Click on the OK button.

Now click on E1.

Click on the 'Control' tab and on the 'New Parameter' drop-down arrow, and select 'Condition'.

In the 'Value' field, click on the button, click on the 'Expression' tab and type the expression '{n} > {N}'.

Click on the OK button.

Run Simulation

  • On the 'Configure BPSim' dialog, in the toolbar, click on the 'Run' icon; the 'BPSim Simulation Controller' dialog displays
  • Click on the 'Run' icon drop-down arrow and select 'Standard Simulation'
  • When the simulation is complete, click on the icon in the toolbar; the 'BPSim PropertyParameter Values' dialog displays
  • Click on the Query button and on the 'Group by Element' tab, and expand 'next=first+second'; all the attributes's snapshot values are listed
  • Apply a filter 'next' (right-click on the list header, select 'Toggle Filter Bar' and type 'next' under the 'Element' heading); the results will resemble this image:

Ten more Fibonacci numbers are generated:

     2,3,5,8,13,21,34,55,89,144