Bruce Silver's Blog - Practical DMN: The Basics
Bruce Silver
blog

Practical DMN: The Basics

By Bruce Silver

Read Time: 8 Minutes

Want to learn DMN decision modeling without training? DMN Method and Style, 2nd edition is a good place to start. But toreally learn it, you need to go beyond books. You need to get your hands dirty in a tool. I suggest starting with a free trial of Trisotech DMN Modeler.

When you log in, go to the EU-Rent repository (File/Open/EU-Rent) and open the model called EU-Rent Pricing. I’ll walk you through it here. Then click File/New and try to re-create the model yourself. That might sound like busywork but, trust me, you’ll learn a lot just doing that.

This model selects the best price for a car rental request based on the type of car, length of rental, applicable promotions, and customer loyalty discount.

DRD

The Decision Requirements Diagram is shown here. In any DMN model, you start by creating the DRD.

DRD

Datatypes

You should get in the habit of specifying the datatype of each DRD element. It’s not absolutely necessary but always best practice, so just do it. The type language for DMN is called FEEL, which is also the language of its value expressions. FEEL base types include string (text), number, boolean, date, time, date and time, and a couple duration types. A variable assigned to a base type can have any value in the domain of that type. Sometimes that’s fine, but often you want to define constraints on the domain of allowed values. A type with defined constraints is called an item definition, meaning a user-defined type. These are not special things. You will use them all the time. An item definition can also be a data structure, a list of components, each with a name and type. And finally, an item definition may be specified as a collection of another type. To see the item definitions in this model, go to the DMN ribbon and select Data Type.

types

There are 7 item definitions in the model. Click on the pencil for tCustomer to view its definition.

tCustomer

You see it is a structure with 6 components. The last component, Past Rentals, is type tRentals, a collection of type tRental, where tRental is a structure with 3 components, the last of which, CarType, is Text with an enumeration constraint. Its value can only be “Economy”, “Compact”, or “Full Size”.

To set the type of a DRD element, right-click Attributes/Input Data Type (for input data) or Output Data Type (for decision or BKM). You can select a base type, an existing type, or create a new type. Here input data Customer is type tCustomer and Rental Request is type tRental.

Decision Logic

Let’s look at the overall decision logic. The top-level decision Best Price, a number, depends on 4 supporting decisions: Weekly Price and Daily Price, both numbers; Applicable Promotions, a 2-column table; and Discount Percent, a number representing a percent. Those dependencies are specified by the 4 information requirements into Best Price in the DRD.

If you click on the icon in the upper left corner of Best Price, you see its value expression. DMN supports a variety of value expression formats. This one, a text formula, is called a literal expression. It uses the FEEL expression language.

Best-Price

The syntax may look daunting at first, but it’s actually simpler than, say, Excel Formulas. FEEL was designed for business users, not programmers. It contains a number of built-in functions, including three used here:

A list variable followed by an expression in square brackets represents a filter of the list. Here Applicable Promotions is a 2- column table, a list of rows with two components, Description and Price.

Best-Price

So Applicable Promotions.Price is the Price column of the table, a list of numbers, and the filter [item>0] here just ensures that if there are no Applicable Promotions the expression is an empty list rather than null. Reading the literal expression from the inside out, we append to the list of prices from Applicable Promotions the discounted Weekly Price and the discounted Daily Price. Then we take the minimum value of the resulting list and round it to two decimal digits following the decimal point. This style of nesting one function inside another is economical but maybe hard for beginners to understand. Alternatively, you could have separate decisions in your DRD for each part of it – the list append, finding the minimum, and rounding – or you could use another value expression type called a context to do each of those steps in a separate table entry.

The decision Weekly Price illustrates a context. We want to multiply the weekly price for the car type by the number of weeks in the rental. We could have written it as a long literal expression as in Best Price, but here we broke out the calculation of Weeks count as a separate context entry. Each context entry has a name, type, and value expression. The last row of the context is the final expression.

Weeks count subtracts the rental start date/time from the end date/time, giving a days and time duration. We divide that duration by the duration 168 hours (7 days x 24 hours), to get the number of weeks, and round that up to the next higher integer using the ceiling built-in function.

Weekly-price

The final result multiplies Weeks count by the result of the BKM Weekly Type Price with the parameter value Rental Request.CarType, meaning the type of car rented. Weekly Type Price’s value expression is a decision table. It has one input, Car Type, type tCarType, which must match the type of the argument in the call, Rental Request.CarType.

