Hi there,
I'm needing to implement what to me looks like a decision tree (though searching on that term returns posts on finding out influencing factors in a decision process - which isn't what I'm after).
The system I'm building will be working out warranty periods to give a product installation based upon some criteria. The requirement is for the creation of a set of possible vectors (e.g. Installation Pitch, Profile, location, material type etc...) and for those vectors to be assembled by the user into a tree structure:
-- Profile == corrugate (warranty = 20 years)
-- Pitch >= 0 && < 5 (warranty = 2 years)
-- Pitch >= 5 && < 20 (warranty = 10 years)
-- Environment == coastal && distance <= 500 meters (warranty 2 years)
This is a simple case, but the theory is that I can then walk this tree when it comes time to figure out a warranty period, and then choose the lowest value that the tree produces given the supplied information.
Right now I can sensibly see this being stored as a tree in the database (it's a Rails app) and just writing some method to walk the tree and decide, but I wanted to know if there is a better way to approach this problem?
I'm going to have to repeat myself later in the project when I also implement another decision tree that will decide whether a warranty application needs further moderation by our warranty team. In that case the outcome from each node will just be true or false.
Seeing as it's a pretty crucial part of the app I'd like to get the structure right first time :) And perhaps learn something new along the way :)