Skip to content
Introducing Aletyx Decision Control — Enterprise decision management with governance and multi-environment deployment ×

Advanced DMN™ Modeling Techniques

Introduction

After mastering the basics of DMN, you're ready to explore more advanced modeling techniques. This guide builds on your foundation to help you create sophisticated decision models that can handle complex business scenarios.

We'll cover advanced features like Business Knowledge Models (BKMs), complex data types, list operations, and context expressions. Throughout this guide, we'll use a travel insurance pricing example to illustrate these concepts.

Working with Complex Data Types

Real-world decisions often require more complex data than simple numbers or strings. DMN allows you to define custom data structures to model your business domain accurately. In this case we're going to build a DMN model for a travel insurance situation for someone building an itinerary to travel to potentially multiple countries and we want to determine how much it will cost to give that person a travel insurance policy. The factors that will be discussed in the next section focused on Creating Custom Data Types.

Creating Custom Data Types

In our travel insurance example we are going to be looking at building a both a traveler and the trip details as complex data objects:

  • A Traveler with:

    • Age
    • Claim history
    • Medical conditions
  • Trip Details with:

    • Countries to visit
    • Start date
    • End date

Here's how to create these data structures:

  1. Navigate to Aletyx Playground in your browser
  2. From the landing page, click New Decision to create a new DMN model
  3. You'll be presented with an empty DMN model editor. This is where we'll design our decision model
  4. First, change the name of the model from "Untitled" to "travelPremium"
  5. In Aletyx Playground, open the properties panel (press "i" with nothing selected)
  6. Click on "Data Types"
  7. Click "Add" to create a new data type

For the Traveler:

Property Type Is Collection
age number no
claim history Claim yes
medical conditions string yes
tDate date no

For the Claim structure:

Property Type Is Collection Allowed Values
total claim amount number no
status string no Approved, Denied, Pending
tDate date no

For the Trip Details:

Property Type Is Collection
country string yes
start date date no
end date date no

Using Complex Types in Decision Models

Once defined, you can use these types for Input Data nodes:

  1. Create an Input Data node named "Traveler"
  2. Set its data type to "Traveler"
  3. Create an Input Data node named "Trip Details"
  4. Set its data type to "Trip Details"

Now your decisions can reference properties of these complex types using dot notation:

  • Traveler.age
  • Traveler.medical conditions
  • Trip Details.country

Working with Lists and Collections

DMN provides powerful capabilities for working with collections of values. In our travel insurance example, we need to:

  1. Evaluate multiple medical conditions
  2. Assess risk across multiple countries
  3. Analyze claim history

Iterating Over Collections

To check if any medical condition is high-risk:

some condition in Traveler.medical conditions
  satisfies list contains(["heart disease", "cancer"], condition)

This FEEL expression:

  • Iterates through each item in the "medical conditions" list
  • Checks if the condition is in the high-risk list
  • Returns true if any condition matches

Filtering Collections

To count approved claims:

count(Traveler.claim history[status="Approved"])

This expression:

  • Filters the claim history to only include approved claims
  • Counts the resulting filtered list

Collection Functions

DMN includes built-in functions for collections:

  • count(list): Returns the number of items in a list
  • sum(list): Adds all numeric values in a list
  • min(list) / max(list): Returns the smallest/largest value
  • mean(list): Calculates the average of numeric values
  • list contains(list, element): Checks if an element is in a list

Business Knowledge Models (BKMs)

Business Knowledge Models (BKMs) are reusable decision logic components that can be invoked from multiple places in your model. They're perfect for encapsulating complex logic or reference data.

Creating a BKM for Country Risk Assessment

In our travel insurance example, we'll create a BKM to evaluate country risk levels:

  1. Add a Business Knowledge Model node to your diagram
  2. Name it "Country Risk Level"
  3. Edit the node and set its logic type to "Function"
  4. Define a parameter named "country" of type "string"
  5. Return type should be "string"

Create a decision table within the function:

country Country Risk Level Annotation
"Iraq" "High" War zone
"Syria" "High" Civil unrest
"Brazil" "Medium" Crime rates
"Mexico" "Medium" Border areas
- "Low" Default

Invoking a BKM

To use the BKM in a decision:

Country Risk Level("Brazil")

This will return "Medium" based on our decision table.

Context Expressions

Contexts in DMN allow you to create local variables and build complex expressions step by step. They're excellent for breaking down complex logic.

Using Context for Destination Risk Factor

