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 execution script, first select the Package in the Project Browser, 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


Code > Configure > Analyzer > Edit Analyzer Scripts

Execute > Run > Analyzer > select and run script

Context Menu

Project Browser | Right-click on Package | Execution Analyzer

Keyboard Shortcuts


Configure a Simulation Script



See also


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;

State Machine Table Conventions Transition View the Local Variables


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


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 (or alternatively, for a BPSim model, a Dependency connector from the configured Package to each external element)

Learn more