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

Sandy Kemsley’s Vlog - Business automation best practices #1 - Introduction
Sandy Kemsley Photo

Business automation best practices

#2 – strategic vision

By Sandy Kemsley

Video Time: 5 Minutes

Hi, I’m Sandy Kemsley of I’m here for the Trisotech blog, with the second in a series on best practices in business automation application development.

In the first episode, I talked about the automation imperatives. All of our cool new technology lets us automate faster and better and automate things that were never possible before. However, everyone else has access to the same technology so they’re automating their businesses too. In other words, it’s essential that you leverage automation in your business, or you just won’t be able to survive. A lot of companies are failing at business Automation and in this series, I’m offering some best practices to make you more successful at this, and indicators for recognizing and avoiding failures.

Today, I’m going to start diving in by talking about two of the best practices in strategic vision for automation application development.

Two of the best practices in strategic vision

#1 – Strategic Direction

Now, the first best practice is to make business automation a strategic direction. It’s not enough to just have the business automation initiatives approved by executive management or to be some executive’s pet project. This needs to be stated from the top level as part of how the organization moves forward. I was recently at a conference presentation where the CIO of a U.S state government showed their current strategic initiatives and process automation was listed right there.

Now, they stated the reason for this is that process automation creates capacity and reduces workloads by having automation do those standard and repetitive tasks and allow people to focus on the higher value work that really requires that human touch. Business automation is a recognized enabler of strategic direction: it supports and promotes Innovation efficiency and globalization among other initiatives. And if your organization isn’t recognizing this in its stated strategic corporate goals, then your automation projects are at risk.

Sometimes automation projects are hard, and they can take a long time and they can cause a lot of disruption. Without some sort of air cover from the executive level, it’s pretty easy to find these projects off in a ditch somewhere lying on their backs and kicking their poor little legs in the air well the Executive Suite chases the next shiny Bobble that they see down the road.

#2 – The Right Process

Now, the second best practice that I want to talk about, in terms of strategic vision, is to pick the right process particularly for your early projects. Nobody really cares if you have the best expense report process in the world. They do care if your core processes are efficient, innovative and a competitive differentiator.

That doesn’t mean that you shouldn’t be automating the expense reports, it means that you should first focus on core processes, since that’s where you get the most bang for your buck.

Now, over my many years of actually implementing business automation, I’ve heard a lot of people — sometimes vendors, sometimes consultants, sometimes internal project people — express the desire to try a pilot project on a less risky process. But you’re not going to understand how business automation can be transformational for your organization until you implement it on your core processes.

You’re not testing out the technology because that’s already proven as solid, these are not brand-new technologies. What you’re doing is trying out that new to you technologies with your own business operations. That’s where you need to demonstrate success.

Pick a core operational process, something that’s critical to your business. You don’t need to do a Big-Bang-Everything-at-Once implementation but do enough automation on that process to show measurable value, as well as the potential improvements to come as the automation expands beyond that initial project rollout.

And this leads me to one of the Prime indicators that your automation initiative is in trouble: Nobody cares about the process that you’re automating. If that’s the case, then you need to check and see where you might be going off the rails. That process needs to have some strategic importance. You need to be able to show the broader reaching impacts than just some departmental efficiency Improvement. Now, even if you’re automating a process that seems pretty much departmental, such as I don’t know accounts payable, you can still show how improving this operation has the ability to integrate with other parts of the company operations. So, the results could be the streamlined corporate cash flow, decreased late payment costs, improve vendor relationships, for a start.

So, those are the kinds of things that you want to look at in terms of how to choose that initial project, how to choose that initial process that you might be automating, and make sure that it’s something that people really care about. Now, coming in the next videos I’ll be covering best practices in design — this will probably be a couple of videos, since there’s a lot to cover here — and some best practices in methodology.

That’s it for today. You can find more of my writing and videos on the Trisotech blog or on my own blog at See you next time.

Blog Articles

Sandy Kemsley

View all

All Blog Articles

Read our experts’ll blog

View all