Prev Next

Building a Decision Model in Enterprise Architect

In the model we described in 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

These steps will guide you through the 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'.

InputData

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 resembles 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 'U' for 'Unique'. This is the policy that we will use for our example, so you do not need to change this column heading. 

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

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

If necessary, click on the 'Type' drop-down arrow and 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' as well. 

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 Spacebar.  The list of input parameters is displayed.  Click on '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 check that its data type is set to 'number'.

6

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

Select all of the text, then press the Spacebar.  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 this image.

Click on a cell to select it, and click again to edit it.

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'.  Overtype the name of the child component with 'Num of Flights in Last Month' and overtype its datatype  with 'number'.  Click the 'Save' button to save the changes, and close the window.

Similarly, double-click on the ItemDefinition named 'CabinStatusDefinition', add a child component named 'Num of Pax Overbooked' and set its data type to 'number'.  Save the changes and close the window.

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

Double-click on the decision element 'Determine Cabin for Upgrade'

In the DMN Expression window, locate the table row containing the text 'Num of Pax Overbooked' in the first column.  Click in the cell in the second column of this row, and press the Spacebar.  A list of possible input values is displayed.  Choose 'Cabin Status . Num of 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, for example, 3. 

Click on the Save icon and the OK button.

5

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

Add a DMNSimConfiguration Artifact

Locate the DMN 'Simulation 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 at the 'Simulate' tab.

From the DMN Simulation 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 the toolbar of this window.

2

Click on the drop-down arrow in this field.

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

3

Click on '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   in the lower toolbar to run a simulation, using the selected data sets.

Learn more