Trisotech's blog post - Two DMN Solutions to the Same Problem
Trisotech Icon

Two DMN Solutions to the Same Problem

By Trisotech

Read Time: 5 Minutes

Often, multiple methods can be used to solve the same business problem. In this blog we will briefly explore two different ways to create a DMN solution to the same decision problem and discuss the pros and cons of each solution.

The Problem

As part of a regulatory process, a government agency wants to determine if an applicant is eligible for a resident permit.

The rule is simple enough. An applicant is eligible for a resident permit if the applicant has lived at an address while married and in that time period, they have shared the same address at least 7 of the last 10 years.

In terms of inputs to make that decision, we are provided with three lists:


A list of periods living at an address for applicant (From, To, Address)


A list of periods living at an address for spouse (From, To, Address)


A list of applicant and spouse marriage periods (From, To)

Modeling the Decision as Stated (Model 1)

The agency suggests that we calculate the time in years, months and days, where the above time periods overlap, then evaluate if this condition has lasted more or equal than 7 of the last 10 years.

The Decision Requirements Diagram (DRD) below captures that method.

Model 1
Eligibility DRD as stated

In the DRD above, the three provided lists are used as Data Inputs to a Decision that produced a collection of Periods Overlaps which are then submitted to a Decision of whether these Periods Overlaps add up to Seven of the last ten years.

Model 1
Defining our Input and Output types

For our inputs, we first define a type tPeriod as follows:

The List of applicant and spouse marriage periods (From, To) is then defined simply defined as a Collection of tPeriod.

As for both the List of periods living at an address for applicant (From, To, Address) and the List of periods living at an address for spouse (From, To, Address), they are defined as a Collection of tLivingAdress that reuses our tPeriod type definition above.

Our Period Overlaps Decision will then lead to a Collection of tPeriod and finally our Seven of the last ten years Decision will provide us with a Boolean true or false.

Model 1
Period Overlaps logic

To obtain the Periods Overlaps Decision which calculates the overlap periods where the Applicant was married and living at the same address as Spouse, we will progressively build a Boxed Context. This is done here to help more novice readers. Advanced users may skip to the completed Boxed Context at the end of this section.

Our first step is to find Common Addresses between the applicant and the spouse to filter the periods to only those that are on common addresses. By doing so, we eliminate processing any farther periods they were not living together.

To achieve this, we take the Address portion from each the List of periods living at an address for applicant and filter that list by retaining only those addresses that are also contained in the Address portion from each the List of periods living at an address for spouse. This provides us with a collection of Common Addresses for both the applicant and spouse. As you can see below, the expression language FEEL from DMN makes this logic quite simple to follow and author. Note that the natural language annotations above the double blue lines make the logic even more obvious to a novice decision modeler or reader.

Using the collection of Common Addresses, we will now filter out the Applicant Periods and the Spouse Periods to only be those that were at a common address.

We can now identify the Cohabitation Periods. To achieve this, we will iterate over the Applicant Periods and the Spouse Periods at a common address identified just before and only extract the subperiods the that overlaps. There is no prebuilt FEEL function that extracts overlapping subperiods, we therefore need to create ourselves a Business Knowledge Model (BKM) that will look at two periods and return either an overlap subperiod or null. Here is the logic of that BKM.

We can invoke this BKM from within our logic as per below. Note the Overlap Interval function invocation in the Then portion below.

The invocation of this new BKM also affects our DRD. As it turns out, we will also need it to decide on the Seven of the last ten years decision later. Here is the DRD now augmented with the two invocations.

We can now complete our Boxed Expression for the Periods Overlaps decision. Armed with the Collection of Cohabitation Periods, we can now look for overlaps with the Marriage periods and return a single Collection of Periods Overlap by flattening the Cohabitation in Marriage Collection while taken care of removing the null entries that our BKM may have introduce when there was no overlap.

Here is below the complete Boxed Expression for the Periods Overlaps decision.

Model 1
Seven of the Last Ten Years Logic

Having obtained a Collection of Periods Overlaps for the applicant and Spouse we can now decide if these overlaps add up to Seven of the last ten years. This Decision simply returns TRUE if the applicant and spouse were living together and married for at least seven of the last ten years. We will not go into all the details this time as by now you can easily read the boxed context and annotations to guide yourself. We will only bring your attention to the invocation of our BKM Overlap Interval created before in the return portion of the Periods Overlaps in the last 10 years below.


Determine the period equating to the last 10 years using today’s date


Find the periods from previous Periods Overlaps decision that occurred during last 10 years


Covert those to the number of days for each period


