Ranking/Prioritization of Tasks Through DMN

Dear all, we have a usecase where once or more often a day, we want to analyze each user task in task pools and dynamically assign a ranking (from 1 to the total no. of tasks) to each. I’ve been wondering, he algorithm for that could be made with DMN. What do you think about that?

Hi @IdemenB,

The ranking or prioritization would be based on what? Can you elaborate more…

Sorry for not giving enough details. Let’s say this is a pizza store. What I have in mind is something as follows:

  • Inputs to be given to the DMN model: Total Number of Orders In Queue (int) , Price Of Pizza Ordered (decimal) , is Returning Customer (bool), Time Since Order Given in mins (int)
  • Output: Ranking of which pizza to cook first from 1 to n (where n = total number of orders in queue)

So, I’ll have some rules using those inputs and for each pizza in the queue, I’ll run that decision to come up with a ranking.

@Philipp_Ossler , I see that the DMN hit policy “priority” could be good use case here, but currently not supported. Any quick idea coming to your mind worth trying?

This is an interesting question!

To sum it up, you have a list of orders. For each order, you want to assign a rank. And you want to sort the orders based on the rank.

"orders": [
			"priceOfPizza": 20.0,
			"isReturningCustomer": true,
			"orderTime": "2021-07-11T14:00:00Z"
			"priceOfPizza": 25.0,
			"isReturningCustomer": true,
			"orderTime": "2021-07-11T14:01:00Z"
			"priceOfPizza": 30.0,
			"isReturningCustomer": false,
			"orderTime": "2021-07-11T14:02:00Z"

These are multiple steps and not so easy to model with one DMN. The challenge here is also that a decision table can’t be applied to a list of orders.

Option 1)

Model a decision table to rank a order.

Evaluate the decision for each order by using a multi-instance business rule task.

Collect the output of the business rule task and sort the list based on the rank. For example, by using a script (expression).

Option 2)

Use a complex FEEL expression to rank and sort the orders.

Cons: the ranking function is not as easy to understand as a decision table.

  ranking: function (order) {
    time: 3 * (now() - date and time(order.orderTime)) / duration("PT1M"),
    isReturning: if order.isReturningCustomer then 10 else 0,
    price: 1 * order.priceOfPizza,
    rank: time + isReturning + price
  rankedOrders: sort(orders, function(x,y) ranking(x) > ranking(y))

Option 3)

Use a DMN engine that supports BKMs.

Model the ranking as decision table.

Call the decision table in a context decision and sort the results.

Read more about it in the blog post: DMN is more than a Decision Table - Camunda

A decision table with the hit policy priority would not help here. It is only to order the matched rules. But it can’t be applied to a list of orders.

Does this help you?

Thank you so much for the valuable insight @Philipp_Ossler , I’ll give them a try and share the results.