Rules

Diagnosing a Problem

knowledgewright4/samples/basic/tutorial/diagnose_1.kb

Next we'll build a simple technical support application with a few simple rules. The goal of the system will be to determine what the problem is.

KnowledgeWright groups rules that deduce values for the same fact in rule_sets.

Set the Goal to 'problem'

  1. Edit the knowledgebase object, main, to have a goal of problem, just as in earlier parts of this tutorial.

Create Rules for Determining the Problem

Each rule object in KnowledgeWright Basic contains a number of individual rules, each of which might be used to determine the value of a fact. So in this case, we'll create a rule_set object, named problem, which will have rules that can be used to determine a value for problem.

    1. Use Object/New to create a new rule_set object, with a name of problem.
    2. In the type field, select single_value.
    3. In the rule editor, select Row/Add. You'll see a blank row beneath the headings for conditions and value.
    4. Enter these conditions for the first rule: symptom = "video screen blank" and led_light = "on".
    5. Enter this value for the first rule: "Screen saver on".
    6. Select Row/Add for another row for another rule.
    7. Enter condition: symptom = "video screen blank" and led_light = "off".
    8. And value: "Monitor turned off".
    9. Repeat for the following conditions and values:
    10. condition: symptom = "mouse sticky" and mouse_pad = "yes" and rollers_clean = "no".
    11. value: "Dirty rollers".
    12. condition: symptom = "mouse sticky" and mouse_pad = "no".
    13. value: "No mouse pad".
    14. condition: symptom = "mouse sticky" and mouse_pad = "yes" and rollers_clean = "yes".
    15. value: "Broken mouse".
    16. The screen should look something like:

Checking the Knowledgebase

The status window at the bottom of the screen provides two tools for analyzing the connections between knowledge objects.

In this example we have so far created a knowledgebase main object that has as a goal problem, and a rule_set problem that has conditions that refer to other, as yet undefined facts.

Click on the exclamation mark tab to see any problems in the structure of the knowledgebase, and you will see a screen like the following:

and the other status tab looks like this:

Adding the Questions

We will get values for the four undefined facts by asking the user. So we need to define question objects for each of them.

Using the Object/New menu, create four questions objects with these attributes:

id
symptom
path
/
prompt
What symptom are you experiencing?
question_type
menu_single_choice
question_style
listbox
choices
    
video screen blank
mouse sticky
default
  
ask_also
   
id
led_light         
path
/
prompt
What is the state of the video LED light?
question_type
menu_single_choice
question_style
listbox
choices
    
on
off
default
  
ask_also
   
id
mouse_pad
path
/
prompt
Are you using a mouse pad?
question_type
menu_single_choice
question_style
listbox
choices
    
yes
no
default
  
ask_also
   
id
rollers_clean         
path
/
prompt
Have you recently cleaned the rollers?
question_type
menu_single_choice
question_style
listbox
choices
    
yes
no
default
  
ask_also
   

Exercises

    1. Run (using Run/Run menu item) using a variety of responses.
    2. Notice that the system only asks the detailed questions that are necessary.
    3. Look at the trace in lower left panel for each, to understand how the system worked for each set of answers.
    4. Use Run/Log Detail to change the amount of trace output. Use the high setting to see exactly how the system works. Use medium or low to get a better overview. (We recommend medium for most use.)



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.