Sum the days and return TRUE if number of days overlapped is greater than or equal to the number of days in 7 years.

In the end, our decision logic turned out somewhat complex when literally following the simple enough suggestions to calculate the time in years, months and days, where the time periods overlap, and then evaluate if this condition has lasted more or equal than 7 of the last 10 years. I wounder if there would be another way to tackle this problem?

Modeling the Decision in a Simplified Way (Model 2)

Upon further analysis of the problem, another simpler model (Model 2) that produces the same results can be created. This decision model requires only a single decision context and is much easier to understand than the original model even though it does not use the explicit steps described in the problem statement.

For Model 2, rather than using periods as the major organizing principle, this second decision model is driven by iterating through each day in the last ten-year period and verifying each day if all the overlapping requirements are met.

Model 2
Simplified Model DRD

Model 2
Seven of the Last Ten Years Logic

Note that we use the same three lists as inputs maintaining their type definitions untouched. Model 2 differ in how we express the logic for the Seven of the last ten years decision.

A brief description of this approach goes like this:


Determine the interval of days that represents the Last 10 years using today’s date


For each day during the Last 10 years, validate if they were Married, and if they were living at the Same Address, if yes then count this day


Compute the total Number of days Married and Living Together by summing all the days that met all criteria from the previous step


Validate if the Number of days Married and Living Together is greater or equal to 7 years

Model 2
Day in Period BKM (Function)

You probably noticed that we introduced a Business Knowledge Model (BKM) in Model 2 as well. This function is invoked by Married, Applicant Address, and Spouse Address in the above Context and returns a Boolean TRUE if the input day is in the input period.

Key Takeaways

Using this simple problem, we have presented two quite different ways to model the same decision. Each model has pros and cons to be considered.

In the original model (Model 1), we have created a solution that literally follows the description of the problem as provided. This typically shows the problem is clearly understood and leads to a solution that allows the business participants to follow the Decision Requirement Diagram (DRD) of the decision as they understand it. On the positive side, the approach taken in Model 1 is computationally efficient as we first discard all periods where the Applicant and Spouse were not living at the same address prior to doing any other checks. However, the resulting logic may seem quite complex for what seems like a simple problem. Some rather advanced list creation and comparison logic were needed, and the logic can look a little daunting.

In the second model (Model 2), while the DRD is not as literal to the problem statement as was the DRD of Model 1, we obtain a logic that is much simpler to understand and maintain. By checking for conditions at each day, it is now easy to see how changes in regulations introducing new overlapping condition requirements could be introduced into this logic. Which is not so obvious for the logic of Model 1. On the negative side, Model 2 will always loop over every single day whether there is overlap or not, making it less computationally efficient as Model 1.

There you have it, Model 1 leads to a DRD closer to the problem definition with a complex logic definition that is computationally efficient while Model 2 leads to a simpler logic that is easier to understand, maintain and modify while being less computationally efficient. The choice is yours.

There are often other real-word practical considerations to factor in. Perhaps the most important is resource usage when the model is automated and placed in production. Perhaps it is understandability and maintainability. Some models will perform much faster than others depending on the selection and structure of the context logic. Because DMN allows powerful operations with simple syntax, it is not always obvious how a specific model will perform when automated. This should be tested and optimized if high volumes of automated decisions are to be processed.

All Blog Articles

Read our experts’ blog

View all

BPM+ Virtual Coffee
5 min Intro to DMN

A short introduction to the Decision Model and Notation (DMN)

Presented by

Denis Gagne, CEO & CTO at Trisotech

Good day everybody and welcome to our BPM plus virtual coffee, I’m Denis Gagne, CEO & CTO of Trisotech, and today’s topic of the BPM+ virtual coffee session is a five-minute intro to DMN.


Let me jump right into the topic, DMN stands for the Decision Model and Notation, and DMN is a specification published by the Object Management Group (OMG). You can find the actual specification freely and openly available at this URL. DMN is a visual notation, and it basically offers you a simple visualization of business decisions with both the requirements for the decision, and the decision logic for the decision. In DMN the decision requirements are depicted in what we call the Decision Requirement Diagram (DRD) which is a visual way of organizing the dependencies between the decision, sub-decisions, and the various data that you’re using in your decision. We also depict the actual decision logic using what’s called box expressions and we have a whole set of different box expressions we can use in depicting and capturing the logic.

DMN is really meant to complement BPMN and CMMN. Basically, you can think of BPMN processes consuming DMN decisions or CMMN cases consuming DMN decisions which in turn the DMN decisions are consuming data. There is a complementary relationship between the three standards that I’ve been referring to for years now as the Triple Crown of process modeling.

