samples/basic/tutorial/loan.kb
In some rule_sets you might find that you are repeating the same conditions over and over again. For example, if you are calculating how much money to loan for the purchase of a house, you might have the following rule_set named max_loan_amount:
conditions value income >= 50000 and debt < 10000 and rating = "poor" 75000 income >= 50000 and debt < 10000 and rating = "good" 150000 income > 35000 and debt < 5000 and rating = "poor" 50000 income > 35000 and debt < 5000 and rating = "good" 100000
A more readable way to represent this would be a table.
We'll create a rules_table as part of a knowledgebase that determines the maximum loan amount based on various factors.
income debt rating max_loan_amount > 50000 < 10000 "poor" 75000 > 50000 < 10000 "good" 150000 > 35000 < 5000 "poor" 50000 > 35000 < 5000 "good" 100000
Notice how this multi-column approach is easier to read than long conditions with lots of 'ands' in them.
The asterisks mean "match any value". So if none of the rows above match, the last one will, returning a max_loan_amount of 0. You can test this by entering an income of 20000 with debt of 10000 and a rating of 'poor'.
income debt rating max_loan_amount * * * 0
|
|
Copyright ©1995-2006 Amzi!
inc. All Rights Reserved. Privacy Policy.
Amzi!, KnowledgeWright and WebLS are registered
trademarks and Adventure in Prolog, Logic Server, Logic Explorer, Adventure
in Prolog and Subscription Plus are trademarks of Amzi! inc.