RULE measles IF temperature = very_high AND spots = yes AND inoculated <> yes THEN Diagnosis = measles; If VP-Expert is attempting to use this rule to find a value for Diagnosis, it will first check whether temperature is very_high (finding a value for temperature if necessary), then whether spots is yes, and so on. For efficiency, VP-Expert gives up on such a rule immediately if it cannot prove one of the premises. For example, if temperature is not very_high, it does not try to find spots or innoculated. OR is handled differently. For example, consider: RULE allergy IF spots = yes OR rash = yes THEN Diagnosis = allergy; Even if VP-Expert can prove spots = yes, it will still ask about rash (even though it doesn't need to). To decrease …show more content…
It is possible, however, to force it to find all values for variables instead. This is done with the PLURAL statement (which must be placed before the ACTIONS block): PLURAL: list of variables; While you don't have to make all of the variables in your knowledge base PLURAL, you must at least include all that would support the kind of multiple results you wish to obtain. In the "medical" knowledge base we have been working with so far, for example, if you wish to make treatment plural, then you must make diagnosis plural as well: PLURAL: treatment, diagnosis; You may also have to change the structure of your rules that deal with PLURAL variables. In particular, you cannot count on the "order of evaluation" when structuring your rules; nor can you use ELSE to set the value of a PLURAL variable, as it would always be used. For example, if the variable cost were PLURAL, we could not use the following rules: RULE cheap IF price < 20 THEN cost = cheap; RULE expensive IF price < 100 THEN cost = medium ELSE cost = …show more content…
Like the ELSE, it should be the last rule involving treatment for this to work correctly. 3.6.9 Plural Inputs It is also possible to set up your ASK statements to allow the user to choose more than one option from the menu by making that variable PLURAL. This is often faster for the user than having to answer multiple questions. For example: PLURAL: symptoms; ... ASK symptoms: "Choose all symptoms that you have." CHOICES symptoms: sore_throat, spots, rash, none; The user can then press ENTER by each one which holds, and press END to confirm the list. 3.6.10 Printing Variables with Multiple Values The DISPLAY statement works with PLURAL variables, printing all of its values in column format. For example, the code: DISPLAY "I prescribe the following:" DISPLAY "{treatment}" Might print: I prescribe the following: Penicillin Allergy pills Bed rest 3.6.11 Adding Explanations to Rules There are many situations where it is useful to justify the conclusions reached by an expert system. VP-Expert has (limited) capabilities for allowing you to add such explanations to rules, with the BECAUSE statement: RULE