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

Prev Next

Building a Decision Model in Enterprise Architect

In the example we described earlier, An Example of Decision Modeling, we showed how a decision can be modeled using a decision table, in which a decision result is determined by finding a row in the table where the input values in the table match the input values under consideration, giving a particular output result.

We will now look at how such a model can be created in Enterprise Architect by stepping through the process of creating the decision model for the Airline Cabin Upgrade example.

There are a number of model elements involved in this example, such as Input Data elements, Item Definitions that are used to describe the Input Data (defining the data types), a Decision Element and also a Business Knowledge Model element that holds the Decision Table definition.

Create a Decision Requirements Diagram

The following steps will guide you through creation of a simple Decision Requirements Diagram (DRD).  In this example, we will create the model from scratch, rather than using a pattern from the Model Wizard.

Step

Description

See also

1

Select the perspective 'Requirements | Decision Modeling'.

(The Model Wizard is displayed, but we will not use it for this example, so close the Model Wizard.)

2

Create a new DMN diagram.  Name it 'Airline Cabin Upgrade'.

3

Using the diagram toolbox, place a Decision Element on the diagram. Choose 'Invocation' as the type - we will use this element to 'invoke' a decision from a Business Knowledge Model element.  Name the element 'Determine Cabin for Upgrade'.

Invocation Input Parameter Values for Simulation

4

Place an InputData element on the diagram.  Name this element 'Customer'.

Input Data

5

Place another InputData element on the diagram.  Name this element 'Cabin Status'.

6

Place a Business Knowledge Model element on the diagram.  Choose the type 'Decision Table'.  Name this element 'Cabin Upgrade Policy'.

Input Parameter Values for Simulation Decision Table

7

Draw an 'Information Requirement' connector from the decision 'Determine Cabin for Upgrade' to the input data 'Customer'.

8

Draw an 'Information Requirement' connector from the decision 'Determine Cabin for Upgrade' to the input data 'Cabin Status'.

9

Draw a 'Knowledge Requirement' connector from the decision 'Determine Cabin for Upgrade' to the BKM 'Cabin Upgrade Policy'.

At this stage, we should have a simple DRD, that looks something like this:

We can now specify the details for each of the elements making up this model.

Define the Decision Table

By double-clicking on the Business Knowledge Model element 'Cabin Upgrade Policy', the 'DMN Expression' window is displayed, showing an empty decision table. This is where we will define the rules of our cabin upgrade policy.

By default, new decision tables are created with two input columns and one output column, a header row and three empty rules rows.

The left-most column in the table displays the 'hit policy' and also numbers the rules.

By default, the 'hit policy' is 'Unique'.  This is the policy that we will use for our example, so leave this as it is. 

For more information on 'hit policy', refer to the topic 'Decision Table Hit Policy'.

Name and Define Types for Decision Table Inputs and Outputs

Step

Description

See also

1

On the toolbar of the 'DMN Expression' window, click on the 'Edit Parameters' button, .

The 'Edit Parameters' dialog displays.

2

Replace the parameter name 'Input 1' with 'Num of Pax Overbooked'. 

Set the type of this parameter to 'number'.

3

Replace the parameter name 'Input 2' with 'Num of Flights in Last Month by Pass'. 

Set the type of this parameter to 'number'. 

Close the 'Edit Parameters' dialog.

4

Edit the input expression that will be evaluated for column 1. 

Select the header cell (containing the text 'Input 1') then click again or press F2 to enter 'Edit' mode.  Select all of the cell text, then press the space bar.  The list of input parameters is displayed.  Choose 'Num of Pax Overbooked', then press 'Enter'.  The expression for column 1 is set to 'Num of Pax Overbooked'.

Note:  The input expressions evaluated for each column typically just use the corresponding input parameter, however you can use a complex expression.

5

Right-click on the column 1 expression and set its data type to 'number'.

6

Edit the input expression that will be evaluated for column 2.

Select all of the text, then press the space bar.  The list of input parameters is displayed.  Choose 'Num of Flights in Last Month for Pass', then press 'Enter'.

The expression for column 2 is set to 'Num of Flights in Last Month for Pass'.

7

Right-click on the column 2 expression and set its data type to 'number'.

