Decision Table
Decision table is a logical expression for constructing conditional results. Table contains all (and only) the inputs required to determine the output. Moreover, a complete table contains all possible combinations of input values (all the rules).
A decision table consists of;
- An output label, which can be any text to describe output of the decision table. The result of a decision table must be referenced by decision name, not the output label, in another expression.
- A set of inputs (zero or more). Each input is made of an input expression and a number of input entries.
- A set of outputs (one or more). A single output has no name, only a value. Two or more outputs called output variables. Each output variable is named and all output entries is referred as an output clause.
- A list of rules (one or more) in rows of table.
The decision table shows the rules in a shorthand notation by arranging the entries in table cells. This shorthand notation shows all the inputs in the same order in every rule and therefore has a number of readability and verification advantages.
For example;
Customer Category | Order size | Discount |
---|---|---|
"Business" | <10 | 0.10 |
read as;
If CustomerCategory = "Business" and OrderSize < 10 then Discount = 0.10
An input expression value satisfies an input entry if the value is equal to the input entry, or belongs to the list of values indicated by the input entry (e.g., a list or a range). If the input entry is ‘-’ (meaning irrelevant), every value of the input expression satisfies the input entry and that particular input is irrelevant in the specified rule.
In general table expressed as;
Input expression 1 | Input expression 2 | Output expression |
---|---|---|
input entry a | input entry b | output entry c |
If input entry is "-" (meaning irrelevant), every value of input expression satisfies the input entry.
If rules overlap, multiple rules can match and a hit policy indicates how to handle the multiple matches.
Input expressions
Input expressions are usually simple FEEL expressions. Order of input expressions is not related to any execution order.
Every input expression has following properties;
Expression
Specifies the input value expression. (Example: Name, BirthDate or Person.Name)
Label
Optionally specifies the display label of input, if not specified expression is used to display input.
Input Values
Optionally specifies the valid range of input. Given inputs are validated by this expression before decision table is executed. For example a "Status" input may use the "VALID", "INVALID" as input values. All of the other values are rejected by decision table.
Also range comparison expressions can be used like "<10" to accept values smaller than 10.
Type
Optionally specifies the type of input expression. When type is specified, some of decision table editor features are enabled by input type.
Output expressions
A rule output entry is also a FEEL expression. Output expressions also have default value if no output entry is specified.
Name
Specifies the name of output value.
Label
Optionally specifies the display label of output. If not specified, expression is used to display output.
Default
Optionally specifies the default value of output if decision table rule does not specify a value.
Type
Optionally specifies the type of input expression. When type is specified, some of decision table editor features are enabled by input type.
Hit Policy
The hit policy specifies what the result of decision table is in cases of overlapping rules, ie. when more than one rule matches the input data. For clarity, the hit policy is summarized with using first character of policy name.
Single and multiple hit tables
A single hit table may or may not contain overlapping rules but returns the output of only one rule. In case of overlapping rules, the hit policy indicates which of the matching rules to select.
A multi hit table may return the output of multiple rules or a function of outputs. For example, sum of values.
Single hit policies
- Unique: no overlap possible and rules are disjoint. Only a single rule can be matched. This is the default value of hit policy. If given input matches the multiple rules, hit policy is incorrect and MultipleHitViolation error is thrown.
- Any: there may be overlap, but all of the matching rules must have equal output entry values for each output so any match can be used. If output entries are non-equal, the hit policy is incorrect and result is undefined.
- Priority: multiple rules can match, with different output entries. This policy returns the matching rule with the highest output priority. Priorities are independent from rule sequence.
- First: Multiple (overlapping) rules can match, with different output entries. The first hit by rule order is returned and evaluation halts. First hit tables are not considered as a good practice because they do not offer a clear overview of the decision logic.
Multi hit policies
- Output Order: returns all of the hits in decreasing output priority order.
- Rule Order: returns all of the hits in rule order. Therefore may depend on the sequence of rules.
- Collect: returns all of the hits in arbitrary order. An operator can be added to apply simple function to outputs. If no operator specified, result is a list of all output entries.
Collect operators are;
- sum (+): sum of all the distinct outputs.
- min (<): smallest value of the all outputs.
- max (>): largest value of the all outputs.
- count (#): number of the distinct outputs.
For the Priority and Output order hit policies, priority is decided in compound output tables over all the outputs for which output values have been provided. The priority for each output is specified in the ordered list of output values in decreasing order of priority, and the overall priority is established by considering the ordered outputs from left to right in horizontal tables (i.e., columns to the left take precedence over columns to the right), or from top to bottom in vertical tables. Outputs for which no output values are provided are not taken into account in the ordering, although their output entries are included in the ordered compound output.
For example; if called with Age=17, Risk Category="HIGH" and Dept Review=true, the following table outputs of all four rules, in the order 2,4,3,1.
O | Age | Risk Category (Low, Medium, High) | Dept Review | Routing (DECLINE,REFER,ACCEPT) | Review Level (LEVEL2,LEVEL1,NONE) |
---|---|---|---|---|---|
1 | - | - | - | "ACCEPT" | "NONE" |
2 | <18 | - | - | "DECLINE" | "NONE" |
3 | - | "HIGH" | - | "REFER" | "LEVEL 1" |
4 | - | - | true | "REFER" | "LEVEL 2" |
Copyright © 2010 - 2023 Emakin. All rights reserved.