Set Up Simulation Script
You can use Simulation Scripts to provide fine control over how a Simulation starts. In general, you do not need to set up a Simulation Script unless:
- You want to run an interpreted Simulation that requires variables to be initialized before the Simulation commences; this is useful for setting up global variables and defining functions
- (In the Corporate Edition and above) You do not want to apply the default behavior of interpreting the Guards (that is, you prefer to use a manual execution), or
- You want to have multiple ways of running the same diagram
For most diagrams it is possible to initialize a script for a Simulation simply by setting variables in the first element or connector after the Start element. For State Charts, this is the Transit connector exiting the initial element, and for Activity models this is the first Action element.
As an alternative, you can use Simulation Scripts to initialize settings before a Simulation starts. This is useful for setting up different sets of initial values using multiple Analyzer Scripts, so that you can run your Simulation under a range of pre-set conditions.
To configure a Simulation Script, first select the Package in the Browser window, Package Browser, Diagram List or Model Search. You can then use the Execution Analyzer window to add a new script for that selected Package. You will use the 'Simulation' page of the 'Execution Analyzer' dialog to configure the relevant properties.
Show the Execution Analyzer window using one of the methods outlined here.
On the Execution Analyzer window, either:
- Locate and double-click on the required script and select the 'Simulation' page or
- Click on in the window Toolbar and select the 'Simulation' page
Develop > Source Code > Execution Analyzer > Edit Analyzer Scripts
Execute > Tools > Analyzer
Browser window | Right-click on Package | Execution Analyzer
Configure a Simulation Script
For UML Activity, Interaction or StateMachine simulation, click on the drop-down arrow and select 'UML Basic'.
For BPMN diagrams, click on the drop-down arrow and select 'BPMN'.
Click on the button and select the:
If you do not specify an entry point, the Simulator attempts to work through the entire Package.
(In Corporate and higher editions) Leave the checkbox unselected to perform a manual Simulation, where you select the next State to transition to and the point where a decision must be made.
The guard must be a valid Boolean expression, also terminated with a semi-colon.
Variables that are members of 'sim' or 'this' are listed in the Locals window when a Simulation breakpoint is reached.
sim.count = 0;
|StateMachine Table Conventions Transition View the Local Variables
Post Processing Script
For example, if you have a script named 'MyScript' in the Script Group 'MyGroup', type in the value 'MyGroup.MyScript'.
Click on this button to save your changes.
- Usually all Simulation elements and relationships reside within the Package configured for Simulation; however, you can simulate diagrams that include elements from different Packages, by creating Package Import connectors from the configured Package to each 'external' Package (alternatively, for a BPSim model, create a Dependency connector from the configured Package to each external element)