Book a Demo

Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next

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.

Access

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

Ribbon

Develop > Source Code > Execution Analyzer > Edit Analyzer Scripts

Execute > Tools > Analyzer

Context Menu

Browser window | Right-click on Package | Execution Analyzer

Keyboard Shortcuts

Shift+F12

Configure a Simulation Script

Option

Action

See also

Platform

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'.

Entry Point

Click on the Browse. button and select the:

  • Entry point for the Simulation, and
  • Activity, Interaction or StateMachine to simulate

If you do not specify an entry point, the Simulator attempts to work through the entire Package.

Evaluate Guards and Effects using JavaScript

(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.

Select the checkbox to execute the code for Effect behavior in the Simulation. The Simulation executes JavaScript code in these places:

  • State entry/exit/do operations
  • Transition guard/effect
  • BPMN Activity Loop Conditions and Sequence Flow Condition Expressions

With the exception of the guard, all of these should be one or more valid JavaScript statements, including the semi-colon.

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

Input

When JavaScript is enabled, you can type script commands in this field that will execute prior to the Simulation being run.

Post Processing Script

Using a Post Simulation Script, you can run JavaScript after the Simulation ends. Type in the qualified name of a script from the model script control.

For example, if you have a script named 'MyScript' in the Script Group 'MyGroup', type in the value 'MyGroup.MyScript'.

OK

Click on this button to save your changes.

Notes

  • 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)

Learn more