• No results found

Interaction of frames and rules

Frame-based expert systems

5.5 Interaction of frames and rules

Most frame-based expert systems allow us to use a set of rules to evaluate information contained in frames.

Are there any specific differences between rules used in rule-based expert systems and those used in frame-based systems?

Every rule has an IF-THEN structure, and every rule relates given information or facts in its IF part to some action in its THEN part. In this sense, there are no differences between rules used in a rule-based expert system and those used in a frame-based system. However, in frame-based systems, rules often use pattern matching clauses. These clauses contain variables that are used for finding matching conditions among all instance-frames.

How does an inference engine work in a frame-based system? What causes rules to fire?

Let us again compare rule-based and frame-based expert systems. In a rule-based expert system, the inference engine links the rules contained in the knowledge base with data given in the database. When the goal is set up – or in other words when an expert system receives the instruction to determine a value for the specified object – the inference engine searches the knowledge base to find a rule that has the goal in its consequent (THEN part). If such a rule is found and its antecedent (IF part) matches data in the database, the rule is fired and the specified object, the goal, obtains its value. If no rules are found that can derive a value for the goal, the system queries the user to supply that value.

In a frame-based system, the inference engine also searches for the goal, or in other terms for the specified attribute, until its value is obtained.

In a rule-based expert system, the goal is defined for the rule base. In a frame- based system, rules play an auxiliary role. Frames represent here a major source of knowledge, and both methods and demons are used to add actions to the frames. Thus, we might expect that the goal in a frame-based system can be established either in a method or in a demon. Let us return to our credit evaluation example.

Suppose we want to evaluate the credit request selected by the user. The expert system is expected to begin the evaluation when the user clicks the

Evaluate Creditpushbutton on the input display. This pushbutton is attached to the attributeEvaluate Creditof the classCredit Evaluationshown in Figure 5.10. The attributeEvaluate Credithas the WHEN CHANGED method attached to it, and when we select the Evaluate Creditpushbutton at run time, the attribute

Evaluate Creditreceives a new value, a value of TRUE. This change causes the WHEN CHANGED method to execute. The PURSUE command tellsLevel5 Object

to establish the value of the attributeEvaluationof the classCredit Evaluation. A simple set of rules shown in Figure 5.11 is used to determine the attribute’s value.

How does the inference engine work here?

Based on the goal, Evaluation OF Credit Evaluation, the inference engine finds those rules whose consequents contain the goal of interest and examines them one at a time in the order in which they appear in the rule base. That is, the inference engine starts withRULE 9and attempts to establish whether the attribute Evaluation receives the Give credit value. This is done by examining the validity of each antecedent of the rule. In other words, the inference engine attempts to determine first whether the attribute Collateral has the value of

Excellent, and next whether the attribute Financial rating isExcellent. To deter- mine whether Collateral OF Credit Evaluation is Excellent, the inference engine examines RULE 1 and RULE 2, and to determine whether Financial rating OF Credit EvaluationisExcellent, it looks atRULE 8. If all of the rule antecedents are valid, then the inference engine will conclude thatEvaluation OF Credit Evalua- tion is Give credit. However, if any of the antecedents are invalid, then the conclusion is invalid. In this case, the inference engine will examine the next rule,RULE 10, which can establish a value for the attributeEvaluation.

Figure 5.10 TheCredit Evaluationclass, WHEN CHANGED and WHEN NEEDED methods 147 INTERACTION OF FRAMES AND RULES

What happens ifCollateral OF Credit EvaluationisGood?

Based on the set of rules provided for credit evaluation, the inference engine cannot establish the value of the attribute Evaluation in some cases. This is especially true when the collateral is good and the financial rating of the business is excellent or good. In fact, if we have a look at Figure 5.10, we find Figure 5.11 Rules for credit evaluation

cases that are not represented in the rule base. However, it is not necessary always to rely on a set of rules. We can use the WHEN NEEDED method to establish the attribute value.

The WHEN NEEDED method shown in Figure 5.10 is attached to the attribute

Evaluation. The inference engine executes this method when it needs to determine the value of Evaluation. When the WHEN NEEDED method is executed, the attributeEvaluationreceives the valueConsult a superior.

How does the inference engine know where, and in what order, to obtain the value of an attribute?

In our case, if the WHEN NEEDED method were executed first, the attribute

Evaluationwould always receive the valueConsult a superior, and no rules would ever be fired. Thus, the inference engine has to obtain the value from the WHEN NEEDED method only if it has not been determined from the rule base. In other words, the search order for the attribute value has to be determined first. It can be done, for example, by means of the SEARCH ORDER facet attached to an attribute that tells the inference engine where, and in what order, to obtain the value of this attribute.

In Level5 Object, a search order can be specified for every attribute, and in our credit evaluation example, we set the search order for the Evaluation value to RULES, WHEN NEEDED. It makes certain that the inference engine starts the search from the rule base.