Simulate DMN Model
A DMNSimConfiguration Artifact contains information to define the simulation of a DMN model depicted by Decision Requirements diagrams, using the DMN Simulation window.
Simulate > Decision Analysis > DMN > Open DMN Simulation | Simulate tab
Double-click on a DMNSimConfiguration element |Simulate tab
To create a DMNSimConfiguration element:
- Open a Decision Requirements Diagram
- Drag the 'Simulation Configuration' icon from the toolbox onto the diagram
By default, all DMN elements in the current Package (Decision, BusinessKnowledgeModel, InputData and ItemDefinition) will be loaded to the DMN Simulation window.
When a target Decision is specified, the 'Simulation' tab will list the related Decisions, in dependency order.
When executing or 'stepping through' the Decision Hierarchy, the Decisions will be evaluated in order and:
- The runtime result will show in the 'Value' column
- The runtime result will be displayed as overlaid text on the diagram
- The Decision logic and input/output data will be presented in the DMN Expression window
Simulation run and stepping through
You can perform a full run of the simulation using the icon. You can step into each Decision to see the invocation sequence using the icon.
For example, in the 'Simulate' tab of our illustration, you can see that:
- The Decision 'Pre-bureau affordability' invokes the BusinessKnowledgeModel 'Affordability calculation'
- BusinessKnowledgeModel 'Affordability calculation' further invokes another BusinessKnowledgeModel 'Credit contingency factor table'
When a Package is loaded, a Decision Requirements Graph (DRG) and decision dependency list is created. The DMN InformationRequirement connectors determine the list order.
- All the decisions will be listed in the drop-down for the toolbar data entry field
Data Set & Input Data
When the target Decision is selected, all the dependent InputDatas are added to the 'Element' column. You can then choose from the data sets defined for each InputData element, using the drop-down lists in the 'Value' column. Each data set provides runtime values to use in the simulation.
Although Enterprise Architect provides a validation feature to help you locate many modeling issues and DMN expression issues, the simulation might still fail (rarely but possible) due to uncaught issues.
However, Enterprise Architect provides the ability to debug the code that is running behind the simulation. You can also modify the code and run it in cycles until the issue is found and fixed.
The drop-down arrow for theon the toolbar displays a menu with these options:
- Generate new Script (Scripting Window)
- Update Selected Script (Scripting Window)
- Run Selected Script (Scripting Window)
- Edit DMN Template
If you select 'Generate New Script (Scripting Window)', the Scripting window displays showing a script created in a Package named 'DMN'.
- The default script name is composed of these parameters: 'ArtifactName - TargetDecision - InputData1(DataSet)_ InputData2(DataSet)_...'
Double-click on this file to open it in the Enterprise Architect Script editor, set a breakpoint, and debug the file.
By selecting the script in the Scripting Window, and if the script matches the model (by the 'Simulation Script Identifier' in the script), you enable the menu option 'Run Selected Script'.
You can customize the DMN Template to generate the correct script for simulation.