Weekly-type-price

Putting it all together, Weekly Price passes the car type to the BKM, gets back the weekly price for that car type, and multiplies that by the number of weeks in the rental.

Finally, let’s look at Applicable Promotions. EU-Rent has a list of Date Based Promotions, here modeled as a BKM decision table. When a BKM is a decision table, the table inputs specify its parameters, so there are 6 of them. The table has 2 output columns, meaning a structure with 2 components, and the table has hit policy C (Collect), meaning return a list of outputs for each matching rule. So what is returned is a list of 2-column structures, the table type tPromotions. Also note that not all outputs are specified as literal values. In the last item in Date Based Promotions, the Price component of the output is an expression calling the BKM Daily Type Price.

Date-Based-Promotions Applicable Promotions calls this BKM by supplying values to the 6 parameters. It is modeled as a context. The first 4 context entries use FEEL calendar type components to extract the month and day value from the rental start and end date-times. The fifth calculates the number of days in the rental. Those context entries are used in the call to the BKM in the final result expression.

/Applicable-Promotions

Validation

Once you’ve completed a decision model you need to validate it. On the DMN ribbon select Validate. That should return no errors. A second form of validation on that ribbon is Method & Style Decision Table Analysis, which looks for gaps, overlaps, and other errors in decision tables. In this model, that validation returns 3 errors on the Discount decision table in Discount Percent.

discount

From the table you can see the reason. Qualifying Rentals Count is really an integer, but FEEL has no integer type, only number. So the reported rule gaps are for intervals like greater than 0 but smaller than 1, impossible for integers. In a case like this you have two choices: (1) Understand the validation error and just accept it; or (2) Fix the table, even though that looks odd. The fixed table is shown below:

discount-fixed

Execution

Now it’s time to execute the model. I don’t think I can emphasize this enough: If you cannot execute your model (and make sense of the results), you can’t have confidence that the logic is correct. Many DMN tools cannot execute the logic. Fortunately, Trisotech can.

In the Execution ribbon, select Test. On the left, you enter values for the input data, then click Run. The tool reports outputs of all decision nodes in the DRD. After a run, Save preserves the input and output values in a Test Case. When entering values in the Test panel, the Load button lets you populate the form with values from a saved Test Case. The screenshots below show the input data for Test Case 2, followed by the execution output.

test testoutput

An Exercise to Get Started

That’s pretty much it. We’ve talked about the DRD, datatypes, FEEL expressions, BKMs, contexts, validation, Decision Table Analysis, and execution. It’s a lot of information in a short space. Remember, I said at the top you need to get your hands dirty in the tool to really get it. So do this: If you haven’t done so already, go to https://dev.trisotech.com/methodandstyletrial to get a free trial account, then log in and open EU-Rent Pricing. In the Import-Export ribbon, click HTML Documentation and print out the web page. That captures all the information in this model. Then click File/New and re-create the model from the documentation. Make sure it validates, then run it.

Help Is Available

If that seems overwhelming, I suggest the training. DMN Method and Style Basics covers DRDs and datatypes, decision tables, BKMs, simple FEEL, and decision services. DMN Method and Style Advanced dives deeper into FEEL functions and operators, contexts, calendar arithmetic, and manipulating lists and tables. They go at a slower pace, with exercises using the tool at each step of the way and post-class certification based on an online exam and mail-in exercise that you iterate until it is perfect. That is the best way to become proficient in DMN.

Blog Articles

Bruce Silver

View all

BPMN: Database Operations with OData

Blog

By Bruce Silver

(Read Time: 12 Minutes)

BPMN 101: What Is a Process?

Blog

By Bruce Silver

(Read Time: 6 Minutes)

DMN: Dealing with Nothing

Blog

By Bruce Silver

(Read Time: 10 Minutes)

Calling Rest Services from DMN

Blog

By Bruce Silver

(Read Time: 7 Minutes)

BPMN Decoded: Data Flow

Blog

By Bruce Silver

(Read Time: 6 Minutes)

BPMN Basics: Providing Information to a Process

Blog

By Bruce Silver

(Read Time: 10 Minutes)

CMMN Method and Style – Part 2

Blog

By Bruce Silver

(Read Time: 8 Minutes)

CMMN Method and Style – Part 1

Blog

By Bruce Silver

(Read Time: 10 Minutes)

Modeling Virus Transmission on an Airplane

Blog

By Bruce Silver