For our travel insurance example, we'll calculate a risk factor based on destinations:

  1. Create a decision named "Destination Risk Factor"
  2. Set the expression type to "Context"
  3. Create context entries:
ContextEntry Type Expression Content
"Highest Risk" (String) FEEL See: Risk Context Entry
"Risk Factor" (number) Decision Table See: Decision Table Context Highest Risk

FEEL Expression: Highest Risk Context Entry

    if
                 some country in Trip Details.country
                 satisfies Country Risk Level(country) = "High"
                then "High"
                else if
                 some country in Trip Details.country
                 satisfies Country Risk Level(country) = "Medium"
                then "Medium"
                else "Low"

Decision Table: Highest Risk Context Entry

The best part about the DMN editor for Decision Tables is you can copy the contents of the three rows and directly paste them into your decision table!

Highest Risk (String) Risk Factor (Number) Annotations
"High" 1.6 // High Risk Factor
"Medium" 1.4 // Medium Risk Factor
"Low" 1 // Low Risk Factor

The result of the context is the last entry (Risk Factor).

Advanced Hit Policies

DMN provides various hit policies for decision tables to handle different evaluation requirements.

Collect Hit Policy with Custom Aggregation

For our medical condition assessment:

  1. Create a decision table with hit policy "Collect"
  2. Select "MAX" aggregation to get the highest risk factor
Traveler.medical conditions (string) Medical Condition Assessment Annotation
some condition in ? satisfies list contains(["heart disease", "cancer"], condition) 2.0 High risk
some condition in ? satisfies list contains(["diabetes", "asthma"], condition) 1.5 Medium risk
some condition in ? satisfies list contains(["high blood pressure"], condition) 1.2 Low risk
- 1.0 No risk

Rule Order Hit Policy

When you need to evaluate rules in a specific sequence:

  1. Set hit policy to "R" (Rule order)
  2. Rules are evaluated from top to bottom
  3. The first matching rule provides the result

This is useful when rules have priorities or dependencies.

Handling Dates and Time

DMN includes robust support for date and time operations, essential for time-sensitive decisions.

Date Comparisons

To calculate the trip duration:

days between(Trip Details.start date, Trip Details.end date)

Date Arithmetic

To check if a claim is recent:

Traveler.claim history[date(now()) - tDate < duration("P1Y")]

This filters claims made within the last year.

Combining Multiple Decision Models

Complex applications often require multiple decision models working together.

Importing Models

To reuse logic from another model:

  1. In the DRD, click the "Import" button
  2. Select the DMN file you want to import
  3. Reference imported decisions and BKMs in your model

Decision Services

Decision Services define a public interface for your DMN model:

  1. Add a Decision Service node to your diagram
  2. Drag the decisions you want to expose into the node
  3. Specify input data and decisions

This creates a well-defined API for your decision model.

Testing Advanced DMN Models

Thorough testing is crucial for complex decision models.

Test Scenarios

Create comprehensive test scenarios:

{
  "Traveler": {
    "age": 42,
    "claim history": [
      {
        "total claim amount": 1200,
        "status": "Approved",
        "tDate": "2023-05-15"
      }
    ],
    "medical conditions": ["asthma", "high blood pressure"]
  },
  "Trip Details": {
    "country": ["France", "Germany", "Brazil"],
    "start date": "2024-06-01",
    "end date": "2024-06-15"
  }
}

Debugging Techniques

When debugging complex models:

  1. Use the DMN Runner to execute with sample data
  2. Add intermediate decisions to expose internal calculations
  3. Review the execution trace to understand evaluation paths
  4. Test boundary cases for each decision component

Performance Considerations

As your models grow in complexity, consider these performance tips:

  1. Limit Collection Size: Large collections can impact performance
  2. Optimize Decision Order: Structure decisions to minimize redundant calculations
  3. Use BKMs Judiciously: They add overhead for simple logic
  4. Consider Caching: For frequently accessed reference data
  5. Test with Realistic Volumes: Validate performance with production-like data

Best Practices for Advanced DMN

  1. Maintain a Clear Hierarchy: Structure your decisions logically
  2. Document Your Models: Add annotations to explain complex logic
  3. Create Reusable Components: Use BKMs for shared logic
  4. Validate with Business Experts: Ensure the model aligns with business intent
  5. Iterate and Refine: Complex models benefit from continuous improvement

Conclusion

You now have a toolbox of advanced DMN techniques to tackle complex decision requirements. By leveraging these features, you can create sophisticated, maintainable decision models that accurately capture your business logic.

In our next guide, Advanced Deployment Options, we'll explore how to deploy these complex models in production environments.