Вы находитесь на странице: 1из 4

Forward Channing

You have only Rp 100.000,-. Determine what food you should buy and what wine you
should serve, for a special diner. Assumption: the store sells both fish and meat.

Rules:
Rule 1: IF you purchase meat
THEN you should serve red wine
Rule 2: IF you purchase fish
THEN you should serve white wine
Rule 3: IF the store has fish
AND you have enough money to buy fish
THEN you purchase fish
Rule 4: IF he store has meat
AND you have enough money to buy meat
THEN you purchase meat
Rule 5: IF you have greater than Rp. 75000,-
THEN you have enough money to buy fish
Rule 6: IF you have between Rp 50.000,- and Rp 75.000,-
THEN you have enough money to buy meat
Rule 7: IF you have less than Rp 50.000,-
THEN please dont get a daydream, man!!

Trace of forward chaining will explained in the class.

First Iteration:
Rule 1 == FALSE (because we dont know what to buy)
Rule 2 == FALSE (because we dont know what to buy)
Rule 3 == FALSE (because we dont know if our money is enough or not)
Rule 4 == FALSE (because we dont know if our money is enough or not)
Rule 5 == TRUE (already true than it becomes a decision, doesnt need to maintain)
Rule 6 == FALSE
Rule 7 == FALSE
Second Iteration:
Rule 1 == FALSE (because we dont know what to buy)
Rule 2 == FALSE (because we dont know what to buy)
Rule 3 == TRUE (already know to buy fish)
Rule 4 == FALSE (because we dont know if our money is enough or not)
Rule 5 == TRUE (already true than it becomes a decision, doesnt need to maintain)
Rule 6 == FALSE
Rule 7 == FALSE

Third Iteration:
Rule 1 == FALSE (because we dont know what to buy)
Rule 2 == TRUE (already buy a fish)
Rule 3 == FALSE
Rule 4 == FALSE
Rule 5 == TRUE
Rule 6 == FALSE
Rule 7 == FALSE

Exercise 2 Investment Advisor


You have some money you want to invest and need some advice. Assume that you
have a steady job, you yearly income is Rp 175.000.000,- and your savings is Rp
100.000.000,-. You expenses each year total Rp 50.000.000,-

Rules:
Rules 1: Advise Investment in Stacks
IF the clients income is good
AND the clients saving is good
THEN advice is invest money is stack
Rules 2: Advise Savings Account Investment
IF the clients savings is not good
THEN advice is invest money in a savings account
Rules 3: Advice Splitting Money Between Savings Account
IF the clients saving is good
AND the clients income is not good
THEN advice is invest money in both a savings account and stacks
Rules 4: Determine if client is a Good Saver
IF clients total savings > 0.5 * INCOME
THEN the clients savings is good
Rules 5: Determine if client is a Bad Saver
IF clients total savings <= 0.5 * INCOME
THEN the clients savings is not good
Rules 6: Clients Income is Not Good based on Not Having a Steady Job
IF the clients job is not steady
THEN the clients income is not good
Rules 7: Clients Income is Not Good based on Small Income
IF INCOME < EXPENSES
THEN the clients income is not good
Rules 8: Clients Income is good
IF the clients job is steady
AND INCOME > EXPENSES
THEN the clients income is good

First Iteration:
Rule 1: FALSE (because we dont know)
Rule 2: FALSE (because we dont know)
Rule 3: FALSE (because we dont know)
Rule 4: TRUE (savings > income)
Rule 5: FALSE (because it doesnt fit to the other statement)
Rule 6: FALSE (because it doesnt fit to the other statement)
Rule 7: FALSE (because it doesnt fit to the other statement)
Rule 8: TRUE (income > expenses)

Working Memory:
Clients income is good
Clients savings is good

Second Iteration:
Rule 1: TRUE (savings and income is good)
Rule 2: FALSE (because we dont know)
Rule 3: FALSE (because we dont know)
Rule 4: TRUE (savings > income)
Rule 5: FALSE (because it doesnt fit to the other statement)
Rule 6: FALSE (because it doesnt fit to the other statement)
Rule 7: FALSE (because it doesnt fit to the other statement)
Rule 8: TRUE (income > expenses)

Вам также может понравиться