(Read Time: 8 Minutes)

Using Decision Services

Blog

By Bruce Silver

(Read Time: 10 Minutes)

Use Contexts to Simplify Your Decision Models

Blog

By Bruce Silver

(Read Time: 9 Minutes)

Helping the Mortgage Industry Go Digital

Blog

By Bruce Silver

(Read Time: 12 Minutes)

BPMN Style Rules

Blog

By Bruce Silver

(Read Time: 6 Minutes)

DMN, Meet Machine Learning

Blog

By Bruce Silver

(Read Time: 12 Minutes)

Matrix Operations in DMN

Blog

By Bruce Silver

(Read Time: 15 Minutes)

Practical DMN: The Basics

Blog

By Bruce Silver

(Read Time: 8 Minutes)

previous arrowprevious arrow
next arrownext arrow
Slider
All Blog Articles

Read our experts’ blog

View all

Slider

Implementation of CDS using DMN

implementation of clinical decision Support CDS using Decision model and notation DMN

Download White Paper

Content

Articles

View all

Slider

From Business Rules to Decision Management using DMN


From Business Rules to Decision Management using DMN

Download White Paper

Content

Articles

View all

Slider

DMN Decisions Execution Scenarios

DMN Decisions Execution Scenarios

The Trisotech DMN Modeler contains all the features required to analyze, develop and test decision models.

A very common path when working with DMN decisions is to deploy these decisions as decision services in an execution environment to invoke them from external business logic.

Trisotech offers two different scenarios to move from modeling to execution of decision services:

This document further explains how to achieve these scenarios as well as their capabilities and constraints.

Download Technical Paper

Content

Articles

View all

Slider
Trisotech-mwd-advisors-review-2017

Download PDF Download the complete research report


FOR IMMEDIATE RELEASE:

MWD Advisors publishes favorable in-depth review of Trisotech’s Digital Enterprise Suite

Montreal, Quebec, Canada, September 15, 2017 — Trisotech (http://dev.trisotech.com) a global leader in digital enterprise transformation software solutions, announced today that MDW Advisors, an independent technology and advisory services firm, has analyzed the Digital Enterprise Suite features and produced an in-depth review of the tool.

The MWD Advisors’ review concludes that Trisotech offers a “comprehensive set of tools and canvases that provide support to a broad range of users, enabling them to capture reusable models of how the business operates.”

The review puts an emphasis on the Suite’s Decision Management component: Trisotech’s Decision Modeling and Notation (DMN) Modeler. Derek Miers, Principal Analyst at MWD Advisors and author of the review, points out that “we struggle to think of scenarios where organisations with significant operational decision-making requirements would not want to look seriously at the product.”

“MWD Advisors is a well-respected analyst firm and we are very pleased that they have great things to say about our Decision Management product,” says George Barlow, Chief Sales Officer at Trisotech. “Mr. Miers also makes the point that the Decision Management product, while available as a stand-alone offering, has even greater customer value when paired with other components of our Digital Enterprise Suite such as our Business Process Modeling, Case Management Modeling and Strategic Planning tools. The Decision Management marketplace is very active right now. Organizations of all types want to take advantage of the OMG international standard – Decision Modeling Notation (DMN) – to replace existing disparate rules systems, coalesce on a standard, and remove embedded decision logic from program code thus making it accessible directly by business users.”

About Trisotech

Trisotech is a global leader in digital enterprise transformation solutions, offering innovative and easy-to-use software tools that allow customers to visualize, innovate, transform and improve their digital enterprise processes and business decisions. Trisotech customers use The Digital Enterprise Suite to provide new and revolutionary ways for their knowledge workers to collaborate and succeed in an increasingly global, connected and competitive world. Trisotech products are providing digital transformation help to communications, agriculture, manufacturing, financial, healthcare, insurance, energy, distribution, government, and many other types of organizations.

Trisotech is a privately held company.

Website: http://dev.trisotech.com

###

For information

Jonathan L’Ecuyer
Marketing Manager
Trisotech
jlecuyer@Trisotech.com

514 990-6639 ext. 501

All registered trademarks are the property of their respective owners.

See awards earned by Trisotech for its Digital Enterprise Suite

Press releases

In the news

View all

Slider

BPMN – CMMN – DMN Poster

BPMN CMMN DMN Poster

Download infographic

Content

Infographics

View all

Slider

DMN Poster

DMN Poster

Download infographic

Content

Infographics

View all