Today there was a post at the LinkedIn group “Looking for a simple example of representing calculations in a Decision Model” with this problem description:
“Trying to determine the risk of meeting a Werewolf based upon two factors: Phase of the Moon, and Distance from Graveyard. But I can’t seem to put these together into a complete Decision Model:
Fact Type: Phase of the Moon
Values: New Moon, Half Moon, Three-Quarter Moon, Full Moon
Rule Family: Phase of the Moon Risk
Conditions Conclusions
New Moon .01
Half Moon .25
Three-Quarter Moon .50
Full Moon .75Fact Type: Miles from Graveyard
Values: < 5 miles, between {5 miles, 25 miles}, > 25 miles
Rule Family: Miles from Graveyard Risk
Conditions Conclusions
<5 miles .75
between {5 miles, 25 miles} .25
> 25 miles .01Fact Type: Werewolf Risk
Values: Phase of the Moon, Miles from Graveyard
Rule Family: Werewolf Risk Weights
Conditions Conclusion
Phase of the Moon .75
Miles from Graveyeard .5Calculate Werewolf Risk:
(Phase of the Moon weight * Phase of the Moon Risk) + (Miles from Graveyard Risk * Miles from Graveyard Risk) = Werewolf Risk”
Instead of figuring out if this is a joke or not, I could not resist a temptation to quickly implement the proper decision model. “Would I be able to do within 1 hour?” – was my question. I did. Here is the Excel-based decision “DetermineRiskOfMeetingWerewolf”
and supporting decision tables:
The calculation rules for the total risk to meet a werewolf may look as follows:
The Glossary for this problem:
I also needed to create a few test cases. Here they are (again in Excel table that define a new type “Werewolf” and two cases “John” and “Mary”:
When I ran this model I received the following output:
You may look at the complete decision model by opening this Excel file. The entire OpenRules project can be downloaded from http://openrules.com/downloads/my/DecisionWerewolf.zip. If you add this project to an OpenRules workspace, you may execute this model against your own test cases.
More serious examples of decision models that include calculation formulas can be found at:
Click to access Tutorial.DecisionPatientTherapy.pdf
Click to access Tutorial.Decision1040EZ.pdf
Jacob, you always come up with the most unexpected examples! I found it fun though, and decided to do it too. Our customers can play with it as a documented example, but if you just want to see what it looks like, check out the snapshot: