home *** CD-ROM | disk | FTP | other *** search
- /* INVESTOR.RSS This rule set was created to show the basic */
- /* difference between forward and backward */
- /* chaining. It is intentionally small and */
- /* thus, incomplete. */
-
- GOAL: advice
-
- INITIAL:
- e.tryp = "e" /* Test premises eagerly */
- e.rigr = "m" /* Accept minimal certainty */
- e.lstr = 80 /* Maximum string length is 80 */
- e.deci = 0 /* No digits after the decimal */
- advice = unknown
- goodsave = unknown
- goodincome = unknown
- income = unknown
- savings = unknown
- steady = unknown
- needincome = unknown
- dependents = unknown
- newcash = unknown
- clear
- at 2,28 output "QUICK INVESTMENT ADVISOR"
- output ""; output""
- input newcash num with "What amount of money would you like to invest? "
-
- DO: /* This section is executed after the rules have been processed */
-
- output ""; output ""
- output "Based on the given information:"
- output ""
- sp = " " /* spaces to pad output */
- test advice
- case "stocks":
- output sp,"You should invest the full amount in stocks"
- break
- case "savings":
- output sp,"You should put the full amount into savings"
- break
- case "split":
- output sp,"You should split the money between stocks and savings"
- break
- endtest
- e.deci = 2
- output ""; output "" /* This is the last command in the consultation */
-
- RULE: R1
- IF: not goodsave
- THEN: advice = "savings"
- REASON: If the client does not have enough in
- savings, the advice is to put all the
- money in savings.
-
- RULE: R2
- IF: goodsave and not goodincome
- THEN: advice = "split"
- REASON: If the client has sufficient savings, but
- not a good income, then the advice is to
- split the money between stocks and savings.
-
- RULE: R3
- IF: goodsave and goodincome
- THEN: advice = "stocks"
- REASON: If the client has a good income and enough
- in savings, then the advice is to invest in
- stocks.
-
- RULE: R4
- IF: not steady
- THEN: goodincome = false
- REASON: If the income for the next year is not
- steady, then it is not good income.
-
- RULE: R5
- IF: income <= needincome
- THEN: goodincome = false
- REASON: If the income is less than that needed by
- a family of this size, then it is not a
- good income.
-
- RULE: R6
- IF: steady and (income > needincome)
- THEN: goodincome = true
- REASON: To have good income, the client's employment
- must be steady.
-
- RULE: R7
- IF: known("dependents")
- THEN: needincome = 15000 + (dependents * 4000)
- REASON: If we know the number of dependents, then the
- needed income is $15,000 plus $4000 times the
- number of dependents.
-
- RULE: R8
- IF: savings > (5000 * dependents)
- THEN: goodsave = true
- REASON: If savings is greater than $5000 per dependent,
- then it is sufficient savings.
-
- RULE: R9
- IF: savings <= (5000 * dependents)
- THEN: goodsave = false
- REASON: If savings is less than $5000 per dependent,
- then it is not sufficient savings.
-
-
- /* Variables are defined below with their label and prompt clause */
-
- VAR: NEWCASH
- LABEL: Amount of cash to invest
-
- VAR: ADVICE
- LABEL: The advice given
-
- VAR: GOODINCOME
- LABEL: Income is good
-
- VAR: GOODSAVE
- LABEL: Savings are good
-
- VAR: NEEDINCOME
- LABEL: Income needed
-
- VAR: INCOME /* Note: the backslash continues a */
- /* command on the following line. */
- FIND: output ""
- input income num with \
- "What is your annual household income? "
- LABEL: Current income
-
- VAR: SAVINGS
- FIND: output ""
- input savings num with \
- "How much do you have in savings? "
- LABEL: Current savings
-
- VAR: STEADY
- FIND: output ""
- input steady str using "u" with \
- "Can you expect a steady income over the next year? (y/n) "
- steady = (steady = "Y")
- /* This changes steady from Y/N to true/false */
- LABEL: Income is steady
-
- VAR: DEPENDENTS
- LABEL: Number of dependents
- FIND: output ""
- input dependents num using "dd" with \
- "How many dependents do you have? "
-
- END:
-