DMN is as easy as one, two, three. The way of working with DMN is quite simple. The first thing you do is come up with the question the Decision will be answering and the possible answers to that question. That’s the core of your root decision. So, let’s say I want to find out who should be responsible for paying the cost of this particular car damage. The question would then be “who should be responsible” and the possible answers would be let’s say “the driver”, a “third party”, Etc. Once I have that, I have my scope of the decision. Then from there I can decompose this decision into its decision requirements — what information or what sub decision — do I need to make that decision, and finally, specify the decision logic of all these nodes. More concretely a DMN model will look something like what you have in the slide where I have a “Decision 1” that is dependent on a “Decision 2”, which is itself dependent on “Input 1” and “Input 2” , and “Decision 1” is not only dependent on “Decision 2” but also another “Input 3” . In the DRD the square shapes are the decisions, the oval shapes are the data inputs, or the input information, and the arrows are showing “requirements”. In this diagram, there is an “Information requirement” link and here we have a “Knowledge Requirement” link. We also have a “Business Knowledge Model” which is basically reusable decision logic that we’re bringing into the decision. Generally speaking, your logic will be expressed using “Box Expressions”. The “Decision Table” that is shown here is a particular case, or a particular style, of box expression that allows you to capture your decision logic.


What is FEEL?

FEEL stands for Friendly Enough Expression Language, and this is the expression language that is used within DMN or specified as part of the DMN standard. What is very interesting about FEEL is that it is a standardized expression language. We hear a lot a lot about low code and no code these days, but all these approaches are relying on proprietary expression languages, but we do have a standard for these, and it’s called FEEL. FEEL provides you with a standard syntax and execution semantic, and the claim is that it’s simple enough for non-technical people but expressive enough for technical people.

What are some of the characteristic of FEEL?

FEEL is a functional expression language, it is stateless, it is side effectless, and it is context sensitive. A lot of very fancy words to say some very simple things: functional means that we compute the value — the resulting value — from the inputs provided. Which means that the variables are immutable, once we have the data we’re done. Side effect less means that we have a closed world assumption. There is no other effect possible than providing you with a result. Context sensitive means that we can use terms that are using spaces in them. That is quite interesting and important because it allows us to create or write expression that are closer to natural language in how we express the logic.

Box Expressions

Now let me give you a little bit more details about what box expressions are. It is a basic visual recursive construct of a name and an expression. Here we have a literal box expression, so we have the name and its expression.

We can then build up a structure where I have a name and its expression and then a name, but its particular expression is built up by two names with each their own expression. So, it is a recursive pattern of for defining the logic. We have different types of box expressions that I invite you to get acquainted with.

To see the full expressiveness of the FEEL language let me show you a very simple example. Here is a natural language policy that says: “The loan monthly installment is obtained by adding the loan monthly fee and the loan monthly repayment. A standard loan carries a 20$ monthly fee, while a special loan carries a 25$ monthly fee, and the loan monthly repayment is calculated based on the loan rate, term, and amount, using the standard Financial monthly payment function.” This simple policy or guidelines or whatever you may want to call it, express the logic and we can then use this actual language to create this box expression for it. Here my loan monthly installment is provided by the loan monthly fee plus the loan monthly repayment, and the loan monthly fee is defined with a conditional that if it is a standard loan, it is twenty dollars, else if it is a special loan, it is 25 dollars, otherwise it is zero. The loan monthly repayment is basically an invocation of a financial payment function with the rate, terms, and amount provided. You can see how, and I’ve put it in comments here, the natural language statement from the policy aligns. We just directly read it and it makes it very simple for anybody to understand. This portion here at the top is because I’ve created as a reusable function. This is a now a function that is defined and that I can reuse. The loan monthly installment function has these four parameters and it’s giving me this result. You can see how with FEEL and boxed expressions it is very easy to capture the logic of your decision in a language that is close to natural language.

In a nutshell

DMN in a nutshell is all about decisions, which are expressed using rules. These rules apply data in context, which gives us knowledge. It is a functional type of language, and it is based on a first order logic.

So that is my five-minute introduction to DMN. Here are a couple of books you may be interested in and that we recommend: the DMN Method and Style and the DMN Cookbook. There are also different trainings that are available.

Thank you for your attention.

View the slides


Recorded webinars

View all videos
Attend a live webinar

Decision Camp 2022
Intelligent Assistance for Knowledge Workers

Presented by

Denis Gagné, CEO & CTO at Trisotech
Tom Debevoise, Director at Advanced Component Research, inc.

View the slides


Recorded webinars

View all videos
Attend a live webinar