Random output rule support in Dmn

I have a problem to define random output rules using DMN engine. For example, if input == 1, output has 30% probability equals 3 and 70% probability equals 4. How can I implement this case using Dmn model?

define like:
a b
a > 3 40% : 4 60% : 5
a <= 3 20% : 4 80% : 5

Hi @xlhtc007,

I’m not sure if I understand your use case correctly. However, the example could be modeled with the following decision table:

probability.dmn (1.4 KB)

Does this help you?

Best regards,

Hi @Philipp_Ossler,
Thanks for ur quick reply! I find a way to model my case, but not convenient. I should define many random input variables. So I hope there is a native method supported by the output handle in decision table.
the model example:
probability.dmn (5.3 KB)
note:“random1” and “random2” are random number between 0 and 1.

the ideal way:
probability-ideal.dmn (3.4 KB)

Thank’s for sharing!

Your example (probalility.dmn) looks good and it’s aligned to the DMN. You could make it more convenient by generating the random number in the input expression itself.

Thanks Philipp! I understand what u mean. I seldom use complex expression. Would u show me a demo for this kind of expression?

You could use a JUEL expression. For example:

new java.util.Random().nextDouble()

I modify the dmn model and throw the exceptino : DMN-01002 Unable to evaluate expression for language ‘JUEL’: ‘${new java.util.Random().nextDouble()}’

probability.dmn (5.4 KB)

I’m sorry. This doesn’t work with JUEL. However, the easiest way may be to use Math.random() as JS expression (since JS is always on board).

probability.dmn (5.4 KB)

Thanks @Philipp_Ossler ! It works! I find that the DRG is not fully supported by Camunda Engine, and there is not api to evaluate the DRG directly. Does the Camunda have the plan to upgrade this function and the route map.

DRGs are not meant to be evaluated directly because they can be different “root” decisions. So, you always need to choose one decision to evaluate.

What do you mean by “DRG is not fully supported”?

From my point of view, DRG describes the decision dependency. I can get the decision collection through the Camunda DRG API, but I cannot get the dependency of the decisions. So I hope the DRG API can provide a data type to describe the dependency.

You can use the DMN model API to get the required decisions. Please have a look at: https://docs.camunda.org/manual/7.11/user-guide/model-api/dmn-model-api/read-a-model/

OK! I have not noticed this. thanks buddy!