8

Edit the name of the decision table output. 

Replace 'Output 1' with 'Upgrade Cabin', then press 'Enter'.

9

Set the data type of the decision output. 

Right-click on the output column header and choose 'string'.

10

Set the allowable values for the decision output.

In the cell directly beneath the output column header (but above row 1), define the allowable values for output.  Enter "Business Class, First Class".

Note:  There is no need for quote marks around the values, as the data type has been specified as 'string'.

Define the Rules of the Decision Table

Enter values into the table cells to match the image below.

A DMN Decision Table for a flight cabin upgrade using Sparx Systems Enterprise Architect.

Click to select a cell, click again to edit.

You can copy and paste existing rules by selecting the rows to copy ('Shift + click' adds to the selection), right-click and choose copy, then right-click and choose append.

Once you have finished editing the rules, click on the 'Save' button .

Finally, click the 'Validate' button ,  to check for errors in the table of rules.

Create ItemDefinition Elements

Add two ItemDefinition elements to the diagram, one for each of the InputData elements.  Name one element 'CustomerDefinition' and the other 'CabinStatusDefinition'.

Double-click the ItemDefinition named 'CustomerDefinition' to edit the definition.  The DMN Expression window is displayed.

Right-click on the cell 'CustomerDefinition' and choose 'Add Child Component'.  Set the name of the child component to 'Num of Flights in Last Month' and set its datatype  to 'number'.  Click the 'Save' button to save the changes.

Similarly, edit the ItemDefinition named 'CabinStatus Definition' adding a child component named 'Num Pax Overbooked' and set its data type as 'number'.  Save the changes.

Specify the Data Type For Each InputData Element

Select the InputData element 'Customer'.  In the Properties window,  select the property 'typeRef' and click on the browse button ('...').

Select the ItemDefinition 'Customer Definition' as the type.  Click on 'OK'.

Similarly, specify 'Cabin Status Definition' as the type for 'Cabin Status'.

Specify the Inputs to the Decision Element

Select the decision element 'Determine Cabin for Upgrade'

In the DMN Expression window, locate the table row containing the text 'Num of pax overbooked' in first column.  Click in the cell in the second column of this row, and press the space bar.  A list of possible input values is displayed.  Choose 'Cabin Status . Num Pax Overbooked' and press 'Enter'.  The selection is written into the cell.

Repeat this process for the second table row 'Num of flights in last month', choosing 'Customer . Num of Flights in Last Month'.

Click on the Save button.

Click on the Validate button.

Define Data Sets

The 'correctness' of your decision model can be tested, by running simulations using a range of representative data sets to verify that the model produces the correct result in all situations.

You can create numerous Data Sets with various names, using a range of data values.  You can set one of the data sets as the default value.

We will now create a Data Set for each of our InputData elements.

Step

Description

See also

1

Double-click on the InputData element 'Customer'. 

The DMN Expression window displays.

2

In the DMN Expression window, click on the 'Edit Data Set' button .

The 'Edit Data Set' window is displayed.

3

Click on the button.

A new data set is created.

4

Overwrite the name of the data set if you wish. 

Leave the Type as 'number'.  Enter a value of say, 3. 

Click on OK.

5

Repeat for the InputData 'Cabin Status'.   Enter a value of say, 4.

Add a DMNSimConfiguration Artifact

Locate the 'DMN Sim Configuration' artifact in the diagram toolbox.  Drop one of these onto the diagram as well.

Double-click on it to open the DMN Simulation window.

From this window, you can run simulations of the completed Decision Model.  You can also perform Validation, generate code and generate test modules.

Step

Description

See also

1

Locate the edit field in toolbar of this window.

2

Click on the drop-down arrow in this field.

A list displays, showing all of the Decision Services and all decision elements in the package associated with the Sim Configuration artifact.   In this case, 'Determine Cabin for Upgrade' is the only item in the list.

3

Choose 'Determine Cabin for Upgrade'.

4

The body of the window now displays the InputData elements and the decision results that are available as inputs to the selected decision.

Click on the Save button.

5

Use the 'Value' column to select one of the predefined DataSets for the InputValues, then you can click on the 'Run' button   to run a simulation, using the selected data sets.

Learn more