Decision Table Hit Policies
This section examines the 7 currently supported hit policies: Any, Collect, First, Rule Order, Output Order, Priority Order and Unique.
Recall from earlier, that the hit policy specifies how the table will be evaluated when multiple rules are applicable and hence, multiple
output values are returned.
The Hit Policy value identifies the supported policies by a capital letter and an operator, when applicable. You may enter the 1st letter
of the policy or the whole word. The currently supported Hit types and their meanings are:
Unique (U): A unique rule must "hit" evaluating to a unique result. If multiple rules are "hit", an error will be returned.
Any (A): If rules overlap, but point to the same result, that unique result is returned.
Priority(P): If multiple rules are "hit" and multiple results collected, return only one result with the highest
priority; the priorities are defined by the order of the output values.
First (F): Only 1 result is returned for this policy. Once a rule is evaluated successfully, or a hit occurs,
the search stops.
Rule Order (R) - If multiple rules are hit, return the collection of results as created in the rule order
Output Order (O) – If multiple rules are hit, return the collection of results in the priority order of the
listed output values.
Collect (C) – The same as (R). However, we may make this policy more specific by adding an operator to it in
order to allow aggregation.
Note: If aggregating a date, a scalar is returned. If using an operator, output must not be a string, but
only a numerical value.
C+ - sum the matched output values
C< - return the min of matched output values
C> - return the max of matched output values
C# - return the number of matched output values
Open the example DT Hit Policy examples.json on the Editor tab of RASON.com.
This example RASON model creates and recalculates seven decision tables; one table for each of the 7 supported hit policies:
tblPolicyAny, tblPolicyCollect, tblPolicyUnique, tblPolicyFirst, tblPolicyRuleOrder, tblPolicyOutputOrder, and tblPolicyPriorityOrder.
{
modelName: "DTHitPolicyExample",
modelType: "calculation",
modelDescription: "Decision Table Hit Policy Example",
modelType: "calculation",
decisionTables: {
"tblPolicyAny": {
inputs: ["creditRating", "creditCardBalance", "studentLoanBalance"],
outputs: ["loanCompliance"],
refTypes: ["", "", "", ""],
hitPolicy: "A",
rules: [
["A", "<10000", "<50000", "compliant"],
["Not(A)", "-", "-", "not compl"],
["-", ">=10000", "-", "not compl"],
["-", "-", ">=50000", "not compl"]
]
},
"tblPolicyCollect": {
inputs: ["age", "service"],
outputs: ["holidays"],
refTypes: ["number", "number", "number"],
hitPolicy: "C+",
rules: [
["-", "-", 22],
[">=60", "-", 3],
["-", ">=30", 3],
["<18", "-", 5],
[">=60", "-", 5],
["-", ">=30", 5],
["[18..60]", "[15..30]", 2],
["[45..60]", "<30", 2]
]
},
"tblPolicyUnique": {
inputs: ["age", "medHistory"],
outputs: ["riskRating", "rule"],
refTypes: ["", "", "", ""],
hitPolicy: "U",
rules: [
[">60,<25", "good", "medium", "r1"],
[">60", "bad", "high", "r2"],
["[25..60]", "-", "medium", "r3"],
["<25", "good", "low", "r4"],
["<25", "bad", "medium", "r5"]
]
},
"tblPolicyFirst": {
inputs: ["order", "location", "customer"],
outputs: ["discount"],
refTypes: ["", "", "", ""],
hitPolicy: "F",
rules: [
["web", "US", "wholesaler", 10],
["phone", "-", "-", 2],
["-", "non_US", "-", 0],
["-", "-", "retailer", 5]
]
},
"tblPolicyRuleOrder": {
inputs: ["gpa", "act_count", "honor_member"],
outputs: ["eligibility", "rule"],
refTypes: ["number", "number", "boolean", "text", "text"],
hitPolicy: "R",
rules: [
[">3.5", ">=4", true, "20% scolar", "r1"],
[">3.0", "-", true, "30% loan", "r2"],
[">3.0", ">=2", false, "20% work", "r3"],
["<=3.0", "-", "-", "20% work", "r4"]
]
},
"tblPolicyOutputOrder": {
inputs: ["age", "service"],
outputs: ["holidays"],
outputValues: ["27", "5", "3", "2"],
hitPolicy: "O",
rules: [
["-", "-", "age - service"],
[">=60", "-", 3],
["-", ">=30", 3],
["<18", "-", 5],
[">=60", "-", 5],
["-", ">=30", 5],
["[18..60]", "[15..30]", 2],
["[45..60]", "<30", 2]
]
},
"tblPolicyPriorityOrder": {
inputs: ["age", "medHistory"],
outputs: ["riskRating"],
refTypes: [ "", "", "" ],
outputValues: ["low", "medium", "high"],
hitPolicy: "P",
rules: [
[">=25", "good", "medium"],
[">60", "bad", "high"],
["-", "bad", "medium"],
["<25", "good", "low"]
]
}
},
formulas: {
"Any": { formula: "tblPolicyAny(,,'B', 12000, 75000)", finalValue: [] },
"Collect": { formula: "tblPolicyCollect(,,58, 31)", finalValue: [] },
"Unique": { formula: "tblPolicyUnique(,,54, 'good')", finalValue: [] },
"First": { formula: "tblPolicyFirst(,,'web', 'non_US', 'retailer')", finalValue: [] },
"Rule_Order": { formula: "tblPolicyRuleOrder('eligibility',,3.6, 4, TRUE)", finalValue: [] },
"Output_Order": { formula: "tblPolicyOutputOrder(,,58, 31)", finalValue: [] },
"Priority_Order": { formula: "tblPolicyPriorityOrder(,,61, 'bad')", finalValue: [] }
}
}
To execute all seven decision tables given the input data passed to each decision table within the formulas section, click
POST rason.net/api/model to POST the model to the RASON Server then POST rason.net/api/model/{nameorid}/decision to calculate the table. For more information
on solving via the Editor page on www.RASON.com, see the previous topic, RASON Services Web IDE.
Getting model results: GET https://rason.net/api/model/2590+DTHitPolicyExample+2020-01-20-02-49-27-161414/result
{ "status": {
"code": 0,
"id": "2590+DTHitPolicyExample+2020-01-20-02-49-27-161414",
"codeText": "Solver has completed the calculation."
},
"observations": {
"Any": {
"value": "not compl"
},
"Collect: {
"value": 30
},
"Unique": {
"value": [ ["medium", "r3"] ]
},
"First": {
"value": 0
},
"Rule_Order": {
"value": ["20% scolar", "30% loan"]
},
"Output_Order: {
"value": [27, 5, 3]
},
"Priority_Order": {
"value": ["medium"]
}
}
}
Let's look at each table individually.
|