Professional Documents
Culture Documents
MANUAL
Copyright EXSYS Inc. 1983-1996 All rights reserved. All product names are trademarks of their respective manufacturers.
Table of Contents
A A1: A2: A3: A4: A5: Introduction System Requirements 5 Runtime License 6 Installing EXSYS Professional 7 Technical Support 9 Compatibility Between GUI EXSYS and Non-GUI EXSYS 10 A6: Working in Multi-user Environments 11 A7: Features in EXSYS Professional 13 A8: EXSYS Professional Files 15 B B1: B2: B3: B4: B5: B6: B7: B8: C Developing Expert System Knowledge Bases What Can an Expert System Do? 1 How to Select an Appropriate Problem 2 Building an Expert System 5 Backward Chaining 14 Using Confidence Modes 19 Using the Command Language 22 Using the Report Generator 23 Creating Your First Expert System 24 EXSYS Rule Editor
C1: Starting the Rule Editor 2 C2: Opening an Existing Knowledge Base 3 C3: Starting a New Knowledge Base 4 Subject 4 Author 4 Confidence Mode 5 Calculation Mode 9 Threshold Level For Display of Results 10 Derivation Mode 11 Rule Display Mode 13 Starting Text 14 Ending Text 14 Starting External Program 15 Initial Choice Value 15 Finished Setting Parameters 16 Entering Choices 16
Table of Contents
C4: Main System Title Screen 17 C5: Saving the Changes to a Knowledge Base 18 C6: Exiting the Editor 20 C7: System Help 21 C8: Copying Text from Other Applications 24 C9: Adding a New Rule to the Knowledge Base 25 C10: Editing a Rule in the Knowledge Base 26 C11: Building a Rule 28 Positioning of New Conditions 28 Adding a Qualifier Condition 29 Adding / Editing a Qualifier 31 Editing an Existing Qualifier Value 32 Deleting an Existing Qualifier Value 33 Options for Each Qualifier 33 Qualifier Name 33 Display of Qualifier Values with Results 34 Maximum Number of Values 34 Default Value 34 Automatic Data Acquisition 36 Custom Formula Systems 36 Finished Setting Qualifier Parameters and Values 36 C12: Selecting Qualifier Values to Build a Condition 37 Adding a New Value 39 Correcting Typographical Errors 39 Qualifier Conditions Combined with OR 39 C13: To Change the AND / OR Blocks 42 C14: Using Qualifiers 43 C15: Mathematical Expressions and Variables 45 Variables 45 Math Expressions in the IF Part 45 Math Expressions in the THEN/ELSE Part 46 Building Math Conditions in a Rule 46 THEN / ELSE Part 47 Variable Parameters 48 Entering the Expression to Assign 53 Expressions 54 Arithmetic Operators 54 Boolean Operators 54 ANSI Standard Order of Priority 56 Conditional Tests 57
Table of Contents
C16:
C23: C24: C25: C26: C27: C28: C29: C30: C31: C32:
Approximately Equal Operator 57 Syntax Checking 57 Conditional Operator 58 Functions 59 Special Functions 61 AGE Function 64 Adding a Choice Condition 65 Choices in the THEN/ELSE Part 65 Choices in the IF Part 66 Adding a New Choice 67 Deleting a Choice 68 Editing a Choice 68 Adding a Command Condition 69 To Copy or Move a Condition 70 To Delete a Condition 72 To Change a Condition 72 To Scroll to the Previous or Next Rule 72 To Add / Edit the Note, Reference and Name 72 Note 72 Reference 73 Name 73 To Repeat a Condition from the Previous Rule 75 Consistency Checking of New Rules 76 Deleting a Rule 79 Moving a Block of Rules 80 Printing a Knowledge Base 82 Displaying the Qualifiers, Variables or Choices 84 Running the Rules 85 Canceling a Run 86 Changing the Knowledge Base Parameters 87 Automatic Validation / Tree Diagrams 88 Introduction 88 Running in Validation Mode 90 Setting the Test Parameters 91 Validation Results 95 Custom Reports 97 Validation Testing to Compare Versions of a Knowledge Base 98 External Program Problems 99 100
Table of Contents
Notebook 101 Asking for Help 102 Editing the Knowledge Base Text Files 103 The Questions Menu 104 Trace the History of the Run 105 Hypertext 107 Custom Formula Confidence 108 Using Custom Formulas Confidence System 108 Confidence Variables 109 Assigning a Confidence Formula 111 User-Supplied Confidence Ratings 112 C41: Custom Help Screens 114 C42: Loop Error Messages 115 D D1: D2: D3: D4: D5: D6: D7: D8: EXSYS Runtime
Starting the RUNTIME 1 Opening an Existing Knowledge Base 2 System Help 3 Notebook 6 Display of Rules During Runtime 7 Title Screen 8 Starting Text 9 User Interaction 10 Asking for a Qualifier Value 10 Asking for a Variable Value 12 D9: External Program Input 13 D10: Custom Screens 13 D11: Asking Why a Question is Being Asked 14 D12: Asking for More Information on a Question 16 D13: UNDO a Previous Answer 17 D14: Save Input 18 D15: Recover Input 19 D16: Displaying the Known Data 20 D17: Displaying the Status of the Choices 21 D18: Displaying a Rule 23 D19: Ending Text 26 D20: Displaying Results 27 Confidence Modes 27 D21: Change and Rerun 30
Table of Contents
D22: Custom Results Screens 31 D23: Existing the Runtime 32 E Configure Options E1: Editor/Runtime Configure Files 1 E2: Knowledge Base Configure Files 2 E3: Creating Configure Files 3 Change Connector Words 4 Asks for Specified Data at the Start of a Run 5 Calling an External Program After Change and Rerun Commands 6 Change the Name of the Configure File Used 7 Allow Data from External Programs to be Modified During Change and Rerun 8 Change the Name of the Command File Executed 9 Control of Runtime Menu Options 10 Automatically Reads a Series of Records of Data and Executes the Rules 11 Change the Standard Ending Message if No Choices are Set 13 External Program Flag File Control 14 Add Extra Space When Printing Rules 14 Stops Execution When Any Choice Has a Final Value Set Greater Than 0 15 Forward Chaining Options 16 Sets an Alternate Knowledge Base Help File 22 Limits Options Available to User of Runtime 23 Turns Off Loop Error Checking 24 Displays Choices Without Sorting by Value 24 Switch Off Color Display 25 Prevents Deletion of RETURN.DAT After Reading 25 Prevents Display of Results at Any Time 26 Disables Option to Use Passwords 26 Eliminates Starting Questions 27 Do Not Display Title and Author 27 Prevents Display of Values Assigned to Choices 28 Prevents Backward Chaining on Simple Expressions 29 Allows Choices with No Value Set to Test False 30 Changes the Name of the File Used to Pass Data to External Programs 31
Table of Contents
Load Password from Command Line or .CFG File 32 Reads Custom Help File When Rules are Read 33 Recovers Data Saved Previously with QUIT 34 Turns Off DISPLAY Command During "Change and Rerun" 35 Releases Memory Used for String Variables 36 Changes the Name of the Report Specification To Be Used 37 Turns Off Report Generator During "Change and Rerun" 38 Changes the Default to Rerun Rules at End 39 Changes the Name of File Used to Return Data from External Programs 40 Changes How Rounding is Handled in Calculations 41 Writes a File of Information on Rule Execution, Data and Other Functions 42 Sets the Number of Times UNDO Can be Called 43 Sets WORKING Screen Color 44 Sets Printer Width 45 F Report Generator F1: Commands 1 Make a Beep Noise 2 Print Data on Choices 3 Examples 5 Close a File for Display 7 Display a File in a Window 8 Exit to the Operating System 10 Select the Output File 11 Print Text Only for First Set of Data in DATALIST 13 Unconditional and Conditional Branches 14 Print the Data Input by the User 16 Print the Notes and References 17 Data on Qualifiers 18 Examples 21 Restart the System 22 Call an External Program 23 Save the Input Data for a RECOVER 24 Print Text String 25
Table of Contents
Print Data on Variables 26 Options 28 Examples 30 G Internal Commands and Data Acquisition
G1: Internal Commands in a Rule 1 G2: Commands Used for Data Acquisition 2 G3: Internal Command Window 4 Direct Command Input 4 Blackboard Interface 5 dBase III Interface 6 Clear Out Known Data or Rules 13 Read a File of Data 17 Display a File in a Window 19 Frame Interface 23 LINDO Linear Programming Interface Lotus 123 Interface Commands 24 Run a Report Specification File 29 Run an External Program 31 Stop Program Execution 32 Table Interface 33 H H1: H2: H3: H4: H5: H6: External Program Calls
23
Syntax 2 RUN Command Window 7 Microsoft Windows Program Calls 8 Macintosh Program Calls 10 UNIX and VMS Program Calls 11 Returning Data to EXSYS 11 RAM Disks 14 Erasing RETURN.DAT 14 Passing Back a Command from an External Program 15 Returning Hypertext Words from External Programs 15 H7: Calling Programs from THEN/ELSE 16 H8: Calling Programs from the Report Generator, Command File or Custom Screen File 18 H9: Calling an External Program at the Start of a Run H10: Calling External Programs from Variables 20 H11: Calling External Programs from Qualifiers 22
Table of Contents
19
H12: Problems Calling External Programs 24 H13: Calling External Programs - Summary 26 H14: DATALIST: Analyzing a Multiple Record Data Report 28 H15: DATAREAD: Reading a File of Data 30 I Customizing the User Interface
I1: GUI Custom Screen Definition Language 2 I2: Screen Files 3 I3: Screen File Structure 4 Indicating the Qualifier or Variable 4 Hypertext Keywords 5 Custom Screens for Confidence Variables 5 I4: Returned Data 5 Returning Commands 6 Passing Back a Hypertext Call 7 I5: Syntax for a RCT 7 I6: Setting the Window Size 8 I7: Embedded Variables 8 I8: GUI Custom Screen Commands 9 I9: Custom Screen Examples 24 I10: EXSYS_CS Custom Screen Preview 35 I11: Custom Screens to Ask Questions 36 I12: Context Sensitive Help Files 38 I13: Hypertext 39 Defining Screens 40 Flagging Keywords 40 Using Keywords 41 The .HYT File 41 Example: 42 I14: Inserting Value Text in the Middle of Qualifiers I15: ASCII Codes 44 I16: Embedding Data in Text 45 Variables 45 Formulas 46 Qualifiers 46 Embedding Qualifier Values 47 Embedding Expressions 48 Recursive Brackets 48 [[ ]] Replacement in the Report Generator and Command File 49
Table of Contents
43
Command Language
J1: Changing the Name of the Command File 2 J2: Expressions and Variables 2 Request User Input for a Specific Item 3 Make a Beep Noise to Alert User 4 Branch Point Label 5 Cause a "Change and Rerun" Option 6 Allow Command Files to be Commented 7 Erase Data or Reset Rules to Unused 8 Call Another Command File 10 Cause the Next Record of Data to be Read from a DATALIST File 11 dBase III Interface Commands 12 Display the Contents of a File 15 Exit a Command File Called by Another Command File 17 Exit to the Operating System 18 Unconditional Branch 19 Allow Conditional Execution of Blocks of Rules 22 Pause Until a Key is Pressed 24 Recover Data saved with a QUIT or SAVEDATA Command 25 Run a Report Generator Specification 26 Display the Results of the Run 27 Run the Rules or a Subset of the Rules 28 Run an External Program 31 Save the Current System Data 32 Assign a Value to a Variable, Qualifier or Choice 33 Execute a Block of rules While a Condition is True 35 K K1: K2: K3: K4: K5: Rule Compiler Getting Started 2 Starting the Rule Compiler 4 Editing the Text Files 5 Producing Files That Can Be Compiled 5 Commands 7 Allow Comments to be Added to a File 9 Define the Subject of the Expert System 10 Define the Author of the Expert System 11
Table of Contents
Define the Starting Text of the System 12 Define the Ending Text of the System 13 Define an External Program to Call at the Start of a Run 14 Set the Threshold for Choice Display 15 Define the Confidence System to be Used 16 Set the Initial Choice Confidence Value 18 Set Option to Display Rules as a System Runs 19 Set Option for How Many Rules to Use in Deriving Information 20 Define List of Qualifiers and Parameters 21 New Qualifiers or Values Found in the Rules 26 Define List of Variables and Parameters 27 Text Only Variables Found in the Rules 31 Define List of Choices 32 Use Only Defined Qualifiers, Variables and Choices 33 Define a Rule 34 Qualifier Conditions in Rules 36 Choice Conditions in Rules 38 Formula Conditions in Rules 40 Text Conditions in Rules 42 NOTE and REFERENCE Text 44 Special Cases 45 Set Space Allocated for Compile 47 K6: Error Messages 48 L Frame and Table Interface
L1: TABLE and NTABLE 1 Data Table Syntax 1 L2: Frame 3 What is a Frame 3 Specifying a Slot 4 Specifying the Frame Row 6 How to Create a Frame 7 Inheritance 8 L3: Reading from a Frame 11 L4: Writing to a Frame 12 L5: Examples 13 L6: Including FRAME and TABLE in Your Expert System 14
Table of Contents
Blackboard Manager
M1: Introduction 1 Recommended Uses for EXSYSBB 1 EXSYSBB Blackboards 1 Communication Between EXSYSBB and Your Applications 2 M2: Calling EXSYSBB 2 3 M3: Including EXSYSBB in Your Expert System Associated with a Qualifier or Variable 3 Run as the Result of a Rule Firing 4 From the Command Language 4 From the Report Generator 4 From the Screen Definition Language 4 Called from the Operating System 4 Called from Other Programs 4 M4: Blackboard Command Window 5 M5: Reading From a Blackboard 6 M6: Writing to a Blackboard 7 M7: Deleting Data From a Blackboard 8 M8: Attributes and Values 9 M9: Parameters 11 M10: External Call Values (demons): 17 M11: Operating Modes 18 M12: Error Messages 19 M13: Common Errors 20 N LINDO Interface N1: Introduction 1 N2: Calling the LINDO Specification File 2 LINDO Specification File 3 N3: Model Commands 5 N4: ~IF test expression, ~ELSE, ~ENDIF 6 N5: ~Results 7 N6: Return Data Commands 7 LINDO Data ID 7 N7: Sample EXSYS / LINDO Interface 12
Table of Contents
Utility Programs Compressing Edited Files 1 Rule Organizer 2 Moving Files Between Operating Systems Pager 4 EX_TIME 7 Repeat 10 EXSQ - Report File Squeezer 11
P SQL Commands Introduction 1 P1: Installation 1 DLL Notes 2 INTERSOLV 2 SQL Interface Technical Support 3 Backward Compatibility 3 P2: SQL Commands 4 Reading a Single Item of Data into a Single EXSYS Variable 4 SQL Commands that Return Multiple Items of Data 5 P3: Connecting to the Database 6 Connection Strings 7 P4: Executing an SQL Command 8 Selecting the Next Record of Returned Data 8 Selecting the Previous Record of Returned Data 9 Selecting a Random Record of Returned Data 10 Finding the Number of Records of Returned Data 10 Creating Random Access Buffers for Returned Data 11 Releasing the Data Returned from an SQL Command 11 Disconnecting from a Database 12 Reading a Specific Field of Returned Data 12 Reading the Name of a Column of Returned Data 13 Reading the Number of Columns of Returned Data 13 P5: Transactions 14 Beginning a Transaction 14 Committing a Transaction 14 Canceling a Transaction 15 P6: Using SQL Commands 15 Some Basic SQL Commands 16
Table of Contents
Q1: Introduction 1 Q2: Master System Help 1 Q3: File Menu 1 New 2 Open 3 Save 4 SaveAs 5 Print 5 Exit 5 About 5 Adding a New Screen 5 Q4: Object Menu 6 Return Strings 7 Rectangles 9 Push Button 9 Radio Button 11 Check Box 12 Slide Bar 13 Edit Box 15 Line 18 Arrow 19 Oval 20 Rectangle 20 Rounded Rectangle 21 Text 21 Mouse Box 22 PCX 24 Meters 25 List Boxes, Buttons and Edits Q5: Aligning Objects 31 Q6: Selecting Multiple Objects 32 R Fuzzy Logic
27
R1: Introduction 1 How Fuzzy Logic Is Implemented in EXSYS Professional 3 Defuzzification 6 Advantage of Fuzzy Sets 7 IF / THEN Only 8
Table of Contents
R2: Building Fuzzy Systems - The Mechanics 8 Starting a System 8 Fuzzifying a Qualifier 9 Choices in a Fuzzy System 15 R3: Defuzzifying a Variable 18 Validation and Defuzzified Variables 20 R4: Building Fuzzy Systems - Techniques and Demos 21 When 21 How 22 Demos 25 R5: Graphing Validation Data 26 Setting Constraints 27 Display Variables 29 Examining Values on the Graph 29 Constraints on the Validation Graph 30 R6: Combination of Confidence 30 IF PART 30 Qualifier Conditions 31 Variable Conditions 33 Choice Conditions 34 Overall IF Confidence 34 If Conditions Summary 36 Rule Confidence Threshold 36 THEN PART 37 Choices (THEN Part) 37 Qualifiers (THEN Part) 39 Variables (THEN Part) 39 Changing the Way Confidence is Combined 40 S Screen Templates
Introduction 1 S1: Using Templates 2 S2: To Add Templates to Your System 2 S3: Previewing Your Screens 3 S4: Template Designs 3 Template Styles: 4 - 14 S5: Modifying / Creating Your Own Templates S6: Editing an Existing Template 19 S7: Handling Individual Screens 19
Table of Contents
15
Chapter A
Introduction
At EXSYS Inc., we believe that expert systems will be widely implemented only if the systems are easy to build. Having the experts build the systems themselves can produce large numbers of systems rapidly. The widespread use of smaller expert systems is often far more effective than one large expert system. This approach requires that the tools to build the system be easy to use. It is not reasonable to ask experts to spend 6 months learning how to use an expert system tool, but it is reasonable to ask them to spend a few days. To be implemented effectively, an expert system shell must not be significantly more difficult to use than a word processor. It is reasonable to ask experts to build their own expert systems, only if the shell is easy to use. We believe that this is the future of expert systems. The goal at EXSYS is to provide easy-to-use tools so that people can build their own expert systems. Both developers and users of expert systems have become more sophisticated. End users now request more from an expert system than a few years ago. A few years ago, simple systems were considered major accomplishments. Now users expect more power and flexibility in an expert system and developers of such systems require the tools to build them. In order to meet this goal, EXSYS Professional was created. EXSYS Professional offers a new level of sophistication to knowledge engineers developing expert systems, while retaining the easy-to-use EXSYS interface that has proven so successful. EXSYS Professional provides many commands to modify the default operation of the shell. If these new capabilities are not used, EXSYS Professional automatically uses safe defaults. EXSYS Professional is a generalized expert system development package. An Expert system is a type of artificial intelligence program that emulates the interaction a user might have with a human expert to solve a problem. The user answers by selecting one or more answers from a list or by entering data. The computer will continue to ask questions until it has reached a conclusion. The conclusion may be the selection of a single solution or a list of possible solutions arranged in order of likelihood. The computer can explain, in English, how it arrived at its conclusion and why.
A - INTRODUCTION
Expert systems can be developed with EXSYS for any problem that involves a selection from among a definable group of choices where the decision is based on logical rules. The rules can involve relative probabilities of a choice being correct. Any area where a person or group has special expertise needed by others is a possible area for EXSYS. Expert systems can help automate anything from automating complex regulations to aiding customers in selecting from among a group of products, from automated user assistance to identification of diseases or problems with a piece of equipment is possible. Expert systems deal with knowledge rather than data and the files they use are often referred to as knowledge bases. The rules that the program uses are IF-THEN-ELSE type rules. A rule is made up of a list of IF conditions (normal English sentences or algebraic expressions) and lists of THEN and ELSE conditions (more sentences) or statements about the probability of a particular choice being the appropriate solution to the problem. If the computer determines that all IF conditions in a rule are true it adds the rule's THEN conditions to what it knows to be true. If any of the IF conditions are false, the ELSE conditions are added to what is known. The computer determines what additional information it needs and how best to get the information. If possible, the program will derive information from other rules rather than asking the user. This ability to derive information allows the program to combine many small pieces of knowledge to arrive at logical conclusions about complex problems. The rule editor allows the rules to be easily modified, added or deleted. The final goal of an expert system is to select the most appropriate solution to a problem based on the data input by the user. If more than one solution is possible the program will provide a list of the possible solutions arranged in order of probability. Essentially all of the instruction necessary to run an expert system knowledge base is provided by the program and all output is in English. Little or no training is required to run an already developed knowledge base. The principal development tool in EXSYS Professional is the EXSYS Professional Rule Editor. It enables you to rapidly generate your own expert system knowledge bases. All options available to you are displayed on the screen. The "Learning to Use EXSYS Professional" videotape takes you step-by-step through a series of lessons on the generation of your own expert system knowledge bases. When running the rule editor, help screens are available for more detailed information on command options. All input is in the form of normal English text or algebraic expression. Since most of the input to the program comes from items selected from a list, virtually all of the typo problems that can confuse some expert system development programs are effectively eliminated. New rules entered are checked
A - INTRODUCTION
2
against the existing rules for consistency. The final decision on whether or not a rule should be included is left up to you. You have various options for assigning and combining probability values. EXSYS Professional also includes a rule compiler that allows you to create or edit rules with a word processor and then compile the rules for use with the EXSYS Professional Runtime or Editor. In general, we believe that it is better to use the EXSYS Professional Rule Editor, rather than a text editor, to create and edit rules. The Rule Editor is faster, easier and provides error checking. However, there are times when having the ability to edit the rules directly can be very powerful. Also, the rule compiler allows other programs to generate EXSYS rules which can be compiled into the EXSYS Professional form. It is even possible to have expert systems that create their own new rules which can be added to make the systems more capable. We feel that EXSYS Professional offers the correct balance of power with ease-of-use. Very complex expert system problems can be handled in EXSYS Professional, but a new user will still be able to learn to create systems in a few days. Also, EXSYS Professional will continue to grow. As users continue to suggest new features, they will be added to the program to make it even more capable. EXSYS Professional is easy to use, no special languages are needed and all input is in the form of either English text, algebraic expression or menu selection. The developer of an expert system works within the EXSYS Professional Rule Editor, which provides menus, prompts and help. It is not necessary to memorize complex rule syntax. EXSYS Professional also includes a rule compiler that allows development or editing of knowledge bases with a word processor. For more complex applications and increased control, there is a command language that can be used to control the execution of the expert system. The command language gives the developer greater control and flexibility in developing rule based systems. Rule subsets, looping and conditional tests are part of the command language. EXSYS Professional expert systems can be run by an end user with essentially no training. The end user of the expert system can ask HOW conclusions were reached or WHY information is needed. The program will respond with a full explanation of the logic used to arrive at the conclusion, including backward chaining and external program calls for data. The developer can customize screens and decide what options are available to the end user. For particularly large or complex problems, blackboarding can be utilized to divide a problem into smaller expert systems that communicate through a common data file (a "blackboard").
A - INTRODUCTION
The EXSYS editor, runtime and utility programs are written in C for high speed and efficient utilization of memory. Expert systems developed with EXSYS Professional function the same way on Microsoft Windows, VAX/VMS Motif, Macintosh Sun Open Look and OS/2 Presentation Manager computers. The EXSYS application need only be moved to the new environment and run with the appropriate runtime program. EXSYS versions are also available in Japanese (with kanji support for Kanji MS-DOS and Kanji Unix computers) and Spanish.
A - INTRODUCTION
Macintosh All Macintosh computers are supported except the Classic. EXSYS will run on the Classic, but some buttons will be off the screen. 4 Meg RAM Hard disk System 6 or System 7
DEC VAX/VMS EXSYS runs on all DEC VAX computers running VMS Motif. EXSYS is a small program for the VAX and runs in all configurations. UNIX EXSYS runs on many UNIX computers. EXSYS is a small program for all but the smallest UNIX computers and should run in all configurations.
A - INTRODUCTION
A - INTRODUCTION
Once EXSYS Professional is installed on the hard disk, store the distribution disk in a safe place.
Macintosh
Create a new folder called EXSYS on your hard disk by selecting New Folder. Insert the distribution disks and copy all files and programs in the disk into the EXSYS folder. Once EXSYS Professional is installed on the hard disk, store the distribution disk in a safe place.
A - INTRODUCTION
UNIXComputers
The UNIX version of EXSYS Professional is distributed on a "tar" tape for the specific target computer. The instructions on the device driver to use are provided with the tape.
A - INTRODUCTION
A - INTRODUCTION
A - INTRODUCTION
10
When EXSYS Professional is used in a multi-user environment, some special precautions have to be taken to prevent inadvertent clashes between users. For example, if two users are accessing the same expert system which calls an external program, their RETURN.DAT files could overwrite each other. Likewise, reports and other output could be confused. To avoid this, EXSYS Professional checks the environment variable EXSYS to see if it exists and has a path associated with it. If the environment variable EXSYS has a path associated with it, all user specific files will be written to or read from files preceded by that path. This is similar to using the HOME path in UNIX. It is possible to override the addition of the path when necessary. If the specification for a read or write in the rules starts with \ in DOS or OS/2 / in UNIX [ in VMS the path from the EXSYS environment variable will NOT be used. The path associated with the environment variable must end in a way that a file name can be appended to it to make a legal path. For example, suppose in UNIX the environment variable EXSYS is \RULES\MY_DATA\ The report command: FILE ABCD would actually open a file: \RULES\MY_DATA\ABCD However, the command FILE \OTHER\ABCD would not have the path added and would open \OTHER\ABCD Likewise, a run command would look for the RETURN.DAT file in \RULES\MY_DATA\RETURN.DAT The addition of the path applies to all files created or read that are unique to a particular user: DATALIST, RETURN.DAT, PASS.DAT, and report output files. The path is not applied to files used by the system: .RUL, .TXT, .OUT, .CMD, .HLP, .SCR, .CFG files or external program calls.
A - INTRODUCTION
11
The use of the environment variable EXSYS makes the path data available to called external programs. If this approach is being used, make sure the called external program also reads the environment variable and writes the RETURN.DAT file to the correct location. Note: See your operating system manual for information on setting environment variables. Environment variables are not supported on the Macintosh. You should also store the EXSYS Professional .HLP files in a single directory accessible by all users. Normally the .HLP files are looked for in the current directory. Adding the command line or .CFG option EXSYS_HELP=<path> causes EXSYS Professional to look on this path for the help files needed. This command would normally be put in the files EXSYSP.CFG and EDITXSP.CFG configure file.
A - INTRODUCTION
12
Developer Environment:
Rule Editor with Context Knowledge Rule Compiler (Text Editor Files) Procedural Command Language Incremental Compile Run or Edit with Single Keystroke Automatic Consistency Checking Automatic Global Change Rule Names Reference by Name Color Coding Menu Driven Repeat Conditions Where Title/Author Option Start/End Text Option Configure File Options User Menu Control Report Generator Language
A - INTRODUCTION
13
Custom Screen Language Custom Hypertext Files Interface Command Generator OR Block Validity Checking Cross Reference Listings Rule Compiler Format Output C Code Output Format
External Interface:
Linear Programming (LINDO) External Program calls: Front End Data Dependent Rule Dependent Command Language Report Dependent Direct Lotus 123 Interface Direct dBase III Interface Graphics Interface Menu Driven Command Definition
A - INTRODUCTION
14
EDITXSP.CFG The configure file for all knowledge bases run with EDITXSP.EXE. This file is automatically read whenever EDITXSP.EXE is used and the configure commands implemented (This is an ASCII file created and edited with a text editor). OPTIONAL EDITXSP(.EXE) The EXSYS Professional editor program for creating and editing knowledge bases. This is the program used to modify EXSYS Professional rules, qualifiers, formulas, etc. EDITXSP has the ability to run knowledge bases during development. EXECUTABLE EXSYSP.CFG The configure file for all knowledge bases run with EXSYSP.EXE. This file is automatically read whenever EXSYSP.EXE is used and the configure commands implemented. (This is an ASCII file created and edited with a text editor.) OPTIONAL EDITXSP.HLP The EXSYS Professional Editor help file. This file contains the help information displayed from EDITXSP. (This file should not be modified.) REQUIRED
A - INTRODUCTION
15
EXSYSP(.EXE) The EXSYS Professional Runtime program. This is the program for running existing, fully developed knowledge bases. EXECUTABLE EXSYSP.HLP The EXSYS Professional help file. This file contains the help information displayed from EXSYSP. (This file should not be modified.) REQUIRED EXSYSRC(.EXE) The EXSYS Professional Rule Compiler. Used for compiling knowledge bases developed or edited in a word processor. This program produces files that can be used with EXSYSP or EDITXSP. EXECUTABLE EXSYSRC.HLP The EXSYS Professional Rule Compiler help file. This file contains the help information displayed from EXSYSRC. (This file should not be modified.) REQUIRED EXSYS-CS(.EXE) The EXSYS Professional Screen Display Utility. Used for displaying custom screens. EXECUTABLE EXSYS_CS.HLP The EXSYS Professional Screen Display help file. This file contains the help information displayed from EXSYS_CS. (This file should not be modified.) REQUIRED PASS.DAT* The default file to pass data from EXSYS Professional to external programs. The name of this file can be changed as a command line option or in the .CFG file with PASS= (This is an ASCII file created by EXSYS). OPTIONAL RETURN.DAT* The default file to return data to EXSYS Professional from external program calls or DATALIST commands. The name of this file can be changed as a command line option or in the .CFG file with RETURN= (This is an ASCII file created by the external program called). OPTIONAL
A - INTRODUCTION
16
<ES name>.CFG* The configure file associated with the specified knowledge base. This file is automatically read whenever the specified knowledge base is used and the configure commands implemented (This is an ASCII file created and edited with a text editor). OPTIONAL <ES name>.CMD* The command file associated with the specified knowledge base. This file would contain commands controlling order of rule execution, looping, etc. It would override the normal EXSYS Professional backward or forward chaining modes. OPTIONAL <ES name>.HLP* The custom help file data. This file contains the custom help information for qualifiers and variables to be used with the specified knowledge base (This is an ASCII file created and edited with a text editor) OPTIONAL <ES name>.HYT* A file created by EXSYS Professional of offset information for the .SCR file. This file should never be modified by the user.GENERATED BY EXSYS <ES name>.OUT* The report generator specification file for the specified knowledge base. This file contains the report generator commands to be used when the knowledge base has completed its run (This is an ASCII file created and edited with a text editor). OPTIONAL <ES name>.RUL* The rule file associated with the specified knowledge base. This file contains the text independent numeric representation of the knowledge base rules. The contents of the file are read when EXSYS or EDITXS reads the rules (This file is modified by the editor EDITXS.EXE and should not be changed by any other program). REQUIRED
A - INTRODUCTION
17
<ES name>.SCR* The screen definition file associated with the specified knowledge base. This file contains definitions for some or all of the qualifiers and variables in EXSYS Professional. This screen would be used to ask the end user for data. OPTIONAL <ES name>.TXT* The text file associated with the specified knowledge base. This file contains the text portion of the EXSYS rules. The contents of the file is accessed when text must displayed to the user (This file is modified by the editor EDITXS.EXE and should not be changed by any other program). REQUIRED TECHHELP.* A technical support expert system. If you have problems running EXSYS Professional, this should be able to answer many of your questions.
A - INTRODUCTION
18
Chapter B Developing Expert System Knowledge Bases B1: What Can an Expert System Do?
The first question in considering the development of an expert system is "Why build an expert system?" Expert systems cannot solve all problems. Understanding why an expert system is desired, understanding what type of system it must be and how it must work are primary questions. The usual reasons for building an expert system are to Disseminate problem-solving knowledge, not just facts, with minimal training of end users. Standardize the conclusions for a given set of data. Interface with other programs and provide analytical capability. Free a human expert from repetitive, routine jobs in order to do activities an expert system cannot do. Codify a problem-solving technique for future users. Provide a safe and effective training tool. Allow the problem-solving skills of several people to be combined. The goal of a particular expert-system project may be a combination of several of the above. Before developing an expert system, first decide on the goals. A system designed to automatically analyze a spreadsheet may be very different from one designed to provide a problem-solving capability or training of users.
Wide
Problems
S c o p e
Specific
Expert Systems
Limited
Deep
Level of Understanding
Defining the problem to fall within the shaded area of the graph is very important. A problem that has too wide a scope or that requires too deep a level of understanding is not appropriate for an expert-system solution. Expert systems cannot emulate deep understanding with insightful solutions to new problems. As the scope of the problem gets larger and larger, the number of rules necessary to express the problem becomes very large. To solve problems with a wide scope, first narrow the scope and solve a small part of the problem. Once that part works, do another part of the problem. Eventually the collection of expert systems can solve a wide range of problems. Keeping realistic goals is very important. An human expert cannot be captured in a computer; only a small part of the problem-solving skill can be expressed in an expert system. A human expert can solve new problems based on experience and intelligence; a computer cannot. However, the expert system can solve the specific problems it has been designed for and will do so for many non-expert users, 24 hours a day. Moreover, the expert system gives consistent answers and usually faster than the human expert can.
Tree-Structured Approach
To get started, choose a simple problem that has a well-defined set of solutions and few alternatives. Even then, the system can be written in a variety of ways. For example, suppose we want to write a system to identify the items on a desk. The desk has a telephone, a computer, a pencil, paper, and floppy disks. One way to write a system is to first create a decision-tree diagram. If the decision tree is complete, the systems developed from it will be complete. First we will make a simple decision tree for the problem of identifying the items on the desk:
TELEPHONE
COMPUTER
Black Flat
Shape White
Cylindrical
PENCIL
This very shallow tree can be converted directly to rules by just tracing each branch of the tree. Tracing each branch always allows a tree to be converted to rules, but if the tree has many branching points, this approach may result in more rules than are needed. For this example, at the same time we identify the items, we can indicate the level of confidence in the answer. We are using the 0-10 Confidence Mode. Beginning with the top branch,
TELEPHONE
Black
White
COMPUTER
Black Flat
Shape White
Cylindrical
PENCIL
the rule would be: Rule 1 IF The item makes noise and The color is black THEN Telephone - Confidence=10/10 The rules for the other branches would be: Rule 2 IF The item makes noise and The color is white THEN Computer - Confidence=10/10 Rule 3 IF The item does not make noise and The color is black THEN Floppy Disk - Confidence=10/10
Rule 4 IF The item does not make noise and The color is white and The shape is flat THEN Paper - Confidence=10/10 Rule 5 IF The item does not make noise and The color is white and The shape is cylindrical THEN Pencil - Confidence=10/10
Black
TELEPHONE
White Flat
Cylindrical Flat
PEN PAPER
Shape White
Cylindrical
PENCIL
We could convert this option to rules as before, by adding a "shape" condition to Rule 3 and adding a new rule for "PEN." However, since the "Shape?" test is repeated, we can restructure the diagram.
TELEPHONE
Black
COMPUTER PEN
Color? Flat
White
PAPER
We can now create sub-goals. This example will require more rules to specify the sub-goal, but the rules will be less complex. In a large system, sub-goals provide a very convenient way to specify a branch point in one condition rather than many. Sub-goals are simply a way of specifying part of the decision process. In this example, if the item does not make noise, we can divide the possible solutions into two categories - writing tools and information storage media (quite a euphemism for paper). Rules 1 and 2 would be the same as above, but now we will add new rules 3 and 4: Rule 3 IF The item does not make noise and The shape is cylindrical THEN The item is a writing tool Rule 4 IF The item does not make noise and The shape is flat THEN The item is information storage media
The conditions in the THEN part of rules 3 and 4 are simply built from qualifiers. They are not choices. These qualifiers will be automatically invoked through backward chaining if the information is needed. We can now add two more rules to complete the sub-set: Rule 5 IF The item is a writing tool and The color is black THEN Pen - Confidence 10/10 Rule 6 IF The item is a writing tool and The color is white THEN Pencil - Confidence 10/10 Rule 7 IF The item is information storage media and The color is black THEN Floppy Disk - Confidence 10/10 Rule 8 IF The item is information storage media and The color is white THEN Paper - Confidence 10/10 The system now has 8 rules to express what could have been expressed in 5, but the problem is broken into smaller parts. The new Rule 6 is easier to understand than the old Rule 5. The system has fewer but more explanatory conditions. If we ask the program *HOW it knows the item is a writing tool, Rule 3 is automatically displayed since the information was obtained through backward chaining.
When we run the rules, however, if we input that the item does not make noise, the program asks if: The item is 1 a writing tool 2 information storage media We have only told the program how to determine if the item is a writing tool or media only for cases that do not make noise. Once we say it makes noise, rules 3 and 4 are false and the program cannot gain any information from them. Consequently, the program will ask us as end users the question about the "item." Suppose, though, that we do not wan the user asked this question. Several modifications to the system are available. First, another value can be added to the sub-goal qualifier: The 1 2 3 item is a writing tool information storage media machine
Now we have three options: 1. Add a rule: Rule 9 IF The item makes noise THEN The item is a machine This rule will provide the information, because now the program can determine data on the sub-goal even if the item makes noise. or 2. Add the THEN condition of Rule 9 to rules 1 and 2. Again, the program is able to get information on the sub-goal even if the item makes noise. or 3. Make value 3, machine, the default value for the qualifier. In this alternative, if the program cannot derive a value from the rules, the default value applies and the end user is not asked the question. Any one of the above solutions complete the rule sub-set.
10
Adding a sub-goal increased the number of rules from 6 to 9. In our example, the sub-goal was unnecessary, but if the sub-goal had 7 decision levels below it, specifying the decision tree only from that point would be useful. Sub-goals should always be used if the decision tree is very deep.
11
Rule 4 IF The item is information storage media and The color is white THEN PAPER - Confidence 10/10 These rules are valid, but when we now run the rules, the program asks The item is 1 a writing tool 2 information storage media For our intended end users, this question is inappropriate. We want the system to provide this information, not the user. When using the technique of starting with the choices, this is expected. The goal is to work out the logic at the highest levels. Creating complete and logical descriptions of the decision is much more important than the questions asked of the user. Sets of rules can be written to handle the user interface after the logic is correct. Once we have the logic correct at the highest level, we will start working down to eliminate the inappropriate questions. To eliminate the question on writing tool versus media, we add these rules: Rule 5 IF The item does not make noise and The shape is cylindrical THEN The item is a writing tool Rule 6 IF The item does not make noise and The shape is flat THEN The item is information storage media
12
and another rule to allow the qualifier to get an answer even if the item makes noise: Rule 7 IF The item makes noise THEN The item is a machine Since we were this time only writing rules to derive a value for the specific qualifier, it was easier to see that a third rule would be needed, rather than in the tree approach above with sub-goals. The advantage of working back from the choices is that a small part of the problem can be in focus, while still maintaining a complete and logical set of rules. We now need to consider the rules for the TELPEHONE and COMPUTER choices. These rules are simple: Rule 8 IF The item makes noise and The color is black THEN TELEPHONE - Confidence=10/10 Rule 9 IF The item makes noise and The color is white THEN COMPUTER - Confidence=10/10 We end up with the same set of rules as above but in a different order. Since this system is backward chaining, the order of the rules does not matter. We produced the same results by very different logical approaches. For many problems, the approach used is purely a matter of personal taste. Both methods can produce equally good systems. However, if confidence factors are used extensively, the method of working backward from the choices seems easier to use. Professional displays the tree diagram of the rules we have input, allowing us to check for incomplete branches or other errors.
13
14
Suppose we are developing an expert system to supply medical advice over the telephone when the doctor is out. Assume calls are answered by non-medical personnel who run the expert system and talk with the caller. Naturally, such an expert system would need to know that if someone is sick and calls after hours, he should take an aspirin and call back in the morning. This can be expressed in rule form as: Rule 1: IF The caller is sick and The hour is late THEN Aspirin - Probability= 10/10 and Call again in morning Confidence= 10/10 This rule will select the aspirin and call again choices. The problem has now been reduced to two smaller problems: determining if the caller is sick and determining if the hour is late. The program could ask the user for this information but the answers on "sick" or "late" would be subjective. If the program derives the information from other rules and asks the user precise questions, the results will be objective. When the program tests Rule 1, it checks the first condition, The caller is sick. The qualifier for this condition is The caller is. Before it asks the user, the program searches all its other rules to see if any can derive the value for the same qualifier in their THEN or ELSE parts. In this case, assume we have put in three rules to help the program determine if the caller is sick. All three rules have the qualifier The caller is in their THEN part. Rule 2: IF The voice sounds hoarse THEN The caller is sick Rule 3: IF The temperature is over 100 degrees THEN The caller is sick
15
Rule 4: IF The voice is not hoarse and The temperature is less than 100 degrees THEN The caller is well In this example, the program first tries to derive information about The caller is from Rule 2. Since no rules have The voice is in their THEN parts, the program asks the user about the voice. If the user selects "hoarse," then the IF condition in Rule 2 is true and the program knows The caller is sick. The developer has the option of directing the program to stop derivations after the first successful rule fires or to apply all appropriate rules (see Section C3.6 for more information.) If only the first successful rule in derivations was selected, the program would return to work on Rule 1 with the new piece of information that The caller is sick. If all applicable rules in derivations was selected, the program also tries to apply Rule 3. (In this example, the additional question would be unnecessary and using the first successful rule for derivations would be adequate.) If the caller answered that the voice was not hoarse, the program would reject Rule 2 as invalid and try Rule 3, since it is the next rule with the same qualifier, The caller is, in its THEN part. The program next asks about the caller's temperature. If the caller responded that the temperature was over 100 degrees, Rule 3 would determine the caller was sick; if the caller said the temperature was less than 100 degrees, Rule 4 would determine the caller was not sick. By using rules 2, 3, and 4, the program can derive whether the caller is sick or well, without directly asking about "sick" or "well." Had we not included Rule 4 and had the caller answered that the voice was not hoarse and the temperature was less than 100 degrees, the program would not have had any valid rules with The caller is in their THEN part. The program could not derive any information on The caller is and would have asked directly if the caller was sick or well. This is what we were trying to avoid, so Rule 4 was added. (Other ways to do this with default values are described in Section C3.6.) Any combination of answers to the questions about voice and temperature will result in at least one of the rules being found true. The program now knows the state of the caller's health. If the caller is well, Rule 1 is rejected. If the caller is sick, the first condition of Rule 1 is true and the program tests the second condition, The hour is late. Since "late" is subjective, we want rules to derive the information.
B - DEVELOPING EXPERT SYSTEMS
16
Rule 5: IF The day is Mon or Tues or Wed or Thurs and The time is between 4:00PM and 9:00AM THEN The hour is late Rule 6: IF The day is Fri and The time is between 2:00PM and 4:00PM or between 4:00PM and 9:00AM THEN The hour is late NOTE: The Doctor plays golf on Friday Rule 7: IF The day is Sat or Sun THEN The hour is late Rule 8: IF The day is not Sat or Sun and The time is between 9:00AM and 2:00PM THEN The hour is early Rule 9: IF The day is Mon or Tues or Wed or Thurs and The time is between 2:00PM and 4:00PM THEN The hour is early The program now only needs to ask easily answered questions about the day of the week and the time segment (9:00AM-2:00PM, 2:00PM-4:00PM, 4:00PM-9:00AM) to know if the hour is late. (The first condition in Rule 8 could have been written THE DAY IS MON or TUES or WED or THURS or FRI and produced exactly the same results. The form used is shorter and simpler.)
B - DEVELOPING EXPERT SYSTEMS
17
To summarize, we broke the problem into three parts: a general rule (Rule 1) based on two smaller problems (sickness and lateness) and two sets of rules to solve the smaller problems. Since in normal backward chaining, Professional will not fire rules unless it needs some piece of information in the THEN or ELSE part, the only time it should have rules do not that contain choices in their THEN/ELSE parts is if they are being used to derive information for other rules. Derivations can continue down many layers in complex expert systems; EXSYS can backward chain well over 100 layers of qualifiers. Other rules can be written using the qualifiers The caller is or The hour is and rules 2-9 are invoked to derive the needed information. Should we later decide that another way to determine if the caller is sick is required, we can simply add a single rule such as: Rule 10: IF The patient is sneezing THEN The caller is sick The new Rule 10 is automatically invoked by any rule that uses The caller is in its IF part. (In practice, we would need to modify Rule 4 so we do not have a patient that is both well and sick). Note: Once rules to solve the small parts of a problem are written, the more general rules are often easier to write. Remember that if the rules are created to derive information, they must be a complete set that accounts for all possible combination of input. If not, the program may ask the complex or ambiguous question that was being avoided. This is where ELSE conditions can be very useful. Rules can call each other to derive information recursively. For example, Rule 1 could use Rule 2 to derive information and Rule 2 could use Rule 1 to derive information causing Rule 1 to again call Rule 2, etc. The program recognizes the loop and breaks out to continue the problem. This type of error in logic will produce an error message. A rule can also have the same qualifier in both its IF and THEN parts. This is useful if, based on other input, a suspicion exists that the user may not have fully considered all of the values for the qualifier or if a value for the qualifier is forced regardless of the user input.
B - DEVELOPING EXPERT SYSTEMS
18
19
Giving specific directions for which confidence system to use is difficult because the selection depends on the purpose of the expert system. Consider what the system will do and how confidence will be used in the rules. The following questions may help with making a selection.
Do solutions with a few rules assigning different values need to be differentiated from solutions with many rules assigning the same value?
If differentiation is needed, none of the systems which use averaging are appropriate. Instead "increment/decrement" or "-100 to 100" in the dependent or independent mode is good.
20
The confidence values for a qualifier or variable can also be derived from other rules. This approach is often better than asking the user for a numeric value. For example, the program could ask the question about the antique chair, and then ask Your opinion of the age of the chair is 1 definite 2 very probably correct 3 probably correct 4 somewhat uncertain Although the number of options for the user has been reduced, the answers still provide the data needed by the program. This method of questioning can be employed with all of the five confidence modes. The qualifier values about the degree of certainty can be used as they stand or can be converted to numeric values. This method produces highly consistent answers among a group of users.
Does the problem require a complex system for combining confidence factors?
The initial four systems in Professional have intentionally been kept easy to use. They are designed for the rapid construction of expert systems by people with domain expertise but not necessarily Artificial Intelligence training. Many very complex systems can be developed for combining confidence factors. These can be implemented by applying the custom formula system when required.
21
22
23
Training
To really get started fast, you may also want to consider classes using EXSYS Professional. Classes are available from many sources including college, universities, third party training and EXSYS Inc. Call EXSYS Inc. (505) 256-8356 for information on classes that are available.
25
C - RULE EDITOR
The configure_commands are described in Chapter E. EXSYS works with two main files for each knowledge base, filename.RUL and filename.TXT. Note: Both the .RUL and .TXT Files must be kept in the same Path/Directory (or Macintosh Folder) or the program will not work. EDITXSP does not load the .TXT file into memory. The .TXT file is accessed as needed from the disk, and if the file is on a floppy disk, it must remain in the disk drive while the program is running.
C - RULE EDITOR
If you select Open, a list of all of the files with a .rul extension will be displayed. Double click on the file you want to use, or select a file and click the Open button. On some operating systems, all files will be displayed, not only those with .RUL extensions. To open a knowledge base, select any of the files in the knowledge base that start with the same filename as the .RUL file. Once the knowledge base file is selected, the files will be read and the system title screen will be displayed. At that time, you can perform operations on the rules, run the rules, and perform a number of other options.
C - RULE EDITOR
Pull down the main menu bar item File and select New. If you select New, EXSYS will ask you for the name of the knowledge base you wish to create. Enter a file name, and if appropriate for your operating system, enter the optional drive or path. Whenever a new knowledge base is created, EXSYS asks you to define certain parameters for the new system. These steps are necessary only when a new expert system is created. All parameters, except for the confidence mode, can be edited later.
C3.1: Subject
Enter a short subject name for the system you are developing. EXSYS requires you to use a subject name which it will display on the system title screen. The text should be less than 200 characters. EXSYS will not continue past this screen unless you enter a subject name.
C3.2: Author
The program asks for the author's name. Like the subject name, EXSYS requires you to enter the author's name which must be less than 200 characters in length. The authors name is also used for the title screen. Like the subject, EXSYS will not continue past this screen unless an author is entered.
C - RULE EDITOR
Knowledge Base Parameters Subject: Author: Confidence Mode: Yes/No 0 -10 -100 to 100 Increment/Decrement Custom Formulas Derivation Mode: All Possible Rules First Successful Rule All Non-redundant Calculation Mode Average Dependent Prob. Independent Prob.
Rule Display Mode: Display Rules Do NOT Display Lock DIsplay OFF Display Threshold:
OK
YES / NO System
If the system does not require any estimate of probability, the YES/NO (0-or-1) System is best. This confidence system is very easy to use since the first rule that fires for a choice sets the value to 1 for Yes or 0 for No. No intermediate values are assigned. This confidence system is good for selecting choices from a list, an automated questionnaire, or other systems which contain choices that can definitely be answered with a "yes" or "no".
C - RULE EDITOR
0-10 System
The 0-10 System provides confidence values on a scale of 0-10. This is often quite compatible with the intuitive knowledge used in the development of an expert system. An assignment of 0 locks the value for the choice at 0 (No), and an assignment of 10 locks the value at 10 (Yes). Confidence values between 0 and 10 are averaged to provide a relative likelihood. This system can positively select or reject a choice (with a value of 10 or 0) but can also allow intermediate values to indicate choices that may be appropriate. For example, suppose Choice 1 was in three rules which fired with assigned confidence values of 3, 7, 8; Choice 2 was in two rules with values of 7 and 10; and Choice 3 was in one rule with a value of 5. The final confidence values would be Choice 2: Choice 1: Choice 3: 10 (the selection of one 10 locks the value at ten) 6 (the average of 3, 7 and 8) 5
This allows the end user to see not only which choices were selected but also provides a means of relative ranking. When obtaining a human expert's intuitive confidence for confidence in an event, a 0-10 scale is often comfortable and easy to use. Unless valid statistical data is available, precision higher than 0-10 is difficult to obtain from intuitive knowledge. Despite its simplistic calculations, the 0-10 System is very useful for many expert systems, and it is easy to use. We recommended this mode for beginning systems.
C - RULE EDITOR
negative values have no meaning. If confidence factors are combined by averaging, the full -100 to 100 range can be used. This system is useful if you wish to use averages without locking values, if you have statistical data, or if you require independent probability.
Increment/Decrement System
This system is intuitive and easy to use. Values are added to or subtracted from the total points for a choice. A rule can add or subtract as much as 100 points from the total for a choice. At the end, the total value for a choice is displayed. This system differentiates among possible solutions that would provide similar or identical scores using other systems. For example, suppose Choice 1 received three values of 9 and Choice 2 received only one value of 9. In the 0-10 System, both Choices 1 and 2 would have the same final score of 9. But in the Increment/Decrement System, Choice 1 would have 27 and Choice 2 would have 9. Clearly, Choice 1 had been selected in more rules. Use this system if having multiple rules fire indicates a higher likelihood for a choice. If multiple rules do not indicate a higher confidence, the 0-10 system may be a better choice While locking a score is not possible using this system, a large number of points can be added or subtracted, thereby clearly pushing the value over or under the display threshold value. This system allows the end user to see a much wider point spread among selected solutions.
method of combining points assigned to choices, the formulas for handling the confidence scores must be part of the rules. This adds complexity and takes much more time than other systems. This system should be used only if you need to have the following elements in your system. 1. You require numeric confidence scores associated with qualifiers or variables. 2. You need to have user supplied confidence values for their answers that effect the final confidence values of choices. 3. Your require specialized formulas for combination of confidence values. In most cases, developing an expert system using one of the other Confidence Systems is faster and easier. However, the flexibility and power of the custom formula system can lead to solutions not found by the other systems. (See Section C40 for additional information.) Confidence System 0 or 1 When to Use
System does not require confidence factors. Choices can be positively selected or rejected in individual rules. Ranking of selected choices is not required.
0-10
Easy to usevery good for beginners. Allows confidence factors to be combined, without requiring complex formulas. Intuitive for most users to assign confidence factors. Most effective general purpose system.
-100 to 100
Provides finer resolution of confidence factors. Should be used only if statistical data is available with appropriate precision.
C - RULE EDITOR
8
Allows factors to be combined as dependent or independent probabilities. Increment/ Decrement Intuitiveeasy to use. Good for distinguishing between choices that would receive similar scores in other systems. Allows wide point spread in selected items. Custom Formulas Most flexible and powerful. Most complex and most difficult. Allows user supplied or derived confidence for qualifiers and variables. Allows any formula to be used to assign confidence values to a choice. Should only be used if none of the other systems can handle the problem.
Average
The first is a simple average of all the individual values the choice received in the rules found to be true. This is the same as the 0-10 system, but no assigned values lock the final value. If this mode is selected, the full range of -100 to 100 can be used.
C - RULE EDITOR
Dependent Probabilities
The second combines the probabilities as if they were dependent probabilitiesthe probabilities are multiplied as percents. For example: if a choice appeared in two rules that were used, with values of 60/100 and 90/100, its final value would be (60% times 90% =54%) for a final value of 54/100. If this mode is selected, only the range of 0 to 100 can be used, since negative values have no meaning.
Independent Probabilities
The third way to combine the values is as if they were independent probabilities. In this system, the combination of the two probabilities is 1 minus the product of 1 minus the individual probabilities. 1-((1-Prob1) * (1-Prob2)) In the example above this would be 1-((1-60%) * (1-90%))=96% for a final value of 96. If this mode is selected, only the range of 0 to 100 can be used, since negative values have no meaning.
C - RULE EDITOR
10
Non-redundant Rules
The "apply all non-redundant rules" mode is appropriate for most cases. A rule is redundant if it supplies no additional information, regardless of whether it is true or false. In this system, after one rule has been determined to be true and provided information, additional rules are invoked only if they add more information. Rules that would not add information, even if they were true, are not invoked. This system is appropriate unless l. Backward chaining is being used as a control mechanism to force rules to fire for procedural reasons. In this case, use "attempt to apply all possible rules." (It is better to use the command language for such procedural control. See Chapter J for more information.) 2 Information on the qualifier or variable is provided by a single rule firing. In this case, "stop after the first successful rule" may produce slightly better speed.
C - RULE EDITOR
11
The difference between the modes is easier to understand if you look at an example of how they work on different problems. For example: Rule 1: IF Wood is needed THEN The shipment includes wood Rule 2: IF Construction materials are needed THEN The shipment includes wood Rule 3: IF Plastic is needed THEN The shipment includes plastic If the program is attempting to derive information on "The Shipment" with the "attempt to apply all rules" option, it will test all rules that have some information on "The Shipment" in their THEN part. 1. The program will test Rule 1. 2. Even if Rule 1 is true, Rule 2 will be tested. 3. Even if Rule 2 is true, Rule 3 will be tested. Since each rule could provide information on "Shipment", each is tested. With the "stop after first successful rule" option: 1. The program will test Rule 1. 2. If Rule 1 is true, the program will successfully derive some information on the contents of "The Shipment" and rules 2 and 3 will not be tested.
C - RULE EDITOR
12
3. If Rule 1 is false, Rule 2 will be tested. If Rule 2 is true, the program will successfully derive some information on the contents of "The Shipment" and Rule 3 will not be tested. 4. If Rules 1 and 2 are false, the program will still not know anything about "The Shipment" and Rule 3 will be tested. If the shipment only includes one material, this might be a good mode to use since it minimizes the number of rules tested. With the "apply non-redundant rules" option: 1. The program will test Rule 1. 2. If Rule 1 is true, Rule 2 will be ignored because the program will already know "The Shipment" includes wood. Rule 2 can add no additional information and is therefore redundant. 3. The program will then test Rule 3 since it adds information (plastic) which is not redundant with existing information, even if rules 1 or 2 are already known to be true. Using the non-redundant option usually avoids unnecessary questions, while still allowing all information to be derived about a specific qualifier.
Display Rules
The Display rules as they are used means all rules are displayed immediately after they fire. This can be useful for many things, including development or providing information to the end user in rule notes. However, usually end users find this mode annoying and there are alternative ways to present the required data to the end user in a more convenient form (e.g. DISPLAY commands, report generator, custom screens)
13
C - RULE EDITOR
15
C - RULE EDITOR
16
Title
Author
C - RULE EDITOR
17
It is a good idea to periodically save to disk the work done on the expert system. This is especially true when testing custom written external programs. EXSYS maintains most of the expert system in memory. If the system crashes, all work since the last save will be lost. Selecting Save from the File menu will save the knowledge base to disk. If any rule editing windows are open, you will be asked if you wish to save the changes made in those windows before the rules are saved to disk. If you attempt to exit EXSYS without saving your work, you will be prompted to save the rules before exiting.
Password Protection
EXSYS provides optional password protection for encryption of a knowledge base file. When the rules are saved, the program will ask if password protection is desired.
Use Passwords? NO YES
If the option of locking out rule display was selected, the password option must be used. Locking the rule display prevents someone with only the Runtime password from accessing or examining the rules with WHY or HOW. Once locked, the rules can be unlocked only with the Edit password. If password protection is used, the rule display locking option may be selected from the Options Menu selecting Parameters, then clicking Lock Display Off. Locking of
C - RULE EDITOR
18
rule display applies only to the Runtime program, not running the rules from within the Editor. If password protection is selected, the program prompts for an Edit password and a Runtime password. These should be alphanumeric strings of 6 or more characters in length. The program has two password access levels, requiring two different passwords. The Runtime password allows an end user to run the knowledge base with the Runtime Program but not to edit or change any of the rules. The Edit password allows access to the knowledge base with the Editor Program. The Edit password does not work with the Runtime program.
Edit Runtime Use Passwords? NO Show Current Passwords YES Hide typing OK Cancel
If password protection has already been selected, the default passwords will be the existing passwords. These can be displayed by clicking Show Current Passwords. Normally, when the passwords are typed, they will be displayed in the editing box. However, if the situation requires that the passwords not be echoed to the screen, click on the Hide Typing box. In this case, the passwords will not be echoed to the screen. Instead, after the passwords are entered, the program will ask you to input the passwords again to confirm the correct input. Use care when using this option since it is possible to make a typographical error both times, in which case the system will be encrypted and you will not know the password. If passwords are not used, EXSYS creates unencrypted knowledge base files.
C - RULE EDITOR
19
To exit the EXSYS Editor, go to the File menu on the menu bar and select Exit. If any edit rules are open and have been edited, you will be asked if you wish to save changes to those rules. If the knowledge base has been edited, you will be asked if you wish to save changes to the knowledge base. Macintosh Note: On the Mac, this menu entry is QUIT, not EXIT.
C - RULE EDITOR
20
To get help in using EXSYS Professional, select About from the File menu. Macintosh Note: On the Mac, there is no About menu item, instead select the About EXSYS menu item under the Apple menu. This will bring up a dialog box with a HELP button.
Cancel
Help
Click on the help button. In Microsoft Windows, you can simply press the F1 key to get to the system help functions. Help is also available by selecting the Help item from the Options menu.
C - RULE EDITOR
21
Help topics
Fresh Window
Cancel
Help
To get more information, either double click on a help topic, or select a help topic with a single click and then click on the Help button. A window will display information on the selected topic. If you wish to have the help information on the topic placed in a new help window, click the Fresh Window button.
Help Information
Cancel
Prev
Next
Topics
C - RULE EDITOR
22
Click the Prev button to see the information on the previous topic in the help topic list. Click Next to see the information on the next topic in the help topic list. Click Topic to bring the help topic list window to the front. Click Cancel when done. Clicking Cancel in either the Help Topic window or the Help Text window will close both windows. There is fairly extensive help information in the Help Topics, and many questions can be answered without referring to the manual. This is especially true for the syntax of the various commands in EXSYS, such as custom screen command, configure options, and report generator commands.
C - RULE EDITOR
23
Text can be transferred from other applications and copied into EXSYS or cut from EXSYS in any place where text input is expected in a window. It is not possible to use these commands for input requested by dialog boxes, since the main menu bar is inactive when the dialog boxes are displayed.
C - RULE EDITOR
24
Add Rule Edit Rule Delete Rule Move Rule Use Rule Names Qualifier List Variable List Choice List Condition Cut Condition Copy Condition Paste
To add a new rule, go to the Rule menu on the menu bar and select Add Rule from the pull down menu. The window that appears is similar to the one which is used for editing a rule, but the rule will be empty. EXSYS keeps track of the rule numbers internally, and will assign the number to the rule automatically. See the section below on Editing a rule for the details on adding conditions to the rule.
C - RULE EDITOR
25
Add Rule Edit Rule Delete Rule Move Rule Use Rule Names Qualifier List Variable List Choice List Condition Cut Condition Copy Condition Paste
To edit an existing rule, go to the Rule menu on the menu bar and select Edit Rule from the pull down menu. A dialog box appears which asks you to select the rule that you wish to edit.
Name: AA AB ABCD BBBB CCC DDDD EEEE FFFF Number: 1 2 3 Edit 4 5 Runtime 6 Use Passwords? NO 7 Show Current Passwords 8 YES Hide typing Last Cancel
C - RULE EDITOR
26
The name list box contains the names of all of the named rules in the system, arranged alphabetically. The Number listbox contains a list of the numbers of each rule in the system. To select a rule, either 1. Click a rule number and then click the OK button. 2. Click a rule name and then click the OK button. 3. Double click a rule name or number. 4. Enter a rule number or name in the edit field. When a rule name or number is selected, the corresponding number or name will be highlighted in the other list box. To start a new rule, click the New Rule button. To edit the last rule entered, click the Last button and click the OK button. Note: For large systems with many named rules, creating and alphabetizing the list of rule names can be a little slow. To disable the display of the rule names (but still allow a rule to be called by name in the edit field), go to the Rule menu on the main menu bar and select Use Rule Names. If this item is checked, rule names will be used, if it is not checked, rule names will not be displayed.
File
Edit
Rule
Options
KBfiles
Questions
Add Rule Edit Rule Delete Rule Move Rule Use Rule Names Qualifier List Variable List Choice List Condition Cut Condition Copy Condition Paste
C - RULE EDITOR
27
After a rule is selected, or a new rule is started, the main Rule window will be displayed. You can work on several rules at the same time and you can open up to 10 Rule windows simultaneously.
Rule Title and Number IF: Qualifier Var. / Math Choice Command Repeat IF Part THEN Part ELSE Part Insert AND OR New OR Change Delete And/Or Cancel Note Reference Name
OK
Prev
Next
Three main types of conditions can be added: qualifiers, choices and mathematical expressions.
C - RULE EDITOR
28
When a new rule is started, the mode is set to add conditions to the end of the IF part. When the IF part is complete, click on the THEN Part radio button. To add a condition to the end of the IF, THEN or ELSE part 1. Click on the radio buttons labeled IF Part, THEN Part or ELSE Part. 2. Click on Qualifier, Variable, Choice or Command and build a condition, or select Condition Paste from the Rule menu. 3. The new condition will be added at the end of the section. To add a condition somewhere other than the end of a section: 1. Click the Insert box. This puts the rule in insert mode. 2. Highlight a condition in the rule by clicking it. 3. Click Qualifier, Variable, Choice or Command and build a condition, or select Condition Paste from the Rule menu. 4. The new condition will be added just before the highlighted condition. All subsequent conditions in the rule will have been moved down one. The selected condition will remain selected. (If no condition is selected, the new condition will be added to the end of the currently active section.) The "end of section" and insert modes can be mixed simply by clicking on the Insert box.. To return to the IF part after the THEN part has been started, simply click on the IF Part button.
C - RULE EDITOR
29
QUALIFER LIST
The Qualifier List area will contain a list of all of the qualifiers known to the system. If you click on a qualifier, the list of values associated with that qualifier will be displayed in the lower window. The meaning of "qualifier" and "associated values" are explained below in the section on adding or editing a qualifier.
C - RULE EDITOR
30
Edit
Replace
Cancel Edit
Add
Delete
OK
Qualifier and their associated values are simply multiple choice lists. Typically, the qualifier is part of a sentence up to and including the verb. "Values" are the possible completions of the sentence that the user is able to select among. A qualifier can have a maximum of 30 associated values. The text of the qualifier is edited in the top edit region. The qualifier text can be directly edited. If this is a new qualifier, the word "Qualifier" will appear here. For new qualifiers, replace the word "Qualifier" with the actual text of the qualifier. To do this, drag across "Qualifier" or double click on it to highlight it. Then type the text of the qualifier. The bottom edit region also has the word Values. This is replaced with the actual values you wish to use. After the text of a value is entered, click on the Add button to add it to the list in the middle listbox. Notice that when text is entered in the "value" edit region, pressing <ENTER> (<RETURN> on some machines) will add the value to the list. For example, suppose we are creating an expert system to identify flowers and we want to create a condition dealing with the color of
C - RULE EDITOR
31
the flower. We would click on New Qual in the Qualifier window. The new qualifier window would be displayed. Replace the word "Qualifier" in the top edit region with THE COLOR OF THE FLOWER IS. Enter the list of values that the user may select among. In this example, the qualifier can have the values RED, BLUE, YELLOW and WHITE. Replace the word "Values" in the lower edit region with the first value "RED" and click the Add button or press <ENTER>. RED will appear in the middle list box as the first value. Enter "BLUE" in the lower edit region and click Add. BLUE will appear as the second item in the value list. Do the same for YELLOW and WHITE. The result will look like:
Add / Edit Qualifier Qualifier ## NEW QUALIFIER Name:
Edit
Replace
Cancel Edit
Add
Delete
OK
C - RULE EDITOR
32
Note: When an edit to a value is accepted by pressing the Replace or Add button, it immediately takes effect. Pressing the Cancel button will not undo it. Pressing the Cancel before the value is accepted will cancel the edits made in the work window. Not all values for the qualifier may be able to be displayed at one time. If there are more values than can be displayed, the listbox will have a scroll bar on the right side.
C - RULE EDITOR
33
selecting from among the possible values of the qualifier. In some cases, the developer may not want a qualifier asked of the user. Perhaps the qualifier asks a more complex question than the user would be expected to answer. In such cases, setting a default value guarantees that the user will never be asked about the qualifier, regardless of other input. The default value should be used rarely, and only in very special cases. The default is a value to be used instead of asking the user for input. Once a default value is set, the user is never asked to provide input on that qualifier. However, if data on the qualifier can be derived from other rules or external sources, the default value will not used. To set a default value, enter the number of the value to use in the edit field labeled "Default Value". Only a single value can be selected as the default. For example, suppose we have a qualifier: The color is 1 red 2 white 3 blue 4 green We could set a default value of 3, blue. When the program needed to know the color, it would first check to see if any information was already available from external programs or other rules that had fired. It would then check the rules to see if any rules could provide information on the color. If any rules were found, they would be tested. If, after testing the appropriate rules, a value had been set for the qualifier, the default would not be used. However, if after testing the other rules, nothing was known about the qualifier, the default value of 3 would be set and the program would continue. The user would never be asked about the color. Note: Default values for qualifiers are different from initial values for variables. The initial value of a variable is always set at the start of a run. It is set regardless of other rules that provide information about the variable. Default values for a qualifier are used only if no other method provides the information. They are set only when needed.
C - RULE EDITOR
35
C - RULE EDITOR
36
QUALIFER LIST
OK
Click on the qualifier you wish to use. Once a qualifier is selected, its associated values will be displayed in the value listbox. To build a condition, click the values you wish to use. If you want to use more than 1 value, click several. All highlighted values will be used. If a value is selected, clicking it again will de-select it. Click the OK button when you are finished selecting your values. A double click on a value also indicates that the selection is complete. The qualifier condition you have selected will be added to the rule. In the IF part, you may also use NOT in association with values. To use NOT, click the box in front of NOT, and an X will appear in the box. This will build a condition of the form qualifier is NOT value, rather than the normal form of qualifier is value. After selecting NOT, select the values in the usual way. If the number of an already entered qualifier is unknown, do not create a new qualifier and list of values identical to the previous entry because the program does not know they are the same and therefore asks the user for the same information twice. Instead, use the existing qualifier. To FIND a qualifier with specific text in it, click on the FIND button. You will be asked for the text to find, and if the qualifier, values or names are to be searched. When you click
C - RULE EDITOR
37
Search, the first qualifier with the specified text will be displayed. To search for the next occurrence of the text, click on Find Again. To select a qualifier by name, click the Name button. A list of all of the qualifier names will be displayed. Click the name you wish to use. Using the previous example, suppose you want the IF condition to say THE COLOR OF THE FLOWER IS RED. The qualifier would be displayed as
Qualifier Select qualifer by text or name: Find Find Again Name
THE COLOR OF THE FLOWER IS THE FLOWER STEM IS THE CENTER OF THE FLOWER IS THE SIZE OF THE FLOWER IS 1 RED 2 BLUE 3 YELLOW 4 WHITE
Edit OK NOT Delete Cancel New Qual.
Since you want RED, you would click "1 RED", and click OK, or double click RED. If you want the condition THE COLOR OF THE FLOWER IS BLUE OR YELLOW, click "BLUE" to select it , then click YELLOW to that color as well. If you want THE COLOR OF THE FLOWER IS NOT WHITE, click NOT, then click WHITE. When the OK button is clicked, the condition will appear in the rule. If multiple values are selected for a qualifier in the THEN/ELSE part, they will be connected by "and" rather than or, as they were in the IF part. This is because in the IF part, if any of the values are true, the rule is true. The IF values are ORed. In the THEN part, all the values are true if the IF part is true, so the THEN values are ANDed. The form "NOT" plus value number(s) cannot be used in THEN/ELSE qualifiers. The conditions in the THEN part must be affirmative.
C - RULE EDITOR
38
Deleting a Qualifier
If a qualifier with all its values needs to be deleted, select the qualifier and click the Delete button. The program checks all the rules to see if the qualifier is used in any rule. If it is not used, it is deleted and the remaining qualifiers or values are renumbered accordingly. If the qualifier or value is found to be in use, it cannot be deleted. The program instead displays a list of the rules in which the value is used. The rules must be edited so the qualifier is not in use before it can be deleted. This prevents accidentally deleting a data element that is expected when the rules are run. To delete a single value from the qualifiers list, select the qualifier and click the EDIT button. Select the value to delete and click Delete. As with qualifiers, if the value is used in the rules, it cannot be deleted.
If any condition in an OR block is true, the entire block is true. Groups of OR blocks can be ANDed to make complex statements. For example: IF: AND AND The color is red Today is Monday The weather is hot
will be true only if all three conditions are true. On the other hand, IF: AND OR The color is red Today is Monday The weather is hot
will be true if "The color is red" and either the second or third condition is true. The "OR" at the start of the third condition indicates an OR block, which is ANDed with the first condition. IF: OR OR The color is red Today is Monday The weather is hot
We could also create two OR blocks, such as: IF: The color is red OR Today is Monday AND The weather is hot OR The price is low Now either the first or second condition must be true, and either the third or fourth condition must be true. The AND in front of the third condition indicates two OR blocks ANDed together. When the rule is tested, the program asks the minimum number of questions. If any condition in an OR block is known to be true, the other conditions in the block are not tested.
C - RULE EDITOR
40
An OR block is created by starting a new rule. The AND radio button will be highlighted. To start an OR block, click the OR radio button and enter a qualifier condition. The OR button will stay highlighted, and multiple qualifier conditions can be entered which will all be part of the same OR block. To return to ANDing conditions, click on the AND button. To start a new OR block, which will be ANDed with the previous OR block, click on the New OR button.
Rule Title and Number IF: Qualifier Var. / Math Choice Command Repeat IF Part THEN Part ELSE Part Insert AND OR New OR Change Delete And/Or Cancel Note Reference Name
OK
Prev
Next
For example to build: IF: OR AND OR The color is red Today is Monday The weather is hot The price is low
Click the OR button and enter the condition "The color is red". Then enter the condition "Today is Monday". The OR button will still be selected and the two conditions will be part of the same OR block. To start the second OR block, click New OR and enter "The water is hot". EXSYS will automatically switch back to the OR button from the New OR button. Now enter "The price is low" and the IF part is complete.
C - RULE EDITOR
41
Text of condition
To AND with the previous qualifier, select AND and press the OK button To start a new OR block, or OR the qualifier with the previous qualifier, select Part of OR Block and press the OK button. To indicate the last OR in the block, select Last OR in Block and click the OK button. This is only necessary if you wish to immediately start another OR block. If subsequent conditions are ANDed, you can simply press AND for the next qualifier. The program will tell you if a condition is not a qualifier condition. It is not necessary to indicate the last OR in a block unless a new OR block is being started. The program will automatically mark the last OR in the block.
C - RULE EDITOR
42
However, using exactly the same qualifier may cause some confusion to the end user and definitely causes problems for the Rule Compiler. A better approach would be THE LEG COLOR IS ... AND THE LEG LENGTH IS... Occasionally you may want to use a condition such as A can be X or Y but not Z. This can be done by repeating a qualifier in the IF part. Suppose possible values for a bird's leg color are black, yellow, green, and red. A condition says leg color can be yellow or green but not black. This is accomplished by using two IF conditions: IF THE BIRD'S LEG COLOR IS YELLOW or GREEN AND THE BIRD'S LEG COLOR IS NOT BLACK Both statements must be true for the rule to be true. If the user inputs both yellow and black in answer to the program's query about leg color, the first condition would be true but the second would be false. When creating rules, all IF conditions and OR blocks in a rule must be true for the THEN conditions to be considered true. However, in a given condition that has multiple acceptable values for a qualifier, only one value need be true for the condition to be true. Since the program checks the conditions in a rule in the order they appear, the most general conditions should appear first. If the
C - RULE EDITOR
43
program determines that a frequently used condition is false, it may be able to eliminate a large number of rules without asking the user unnecessary questions. If the expert system is asking unnecessary questions, it may need more general conditions at the start of some rules. The ability to copy conditions from previous rules and reorder conditions makes it easy to add general conditions to rules.
C - RULE EDITOR
44
C15.1: Variables
A variable is any string of alphanumeric characters, including spaces, enclosed in brackets [ ]. Only the first 18 characters are significant. Only letters, digits, and spaces can be used in variable names. Variable names should be descriptive of what they represent. The following would be valid variable names: [COST], [COST OF SYSTEM], or [X]. The following would not be valid because they include illegal characters: [X#], [X/Y] or [NAME 1.2]. These are not valid names because they all include characters other than letters, digits and spaces. EXSYS supports only three types of variablesnumeric, string and text-only. Numeric variables can be assigned a numeric value. String variables can be assigned a string value, and text-only variables take no value but are used to display special text to the user. As with qualifiers, when the system needs the value of a variable to evaluate an IF expression, backward chaining will invoke the rules that assign a value to the variable in the THEN/ELSE parts to determine the value.
C - RULE EDITOR
45
Additional details on conditional operators and mathematical expression syntax are described below.
IF Part
If you are adding a condition to the IF part of the rule, a window will appear for you to enter the expression you wish to add.
Add Formula Please enter a formula
OK
Display Variables
Cancel
Enter a formula that can be tested as a boolean expression (such as the formula [X] > 0). To see a list of the variables currently defined in the system, click the Display Variables button. The expression you enter can contain new variables. EXSYS will automatically check for new variables and ask you to set the parameters for them. If a new variable is found in the expression, EXSYS will display the Add/Edit Variable window which is described later.
C - RULE EDITOR
46
EXSYS will also perform a syntax check of the expression you have entered and warn you of any syntactical errors.
OK
VARIABLE LIST
Numeric String Text Only Edit Options New Variable
VARIABLE TEXT
Cancel
When a variable is selected from the list by clicking on it, its type is displayed by having the Numeric, String or Text Only button selected. The prompt text of the selected variable will be displayed at the bottom of the window. These variables can not be edited or changed from this window. They are presented for information only. To change the parameters for a variable, select a variable and click the Edit Options button. Either select a variable from the list to assign a value to, or click on New Variable to add a new variable to the system. If a variable is selected from the list, either click the variable and then click the OK button, or double click the variable you wish to use.
C - RULE EDITOR
47
If you have selected to either edit an existing variable or add a new variable, the Add /Edit Variable window will be displayed. If editing an existing variable is selected, the current parameters for the variable will be filled in.
Add / Edit Variable Name: Prompt:
Cancel
Variable Name
Each variable must have a unique name. The name can be up to 18 characters in length and can contain spaces. Try to make the name descriptive of what the variable represents. EXSYS requires you to use a name.
Variable Prompt
Each variable must have associated text that will be used when asking the user for the value of the variable or for displaying the value of the variable. Usually this text should describe what the variable represents (the exception to this is Text-Only Variables, described below). The variable name used in the formula should only be descriptive enough to identify what the variable means, but the text prompt can be very specific. For example, you might have a variable [LENGTH OF BEAM] which suggests what the variable means, but the text you associated with it could be "The length of the beam from the base to the first cross beam as measured in centimeters." This tells the user exactly what information is expected.
C - RULE EDITOR
48
Variable Type
EXSYS has two types of variablesnumeric and string variables. Numeric variables are stored as floating point numbers and are handled in algebraic expressions. String variables are text strings and can be used for string concatenation or comparison. Text-Only variables are used in the THEN / ELSE part of rules to display special messages. To set the variable type, click the appropriate radio button for Numeric, String or Text Only. Note: Once the variable type is set, and the variable has been used in an expression, changing the type may be prohibited.
Numeric Variables
If the variable is handled as a numeric, its value will be a floating point value. Numeric variables can be used in algebraic expression for testing or assignment. Only numeric variables can have initial values or upper and lower bounds assigned. The following would be valid expressions with numeric expressions: [X] < 1.56 [X] + [Z] >= [Z]/7.4 SIN([LENGTH]) <= [X]*[Z] [X] IS GIVEN THE VALUE [Z]/8.26 The following are not valid expressions if [X] is numeric: [X] > "ABCD" [X] IS GIVEN THE VALUE [X] + "ABCD"
String Variables
If the variable is handled as a string, its value will be text and not a floating point value. This can be very useful for names or other text information. When the end user is asked for the value of a string variable, the text input will be taken as the string value of the variable. String variables can be used in the IF part in expressions comparing them to other string variables or text strings (for example, you may have text enclosed in double quotation marks). The standard comparison tests of <, >, =, <=, >=, and <> can be used. Validity of
C - RULE EDITOR
49
the comparison is based on alphabetical order. For example, if [S] and [T] are string variables, the following would be valid expressions: [S] [S] [T] [S] = "EXSYS" <= [T] <> "THIS IS A TEST" + [T] <= "THIS IS A TEST"
The first would be true if the string value of the variable [S] were the string EXSYS. The second would be true if the string value of [S] were alphabetically less or equal to the string value of [T]. The third would be true if the string value of [T] were not THIS IS A TEST. The fourth would concatenate [S] and [T] and then do the comparison. The following would not be valid string expressions: [S] > 4 [S] = EXSYS [S] + 3 > [T] The first compares a string variable with a numeric value. The second does not have the comparison string in quotes. The third attempts to add a numeric value to a string variable. String variables can also be used in the THEN or ELSE part of rules in assignment of value statements. This is done the same as a numeric variable, but the value assigned must be another string variable or a string enclosed in double quotes. The following would be valid: [S] [S] [S] IS GIVEN THE VALUE "EXSYS" IS GIVEN THE VALUE [T] IS GIVEN THE VALUE [T] + "ABC"
The following would not be valid: [S] [S] IS GIVEN THE VALUE 4 IS GIVEN THE VALUE EXSYS
The first assigns a numeric value to a string variable. The second does not have the text in quotes. Data for a string variable can also be passed in from external programs.
C - RULE EDITOR
50
Display of Variable
A variable can be displayed at the end of a run in the result screen. Usually, only variables that are calculated by the program during the run would be flagged for display. However, in development, having the variables displayed may be useful for checking the expert system. To indicate that the variable should be displayed, click the Display at End box. This display can be switched on or off later.
For example, to add 10 to the running total for [PRICE], use [PRICE] IS GIVEN THE VALUE [PRICE] + 10
We do not want the program to ask the user for a starting value for [PRICE]. Instead, we want the program to start with a value of 0.0. This could be done in the command language, but it is easier to set the starting value to 0.0 by initializing the variable [PRICE] to a value of 0.0. Most variables should not be initialized. Variables that require end user response should never be initialized. Only numeric variables can be initialized. To indicate that the variable should be initialized and set the initial value, enter the value in the edit field labeled Initialize.
Range Limits
If the variable is numeric, the acceptable user input can be limited using pre-established upper and lower bounds. If limits are set, and the user's input is outside the acceptable range, the program will indicate that the data is out of range and asks, again, for input. An upper limit, lower limit, or both can be assigned. Range limits are very useful when the rules only make sense if the user provides input within a certain range. For example, you might have a rule that is valid only if [X] is greater than or equal to 0. If the end users input a negative value for [X], they will get invalid answers. By setting a lower limit of 0, you can guarantee that the value of [X] will be acceptable, and not have to handle unrealistic input in the rules. To set an upper or lower limit, enter the limit value in the edit field labeled Upper Limit or Lower Limit. The value selected as a limit will be an acceptable value. If the limit is set to 0, the user will be able to input a value of 0. Limits can only be applied to numeric variables. Limits are optional and are not required.
If a data acquisition command has been associated with the qualifier, it will be displayed in the prompt. You can either directly edit the data acquisition command, or press the Data Acquisition button to build a new command.
OK
Display Variables
Cancel
This is the same window that appeared in the IF part for entering a conditional test, but in this case, enter just the expression to assign to the variable. The condition that will appear in the rule has the form: [VARIABLE] IS GIVEN THE VALUE expression
C - RULE EDITOR
53
The [VARIABLE] has already been selected. The "IS GIVEN THE VALUE" is supplied automatically by EXSYS, so only the expression is needed. When the expression is entered, click the OK button. The formula will be automatically checked for new variables. If any new variables are found, EXSYS will display the dialog box for setting the prompt and other parameters for the new variable. Once all the variables in the formula are defined, the condition will be added to the rule.
C15.8: Expressions
An EXSYS expression can range from any algebraic expression derived from a single number to complex expressions. Usually the expression contain EXSYS variables. Expressions can be simple or complex.
Parentheses can group expressions in the order of calculation that you wish to use. Spaces can be included between operators to make the formula easier to read.
C - RULE EDITOR
54
The boolean operators supported are: OR AND NOT || (same as OR) && (same as AND) ! (same as NOT) These operators can be used with parentheses to produce complex expressions. Remember, if the users ask WHY or HOW, they may not easily read and determine the validity of expressions with complex boolean operations. The result of a boolean operation is 0 if false or non-zero if true. Since the result of a boolean operation is a numeric value, it can be used with other numeric expressions. For example: 6 * (4=2) && 1 is acceptable. It would be evaluated as: (4=2) is a test expression returning 0, boolean FALSE. 6 * 0 is 0, a numeric variable. 0&&1 is 0, a boolean expression returning false, 0. While this expression is acceptable, it is somewhat unusual, and when it is entered in an expression, a warning message such as "Boolean where numeric expected" would appear. This is not necessarily an error. It is only a warning that the syntax is unusual and a numeric value is being used as a boolean operator. Note: Boolean true is not always 1, but it is guaranteed to be non-zero. It will not be 1 in cases where numerics other than 0 or 1 are used where booleans are expected. Non-zero numeric values combined with booleans will be taken as true, but the value will propagate through the expression. For example: (4=4) && 7 will return TRUE, but it will not be equal to 1. EXSYS will warn you if you use a boolean result as a numeric value. Even though it is allowable to use a boolean value where a numeric value is expected, it is unusualso unusual in practice that you probably have made an error. For example: 66<[X]<99 does not test if [X] is between 66 and 99. Instead, it tests the boolean result of: 66<[X]
C - RULE EDITOR
55
which will be true or false, (1 or 0) either of which is less than 99. Therefore, this example is always TRUE. What should have been entered is: 66<[X] and [X]<99 Another example which generates two warnings is: [X] = 32 or 64 or 91 This example does not test if [X] is an element of the set [32, 64, 91]. Instead it tests: [X] = 32 or TRUE or TRUE which is always equivalent to TRUE. What you should have entered was: [X]=32 or [X]=64 or [X]=91 If you receive an error about using a boolean as a numeric, or visaversa, carefully check the expression for a mistake similar to one listed above.
If you are not sure how an expression will be evaluated, add parenthesis to make it unambiguous.
C - RULE EDITOR
56
If [X] values is equal to 0, this would produce a division-by-0 error. If [X] and [Y] are very small, [X] ~= [Y] will be TRUE if both values are within .000001 of 0.
C - RULE EDITOR
57
If a formula contains embedded variables (variables in double square brackets, [[]], that will be replaced by their values before the formula is evaluated), the text of the formula is not known until Runtime, and will not be checked for syntax when it is entered . At Runtime, the double square bracket expressions will be replaced with their values and the expression's syntax will be checked. If a syntax error is found, it will be reported then. The syntax checker evaluates constant expressions and would not allow ([X]/(1-1)) because the program would determine that the expression would be a division-by-zero error.
where the value assigned to [Y] will be 5 or 10, based on the value of [X]. The conditional operator can be used with other expressions in tests: [Z] < (([X] > 0) ? ([X] + [Y]) : ([Y]/[X])) which tests if [X] is greater than 0. If it is, the test [Z] < [X]+[Y] is made. If it is not, the test [Z] < ([Y]/[X]) is made.
C - RULE EDITOR
58
The conditional operator is very useful and can reduce the number of rules in some cases The two rules: IF AND THEN Qualifier 1 is true [X] > 10 [Y] IS GIVEN THE VALUE IF AND THEN Could be replaced with: IF Qualifier 1 is true THEN [Y] IS GIVEN THE VALUE [X]>10?([X]+5):100 The conditional operator can also be used in cases where data could lead to a division-by-zero error. For example: [Y] IS GIVEN THE VALUE ([X] < > 0) ? (100/[X]) : 10000000 where [Y] is normally given 100/[X], but if [X] is equal to zero, instead of getting an error message, [Y] is assigned a large value, 10000000. Qualifier 1 is true [X] <= 10 [Y] IS GIVEN THE VALUE 100 [X] + 5
C15.16: Functions
The following functions are supported. SIN( ) COS( ) TAN( ) ASIN( ) ACOS( ) ATAN( ) EXP( ) LOG( ) LOG10( ) ABS( ) Sine in radians Cosine in radians Tangent in radians Arc sine in radians Arc cosine in radians Arc tangent in radians Exponential function base e Log base e Log base 10 Absolute value
C - RULE EDITOR
59
SQRT( ) Square root INT( ) Integer part (rounded down) MIN( ) Minimum MAX( ) Maximum TOPREC( ) Number of records in a dBase file QCHK( ) Qualifier status AGE( ) Time since value was set The functions evaluate the expression in parentheses and perform the appropriate function on the result. The parenthetical expression must immediately follow the function name without a space in between.
C - RULE EDITOR
60
C - RULE EDITOR
61
MAX(x1, x2, x3 ...) Returns the argument with the maximum value. (The number of arguments is not limited.) The MIN and MAX functions can be used in the custom formula confidence mode for systems where the confidence of a choice is the minimum (or maximum) of the confidences of the IF conditions. Example: MAX([X],[Y],[Z]) Will return the value of either [X], [Y] or [Z], whichever is highest. TOPREC("<filename>") Returns the number of records in the dBase III database file specified by the filename. This is most often used in the command language. Example: TOPREC("price.dbf") Will return the number of records in the dBase file "price.dbf." INSTR(STR1, STR2) Returns TRUE if STR1 is in STR2 or else it returns FALSE. If TRUE, the value is NOT 1, it returns the string offset where the sub-string was found. If FALSE, it returns 0. The test is case sensitive. Examples: INSTR("in", "incalculable") ==1 INSTR("able", "incalculable") ==9 INSTR("on", "incalculable") ==0 INSTR(STR, STR, BOOLEAN) Same as INSTR except it allows you to specify whether or not it is case sensitive. (If there is a third operator, EXSYS will automatically use this form.) Examples: INSTR("in","INCACULABLE",TRUE) ==0 INSTR("in","INCALCUABLE" ,FALSE) ==1
C - RULE EDITOR
62
GETENV(string) The string is the name of an environment variable. This function returns the value of the environment variable as a string. This function must be used as a string. Example: GETENV("EXSYS") will return the string value of the environment variable EXSYS. TOUPPER(string), TOLOWER(string) Converts the string to upper or lower case.
C - RULE EDITOR
63
C - RULE EDITOR
64
C - RULE EDITOR
65
CHOICE LIST
Assign Value OK
Edit Delete
After selecting a choice, enter the confidence value that you wish to assign to the choice in the edit box. Depending on the Confidence System chosen at the start of the program, this is 0 or 1, 0-10, -100 to 100, increment/decrement value or a custom formula. (If a custom formula system is used, see Section C40 for more information.) Click the OK button and the text of the choice plus " - Confidence =" and a value will appear in the rule.
C - RULE EDITOR
66
CHOICE LIST
>
>=
<
<=
Select a choice by clicking on a choice in the list of choices. Then select a test expression by clicking on the appropriate radio button in the Test Type section. The tests available are: <, >, =, <=, >=, or < >. Then enter the comparison value to test against. The program asks for the value with which to compare the choice's final score. This information is input as an integer. Then click the OK button and the full text of the condition will appear as part of the rule. (If you are using the custom formula mode, see Section C40 for special instructions on the comparison tests.) If the system finds no way to determine the value of a choice used in a rule's IF part, an error message is displayed when running the expert system. This can happen if no valid rules assign a value to the choice. This mode can be changed with system configuration options.
C - RULE EDITOR
67
C - RULE EDITOR
68
C - RULE EDITOR
69
1. Highlight a condition in a rule by clicking it. 2. On the menu line, pull down the Rule menu and select Condition Cut or Condition Copy. (Both of these commands copy the condition into a buffer, but Cut also deletes the condition.) 3. Select another rule, or another part of the same rule in Insert mode. 4. On the menu line, pull down the Rule menu and select Condition Paste. 5. If possible, the selected condition will be added to the rule in the same place as if it were a new condition. Some operations are logically impossible, for example in the THEN part, choices are assigned values, while in the IF part their value is tested. It would not make sense to move a THEN syntax choice condition to the IF part. EXSYS will check for such errors and will not allow you to perform such operations. If a condition is copied or cut from the IF part of a rule, it can only be pasted into the IF part of another rule. If a condition is copied or cut from the THEN or ELSE part of a rule, it can only be copied to the THEN or ELSE part of another rule.
C - RULE EDITOR
70
Note: To move conditions, use the Condition Cut, Condition Copy and Condition Paste commands. The standard Cut, Copy and Paste commands under the Edit menu are used in some places in EXSYS to move text, but they can not be used to move rule conditions. To the developer, conditions appear as text, but internally they are far more complex structures. Only the Condition Cut, Condition Copy and Condition Paste commands perform all of the required operations and checks.
C - RULE EDITOR
71
C22.1: Note
The note can supply some additional information to the user. The note has no effect on the program and is used only to provide information to the end user. Whenever the rule is displayed, the note will also be displayed.
C - RULE EDITOR
72
The notes associated with rules that fired can be easily incorporated in a report using the report generator command NOTE. This can create a text explanation of how the system reached its conclusions. To add a note, click the Note box. A edit box will be displayed with the existing note if there is one. Make any changes and click OK. If there is NOTE text, the Note box will be checked.
C22.2: Reference
A reference can also be associated with a rule. This, like the note, is optional. The reference usually contains the source of the knowledge represented in the rule. If users question the rule, they can refer to the reference. The reference, like the note, may also be used to provide more information to the user. Unlike the note, the reference is displayed only when the user requests it. References from rules which fired can also be incorporated in a report using the REFERENCE command. To add a reference, click the Reference box. An edit box will be displayed with the existing reference, if there is one. Make any changes that you think are necessary, then click OK. If there is reference text, the Reference box will be checked.
C22.3: Name
A name can also be associated with a rule. The name is optional, but is very useful when referencing the rule from the command language or report generator. Names allow the knowledge base to be divided into sections when it is run or referenced. Names also allow rules to be moved with the knowledge base without affecting numeric referencing from the command language or report generator. For example, the command language command RULES 1-20 will run the rules numbered 1 to 20. However, if the rules are moved or another rule is added, the Command Language command would have to be corrected. If, instead, each of the relevant rules had a name that started with the letter 'A', we could just use the Command Language command RULES A*. This would run all rules that have names that start with 'A'. This is not affected by position or re-numbering. Rule names are also useful when editing rules since the rule edit selection dialog box displays all the rules by name as well as number. Adding a meaningful name can make the rule much easier to find later.
C - RULE EDITOR
73
To add a name, click the Name box. An edit box will be displayed with the existing name, if there is one. Make any changes that you think are necessary, then click OK. If there is name text, the Name box will be checked.
C - RULE EDITOR
74
C - RULE EDITOR
75
C - RULE EDITOR
76
it would also display the rule, since the IF condition in the new rule implies that the IF condition in this rule would be true. When checking rules, the program does not consider the effect of having an IF condition false to add ELSE conditions. When possibly conflicting rules are found, the program will be display a list of the possibly conflicting rules:
If Rule 75 were true, the listed rules could also apply
2 7 23 34
Clicking Accept New Rule will add the new rule to the knowledge base. Selecting a rule from the list and clicking Edit / Examine Rule will display the selected rule. Both the new rule and the selected rule will be displayed for editing. Switching Off Rule Checking The program supplies the option of switching off the rule-checking function. Checking can be canceled by selecting the Parameters item from the Options menu, and checking the No button marked Check New Rules for Consistency. Turning rule checking off is a good idea when mathematical expressions are used because the rule checker does not check the validity of those expressions.
C - RULE EDITOR
77
For example: IF AND THEN THIS IS VALUE 1 [X] < 20 CHOICE 1 : Probability = 3/10 The rule checker might display the following rule, that had already been entered, as also possibly true: IF AND THEN THIS IS VALUE 1 [X] > 20 CHOICE 2 : Probability 5/10 This program will not recognize that [X] <20 and [X]>20 cannot both be true. Mathematical expressions are ignored when checking rules for consistency. This approach was used because, for complex equations, determining if two or more equations can be simultaneously true is difficult, especially when variables are involved.
C - RULE EDITOR
78
Add Rule Edit Rule Delete Rule Move Rule Use Rule Names Qualifier List Variable List Choice List Condition Cut Condition Copy Condition Paste
To delete a rule, go to the main menu bar and pull down the Rule menu. Select Delete Rule. A window will be displayed, allowing you to select the rule to delete either by name or number. Select a rule and click the OK button. The rule you have selected will be displayed along with a window asking you to confirm that this rule is to be deleted. If you click YES, the rule will be deleted and all other rules will be re-numbered accordingly. Any rule windows open for editing will also be re-numbered.
C - RULE EDITOR
79
Add Rule Edit Rule Delete Rule Move Rule Use Rule Names Qualifier List Variable List Choice List Condition Cut Condition Copy Condition Paste
Rules are tested in the order that they occur. Forward chaining systems are particularly sensitive to rule order, but even backward chaining systems will test the rules in order. Sometimes you may want to move a block of rules to a particular place in the system. To move a block of rules, go to the main menu bar and pull down the Rule menu. Select Move Rule. A window will be displayed, allowing you to select the block of rules and destination either by name or number.
C - RULE EDITOR
80
Name:
Number: 1 2 3 4 5 6 7 8 Last
OK
Cancel
To select the start of the block, click Move from rule and select a rule. To select the end of the block, click to Rule and select a rule. To select the destination for the rules, click Before rule and select a rule. To move the block to the end of the rule list, click the To end button. When you click on the OK button, the block of rules will be moved and all rules will be re-numbered accordingly. Any rule windows open for editing will also be re-numbered if necessary.
C - RULE EDITOR
81
Selecting Print from the File menu allows you to print the knowledge base to a disk file or to a printer, in several different forms.
Print to PRINTER Print to FILE Standard Output Format Rule Compiler Format C Code Replacement for Rules
Rules Qualifiers / Variables Cross Reference List Formulas One Per Page Continuous Small Font Cancel OK
Having a print-out of the rules, qualifiers, variables, and choices is sometimes useful while developing an expert system. Printing in the rule compiler or C code formats allows special editing operations or embedding of the rules.
C - RULE EDITOR
82
To send something to a printer or file, click the Print to Printer or Print to File button. Normally, only the Standard Output Format would be sent to a printer. If a file is selected, enter the name of the file. Important Note: When selecting a filename, do not give it the same name as one of the existing expert system filenames or the expert system will be destroyed. Select a format for the output. The Standard Output Format is a readable form without any special syntactical characters. In the Standard Output format, you can select which parts of the knowledge base you wish to print. The Rule Compiler Format adds the special syntactical control characters and format needed by the EXSYS Rule Compiler. Text in this format can be edited with a text editor and then recompiled using the Rule Compiler. (See Chapter K for more information on the Rule Compiler.) If this format is chosen, the output should be sent to a disk file. The C Code Format outputs a C Code replacement for the rules which can be used with EXSYS Linkable Object modules to embed the rules in a single executable file. The C Code is only useful when used with EXSYS Linkable. If this format is chosen, the output should be to a disk file. The Small Font box should be selected to print the rules to a printer using a small font. The default font is too large on some printers and a smaller font may work better for your needs. However, be aware that not all printers support a small font.
C - RULE EDITOR
83
To display the list of qualifiers, go to the main menu bar and pull down the Rule menu. Select Qualifier List. The qualifier window will be displayed. This is the same window as adding a qualifier condition to a rule. Once a qualifier is selected, it can be edited by clicking the Edit button or it can be deleted by clicking the Delete button. A new qualifier can be added to the list by pressing the New Qual button. The new qualifier window is the same as adding a new qualifier during the editing of a rule. To display the list of variables, go to the main menu bar and pull down the Rule menu. Select Variable List. A window will be displayed, allowing you to select a variable. This is the same as selecting a variable when adding a math condition to a rule. All the options for editing the variable are active. To display the list of choices, go to the main menu bar and pull down the Rule menu. Select Choice List. A window will be displayed, allowing you to select a choice. This is the same as selecting a choice condition to a rule. All the options for editing the choices are active.
C - RULE EDITOR
84
To run the rules, go to the main menu and pull down Options. Select Run. The rules will run as if they were being run from the Runtime. (See Chapter D on the Runtime for details.)
C - RULE EDITOR
85
To return to the Edit mode during a run, select Cancel Run from the Options menu. The run will be terminated and EXSYS will return to the edit mode.
C - RULE EDITOR
86
To Change the general parameters of the knowledge base (rule display, derivation mode, starting and ending text, etc.), select Parameters from the Options menu. The same window as seen at the start of a new knowledge base will be displayed. Some items which can only be set at the creation of a new knowledge base (Confidence mode) will be disabled. Make any desired changes and click the OK button.
C - RULE EDITOR
87
C32.1: Introduction
Validating an expert system should be a major part of any expert system development project. It is important to make sure that end users will receive valid answers to any input. The EXSYS automatic validation function greatly simplifies and automates this process. EXSYS supports two methods of validation testingsystematic and random. Systematic testing allows all possible combinations of input to be tested for a variety of possible errors. If the expert system is large, and systematic testing the entire system would take too long, systematic testing of portions of the system or random testing of the entire system can be performed. Three files are producedtwo types of tree diagrams, and an error report file. The tree diagram shows all the possible combinations of input and the resulting output of the system. Regardless of the complexity of the logic of the system, the input and output can always be diagrammed as a tree. The trees can be examined with a special display routine in EXSYS that enables you to scroll through the tree diagram. The nodes on the diagram are written in an abbreviated form (something like, Q3:2 which represents qualifier number 3 value 2). When the tree diagram is displayed, clicking the node expands the abbreviated form to the full text form of the qualifier or variable. The two types of tree diagrams produced are linear and branched tree diagrams. These two diagrams are equivalent in information
C - RULE EDITOR
88
content, but are diagrammed differently. The branched tree diagram graphically shows the branching in the system. For example:
Q7:1
[X]:30
Q4:1 >>> C3:7 C2:1 Q4:2 >>> C3:5 Q4:3 >>> C1:2 C4:8 Q4:1 >>> ERROR: Q6 could not be derived Q4:2 >>> C5:7 Q4:3 >>> C6:6 Q9:2 Q11:1 Q11:2 Q11:3 Q11:4 >>>C4:6 >>>ERROR: Variable out of >>>C5:2 >>>C5:7
[X]:35
[X]:40
Q7:2
>>>Error: No choices set >>>ERROR: Q4 loop error >>> C6:3 C5:1 >>> C3:4
A branched tree diagram is convenient for seeing the overall structure, but if a particular set of input produces an error, it may take some scrolling to read all the information on the input. In a linear tree diagram, all the node values for a branch are displayed on a single line. If you took the same information from the above diagram and assembled it into a linear tree diagram, it would be displayed as:
Q7:1 Q7:1 Q7:1 Q7:1 Q7:1 Q7:1 Q7:1 Q7:1 Q7:1 Q7:1 - [X]:30 - Q4:1 >>>C3:7 C2:1 - [X]:30 - Q4:2 >>>C3:5 - [X]:30 - Q4:3 >>>C1:2 C4:8 - [X]:35 - Q4:1 >>>ERROR:Q6 could not be derived - [X]:35 - Q4:2 >>>C5:7 - [X]:35 - Q4:3 >>>C6:6 - [X]:40 - Q11:1 >>>C4:6 - [X]:40 - Q11:2 >>>ERROR: Variable out of .. - [X]:40 - Q11:3 >>>C5:2 - [X]:40 - Q11:4 >>>C5:7
In the linear tree, it is easier to follow the data that lead to the conclusion, especially in large trees. However, it is not as easy to see the overall structure. When random testing is selected, only a linear diagram will be created. Due to the random nature of the testing, the data will not be tree structured. The error file contains reports of any detected errors and the input which produced the error. In the random mode, only the error file is produced.
C - RULE EDITOR
89
The validation function will detect and report combinations of input that 1. Produced no conclusions. 2. Failed to derive needed qualifiers or variables that should be derived. 3. Created loop errors. 4. Assigned a variable a value which is outside of the limits specified for the variable. 5. Assigned more values to a qualifier than the maximum number allowed for that qualifier. 6. Special custom tests designed with the report generator. Only the combinations of input that might actually be supplied by an end user are considered. This usually reduces the number of tests that must be run to much less than the total number of possible combinations of data.
A menu is displayed. Select either: 1. Test the system systematically 2. Test the system randomly
C - RULE EDITOR
90
A systematic test will consider all possible combinations of input within the ranges specified. This is the best type of validation, however the size of the file may get large very quickly. If the number of combinations becomes impractically large, limit the scope of the systematic test or use random testing. Random testing will consider random sets of input. This may not cover all possible input, but for large systems or systems with many numeric variables, it will allow testing of many possible inputs.
C - RULE EDITOR
91
Find
Find Again
Name
List of Qualifiers
Set ALL Qual. to ALL Values Save to File Read from File Cancel
Each of the qualifiers in the list will be preceded by a 'D'. This indicates that the qualifier should be derived from other data in the system. Failure to derive a value would be considered an error. All of the qualifiers that are intended to be asked of the end user (and assigned values by the validation function) must be marked. If a qualifier is not to be derived, the test can include all or only some of the qualifiers values. Limiting the number of tested values will reduce the time to perform the test. To mark all qualifiers to use all values, click the Set ALL Qual to ALL values button. All of the qualifiers will now be preceded by an 'A', indicating that all their values are to be used. Individual qualifiers can be set by selecting the qualifier in the Qualifier list. The values associated with the qualifier will be displayed in the Values list window. The current state of the qualifier will be indicated. To mark the qualifier to be derived, select the qualifier and click the Derive button. To mark the qualifier to use all values, select the qualifier and click the All Values button. To mark the qualifier to use only some values, select the qualifier and click the individual values to be used. The Limited Test button will automatically be selected.
C - RULE EDITOR
92
To save the parameters set to a file, click the Save to File button. You will be asked for the name of the file in which you wish to save data. This is useful when there is a complex set of parameters for the qualifiers. To read the parameters back from a file, click the Read from File button. You will be asked to select the file containing the parameter data. If the knowledge base has been modified since the data was saved, EXSYS will notify of this. The parameter data will be read back from the file and displayed in the window for additional editing. When the parameters are set correctly, click the OK button. After the qualifiers are set, the variables must also be set.
Variable List
Derive Single Value Range of Values Lower: Upper: Step: Save to File
Text of variable
OK
At the start, each of the variables will be preceded by a 'D', indicating that they must be derived. To have EXSYS automatically test each of the variables, it must be marked to have a single value or a range of values. If it has a single value, only that value will be used. In the systematic validation case, the program will ask for an upper and lower bounds and an increment. The validation test will automatically consider variable values from the lower bound to the upper bound by increasing the value by the specified increment. This
C - RULE EDITOR
93
data will be combined with the selected qualifiers, so be careful when you choose an increment. If there are 10 increments between the lower and upper bounds, it will take 10 test cases every time the variable is tested. If there are multiple variables, the number of possible test cases can get quite large. Therefore, it is better to use the Random testing mode with multiple variables. For random validation, the program will only ask for upper and lower bounds. The value will be randomly chosen at any point between these boundsnot on specific increments. Select a variable by clicking on it. The text of the variable will be displayed at the bottom of the window. To mark the variable to be derived, select the variable and click on the Derive button. To mark the variable to be given only a single value, select the variable and click on the Single Value button. You will then be asked for the value you want to use. To test the variable over a range of values, select the variable and click the Range of Values button. You will then be asked for the lower, upper, and (if systematic testing) the incremental step. The type of variable is indicated by the Numeric, String and Text Only buttons. You can not change the type of variables, this in only for your information. Text- only variables can only be derived. This is because they can only be used in the THEN/ELSE part of rules and will never be asked anyway. String variables can only be derived, or given a single value. To save the parameters set (plus the parameters set for the qualifiers) to a file, click the Save to File button. You will be asked for the name of the file in which you want to save the data. To read parameters saved to a file, click the Read from File button. You will be asked to select the file to read. Remember, the file read may also set the qualifier parameters to new values. To return to edit the qualifier parameters, click the Return to Qualifiers button. When the variable parameters are set correctly, click the OK button. If random testing was selected, you will now be asked how many random tests you wish to run. EXSYS will now start the automatic validation process. A window will be displayed indicating that automatic validation is being used and giving the option to cancel the test.
C - RULE EDITOR
94
In the random mode, after the 5th test is run, the system will start to calculate the approximate time to completion based on the average time spent on the tests run thus far. In the systematic mode, the number of the test will be displayed, but until the rules are actually run, the system has no way to tell how many tests actually must be run. Because only possible combinations of input that might be supplied by a user are considered, the number of tests is usually far smaller than the total number of possible combinations of data. You can stop the run at any time by pressing a key and waiting for the current record to finish. When the system finishes the tests, the diagram of the test results will be displayed.
If you click on the Stop Validation Tests button before the tests are completed, you will cancel the remaining tests and be able to examine results of the tests run to that point. If you let the test run to completion, you will be able to examine all the results.
Error File
All errors are written to the file name <knowledge base name>.ERR. It will show all cases where the input 1. Produced no conclusions 2. Failed to derive needed qualifiers or variables that should be derived 3. Created loop errors 4. Assigned a value to variable which is outside the limits specified for the variable. 5. Assigned more values to a qualifier than the maximum number allowed for that qualifier
C - RULE EDITOR
95
The report includes the error and the data which produced the error. Since after detecting an error the system continues testing, the error file may contain multiple error reports.
Tree Files
In addition to the error file, two tree files will be created. (The random mode produces only an error file and a linear file.) If you do not want the tree files created, and only want the error file, use the configure option ERROR_FILE_ONLY. Usually is only done if you suspect your available disk space is insufficient for the tree files. The file <knowledge base name>.TR1 will contain a list of all of the data for all the runs. If the validation is systematic, the data will be arranged as a tree, but each line will contain all the input data. In systematic test mode, a second file will be created, <knowledge base name>.TR2. This is a branched tree diagram showing the possible user input and resulting output. Both of these files are ASCII files and can be examined or printed with a text editor. They can also be examined with a special display routine in EXSYS. In the random testing mode, the <knowledge base name>.TR1 file will contain data and results from all the random test cases that were run. The values are selected randomly, so they can not be converted to a branched tree diagram. The tree diagram shows how user input relates to the expert system's results. In a systematic test, all possible combinations of input will be diagrammed. If the tree is too large, you can reduce the scope of the tree by limiting some qualifiers to one, or a few, values. For a systematic test, you will be asked if you wish to examine the branched or linear tree diagram. For Random tests, only the linear diagram is available.
If you select the Branched diagram, a window will be opened with the tree diagram.
C - RULE EDITOR
96
Q1:1
Q2:1 Q2:2
C1:5 >>> >>> >>> >>> Error: No Results C2:4 C2:7 C2:1
Q2:3
Q3:1 Q3:2
Q1:2 Q1:3
OK
The tree diagram displays the structure of the knowledge base by diagramming the input and output. Even very complex and non-tree structured systems can be diagrammed this way. The diagram uses a shortened notation for the qualifier and variable values. For example Q1:2 means the second value of qualifier 1. To see the full text of the qualifier and variable for the condition described at the node, click on the node. A window will open with the full text of the qualifier, variable or choice. The tree diagram can be resized using the resize control on the window. You can scroll horizontally or vertically in the window. When you are finished examining the diagram, click the OK button. The information from the tree diagram is stored in the files <knowledge base name>.TR1 - Linear diagram <knowledge base name>.TR2 - Tree Diagram <knowledge base name>.ERR - Error data and rule use
If a report generator file is used, be sure to use the /A option in the FILE command to append each record of data to the report file. For example suppose you wish to know all cases where two specific choices are simultaneously given a high value. The following will list all cases of input which resulted in the value of choice 5 and choice 7 both being greater than 8. FILE CHK.RES /A C5 <=8 /G:end C7 <=8 /G:end "*******************************" "Choices:" C " " "Input:" INPUT :end close If the value of choice 5 is less than or equal to 8, the /G option will cause it to go to the end of the report file. If choice 5 is greater than 8, choice 7 will be tested. If choice 7 is less than or equal to 8, the report file will also go to the end. If both values are greater than 8, the data output commands will be used and the choices and input data will be written to the file. This technique can be used to produce customized tests that are systematically applied to all possible combinations of input.
C - RULE EDITOR
98
C - RULE EDITOR
99
To examine an existing tree or linear diagram file, select Examine Tree Diagram from the Options menu. You will be asked which type of diagram you want to examine. The diagram will be displayed in the same way as it is after a validation test run.
C - RULE EDITOR
100
C34: Notebook
File Edit Rule Options Run Cancel Run Parameters Validation Examine Tree Diagram Notebook Help KBfiles Questions
EXSYS maintains a system notebook file for each expert system. Notes can be added in this file by the developer or end user on various aspects of the system. This can be a way to get end user feed-back on a fielded system, or suggestions for enhancements. The file is named <knowledge base name>.NBK. To make a note in the knowledge base notebook file, go to the main menu and pull down Options and select Notebook. You will have the option to Write, Read or change the notebook file name.
Notebook Option Notebook Functions: Write to Notebook Read from Notebook Change Notebook File CANCEL READ WRITE
Notebook File:
To write, click Write and enter the note that you want to add. The text you enter will be added to the notebook and then will be date stamped with the current date and time. To read, click Read and the notebook file will be displayed. To change the name of the notebook file to be used, edit the file name displayed at the bottom of the window.
C - RULE EDITOR
101
To display the system help windows, select Help from the Options Menu. This is the same help system described previously.
C - RULE EDITOR
102
In addition to the .rul and .txt files created by the EXSYS Rule Editor, there are also several associated files which can be created and edited with a text editor. To make it easy to modify these files from within EXSYS, a small text editor is available. The details of commands available in each of these files is discussed in the appropriate section of this manual. Select the file to edit, and an edit window will appear, allowing you to enter or edit the text. If Other is selected, you will be asked for the name of the file to edit.
C - RULE EDITOR
103
Almost all the items in the Questions menu are identical to those in the Questions menu of the Runtime program, and are discussed in Chapter D on the Runtime. The one exception is the Trace Window selection which is only found in the Editor.
C - RULE EDITOR
104
When developing an expert system, it is often useful to trace what rules are firing, where variables are being set, and a variety of other actions. This is especially true when tracking down a bug in the rules. There are two ways to create a history of a run. The first is to use the configure option TRACE=file. This will create a history of the run in the file specified. The use of TRACE= is covered in Chapter E on Configure Options. The second way is to create a trace window. This is done by selecting Trace Window from the Questions menu. A trace window will be created. All user or external program input will be written to the window. Also, as each rule fires and adds data to the system, the information will be added to the window.
C - RULE EDITOR
105
Trace Text
OK
Find
Find Again
As the expert system executes, a history of the execution will be written to the trace window. The trace window can be brought to the front at any time by clicking in it. To check on a specific data item, click the Find button. Enter the name of the data item that you want to find and the trace window will scroll to the item. Click the Find Again button to see the next occurrence of the item in the file. To scroll the text in the window, use the scroll bar. When you are finished with the trace window, click the OK button.
C - RULE EDITOR
106
C39: Hypertext
EXSYS supports hypertext to provide information on key words used in the expert system. To designate a word as a hypertext key word, it is preceded and followed by ^^. For example, to make EXSYS a hypertext keyword, it would be entered as ^^EXSYS^^. This makes it easy to add hypertext help to an expert system. Virtually all windows in EXSYS support hypertext during the running of the system, including the screens to ask for qualifiers or variables, display results, display known data or rules, and other actions. Hypertext is not supported in the edit mode. In the GUI versions of EXSYS, hypertext keywords are highlighted in blue. A click on a hypertext keyword will bring up the screen associated with that word. For detailed information on using hypertext, see Chapter I. The hypertext custom screens are stored in the file: <knowledge base name>.SCR and are marked in the screen file with ~~keyword. See the Chapter I on the GUI Custom Screen Language for details on creating the hypertext screens.
C - RULE EDITOR
107
The first four systems all function similarly in terms of user input and interface. However, the fifth system (custom formulas) has significant differences. The custom formula confidence system in EXSYS allows developers to supply their own formulas for the combination of confidence factors. This is by far the most complex of all the confidence systems available in EXSYS and should be used only by advanced users who need the special flexibility this approach offers. In this system, the end users can be asked to supply a confidence value for the data they provide about qualifiers or variables. This user-supplied confidence rating may be used to calculate the confidence in the choices or in backward chaining to calculate the confidence of other qualifiers or variables. A backward chain may not only determine a value for a variable or qualifier but may also determine the confidence in that qualifier or variable. This confidence value can be displayed to the user at the end of a run.
C - RULE EDITOR
108
Confidence variables are maintained as double precision floating point values, so the confidence values are not limited to integers. The confidence variables can be used in combination with other variables in formulas for derivation of confidence values for other qualifiers, variables or choices. When a new variable or qualifier is used in a knowledge base, the program asks the developer a series of questions to determine the options that are to be used. The options include a button labeled Conf Options. If the Custom Formula Confidence mode was selected, this button will be active. Clicking this button allows you to set parameters for how the confidence of the qualifiers and variables will be handled.
C - RULE EDITOR
109
Display Confidence Value Ask User for Confidence Value Minimum Maximum Initialize Confidence Value Initial Value
o.oo
Cancel
OK
Display Value
If the variable or qualifier is to be displayed, the confidence value assigned to it also can be displayed or not, as desired. If the confidence has been derived, it may be best to display it. If no derived confidence is associated with the variable, it may be better to simply display the qualifier without a confidence value. To display the confidence value, click the Display Confidence Value box.
C - RULE EDITOR
110
For example, you could have: Choice 1 Confidence = [%C1]+[%C2] where Choice 1 is given a value equal to its current value plus the final value of Choice 2. This is the type of operation the custom formula system can do easily but which is very difficult to do in other confidence systems.
C - RULE EDITOR
112
In many systems, it is often better to ask the user questions such as, The color was seen 1 very well 2 well 3 poorly which the end user is more likely to answer consistently, and then convert these to numeric values internally with rules like, IF The color was seen very well THEN [%[COLOR]] is given the value 90 IF The color was seen well THEN [%[COLOR]] is given the value 50 IF The color was seen poorly THEN [%[Color]] is given the value 20
C - RULE EDITOR
113
C - RULE EDITOR
114
For example, if you had the following rule, IF ....... THEN [X] IS GIVEN THE VALUE [A] + 1 [A] IS GIVEN THE VALUE 12 you would not expect the program to fire the second THEN condition to establish a value for [A], even though it is relevant to the calculation in the first condition. The "[A] is given the value 12" is ignored when assigning the value to [X]. This is a very simple, and easy to avoid example (simply reverse the THEN conditions). However, the same effect can happen in a more complex way. Consider the following rules: Rule 1 IF [B] > 0 THEN .......... Rule 2 IF ........... THEN [X] is given the value [A] + 1 [B] is given the value ........... Rule 3 IF ................ THEN [A] is given the value [B] + 1
C - RULE EDITOR
115
When Rule 1 is tested, the program determines it needs the value of [B]. It invokes rule 2 to determine a value for [B] (We will assume rules 2 and 3 are true). The first condition in the THEN part of rule 2 is applied. It requires that the value for [A] be known. To determine the value for [A], rule 3 is invoked. It also requires a value for [B]. Since the program has already used rule 2 (even though it has not completed the adding of the THEN parts), it cannot again invoke rule 2. The program must find another way to determine [B]it would use other rules or ask the user, but it would not use the second THEN condition in rule 2 when calculating [A]. The program would then finish adding the first THEN condition in rule 2 and would move on to the second. [B] would be assigned a value after it had been used to assign a value to [A] in rule 3. This may result in [A] having an incorrect value. EXSYS will detect this error of logic and warn the user. If the situation described above occurs, you will get the error message POSSIBLE LOGIC ERROR: Loop in ([variable name] or Qualifier number) in Rule #. This error message means the variable or qualifier cannot be fully derived because of the problem described above. That variable or qualifier should be placed, with any preceding conditions it needs, into a second rule with the same IF conditions. This could be prevented by not having the THEN part of rule 2 include assignments to two variables that are derived from one another in other rules. If Rule 2 were broken into two rules, one for [X] and one for [B], the value of [B] would be fully calculated before being used to calculate [A]. Here is an example: IF ........... THEN [X] is given the value [A] + 1 and IF ........... THEN [B] is given the value ........... It is not practical to force the program to apply the second condition in the THEN part of 2 prior to the first, since the first condition could have some effect on the value of the second, resulting in the same problem in a slightly different set of rules.
C - RULE EDITOR
116
D - RUNTIME
When you select Open, a list of all of the files with a .rul extension is displayed. Double click on the desired file, or select a file and click on the Open button. Note: For the Macintosh, all files will be displayed. The extension past the period in the name is ignored. Select any of knowledge base files (.RUL, .TXT, .CMD, .SCR, .HYT, .HLP, etc.).
Passwords
If the developer selected password protection, the program asks for the users Runtime password. When correct password is entered, the system continues. If the password is not known, click on the EXIT button to exit the system.
D - RUNTIME
To get help in using EXSYS: In Microsoft Windows, select About from the File menu, or press the F1 key. On the Macintosh, select About EXSYSP in the Apple menu. In all operating systems, select the Help item from the Options menu. This will go directly to the Help Topics dialog box.
File
Edit
Rule
KBfiles
Questions
D - RUNTIME
This will bring up the following dialog box. Click on the HELP button.
EXSYS Professional Editor Version 5.0 1083-1996 EXSYS, Inc. Albuquerque, NM
Cancel Help
In all operating systems an alternative is to select the Help item from the Options menu. This will go directly to the Help Topics dialog box.
Help topics
Fresh Window
Cancel
Help
Either double click on a help topic, or select a help topic with a single click and then click on the Help button. A window will display information on the selected topic. If you wish to have the help information on the topic placed in a new help window, click on the Fresh Window button.
D - RUNTIME
Help Information
Cancel
Prev
Next
Topics
Click on the Prev button to see the information on the previous topic in the help topic list. Click on Next to see the information on the next topic in the help topic list. Click on Topic to bring the help topic list window to the front. Click on Cancel when done. Clicking on Cancel in either the Help Topic window or the Help Text window will close both windows.
D - RUNTIME
D4: Notebook
File Edit Rule Options Run Cancel Run Parameters Validation Examine Tree Diagram Notebook Help KBfiles Questions
To make a note in the knowledge base notebook file, go to the main menu and pull down Options and select Notebook. You will have the option to Write, Read or change the notebook file name.
Notebook Option Notebook Functions: Write to Notebook Read from Notebook Change Notebook File CANCEL READ WRITE
Notebook File:
To write, click on Write and enter the note to add. The text entered will be added to the notebook and stamped with the current date and time. To read, click on Read and the notebook file will be displayed. To change the name of the notebook file to be displayed, edit the file name displayed at the bottom of the window.
D - RUNTIME
D - RUNTIME
Title
Author
To start the expert system, click on the Run Expert System button.
D - RUNTIME
Text
Continue
D - RUNTIME
OK
Select values from the Qualifier Value List by clicking on them. A click on a value will highlight the value. Some screens allow only a single value, others may allow multiple values. If the screen only allows a single value, clicking on another value will de-select the first value and select the second. If the screen allows multiple values, clicking on several will highlight each of them. To de-select a highlighted value, click on it again.
D - RUNTIME
10
As you select values, their respective numbers will appear in the box at the bottom of the screen. If you wish, you can type the numbers of the desired values desired into this box. When the correct values have been highlighted, click on the OK button. There is no Cancel button for a qualifier question. The expert system requires this information to continue processing. If you do not wish to continue, select Exit from the File menu. It is also possible to save the input already entered prior to exiting by using the Quit and Recover options. To ask Why the question is being asked, Undo a previous answer, get more information on the question, or display the current status, use the items on the Questions menu discussed later.
D - RUNTIME
11
OK
Enter a value to answer the question in the box at the bottom of the window. When the correct value has been entered, click on the OK button or press the Enter key. The value can be numeric or a string value depending on the nature of the question asked. For numeric values, the string can contain commas. The commas will be ignored in converting the value. There is no Cancel button for a variable question. The expert system requires this information to continue processing. If you do not wish to continue, select Exit from the File menu. It is also possible to save the input already entered prior to exiting by using the Quit and Recover options. To ask why the question is being asked, UNDO a previous answer, get more information on the question, or display the current status, use the items on the Questions menu discussed below.
D - RUNTIME
12
D - RUNTIME
13
To ask why a particular qualifier or variable question is being asked, select Why from the Questions menu. EXSYS will explain why the data is needed. Usually this results in the display of the rule that is currently being tested. If the data is needed because of backward chaining, there may be a series of rules displayed. There may also be some other explanation of why the question was asked. Here's an example: 1. The program may respond that the end user supplied the information. 2. The program may display a rule or rules that allowed it to derive the information. A rule used for derivation will have information about the condition being queried in its THEN or ELSE part. The rule used to derive the information will have already fired, providing the needed information. (EXSYS automatically calls all possible rules to derive needed information, rather than ask the user.) The end user could continue asking how the program knew the rules IF conditions were true. When a rule is displayed, there are a variety of options available to get more information about the rule. For more information, see Displaying a Rule. 3. The program may respond that it does not yet know whether the condition is true or not. This can occur when the user asks the program WHY in response to a question. The rule displayed will not have been fully tested yet. Such conditions will be displayed in blue.
D - RUNTIME
14
4. If the information came from an external program, the program will indicate which external program returned the data. 5. The program may indicate that particular statement is false and display the source of the information that determined the statement was false. In such a situation, the condition is displayed in red. 6. If a formula is questioned, the program displays a list of the values of all of the variables used in the formula. Clicking on any of the variables in the list will display information on the source of that value. With well written rules, tracing the logic of the knowledge base back through the rules which were used to derive information is easy. After displaying a rule, the program may either repeat the question originally asked or it may display another rule. Another rule is displayed if the first rule was only used to derive information needed by the second rule, and the second is the rule actually being tested. (One of the THEN or ELSE conditions in the first rule will be in the second rules IF conditions - this is backward chaining.) All of the questions asking for information about the rule are available. The program will continue showing the rules it is using to derive information until it reaches the base rule it is trying to test. Clicking on OK continues the programs run. If more than one rule was displayed, each time OK is selected, the program goes up one rule on the list being used in the derivation. Eventually, the program repeats the question originally asked.
D - RUNTIME
15
In some expert systems, the developer may have included additional information on what a question means, or where to find the answer to a question. This information is optional and may not have been necessary, or included. If there is additional information on the question being asked, Explain Question from the Questions menu will be active. If there is no information, this item will be inactive and can not be selected. To ask for more information, select Explain Question. A window will appear which explains the question in more detail. This explanation screen is designed by the developer with the custom screen language and may be of any form, but it should have a button labeled OK (or something similar) which allows you to exit the screen and return to the question. See Section I-12 for details on builing Custom Help screens.
D - RUNTIME
16
Sometimes, during the running of a system, an end user may realize that their answer to a previous question was incorrect. In EXSYS, it is possible to backup and correct the previous answer. The exact number of questions that can be undone is set by the developer. Most developers allow the user to correct between 3 and 10 previous answers. To undo a previous answer, select Undo Prev Answer from the Questions menu. You will be asked the previous question. If you wish to backup farther, select Undo Prev Answer again. You may continue backing up as long as Undo Prev Answer is active. When you reach the question which was incorrectly answered, enter the correct answer and processing will continue.
D - RUNTIME
17
EXSYS provides the option of storing input data, exiting before completing the program, and returning to the same point later. This option can be useful if the user needs to look up information for the program or must leave the program but does not want to lose the data already input. To save the input entered to a disk file, select Save Input from the Questions menu. You will be asked for the name of the file in which to save the data. The file may be any legal filename, except the name of the Knowledge Base. If a file with the same name already exists, it will be erased and replaced with the new data. After saving the input, you may wish to exit the run. Data saved can be read back into the system with the Recover configure option, or by selecting Recover Input from the Questions menu.
D - RUNTIME
18
Input saved with a Save Input command, or the SAVE command language command, can be recovered only at the start of another run. To indicate that data is to be recovered, use the configure option RECOVER or RECOVER=file. Alternatively, you may select Recover Input from the Questions menu when the expert system title screen is displayed. The only immediate effect of this will be to put a check mark beside Recover Input. This indicates that the recover mode is active. If there is already a check mark, selecting Recover Input will de-active it. If the configure option RECOVER has been used, Recover Input will be checked automatically. If recover mode is active at the start of a run, EXSYS will ask if you wish to recover data from a file. If you answer "YES", you will be asked for the name of the file. The data will be read in and processing will continue. To have the data read automatically without asking for user interaction, use the RECOVER=file configure option.
D - RUNTIME
19
To display all of the data known to the system, select Known Data from the Questions menu. This will create a Known Data window. It lists all of the data known. If you wish to know the source of any of the data displayed, select an item by clicking on it and click on the How button, or double click on the item. The source for the information will be displayed. The display may also include the rules if they are the source of the data.
KNOWN DATA
Known Data
OK
HOW
If the Known Data window is kept active while the system is running, each new item of data will be added to the window as it is asked of the user or derived from rules.
D - RUNTIME
20
D - RUNTIME
21
To display the current status of the choices in the system, select Display Choices from the Questions menu. This will create a Choice Data window. It lists the status of each choice. If you wish to know the source of any of the data displayed, select an item by clicking on it and click on the How button, or double click on the item. The source for the information will be displayed. Usually, the display is the rules that set the value for the choice.
CHOICE DATA
Choice Data
OK
HOW
ALL
The Choice Data window displays the choice and the value set. Initially, only choices with values over the threshold for choice display
D - RUNTIME
22
are shown. To see all of the choices, click on the All button. If a choice has a value of "None", that means no rules have fired assigning any value to the choice. A value of "None" is not the same as a value of 0, which means something has assigned a value of 0 to the choice. After the All button is clicked, the button label will change to > #, where # is the threshold value. To return the display to only those choices over the threshold, click on the ># button, which will return the button label to All. If the Choice Data window is kept active while the system is running, each new choice value will be added to the window as it is derived from rules.
D - RUNTIME
23
Rules can be displayed in EXSYS in many ways. Often asking for the source of a piece of data, or asking Why a question is being asked will result in the display of a rule. It is also possible to ask to see a specific rule by selecting Display Rule from the Questions menu. Select the rule to display by either name or number. The rule display is color coded. A condition displayed in RED is false, a condition displayed in BLACK is true and a condition displayed in BLUE is unknown. In addition, the status of the rule (TRUE, FALSE or NOT TESTED) appears on the top line of the window. (Note: "Not tested" may appear for a rule that is definitely true or false, it only indicates that the rule has not yet been used by the expert system.). Also the background color for the window indicates its status. A RED background indicates a FALSE rule, a GREEN background a TRUE rule and a BLUE background an untested rule. The color coding for the rules is updated as each new piece of data is added. If a rule is displayed during a run, it is easy to notice the color change from BLUE to GREEN indicating the point at which it fired. The menu bar also displays if the rule is true, false or unknown.
D - RUNTIME
24
FALSE
OK
Source
PREV
NEXT
Jump
Reference
Color Coding of Rules Condition TRUE BLACK Condition FALSE RED Condition UNKNOWN BLUE Rule TRUE Rule FALSE Rule UNKNOWN GREEN background RED background BLUE background
To examine the source of the information for any of the IF conditions, click on the IF condition to select it and click on the Source button, or double click on the item. To examine the numerically previous or next rule, click on the Prev or Next button respectively. To jump to another more distant rule, click on the Jump button, and select the rule to jump. It is possible to have multiple rule windows open on the screen. However, as the number of rules becomes large, processing may slow due to the need to update each rule as new data is added.
D - RUNTIME
25
A rule may have a note associated with it. Notes are used to provide additional information or to explain a complex rule in simpler terms. The note has no effect on the running of the rule. If there is a note associated with the rule, it will automatically be displayed. Rules often also have a reference for the source of the fact represented in the rule (e.g., personal observation, book, article). To examine the reference for the rule, click on the Reference button. The reference will be displayed. If no reference is available, the button will be inactive.
D - RUNTIME
26
Text
Continue
D - RUNTIME
27
0/1
If the developer selected the 0-1 System, the user sees a confidence values of 0 or 1 . A value of 0 means "absolutely no" and a value of 1 is equivalent to "absolutely yes". This mode has no real probability, only yes or no.
0/10
If the developer selected the 0 to 10 System, the user sees a confidence value between 0 and 10. In the rules this is displayed as a ratio with a denominator of 10. This mode is often encountered. In this mode, 0 is equivalent to "absolutely no". (A single rule assigning a value of 0 locks the value at 0 regardless of any other value the choice may have received from other rules.) A value of 10 is equivalent to "absolutely yes" and also locks the value for the choice at 10 regardless of any other values the choice may have received.
D - RUNTIME
28
Values of 1 to 9 represent degrees of certainty ranging from "very probably no" to "very probably yes". The values from 1 to 9 do not lock the value but are averaged to give the final value for a choice. For example: if the same choice appears in the three rules that had true IF parts with values of 3/10, 8/10, and 4/10, the final value for the choice will be the average - 5/10. If the values found were 3/10, 9/10 and 0/10, the 0/10 would prevail and the result in a final value of 0/10 despite the other values. If the values were 1/10, 3/10, and 10/10, the 10/10 would lock the value at 10/10 regardless of the other values. Values of 1 through 9 are averaged to a final value only if not over-ridden by a 0/10 or 10/10. The first 0/10 or 10/10 prevails and will not be changed even by another 10/10 or 0/10.
-100/+100
If the developer selected the -100 to +100 System, the values will be between -100 and 100. (In the rules this will displayed as a ratio with a denominator of 100.). In this system, values of 0 to 100 can be assigned but the values of 0 and 100 do not lock the value. The final value can be computed as an average of the probabilities or can be combined as dependent or independent probabilities. The first is a simple average of all of the individual values the choice received in the rules found to be true. The second combines the probabilities as if they were dependent probabilities. That is, the probabilities are multiplied as percents. For example, if choice appeared in two rules that were used, with values of 60/100 and 90/100, its final value would be 60% times 90% =54% for a final value of 54/100. The third way to combine the values is to treat them as independent probabilities. In this system, the combination of the two probabilities is 1 minus the product of 1 minus the individual probabilities. In the example above, this would be 1-((1-60%) * (1-90%))=96% for a final value of 96/100. If negative values are used only the average mode can be used.
Increment/Decrement
If the developer has chosen the Increment/Decrement Mode, points are added or subtracted from the total points for a particular choice. Final values may be between -10,000 to 10,000. In the rules, there will not be any ratios for the confidence values. For example, we might have "Choice 1 - Confidence=5". This means that if the rule fires, Choice 1 will get 5 points added to its total. At the end of the run, the total number of points is displayed. All choices getting values higher than a threshold will be displayed with the results. No values lock a choice, but giving a choice a large number of points can push it over the threshold value.
D - RUNTIME
29
Custom Formula
If the developer selected the Custom Formula Mode, the confidence statements for the choices have formulas in them. This mode allows developers to write their own formulas for the combination of confidence values. User-supplied confidence, derived confidence on variables or qualifiers, and numeric variables can be included in complex formulas to determine the confidence for a choice. This is a much more complex system to use and it is described in greater detail in Section C3.3.
Results
Results
OK
HOW
Change/Rerun
All
In most systems, the results of the run will be displayed at the end of a run. This includes all choices which received confidence values over the threshold value, and all qualifiers and variables which were flagged to be displayed with the results. Some systems may also display intermediate results, or may simply output the results to a file or pass data to another program to take some action. To ask the source for any of the items, select the item by clicking on it, and then click on the How button; or double click on the item. Initially only choices with values over the threshold for choice display are shown. To see all of the choices, click on the All button. If a choice has a value of "None", that means no rules have fired which assign any value to the choice. A value of "None" is not the same as a value of 0, which means value of 0 was assigned to the choice. After the All button is clicked, it will change to >#, where # is the threshold value. To display only those choices over the threshold, click on the ># button, which will return the button label to All.
D - RUNTIME
30
Data
RUN
Change
Cancel
Original Data
To change a data item, click on it to select it and click on the Change button, or simply double click on the data item. You will be asked the data item that you are testing. Select a new answer. The window will display the selected item highlighted and then display the new value. You may change as many data items as you wish. When you have finished modifying the data, click on the Run button. The data will run, possibly asking additional questions if the modifications lead to new rules firing, and then it will present the results. However, this time the results screen will have two columns of data, the original values and the values obtained as a result of the modified data. This allows side by side comparison of the effects of making the changes.
D - RUNTIME
31
The ability to change and rerun the data allows expert system models to be built and tested to see if an answer is vital to the final outcome or really has little effect. Experiment with Change and Rerun; it is a very powerful feature. If several changes to the input data were made, and the user wants to return to the original input, click on the Original Data button. The data will return to the original input values. To Cancel the change and rerun, click on the Cancel button.
D - RUNTIME
32
To exit the EXSYS Runtime, go to the File menu on the menu bar and select Exit.
D - RUNTIME
33
There are a variety of command line options available in EXSYS Professional. Command line options are given when the program is called from the operating system. For example: EDITXSP <filename> <command line options> or EXSYSP <filename> <command line options> The command line options must follow the file name and can only be used in the command line if you have specified a file name. Since EXSYS Professional has a large number of command line options, some with fairly long commands; it can be inconvenient to enter all these options each time an expert system is called. Also, you may wish to always use the same options for all your expert systems or for each time a particular expert system is run. Configure files can be defined containing the same command line options. The configure file will be read each time the system is run. The configure files are much more convenient, especially for final distribution of an expert system to end users.
E - CONFIGURATION OPTIONS
You can create the file EDITXSP.CFG with a text editor and list as many command line options as you wish. Each time the EXSYS Professional Editor program, EDITXSP.EXE is called, it will check for this configure file and use any options you have specified. Likewise, the file EXSYSP.CFG applies to the runtime program EXSYSP.EXE. NOTE: The editor configure file has no effect on the runtime and visa versa. If you have developed an expert system in the editor, and it behaves differently when you run it with the runtime, make sure the configure options are identical.
E - CONFIGURATION OPTIONS
E - CONFIGURATION OPTIONS
These three commands allow the user to change the connector words used in EXSYS qualifier conditions from and/or/not to other words. This makes it easier to use EXSYS Professional in languages other than English. For example, to change the AND connector to the German word UND, you can use AND=UND in the command line or configure file. In all rules and statements where EXSYS Professional uses qualifier conditions, the "AND", "OR" or "NOT" will be replaced by the text specified in the command. This will not change the "AND" or "OR" used to build rules.
E - CONFIGURATION OPTIONS
E - CONFIGURATION OPTIONS
E - CONFIGURATION OPTIONS
Normally EXSYS Professional uses the file <knowledge base name>.CFG to set configure options. This can be changed by using the command line option CFG=filename. The specified file will be used instead of the normal file. The files EDITXSP.CFG or EXSYSP.CFG will still be read, as will any other command line arguments. Note: This can only be used in the command line, EDITXSP.CFG or EXSYSP.CFG. Using this command in the file <knowledge base name>.CFG will have no effect.
E - CONFIGURATION OPTIONS
Allow Data from External Programs to be Modified During Change and Rerun CHANGE_EXT
The CHANGE_EXT option allows data from external programs to be displayed for modification during a change and rerun. Data from external programs is not normally displayed. Displaying this information is particularly useful for data that was returned from a program called with a /M option to allow multiple items of data to be returned.
E - CONFIGURATION OPTIONS
EXSYS Professional supports command files. A command file is an optional file which contains commands that override the usual operations of EXSYS. The default mode for EXSYS is backward chaining, using all rules with results displayed at the end. The command file can completely change the way in which rules are used. See chapter J for information on the command language. If there is no command language file present, EXSYS will use its default modes of operation. However, if the command file is present, EXSYS will use it. The default command file which EXSYS looks for is <knowledge base name>.CMD. For example, if the knowledge base was named ACCTS, EXSYS Professional would look for the default command file ACCTS.CMD. The default command file name can be changed with the command line or .CFG option COMMAND=<filename> in which case <filename> will be used as the command file. If the COMMAND= option is used, Professional will not look for <knowledge base name>.CMD.
E - CONFIGURATION OPTIONS
QUITOFF
HELPOFF LIMITOFF
The end use can circumvent the options that prevent rule display by editing the .CFG file. However, to ensure that your end user will not have access to the rule display, use the rule locking options with password protection.
E - CONFIGURATION OPTIONS
10
Automatically Reads a Series of Records of Data and Executes the Rules DATALIST DATALIST=<filename>
The DATALIST command tells EXSYS that there is a list of data in the file RETURN.DAT which needs to be read. The list can contain multiple sets of data for batch mode analysis. The program will behave as if an external program had already been called that wrote the data to this file. This has two advantages. 1. The structure of the data in a DATALIST allows a series of records to be separated by the END statement. EXSYS Professional will read the first set of data, analyze it, write its report on that data, then read the next set of data, analyze it, and continue with this process until it is finished. This is a very powerful technique that allows an expert system to analyze large amounts of data in a batch mode. This process is described in Section H14 on analyzing data base reports. 2. It allows you to run a very large program to create the return data. An external program must fit into memory at the same time as EXSYS. The memory used by EXSYS reduces the available memory and may prevent some external programs from running. With the DATALIST command, a batch file can be written to call a program and have it create the RETURN.DAT file, then when that program exits, the batch file calls EXSYS. This way both programs do not have to be resident in memory at the same time.
E - CONFIGURATION OPTIONS
11
The DATALIST command can also be used with a filename DATALIST=<filename> In this case, EXSYS will read the file <filename> rather than RETURN.DAT for the data used in the datalist. However, there could be a problem if a datalist call and an external program call are wanted at the same time. This could create problems because both the datalist file and the external program would try to use RETURN.DAT for data. The form DATALIST=<filename> avoids this problem. For example, the command DATALIST=ZZZ.DAT will cause Professional to read DATALIST data from ZZZ.DAT, leaving RETURN.DAT available for external program calls. See chapter H on external program calls and Section H14 on analysis of lists of data for more information on the use of DATALIST.
E - CONFIGURATION OPTIONS
12
This command option will replace the standard ending text message if no choices fire. The specified text will then be used as the new ending text. The default ending message if no choices fire is NO CHOICES RECEIVED A VALUE GREATER THAN THE THRESHOLD VALUE ___ In some cases it may be confusing or inappropriate to display this message to an end user. It may be better to provide some specific instruction if no choices fire, such as informing the end use that he should contact the author of the expert system for further instruction. For example, you might have the program say ENDMSG=ERROR: Call (911)555-1234 for assistance. This replaces the standard ending message with instructions on how to get assistance. If you choose the replace the standard ending message, your new text must be at least one character long and must be on a single line.
E - CONFIGURATION OPTIONS
13
These command options control the flag files necesary for calling external programs in MS Windows and Macintosh. See Sections H3 and H4 for details of using these commands.
This command option adds extra space between lines when printing rules to a printer. This is helpful if you want to add space in the printout for changes, notes, or some other form of additional comment. If you dont invoke the command option EXTRA_SPACE=#, then EXSYS will automatically calculate the space between the lines. The # parameter is a numeric value in pixels. In general, a character is 12-15 pixels, so to add an extra character width between lines use EXTRA_SPACE=15
E - CONFIGURATION OPTIONS
14
Stops Execution When Any Choice Has a Final Value Set Greater Than 0 FIRSTONLY
The FIRSTONLY command tells EXSYS to stop execution after any choice receives a value of 1 in the 0/1 system, or a value of 10 in the 0-10 system of probability. This is useful for expert systems that are designed to pick only one solution to a problem. Once the single solution has been found, the FIRSTONLY command will cause the execution to stop and display the results. The FIRSTONLY command does all this without asking the user unnecessary questions related to the other choices.
E - CONFIGURATION OPTIONS
15
FINALPASS This command makes EXSYS do a final forward chaining pass through the rules after it has finished the backward chaining. Backward chaining will invoke a rule only if it is relevant to a choice. This option allows a final pass to test all ruleseven if not relevant to a choiceto see if they are valid. It can be used with the RUN command to execute external programs that are not referenced in rules related to choices. FORWARD This command line option keeps EXSYS from performing a backward chain on each of the choices. Instead, the FORWARD command makes EXSYS examine each rule in the knowledge base, in order of occurrence. Backward chaining is still used to derive information needed in testing the IF conditions of a rule. The FORWARD command can result in much faster execution than backward chaining of the choices. NOBACKWARD This command line option prevents EXSYS from performing a backward chain function to derive information. However, EXSYS will still examine the choices in order. Note: All rules that derive information must occur in the knowledge base prior to the need for the derived information. This command is usually used in conjunction with the FORWARD command.
E - CONFIGURATION OPTIONS
16
The effect of FORWARD, BACKWARD and FINALPASS can be seen in a simple example. Consider the following set of rules:
RULE 1: IF Y IS TRUE THEN CHOICE 2 - Probability 3/10 8/10 RULE 4: IF X IS TRUE THEN CHOICE 1 - Probability
2. The program would then look for the rules that contain CHOICE 2. EXSYS finds the first mention of CHOICE 2 in Rule 1. Since the IF condition of this rule can be derived from Rule 2, the program invokes Rule 2 through backward chaining to derive information. Since there are no rules that would aid in determining if the IF condition in Rule 2 (Z IS TRUE) is valid, EXSYS asks the user about Z. 3. EXSYS will then look for the next rule with CHOICE 2 in itRule 3. Since the program already knows the status of X, this rule can be tested and, if it is found to be valid, EXSYS will use it. 4. When all the choices have been tested, the program stops and displays the results. Notice that rule 5 has not been used. This is because it does not have a choice in it and W is not needed in any rule relevant to a choice. Irrelevant rules are not used. The order of operations would be: Test Rule 4Used for Choice 1 Ask X Test rule 1Used for Choice 2 Test Rule 2Invoked by backward chaining from Rule 1 Ask Z Test Rule 3Used for Choice 2
E - CONFIGURATION OPTIONS
18
4. In this case, both rules 2 and 5 are not used. The order of operations would be: Test Rule 4Used for Choice 1 Ask X Test Rule 1Used for Choice 2 Ask Y Test Rule 3
RULE 2: IF Y IS TRUE THEN CHOICE 2 - Probability 3/10 RULE 3: IF X IS TRUE THEN CHOICE 2 - Probability 7/10
E - CONFIGURATION OPTIONS
20
1. The program tests Rule 1 and asks the user about Z. 2. The program tests Rule 2. Rule 1 has established the state of Y, so no additional information is needed from the user. 3. The program then tests Rule 3. The program asks the user about X. 4. The program then tests Rule 4. 5. The program then tests Rule 5. The order of operations would be: Test Rule 1 Ask Z Test Rule 2 Test Rule 3 Ask X Test Rule 4 Test Rule 5
The options on order of rule execution can greatly improve the speed of large expert systems through the use of the FORWARD NOBACKWARD option. The use of the FORWARD NOBACKWARD option can improve execution speed by a documented factor of 20 to 50 for large systems. If the knowledge base is structured so all the rules used to derive information can be placed in the rule list prior to the point where the derived information is needed, the rules can be run with the FORWARD option. Unless the rules have complex derivation paths that require backward chaining, the NOBACKWARD option can also be used. To be certain that the rules can be run in the forward mode, use the print command to print a cross-reference list on the qualifiers, choices and variables. The list will show what rules each qualifier and variable is used in and if it is used in the IF, THEN or ELSE part. Make sure each qualifier, variable and choice is not used in a THEN or ELSE part after it is used in an IF part. In other words, all uses in the THEN or ELSE part of the rules must occur numerically before the uses in the IF part. Remember, using FASTERP rearranges rules and can have an effect on the use of forward chaining.
E - CONFIGURATION OPTIONS
21
EXSYS Professional usually expects to find the custom help for the knowledge base in <knowledge base name>.HLP. If you wish to change to the use of another help file, use the command HELP=. For example, HELP=TEST.ABC would use this file as the custom help file for the system. This can be useful if there are different help files for different users who need help aimed at differing knowledge levels. This can also be used to assign a help file in a different language to a system without duplicating the rules. This does not change the system help. See the command EXSYS_HELP= for information on how to assign a path to the system help file EXSYSP.HLP
E - CONFIGURATION OPTIONS
22
This command causes the EXSYS Runtime to limit the options available to a user. 1. When asking questions: QUIT is eliminated from the menus and ignored. 2. In the display of rules: the options to see what is known, examine choices, scroll and jump to other rules are eliminated from the menus and ignored. 3. In the display of the results: the options to display all, display greater than, print, change sort method and quit are all eliminated from the menu and inactive. This option is useful when creating expert systems for users that might be confused by more advanced options and where you wish to only have the minimum functions available. LIMITOPTIONS applies only to the Runtime and has no effect on the editor. For more information, see the Control of Runtime Menu Options Command Line Options.
E - CONFIGURATION OPTIONS
23
This option doesnt allow EXSYS to display the choices sorted in order of their final, assigned confidence. Instead, the choices are displayed in the numeric order of the choices themselves. Only choices over the threshold value will be displayed. For example, suppose the first choice, CHOICE1, has a value of 3 and the second choice, CHOICE2, has a value of 5. Normally, CHOICE2 would be displayed before CHOICE1 in the list because its final confidence value is higher. However, with the NO_CH_SORT option, CHOICE1 will be displayed first because it is the first choice in the list over the threshold value. This is useful when the numeric order of the choices is significant.
E - CONFIGURATION OPTIONS
24
This command switches color off and forces the program to run in monochrome. This command is not needed if you are using a monitor attached to the IBM monochrome display card, but it may be necessary if you are using a monochrome monitor attached to a color display card. Some monochrome monitors are unreadable when color text is sent to them. This command also should be used when running on the Macintosh Powerbook.
After EXSYS reads the data returned from an external program, it erases the file that returned the data. This prevents EXSYS from inadvertently reading the file again the next time an external program call does not return data. If you do not want to automatically delete the file returning the data, use the configure option NODELETE. This applies to RETURN.DAT or another file name if the RETURN= command has been used.
E - CONFIGURATION OPTIONS
25
This option prevents EXSYS from displaying results at any time. The screen will immediately go to the "RUN AGAIN?" question. This should be used with the RERUN=Y or RERUN=N configure option described below. This option can be used to force restarting without showing results. Otherwise, a .OUT or .CMD file would be needed to do this.
If the NO_PASSWORD option is used, EXSYS will not ask for a password when saving rules. All rules will be saved unencrypted. If you never use passwords, put the NO_PASSWORD command in the EDITXSP.CFG file.
E - CONFIGURATION OPTIONS
26
This option prevents the Runtime program from asking users if they wish information on running EXSYS, or if they want to have the rules displayed. The program simply displays the splash screen, then begins executing rules. This command has no function in the Editor.
EXSYS Professional normally displays the title and author of a system before the program is run. Adding the NOTITLE command suppresses this display and the system immediately starts running.
E - CONFIGURATION OPTIONS
27
This command does not allow EXSYS to display any values for choices in the final result screen. Only the values for qualifiers and variables will be displayed. This is useful if all you need to know is which choices were selected, not the values assigned to them. In some cases, the display of these values may actually confuse endusers. However, the end-user still has all the options for asking HOW.
E - CONFIGURATION OPTIONS
28
This command doesnt allow EXSYS to backward chain expressions of the type [X] is given the value [X] + n [X] is given the value [X] - n [X] is given the value [X] * n [X] is given the value [X] / n (where n can be any constant). Backward chaining on large numbers in expressions similar to the one displayed above, can result in very long chains that use up the available stack space. Note: This option should be used with care since [X] must have a value assigned to it prior to encountering this expression through initialization or any other assignment.
E - CONFIGURATION OPTIONS
29
When a choice is used in the IF part of a rule, EXSYS attempts to determine a value for the choice to test if the condition is true. If no value for the choice can be derived, EXSYS issues an error message because the condition is indeterminate. This is a good idea in general, but there are some systems that operate on the principle that choices which dont receive values are assumed to be false. This can be a valid way to approach some problems. However, it is better to not rely on undefined choices in the IF part. The NULLCHOICE option turns off error messages if condition choices have no values. Such choices set the condition to FALSE. Note: This option should be used with caution, since it disables error messages and can result in actual errors remaining undetected.
E - CONFIGURATION OPTIONS
30
Changes the Name of the File Used to Pass Data to External Programs PASS=filename
This option changes the name of the file that is used to pass data to external programs from EXSYSP or EDITXSP. When an external program is called, data can be passed to the program in a file. The default name of the file is PASS.DAT. If it you want to change the name of this file, use the PASS= command. Once the name is changed, it applies for the entire run and must be used in all calls to external programs that pass data. For example, passing data on a RAM disk is much faster than passing it on a conventional disk. For example, if you want to pass data on a RAM disk labeled drive D, but still want to use the name PASS.DAT., use the command PASS=D:PASS.DAT. If you redefine the file in which data is passed, be sure to modify the called program so it knows where to look for the data that is being sent.
E - CONFIGURATION OPTIONS
31
The PASSWORD= command allows a password to be passed into a file. This tends to defeat the purpose of a password, but is useful when several expert systems will be called sequentially from a batch file. The password can be entered when the batch file is called. The password is then passed to each expert system as a replaceable parameter. For example, the following DOS batch file would call three expert systems with the same password. EXSYSP SYSTEM1 PASSWORD=%1 EXSYSP SYSTEM2 PASSWORD=%1 EXSYSP SYSTEM3 PASSWORD=%1 The %1 in the batch file would be replaced with the parameter entered after the batch file name. For more information on replaceable parameters in batch files, see your DOS manual. The PASSWORD= command can also be used when calling EXSYS from another program. This enables you to have an encrypted file with the password supplied by the other program. This prevents the knowledge base from being run by any source other than your starting program.
E - CONFIGURATION OPTIONS
32
This command is used with custom help files. (See Section I12 for information on custom help files). When a user inputs ? in response to a request for information, EXSYS checks to see if information on the qualifier or variable is in the custom help file <knowledge base name>.HLP. The file is rapidly examined and only read once since file pointers are set during the read. While this process is rapid, it does take about 1 or 2 seconds per 10k of custom help file to reach the end of the file. In some cases you may want to have the examination of the .HLP file and the setting of pointers be performed when the rules are read in. The READHELP command tells EXSYS to read the .HLP file when the rules are read and it also sets the file pointers at the same time. Calls to the custom help file are then almost instantaneous. When this command is used with the Editor, EDITXSP.EXE, the .HLP file is examined and the file pointers are set whenever the RUN option is selected. This allows modification of the .HLP file between runs by using the <Ctrl-X> command to go to the operating system to modify the .HLP file and then return to EDITXSP.
E - CONFIGURATION OPTIONS
33
This option tells EXSYS that you may wish to recover data saved with the QUIT command during an earlier run. If the RECOVER command is used, the menu option Recover Input under the Questions menu will be checked. At the start of a run you will then be asked for the filename of the file that contains the saved data. The program will read in the data and, after displaying the starting title screens, return to where you left off. The RECOVER command can also be used with the filename RECOVER=<filename>. In this case, without asking the user, the program automatically recovers the input saved in the file <filename> and begins the run immediately where it left off earlier under the QUIT command. In the Editor, the recover option can be selected by selecting the menu option Recover Input under the Questions menu prior to a run. The RECOVER command is REQUIRED to recover data in the Runtime.
E - CONFIGURATION OPTIONS
34
E - CONFIGURATION OPTIONS
35
When EXSYS assigns values to string variables there is a small portion of memory that is not released and is lost. This is due to the way certain operations (CHANGE AND RERUN and UNDO) are performed and the need for data in other operations. Normally, the amount of memory lost per cycle is about the size of the strings being assigned and is inconsequential. However, if a system makes extensive use of string variables and will cycle hundreds or thousands of times, the memory loss can become significant. This is very rarely a problem, but the RELEASE_STRINGS command prevents this small amount of memory from disappearing. Unfortunately, RELEASE_STRINGS prevents UNDO and CHANGE AND RERUN from working since they both require that the earlier data be available. The RELEASE_STRINGS option allocates memory only once for all string variables. The memory is released when the run finishes. CHANGE AND RERUN and UNDO cannot be used with this option. The default maximum string length is 256 characters. If this needs to be changed use RELEASE_STRINGS=<max length>. For example, RELEASE_STRINGS=1000 would allow 1000 character strings. Strings longer than the maximum are truncated and null terminated. Remember, each string variable will have this much memory allocated for it, so try to use the minimum. If you have 50 string variables, but the longest string that will be input is 20 characters, RELEASE_STRINGS=20 will use only 1k of memory, while just RELEASE_STRINGS will use over 12k (50 * 256). The release strings options should rarely be needed. If it is not used, the minimum amount of memory will be used by EXSYS. Note: The RELEASE_STRINGS option disables the CHANGE AND RERUN and UNDO functions that require the memory not be released.
E - CONFIGURATION OPTIONS
36
The default report generator specification associated with a knowledge base is <knowledge base filename> .OUT. The REPORT= command allows a different report specification file be assigned to a knowledge base. If there is a knowledge base named TEST, the default report specification would be in the file TEST.OUT. You could assign a different report specification named OTHER.RPT with REPORT=OTHER.RPT in the command line or configure file. Note: This command effects only the report produced at the end of a run. It does not effect reports produced as a result of rules firing.
E - CONFIGURATION OPTIONS
37
When the CHANGE AND RERUN command is selected in EXSYS, the report generator will be called at the end of the run if a report specification file is present. In some expert systems, you many to not run the report generator during CHANGE AND RERUN operations since it might overwrite the original data. When used in the command line or a .CFG file, this command prevents EXSYS from running the report generator during a change and rerun operation. This is useful in allowing a user to experiment with CHANGE AND RERUN without affecting the file originally produced by the report generator. If this command is not used, the default is to run the Report Generator in CHANGE AND RERUN.
E - CONFIGURATION OPTIONS
38
When EXSYS finishes a run, the user is asked if he wishes to rerun the rules. The default for this option is NO. In some cases the system may be designed to rerun the rules many times. The RERUN command changes the default to YES. The user can still override the default value of YES.
RERUN=Y
This prevents Professional from asking the user if he wishes to run the system again. ESXYS instead assumes an answer of YES and automatically restarts after the results screen.
RERUN=N
This doesnt allow EXSYS to ask the user if he wants to run the system again. EXSYS instead assumes an answer of NO and automatically exits (runtime) or returns to edit mode (editor) after the results screen.
E - CONFIGURATION OPTIONS
39
Changes the Name of the File Used to Return Data from External Programs RETURN=filename
This option changes the name of the file used to return data to EXSYS from an external program. The default name that will be used if this option is not selected is RETURN.DAT. If you are calling a program that supplies its own file extension or if for some reason you want to return data in a file with another name, use the RETURN= command to define the new default name. Only one name can be used in an expert system. If you change the file name, that file must be used for returning data from all external program calls. The RETURN= command can also be used to change the default drive that data is passed on. It is often desirable to pass data on a RAM disk for maximum speed. For example, if you have a RAM disk defined as drive D, and you want to pass data on D in a file TRANS.DAT use the command RETURN=D:TRANS.DAT in either the command line or a configure file. Note: Make sure that the external program called by EXSYS writes its data to this same file.
E - CONFIGURATION OPTIONS
40
EXSYS can be made to calculate the final value of a choice slightly differently than older versions of EXSYS. Older versions of EXSYS use truncation of fractions. For example, if you are using the 0-10 confidence system and you assign it values 4, 6 and 7, the exact average would be 5.66666... EXSYS would display a final value of 5 (truncated value) while 6 would be the rounded value. ROUND causes rounding rather than truncating of the choice values. The default mode for EXSYS is truncation which provides compatibility with earlier versions. The command ROUND causes EXSYS to use the rounding mode. Important Note: If you use ROUND with some expert systems that rely on truncation, especially if you are testing on choice values, you could get different results when you use the new version of EXSYS on programs designed under an older version of EXSYS. If the ROUND option is not used, both the new version of EXSYS and all its previous versions will provide the same results.
E - CONFIGURATION OPTIONS
41
Writes a File of Information on Rule Execution, Data and Other Functions. TRACE TRACE = filename
When a knowledge base is run, you can turn on a trace (TRACE) of the execution of the rules as they fire. This can be very useful when trying to debug a knowledge base. The trace file can be created on disk or sent to the printer. The trace feature is turned on by entering TRACE=filename in the command line or a .CFG file. For example, if you start by entering EDITXSP TEST TRACE=XXX.TRC it will cause EDITXSP to write information to the file XXX.TRC when the rules are run. This command option allows you to collect information on which rules fired, when the rules fired, what values were set, and a wide selection of other information. The trace file this creates is an ASCII file that can be printed or examined with an ASCII editor. The TRACE from each run of the rules is appended to the trace file until you restart the editor. If a variable [X] is finishing with a different value than you believe it should have, you can search the trace file for [X] to see where the value of [X] is being set and why it is different from what you thought it should be. Using TRACE greatly simplifies checking for logic errors in your rules.
E - CONFIGURATION OPTIONS
42
EXSYS allows a user to change his mind and undo previous answers. This is particularly useful when a user running a system makes a typographical error. The default is to allow the user to backup a maximum of 3 steps. The command line option UNDO allows this maximum to be changed to anything from 0 to 10. The command UNDO=0 will disable the UNDO function. When UNDO is active, and there is some data to undo, the menu asking for input will include the item UNDO-<Ctrl-U>. Pressing the Ctrl and U keys simultaneously will cause the program to back up one question. Doing the same thing again will back up another question, until the program no longer displays the UNDO menu option. The default value of 3 is usually appropriate, but there are times when it might be desirable to change it. First, if an error in input is not likely to be detected until more than 3 questions later, the limit should be raised. Second, if memory is very limited, you may want to reduce the number of steps the user can back up, or disable the function with UNDO=0. The UNDO option does have some memory overhead, which can become significant for large systems close to the memory limitations. UNDO can only work within a single knowledge base. If an earlier answer leads to exiting one module and starting another, EXSYS will not be able to step back. Likewise, if the rules are being run from the command language, it can only back up within a single RULES command.
E - CONFIGURATION OPTIONS
43
The screen which displays the WORKING message has a cyan background. If several external programs are called that have different backgrounds, you may want to change the background color of the WORKING screen. The color parameter is the name of the color to use. color: RED GREEN BLUE CYAN MAGENTA YELLOW BLACK DKGRAY GRAY LTGRAY WHITE
E - CONFIGURATION OPTIONS
44
This option causes the EXSYS Professional report generator to do word wrap on a line whose width is specified by # in characters per line. The default value is 80. This is useful when printing reports on wide paper.
E - CONFIGURATION OPTIONS
45
F1: Commands
The report specification is made up of a series of commands, each of which may cause one or more lines to be printed to the output file or cause some other operation to be performed. Many commands can have several basic forms. These are listed in order of complexity. Most report specification commands have a variety of options controlled by "/" followed by a letter. The following list of commands gives the basic command first, followed by the available options. If options are selected, they follow the basic command on the same line. Special Note to UNIX users: In the UNIX version of EXSYS, replace the / in all commands with -. For example, /D would become -D. This prevents confusion with UNIX path names.
F - REPORT GENERATOR
1
The BEEP command causes EXSYS to make a beep noise to alert a user.
F - REPORT GENERATOR
choice #the number of the choice to be output. choice texta text string unique to a single choice. The string must be in quotes. test exp.the first test you should use to determine if the choice should be output. The available tests are <,>,=,>=,<=, and <>. The type of test is followed by the integer value to test the choice against (e.g. =10, <5, >9). If no test expression is specified, >0 is assumed. 2nd test exp.an optional second test you should use to determine if the choice should be output. The available tests are <,>,=,>=,<=, and <>. The type of test is followed by the integer value against which EXSYS will test its choice. The second test expression can be used to select choices only in a specific range. For example, C >5 <8 would display those choices with final values of 6 or 7. There must be a space between the first and second tests. The choice commands print data on the final values provided to the choices at the end of the run. The data is output to the current file that has been opened with the FILE command. There are several forms of the choice command that allow specification of what choice and under what conditions information will be output. A variety of options allows printing of other information when the choice meets the test criteria.
F - REPORT GENERATOR
1. The simplest form of the command is just C. This outputs to the file (one choice per line) the choice text and final value of all choices that received a value greater than 0. 2. The second form of the command, C <choice #> allows specification of a particular choice for output if the value received is greater than 0. Only that particular choice will be output. The choice text and value will be output. 3. The third form of the command, C <choice #> <test exp> or C <test exp> outputs the text and value of the choice only if the final value meets the test condition. If the choice number is omitted, all choices are tested against the test expression and all those passing the test will be printed. 4. The fourth form of the command, C <choice #> C <test exp> <2nd test exp> or <test exp> <2nd test exp>
outputs the text and value of the choice only if the final received value meets both the first and second test conditions. If the choice number is omitted, all choices are tested against the test expressions and all choices passing the test will be printed.
Options:
/T /V /L /S Output the text of the choice only. The value is not output. Output the value of the choice only. The text of the choice is not output. Add an extra blank line following the output if the test is true. Causes EXSYS to suppress the line feed at the end of the line.
F - REPORT GENERATOR
/"string" If the test(s) on the choice value is true, do not output the choice text or value but instead output the text in the string. The string must be enclosed in double quotes and the first quotation mark must immediately follow the /. /[var#] If the test(s) on the choice value is true, do not output the choice text or value, instead output the value of variable var#. The number of the variable must be in brackets ( [ ] ), and the left bracket ( [ ) must immediately follow the / without any spaces in between. /[var name] If the test(s) on the choice value is true, do not output the choice text or value, instead output the value of the variable named in the brackets ( [ ] ). The name of the variable must be in brackets, and the left bracket ( [ ) must immediately follow the / without any spaces in between. /Q Forces the program to terminate and exit to the operating system if the test condition was met. If the command also causes output, the output will be written before exiting. Goto a specified line if the conditional test is met. See the GOTO command in this section for more information on branching. Print the choice only if it had no value assigned (no rules fired which assigned a value to the choice). This automatically does a /T, since there is no value to output. This can be combined with other options such as /".
/G
/U
Examples:
C C2 = 10 will cause the text and final value of all choices with values greater than 0 to be sent to the output file. will cause the text and value of choice 2 to be sent to the output file if the final value of choice 2 is 10.
C "Part 1234" will cause the text and value of the choice whose text contains "Part 1234" to be sent to the output file.
F - REPORT GENERATOR
C4 >7 /[9] will output the value of variable 9, either numeric, string or text, if choice 4 received a value greater than 7. C4 >7 /[X] will output the value of variable [X], either numeric, string or text, if choice 4 received a value greater than 7. C >=5 <=8 /T will cause only the text (not the value) of all choices that receive values greater than or equal to 5, but less than or equal to 8, to be sent to the output file. C4 >9 "THE DATA IS GOOD" /L will cause the text "THE DATA IS GOOD" to be sent to the output file if choice 4 has a final value greater than or equal to 9 and then an extra blank line will be added. C5 /V will cause the final value of only choice 5 to be sent to the output file.
F - REPORT GENERATOR
F - REPORT GENERATOR
Options
/C - File to display uses GUI Custom Screen Commands The /C option should be used if the file to display contains Custom Screen Commands. See chapter I for a discussion of the GUI Custom Screen Language. /N - No wait after screen is displayed The /N option allows the DISPLAY command to display the requested file in a window and immediately continue processing. This can be useful for report files that are created and displayed. By using the /N option, several report data windows can be simultaneously active. /S - Small text The /S option causes the DISPLAY command to display a text file using a small font. The default is to use a larger font. This option only applies to ASCII files. /F - Fixed size font The /F option causes the DISPLAY command to display a text file using a fixed size font. This is useful for aligning columns of data. The /S and default fonts are proportionally spaced and aligning data can be difficult. This option only applies to ASCII files. The DISPLAY command displays the contents of an ASCII file or Custom Screen Language Command file on the screen. Users can go forward or backward in the file as they examine it. When they are finished reading the file, the report generator function continues. 1. The first form DISPLAY <filename> allows the name of the displayed file to be explicitly specified.
F - REPORT GENERATOR
8
2. The second form DISPLAY [string variable name] allows a variable to set the name of the file to display. In this way, the knowledge base can set the name of the file to be displayed. The DISPLAY command is very useful for displaying the report produced by the report generator to the user. Important note: When displaying the file produced by the report generator, close the file before displaying it.
Examples:
DISPLAY INFO1.T displays the contents of the ASCII file INFO.T for the user to read. FILE F1 . . (report generator commands) . CLOSE DISPLAY F1 creates a file F1 containing output from the report generator commands. The file F1 would be closed by the CLOSE command. The DISPLAY command would then display the contents of the recently created report on the screen or terminal. The CLOSE command must be used to close F1 before it is displayed. DISPLAY SCR1.SCR /C
F - REPORT GENERATOR
F - REPORT GENERATOR
10
Options:
/A opens the file for output with the data appended to the existing contents of the file. If the file does not exist, the file will be created. If /A is not added, the contents of the existing file will be lost and replaced by the new data.
Example:
FILE B:REPORT.A . . (output commands) . FILE C:\DATA\LIST.RPT /A . . (output commands) . FILE LPT1 . . (output commands) .
F - REPORT GENERATOR
11
would open the file B: REPORT.A, deleting any previous data in this file. All data would be sent to this file until the second FILE command is reached. This second FILE command would close the file B: REPORT.A and open the file C:\DATA\LIST. RPT. Since the second FILE command used the /A option, the new data will be appended to the data already in the file. All data would be sent to C:\DATA\LIST.RPT until the third FILE command. The third FILE command would close file C:\LDATA\LIST.RPT and open the printer attached to the LPT1 port of the PC for the subsequent output.
F - REPORT GENERATOR
12
Print Text Only for First Set of Data in DATALIST FIRST "string"
When the FIRST command precedes text in double quotes, the text will be printed only during the processing of the first record being examined with the DATALIST command. This allows a title to be put on reports without having the text print each set of data in a DATALIST file. If there is no datalist, the FIRST command behaves as a simple, quoted string.
Example:
FILE XYZ.RPT /A FIRST "REPORT OF EXPERT SYSTEM" C RESTART could be used with a DATALIST command to examine a series of sets of data. The title "Report of Expert System" would be printed only once. The choices would be printed for each set of data in the DATALIST.
F - REPORT GENERATOR
13
EXSYS Professional supports conditional and unconditional GOTO commands in the report generator. The line which GOTO will transfer to is indicated by a single line that starts with a colon ( : ), followed immediately by the label name. The command GOTO LABEL will transfer execution to the line following the line marked label. For example: commands... :XXX commands... GOTO XXX will cause the execution to return to the line ":XXX" in the report file. Alternatively, the /G:label option can be used with the C, Q or V commands in the report generator to produce a conditional GOTO. In this case, the GOTO will be executed only if the C, Q or V command is valid. For example: V1 > 4 /G:end will transfer the line ":END" only if variable 1 has a value greater than 4. By combining conditional and unconditional GOTO commands, the report file can be made much more flexible. Note: If you use GOTO to jump over a FILE command, the FILE command will not be executed.
F - REPORT GENERATOR
14
For example, the report file FILE FILE1 . . . GOTO XXX . FILE FILE2 . . :XXX . . would not open FILE2, but would continue writing to FILE1.
F - REPORT GENERATOR
15
Options:
/L Adds a blank line after each line of data is output
F - REPORT GENERATOR
16
Print the Notes and References NOTE NOTE <rule#> REF REF <rule #>
rule # the number of the rule to print the note or reference from. The NOTE and REF commands cause the report generator to print the note or reference of a specified rule to the report file if the rule has fired. The optional rule number can be left off, in which case notes or references from all rules that fired will be printed to the report file in the order of the rules. This provides a convenient way to provide the information in the notes and references to a user, even if rule display is turned off.
Example:
NOTE REF 4 would cause the printing of the notes from all rules that fired, followed by the reference from rule 4, if rule 4 fired.
F - REPORT GENERATOR
17
Data on Qualifiers Q Q Q Q Q
qual #the number of the qualifier to output. If the number is omitted, all qualifiers are tested. testa qualifier is tested by checking to see if its values are true. The test condition is a list of the qualifier's values such as numbers separated with commas (just like creating a condition when building a rule). If any of the values specified in the test are set, the test is true. For example, Q2 1,3,7 would be true if qualifier 2 has values 1,3 or 7 true. The test will be true if any of the listed values are true. Qual namethe name associated with the qualifier. Note: This is not the text of the qualifier, but the name used to identify the qualifier. The name must be in quotes. The qualifier command outputs the text of a qualifier with all the values that have been set to the file opened with the FILE command. There are three main forms of the command. 1. The simplest form is just Q. This outputs the text of all qualifiers that had values set.
F - REPORT GENERATOR
18
2. The second form of the command is Q <qual#> Q "Qual name" This outputs the qualifier specified by number or name if any of its values were set during the run. Any values set are also output. 3. The third form of the command is Q <qual#> <test> Q "Qual name" <test> This outputs the qualifier specified by number or name if any of its values were set during the run and the set values match at least one of those specified in the list of values in the test. Any set values are also output.
Options:
/L /S Adds a blank line after the qualifier is output. Suppresses the line feed at the end of the line.
/"string" If the test is true, the qualifier/values are not output, but instead the string in quotes is output. /[var#] If the test(s) is true, do not output the qualifier/values, instead output the value of variable var#. The number of the variable must be in brackets ( [ ] ) and the left bracket ( [ ) must immediately follow the slash ( / ) without any spaces in between. /[var name] If the test(s) is true, do not output the qualifier/values, instead output the value of the variable whose name is specified in the brackets ( [ ] ). The name of the variable must be in brackets ( [ ] ) and the left bracket ( [ ) must immediately follow the slash ( / )without any spaces in between. /Q forces the program to exit to the operating system if the test condition was met. If the command also causes output, which will be written before exiting. causes output of the data on the qualifier(s) to be in a form that can be read in with a DATALIST command. This makes it possible to have one expert system call another and then pass data between them. Such chaining of knowledge bases can be very powerful.
F - REPORT GENERATOR
19
/D
For example, suppose qualifier 7 is THE 1. 2. 3. 4. COLOR IS: RED WHITE GREEN BLACK
and values 1 and 3 are chosen. The report generator line Q 7 would output : THE COLOR IS RED OR GREEN However, the line Q 7 /D would output Q7 1 3 (a form that could be read in with the DATALIST command line option). There can also be an optional number specified immediately after the /D (no space between D and the number). This number will be used in the output of the data as the destination qualifier number. This allows you to specify a different qualifier to be used when the data is read in by another expert system using DATALIST. To use the qualifier example above, the report generator line Q 7 /D outputs Q7 1 3. However, the line Q 7 /D12 would output Q12 1 3. The 12 specified after the /D caused qualifier 12 to be specified as the destination of the data. This allows data from one expert system to be passed to another, even though the qualifier numbers do not necessarily match. If a number is not specified after the /D, the number used will be the same as the qualifier or variable specified. See Chapter M on blackboarding for more information on passing information between knowledge bases. /G Go to a specified line if the conditional test is met. See the GOTO command in this section for more information on branching. Print the qualifier only if it did NOT have a value assigned, (no rules fired which assigned a value to the qualifier, it was not asked of the user and no external program assigned a value). This can be combined with other options such as /".
/U
F - REPORT GENERATOR
20
Examples:
For these examples use qualifier number 6 with an associated name "COLOR" and four values: Qualifier 6: The color is 1 red 2 white 3 blue 4 green Q6 or Q "COLOR" causes the status of qualifier 6 to be output. Q6 2,3 causes the status of qualifier 6 to be output if the statement the color is white or the statement the color is blue is true. Q6 1 /"RED PAINT WILL BE NEEDED"causes the text RED PAINT WILL BE NEEDED to be output if the qualifier statement "The color is red" is true.
F - REPORT GENERATOR
21
to have each new report appended to the existing report. End with RESTART to cause EXSYS to restart and run the next set of data. The program will end automatically when the end of the DATALIST is reached and EXSYS returns to the operating system. 2. MonitoringAn EXSYS expert system can be designed using external programs to obtain data that monitors the status of a process. If no action is necessary, it is only necessary to restart the run. If action is necessary, data can be output, alarms can be triggered, and a variety of other actions can be performed.
F - REPORT GENERATOR
22
Options:
/C Causes the parameters to be passed as command line arguments. If the /C is not present, the parameters will be passed in PASS.DAT. Causes the first # arguments to be passed on the command line, with the rest passed in PASS.DAT. See Chapter H on calling external programs for more / options. For example, RUN BASIC GRAPH1 /C executes the basic program GRAPH1 from the BASIC interpreter. RUN TEST [X] [Y] [Z] runs the program TEST with the values of variables [X], [Y] and [Z] passed in PASS.DAT. RUN TEST [X] [Y] [Z] /C runs the program TEST with the values of variables [X], [Y] and [Z] passed in on the command line. RUN TEST [X] [Y] [Z] /2 runs the program TEST with the values of variable [X] passed on the command line and the values of variables [Y] and [Z] passed in PASS.DAT.
F - REPORT GENERATOR
23
/#
F - REPORT GENERATOR
24
Example:
FILE CON: "The report is being produced" FILE XYZ.RPT . . . Will write the message "The report is being produced" to the screen, then open the file XYZ.RPT for output. The message will stay on the screen until the report specification is finished. This is a useful technique for giving the user status reports when very large report files are used.
F - REPORT GENERATOR
25
variable #the number of the variable to output. If the number is omitted, all variables will be tested for output. variable nameThe name of the variable to output. The name must be enclosed in brackets ([ ]). test expA test to determine if the variable should be output. The available tests are >,<, =, >=, <=, and < >. The test expression must be followed by either a numeric value (for numeric variables) or a string in quotes (for string variables). If string variables are used, the validity of the test is based on alphabetical order. 2nd test expA second test to determine if the variable should be output. The available tests are >,<, =, >=, <=, and < >. The test expression must be followed by either a numeric value (for numeric variables) or a string in quotes (for string variables). If string variables are used, the validity of the test is based on alphabetical order. This second test is used to select variables only within certain bounds. For example: V2 >23.5 <78.4 would output the text and value of variable 2 only if its value was between 23.5 and 78.4. There must be a space between the first and second tests. The variable command outputs the value of variables to the file opened with the FILE command. There are a number of forms of the variable command, most of which have the option of either specifying the variable by number or by name.
F - REPORT GENERATOR
26
1. The simplest form of the command is just V. This outputs the text and value of all variables that received a value during the run. The text of the variable and the value will both be printed, unless options are selected. If a variable is a text only variable, it will be displayed only if it was applied by a rule that fired. 2. The second form of the command, V <variable #> or [variable name] specifies which variable is to be output. Both the text of the variable and the value will be printed, unless options are selected. If a variable is a text-only variable, it will be displayed only if it was selected by a rule that fired. 3. The third form of the command, V <variable #> <test exp> or V <test exp> or [variable name] <test exp> specifies which variable is to be output and sets a test condition which the variable must meet to be printed. Either numeric or string variables can be tested. The text of the variable and the value will both be printed, unless options are selected. If a variable is a text only variable, it will be displayed if it was selected by a rule that fired. If the variable number is omitted, all variables will be tested against the test expression and all variables passing the test will be printed. 4. The fourth form of the command, V <variable #> <test exp> <2nd test exp> or V <test exp> <2nd test exp> or [variable name] <test exp> <2nd test exp> specifies which variable is to be output and sets two test conditions which the variable must meet to be printed. Either numeric or string variables can be tested. The text of the variable and the value will be printed unless options are selected. If a variable is a text-only variable, it will be displayed if it was selected by a rule that fired. If the variable number is omitted, all variables will be tested against the test expressions, and all variables passing the tests will be printed.
F - REPORT GENERATOR
27
Options:
/T /V /L /S Output the text of the variable only, not the value. Output the value of the variable only, not the text. Add an extra blank line after the output. Suppress the line feed at the end of the line.
/"string" If the test is true, do not output the variable, but instead output the quoted text in the string. The string must be enclosed in double quotes and the first quotation mark must immediately follow the slash (/). /[var#] If the test(s) is true, do not output the variable text or value, instead output the value of variable var#. The number of the variable must be in brackets ([ ]), and the left bracket ( [ ) must immediately follow the slash (/) without any spaces in between. This is very useful for printing identifiers, such as a person's name, if they meet the test conditions specified. /[var name] If the test(s) is true, do not output the variable text or value. Instead, output the value of the variable named in the brackets ([ ]). The name of the variable must be in brackets, and the left bracket must immediately follow the slash (/) without any spaces in between. /Q Forces the program to exit to the operating system if the test condition was met. If the command also causes output, the output will be written before exiting. Output data on variables in a form that can be read in with a DATALIST command. This makes it possible to have one EXSYS expert system call another and pass data between them. Such chaining of knowledge bases can be very powerful. For example, suppose variable 3 has a value of 7.9. The report generator line V 3 /D would output V 3 7.9 to the output file rather than printing the text to describe variable 3 followed by the value. There can also be an optional number specified immediately after the /D (no space between D and number). This number will be used in the output of the
F - REPORT GENERATOR
28
/D
data as the destination variable number. This allows you to specify a variable to send the data into. To use the example above: the report generator line V 3 /D
outputs V 3 7.9. However, the line V 3 /D12 would output V 12 7.9. The 12 specified after the /D caused 12 to be specified as the destination of the data. This allows data from one expert system to be passed to another, even though the variable numbers do not necessarily match. If a number is not specified after the /D, the number used will be the same as the variable specified. See Chapter M on Blackboarding for more information on passing data between knowledge bases. /F-m.n Formats the output variable value with format controlled by the parameters. This can be used only for numeric variables. The optional hyphen causes left justification. The default is right justification. The optional parameter m is the total field width. The optional parameter n is the number of places displayed right of the decimal point. For a variable with value 1234.5678: /F6.0 outputs 1235 /F6.2 outputs 1234.57 /F10.3 outputs 1234.568 /E prevents EXSYS from printing the equal sign between the text and the value of the variable. Go to a specified line if the conditional test is met. See the GOTO command in this section for more information on branching. Print the variable only if it did NOT have a value assigned (No rules fired which assigned a value to the variable, it was not asked of the user and no external program assigned a value.) This automatically does a /T, since there is no value to output. This can be combined with other options such as /".
F - REPORT GENERATOR
29
/G
/U
/,
Commas can be inserted into a numeric variable value in the report generator by using the /, option. This would normally be done in conjunction with the /F#.# option to format the output. For example, a variable [X] equal to 123456578.9 could be output various ways: Report Generator Command [X] [X] /, [X] /F15.2 [X] /F15.2 /, Output 12345678.9 12,345,678.9 12345678.9 12,345,678.9
Note: if there are preceding format spaces from a /F#.# command, the /, command will remove one space for each comma added. This preserves the total field width produced by the /F command. Enough extra spaces must be left to allow for the commas. If there is not enough space, the total field width will expand.
Examples:
V causes the text and value of each variable to be output. V2 > 1.5 /T causes the text of variable number 2 to be output if the value of the variable is greater than 1.5. V4 <0 /[8] outputs the value of variable 8 if the value of variable 4 is less than 0. V4 <0 /[X] outputs the value of variable [X] if the value of variable 4 is less than 0. V7 = "ABCD" /L causes the string variable number 7 to be printed if its value string is ABCD, then a blank line will be output. [X] /V causes the value of the variable [x] to be output. [X] >= 2.7 /"THE VALUE WAS HIGH" causes the string THE VALUE WAS HIGH to be output if the value of the variable [X] is greater than or equal to 2.7.
F - REPORT GENERATOR
30
Examples:
FILE B:RESULTS "RESULTS OF EXSYS RUN" C > 2 "USER INPUT" INPUT will cause EXSYS to: 1. Open the file B: Results. 2. Send the text RESULTS OF EXSYS RUN to the file. 3. Send the text and value of each choice with a value greater than 2 to the file. 4. Send the text USER INPUT. 5. Send all the input data obtained from the user. FILE C:\ANALYSIS\TEST.RPT /A V3 /V /L C = 10 /T "*********" FILE LPT1 V3 /V C > 5 BEEP EXIT will cause EXSYS to: 1. Open the file C:\ANALYSIS\TEST.RPT so output is appended to the end of the file, if one exists. 2. Output only the value of variable 3, followed by a blank line. 3. Output a list of only the text of all choices with values of 10. 4. Output "*********" to separate records in the file. 5. Close the first file and open the printer for output. 6. Print the value of variable 3 to the printer. 7. Print all choices that had values greater than 5. 8. Make a beep sound to alert the user. 9. Exit EXSYS and return to the operating system. FILE LPT1 FIRST "POSSIBLE CANDIDATES" FIRST "____________________" FIRST " " C3 >8 /[6] RESTART This would be used with a DATALIST command line option to provide data.
F - REPORT GENERATOR
31
It causes EXSYS to: 1. Open the printer for output. 2. After analyzing the first record, EXSYS prints the report title "POSSIBLE CANDIDATES" (This will be printed for the first record only). 3. Underline the title. 4. Skip one line. 5. Print the value of variable 6 (possibly a name) if choice 3 received a value > 8. 6. Read the next record of data and restart the analysis.
F - REPORT GENERATOR
32
In general, EXSYS Professional does not care what text you enter for a qualifier or variable, provided you don't duplicate the names of the special commands that EXSYS recognizes. These internal commands can be used to perform a variety of functions, control EXSYS rule execution and interface to external sources of data. The EXSYS Internal commands can be associated with a qualifier or variable, added as part of the THEN or ELSE part of a rule or (in most cases) included in the command file (<knowledge base name>.CMD).
G - INTERNAL COMMANDS
Rule Title and Number IF: Qualifier Var. / Math Choice Command Repeat IF Part THEN Part ELSE Part Insert AND OR New OR OK Change Delete And/Or Cancel Prev Next Note Reference Name
G - INTERNAL COMMANDS
Edit
Replace
Ca ncel Edit
Add
Delete
OK
G - INTERNAL COMMANDS
Direct Command Input Run External Program Lotus 123 dBase III Interface Table Lookup Display a File Frame / Array Lookup LINDO Interface
OK
Cancel
The edit region at the top of the screen will display the command. This command can be edited directly, or its value can be created using the windows that build the commands. To guarantee correct syntax for the commands, we recommend you use the individual command windows. To select a command window, click on the desired command. When the command in the top edit box is correct, click on the OK button.
G - INTERNAL COMMANDS
The full name of the dBase III file to be used. The full name of the file that has the index of the <db file>. The value to search for in the index.
G - INTERNAL COMMANDS
<field name>
The name of the field that containing the data to be read from or the name of the field to be written to. The name of the EXSYS variable in [ ]. The value of the variable will be read from or written to the specified db field. The variable name ALWAYS applies to the field name specified to its left. The item in which to store the obtained data. The item can be a variable, qualifier or choice. For a variable, use the name of the variable in [ ] For a qualifier, use "Q" followed by the number of the qualifier or the name of the qualifier in quotes For a choice, use "C" followed by the number of the choice or a unique text string in quotes. There must NOT be any spaces in the string between the C, V, or Q and the number or quotation mark. The number of the db record to work with.
<var name>
<address>
<rec #>
The database file name, index name and index variable may be string variables that are set by expert system. <var name> must be an EXSYS variable. Since the field name and associated variable may be repeated as many times as desired, multiple fields from the same record can be passed or returned on a single call.
G - INTERNAL COMMANDS
OK
Prev. Field
Next Field
Cancel
To build a dBase internal or data acquisition command, select GET or PUT by KEY or Record Number then enter the database filename. If an index file is used, enter the index filename and index value used to select a record. If record numbers are used, enter the record number used to select a record. Fields in the record and EXSYS addresses are used in pairs. Each field must have a corresponding EXSYS address. With GET, the value of the field will be put in the EXSYS address. With PUT, the value in the EXSYS address will be put in the field specified. Enter the first pair of field and address names. To enter a second pair in the same command, click on Next Field. The Field and EXSYS Address edit boxes will clear and you can enter another pair. This can be done repeatedly. To examine a field or variable pair already entered, click on Prev Field. This will display the previous pair. When all field or variable pairs have been entered, click on OK. The general Command window will return, with the dBase command in the top edit window. When you click on OK again, the command will be added to the rule, qualifier or variable (depending on how the window was called.)
G - INTERNAL COMMANDS
Use in Rules
In rules, dBase commands are usually used to set data as the result of a rule firing. In some cases, a rule may also trigger a dBase command to get data into a particular variable. Since the commands to get data have a variable associated with them, they can be called independently of a specific variable. The following example, IF ...... THEN DB_PN(parts.dbf, 5, price, [X]) will WRITE the value of variable [X] into field "price" of record 5 of database "parts" if the rule fires.
Use in a Variable
When a dBase command is associated with a variable, it will automatically be called if a value for the variable is needed. Rather than asking the end user for the value, the call to dBase will be made. If a value for the variable is never needed in the system, the dBase call will never be made. To associate the dBase call with a variable, the dBase command precedes the text entered as the Prompt Text for the variable. The dBase call will not be displayed when the prompt text is used in reports, final results, etc. For example, if we had a variable [X] with a prompt "The price is," we would associate a dBase call with the variable by changing the prompt to: DB_GN(parts.dbf, 5, price, [X]) The price is If the value of [X] is needed, the program will READ the value of field "price" from record 5 of database "parts" into variable [X]. If needed, there could be additional field and address pairs in the expression to get more data from the record. If the variable is a string variable, the value returned will automatically be handled as a string--even if it contains numeric data. If the variable type is numeric, the value returned will automatically be converted to a numeric. Be sure to return string data (names, addresses, etc.) to string variables. If the data from the database is to be used in numeric calculations, make sure it is returned to numeric variables. When the data acquisition windows are used to build the command, the command will automatically be added to the prompt text.
G - INTERNAL COMMANDS
9
Use in a Qualifier
The use of a dBase command in a qualifier is very similar to the use in a variable. The dBase command precedes the qualifier text. The command will not be displayed when the qualifier text is used in reports, conclusions, etc. However, when a value for the qualifier is needed, the dBase call will automatically be used. For example, if we had a qualifier named "COLOR," The color is 1 red 2 blue 3 green and we wanted to get the color from the data base, we could change "The color is" to DB_GN(parts.dbf, 5, part_color, Q "COLOR") The color is When the qualifier's value was needed the dBase call would automatically be made and the value in the field part_color in record 5 would be used to set the qualifier named "COLOR." The data returned from the database for qualifiers must be in the form of a string containing the numbers of the values to select. If more than one number is returned, they must be separated by spaces of a comma. For example, if the database call returned "1,2" to a qualifier, it would set the first two values of the qualifier to be true. If it returned "3," it would set the third value to true. When the data acquisition windows are used to build the command, the command will automatically be added to the qualifier text.
Use in Choices
The command text cannot be associated directly with a choice. Instead, dBase commands that assign values to choices must be in the THEN /ELSE part of a rule or used in one of the other command files. When a value is to be assigned to a choice, the data returned from the database must be consistent with the confidence mode being used. For example, if the mode is 0-10, the value must be an integer between 0 and 10. The value returned will be combined with the other values given to the choice by rules that fired. For example (in the 0-10 system), a value of 10 assigned by a database call would lock the value at 10. A value of 5 would be averaged with any other values assigned to the choice.
G - INTERNAL COMMANDS
10
DB_GN(parts.dbf, 5, val, C 4) will return the value of field "val" into choice 4.
would return the number of records in the database file "price.dbf." This function can be used like sin( ), cos( ) or any other EXSYS function in an expression. It can be used most effectively in the command language, such as in the following: SET [I] 0 WHILE ([I] < TOPREC("price.dbf")) RULES ALL REPORT DBRPT CLEAR ALL SET [I] ([I]+1) WEND The above example would initialize the variable [I] to 0 then run the rules against each record in a database. After each record, the values are cleared and [I] is incremented and checked against the total number of records in the data base. If there is another record, the rules are run again. Each run adds the report produced with the report specification DBRPT. A simple command file like this can run an expert system against each record in a database to select those with particular characteristics and write them to a report.
G - INTERNAL COMMANDS
12
The internal command CLEAR( ) allows a qualifier, variable, choice or rule to be reset to an unknown or unused state. Normally, EXSYS will only ask a qualifier or variable once and will only fire a rule once in a run. There are cases, however, where it is desirable to clear user input or re-use a rule. The CLEAR command makes this possible. When the CLEAR command is encountered, EXSYS will reset the rule, qualifier, variable or choice to its original unknown state or flag a rule as unused. This allows user input to be erased. If the qualifier, variable or choice is needed later during the run, it will be reasked or rederived from other rules. If a rule is reset with CLEAR, it can be reused if needed. There are many forms of the CLEAR( ) command. The easiest are CLEAR(Q #) CLEAR(V #) CLEAR([var name]) CLEAR(C #) CLEAR(R #) Clear Qualifier # Clear Variable # Clear Variable [var name] Clear Choice # Clear Rule #
For example, suppose we want to allow the user to ask for more information on a qualifier. We could have the qualifier Qualifier 7: The model needed is: 1 Model A 2 Model B 3 Model C 4 Need more information
G - INTERNAL COMMANDS
13
and a rule Rule 22 IF 1 THEN ...... ELSE 1 2 3 DISPLAY(model.inf) CLEAR(Q 7) CLEAR(R 22)
where the THEN part of rule 22 performs some action relevant to the run. If the user selects a model from the list, the THEN part will continue execution. If the user selects value 4, NEED MORE INFORMATION, the ELSE part will fire and display the file MODEL.INF (an file created to provide assistance to the user), CLEAR qualifier 7 to unknown and reset rule 22 to unasked. The program would then go back and again ask for information on qualifier 7 and re-use rule 22. This same effect could be achieved more easily with hypertext help associated with some of the word; it is used here only to show the use of the CLEAR command.
Clearing Ranges
The internal command CLEAR( ) can also be given a range to clear, rather than your having to specify each item individually. CLEAR(X a-b) will clear all items between a and b. The X can be Q, V, C or R for qualifier, variable, choice or rule. In the following example, CLEAR(R 34-56) CLEAR(Q 1-5) CLEAR(X ALL) will clear ALL items. The X can be Q, V, C or R for qualifier, variable, choice or rule. In the following example, CLEAR(R ALL) clears all rules CLEAR(V ALL) clears all variables CLEAR(ALL) will clear ALL qualifiers, variables, choices and rules.
G - INTERNAL COMMANDS
14
will clear all rules from 34 through 56 will clear the first 5 qualifiers
CLEAR(R THIS) clears the rule that the command occurs in. This applies ONLY to rules. The command prevents problems when rules are reorganized. In the following example, IF ...... THEN ...... ELSE CLEAR(R THIS) will clear the rule if the rule is false, regardless of the rule's number.
Clearing by Name
In EXSYS, both rules and qualifiers have optional names. These names can be used in the CLEAR command with wild card matching. The name must be in quotation marks used in place of a number to specify the rule or qualifier. Names may be given to groups of rules for convenience when referring to them. Wild card matching allows referring to groups of rules. In wild card matching, a "?" may be used anywhere in the name to match any single character and a final "*" will match any string. The "*" may only be used as the last character. For choices, rather than names, the choice can be identified by any unique text sub-string in the choice. CLEAR(Q "name") CLEAR(R "name") CLEAR(C "text") In the following example, CLEAR(Q"A*") CLEAR(R"XXX") CLEAR(C"ZZZ") CLEAR(R"?XX") will clear all qualifiers whose NAME starts with A will clear the rule named XXX will clear all choices that have the string "ZZZ" in them will clear all rules with 3 character names ending in "XX" Clear Qualifier name Clear Rule name Clear the Choice containing the string "text."
G - INTERNAL COMMANDS
15
To build the command using the CLEAR command window, click on one of the buttons on the left to indicate what is to be cleared. The appropriate items on the right will be enabled or disabled. Select one of the items on the right an, if necessary, enter the number or name of the item. Then click on OK. The general Command window will return, with the CLEAR command in the top edit window. When you click on OK again, the command will be added to the rule.
While Loops
Clearing rules can also be used to create WHILE loops, in effect, in a set of rules. In the above example, until the user selects a Model from the list, the question will be reasked. The same effect could be obtained from a value calculated by other rules or external programs. The rule(s) would loop until the IF conditions were true. Note: The preferred, and recommended, technique of creating WHILE loops is through the command language. CAUTION: CLEAR allows certain problems to be handled by EXSYS that are not possible otherwise, but clearing already asked or derived information should be done with great care. The changing of the normal EXSYS flow can easily result in an infinite loop or errors of logic. If you experience problems with CLEAR, use TRACE to see what is happening as the rules fire. This should help to find the error in the logic. Experience has shown that it is almost impossible for our technical support to help with CLEAR( ) problems over the phone due to the very convoluted logic that can result from use of this command.
G - INTERNAL COMMANDS
16
For variables:
For choices: C <choice #> <value> or C "text" <value > <qual #>, <var #> or <choice #>: The number of the qualifier, variable or choice that the data is being passed back to. "name": The name associated with the qualifier. "text": A unique text sub-string in the choice. <value>: The data to assign. See Section H6 for more details on the syntax of data passed to EXSYS. This is useful if you have several files of data created by a single external program. Normally, an external program call will read only one file of return data, but with DATAREAD, other files can be also read.
G - INTERNAL COMMANDS
17
OK Cancel
G - INTERNAL COMMANDS
18
Options
/C: File to display uses GUI Custom Screen Commands The /C option causes the DISPLAY command to parse the file for Custom Screen Commands. See Chapter I for a discussion of the GUI Custom Screen Language. /N: No wait after screen is displayed The /N option causes the DISPLAY command to display the requested file in a window then immediately continue processing. This can be useful for report files that are created and displayed. With the /N option, several report data windows can be simultaneously active. /S - Small text The /S option causes the DISPLAY command to display a text file using a small font. The default is to use a larger font. This applies only to ASCII files. /F: Fixed size font The /F option causes the DISPLAY command to display a text file using a fixed-size font. This is useful for aligning columns of data. The /S and default fonts are proportionally spaced and aligning data can be difficult. This applies only to ASCII files. The internal command DISPLAY(filename) causes the file "filename" to be displayed on the screen in a window. The file can be an ASCII file or a file containing EXSYS Custom Screen language commands. If it is an ASCII file, the user can move forward and backward in the
G - INTERNAL COMMANDS
19
file as needed. If it is a Custom Screen file, it can have buttons, scroll bars, mouse regions, etc. The window can be set so that when the user finishes reading the file, execution of the rules continues, or execution can continue as soon as the window is drawn and the user can read it later. This is used to display a larger section of text than is possible in a note or reference. Also, it allows the text to be displayed to the user even though the rule display is switched off. The custom help screen feature can also be used to display text to the user and sometimes is more appropriate than the DISPLAY command See Chapter I for information on custom help screens. The DISPLAY command is very useful for displaying the report produced by the report generator to the user. When displaying the file produced by the report generator, CLOSE THE FILE BEFORE DISPLAYING IT. Here are some examples: DISPLAY INFO1.T would display the contents of the ASCII file INFO.T for the user to read. FILE F1 . . (report generator commands) . CLOSE DISPLAY F1 would create a file F1 containing output from the report generator commands. The file F1 would be closed by the CLOSE command. The DISPLAY command would then display the contents of the newly-created report on the screen or terminal. The CLOSE command must be used to close F1 before it is displayed. DISPLAY SCR1.SCR /C
would display the file SCR1.SCR which contains Custom Screen Commands. IF . . THEN DISPLAY(FILE1)
G - INTERNAL COMMANDS
20
would display the contents of the ASCII file FILE1 on the screen if the rule fired. The text will be displayed immediately when the rule fires, even if execution were not yet complete. IF . . THEN DISPLAY([X]) would display the contents of the ASCII file whose name is stored in the string variable [X] if the rule fired.
Use Custom Screen commands No wait after display Normal font Small font Fixed space font
OK
Cancel
Enter the name of the file to display. Two types of files can be displayed: simple ASCII text files and files with Custom Screen Commands. If you are using custom screen commands, check the Custom Screen box. If the file is just text, do not check the box.
G - INTERNAL COMMANDS
21
In a GUI, after a window is created, the processing of the expert system can either continue or wait until the window is closed. If you wish the file to be displayed and processing to immediately continue, check the No Wait box. If the box is not checked, the window will be displayed, and processing will wait for the user to click OK to dismiss the window. There are three possible fonts to use in the display box. These only apply to the display of simple ASCII text files. The default is a fairly large font. If there is a large amount of text, it may be better to use the small font. If positioning of the text is important for alignment of columns, use the Fixed font. The default and Small font are proportional and it is difficult to align columns. When the correct parameters are set, click on the OK .
G - INTERNAL COMMANDS
22
G - INTERNAL COMMANDS
23
G - INTERNAL COMMANDS
24
If the variable must select the column, use the #-# form. For example, if variable [C] contains the column to use, you could use [[C]]-5 to select a specific column in row 5. You can also use [[C]]-[[R]] to select an arbitrary column/row determined by the variables. NOTE: In all cases, there must not be any spaces in the cell specification; B2 will work, but B 2 will not. Likewise, there must not be any spaces between characters if the #-# form is used. var name The name of the EXSYS variable to use. If the SS_RD is used, the data is read INTO this variable. If the SS_WR command is used, the data is written FROM this variable to the cell. The variable always applies to the cell on its left.
The <cell> and <var name> pairs may be repeated as many times as needed in a single call. For example, SS_RD(salary.wks, C3, [X], D5, [Y], E12, [Z]) will read the contents of cell C3 into [X], D5 into [Y] and E12 into [Z]. The same can be done for the SS_WR command as well. If the variable is numeric, the data will be assigned as numeric-assigning a text string will produce a 0 value. If the variable type is string, the data will be assigned as a string, even if it is numeric data. Likewise, if the variable type is numeric, the data will be written to the spreadsheet as numeric. If the variable type is string, the data will be written as a string. Note that if the SS_RD command is used as the text of a variable; to get data for that variable, you must include the variable name in the SS_RD command. For example, if you want the value of variable [X] to be obtained automatically from cell D7 of a spread sheet, you could make the text associated with [X] SS_RD(data.wks, D7, [X]) The value of ... This will automatically read the data from D7 if [X] is needed. But, you must specify that the data is for [X] in the third parameter of the SS_RD command. This is unlike a RUN( ) command that would "know" the data was for [X].
G - INTERNAL COMMANDS
25
The SS_WR command will not work with Lotus 1 or 1a, since these ignore multiple cells with the same address. It will work with Lotus 2 and clones that allow multiple cells with the same address. Note: The SS_WR command writes the new cell information to the end of the spreadsheet. The SS_RD command reads the first cell with the correct address that it finds. Consequently, SS_WR followed by a SS_RD for the same cell new value. If the cell had no old value, then the new value will be read. Once the spreadsheet is read and saved by 123, the SS_RD will return the new data because 123 will have removed the old data. 123 will correctly display the new data.
Here are some examples: In a Rule, IF ...... THEN SS_WR(price,F35,[X]) will WRITE the value of variable [X] into cell F35 of the spreadsheet "price," if the rule fires. In a Variable, SS_RD(parts,E22,[X],E23,[Available]) The price is is the text associated with a variable [X]. If the value of [X] is needed, the program will read the value cell E22 from the "parts" spreadsheet into variable [X] and the data in E23 into a variable on part availability. If needed, there could be additional cell and variable pairs in the expression to get more data from the spreadsheet. In the Report Generator or Command Language, the line SS_WR(price,H78,[TOTAL COST]) in the report generator will WRITE the value of variable [TOTAL COST] into cell H78 of the "price" spreadsheet.
G - INTERNAL COMMANDS
26
In a WHILE loop, SET [I] 1 WHILE ([I] < 100) SS_RD(parts,E[[I]],[X], F[[I]], [Y]) RULES ALL REPORT SS.RPT CLEAR ALL SET [I] ([I]+1) WEND would initialize [I] to 1 then read the value of row E column [I] into [X] and row F column [I] into [Y]. Then the rules would be executed and a report written. [I] is then incremented until it is greater than 100. In this example, [[ ]] are used to insert the value of the variable in the expression.
Spreadsheet Filename
OK
Prev. Field
Next Field
Cancel
To build a Lotus 123 data acquisition command, select READ or WRITE and enter the spreadsheet filename. Cell IDs (row, column) and EXSYS variable names are used in pairs. Each Cell ID must have a corresponding EXSYS variable. In a READ, the value of the cell is put in the EXSYS variable. In a WRITE, the value of the EXSYS variable is put in the cell.
G - INTERNAL COMMANDS
27
Enter the first pair of cell and variable name. To enter a second pair in the same command, click on Next Field. The Cell ID and EXSYS Address edit boxes will clear and you can enter another pair. This can be done repeatedly. To examine a cell or variable pair already entered, click on Prev Field. This will display the previous pair. When all cell or variable pairs have been entered, click on the OK button.
G - INTERNAL COMMANDS
28
Run a Report Specification File REPORT <filename> REPORT [string variable name]
filename: the name of the report command file to use. string variable name : a string variable whose value is the name of the report command file to use.
The REPORT( ) command allows the report generator to be called from any EXSYS rule or from the command file. The report specification file contains the report generator commands to be used in creating a report. The first form allows the report file to be specified explicitly, while in the second form the value of the string variable is used as the name of the file to use for the report specification. In this way, the knowledge base itself can set the name of the report specification file to be used by assigning a value to the string variable. The REPORT( ) command is also useful when a large amount of data must be passed to an external program. Here is an example: IF . . THEN REPORT(RPTFILE.1) RUN(PROG1) The report specification RPTFILE.1 could contain commands to write a large amount of data into a file that would then be read by PROG1 when it is called.
G - INTERNAL COMMANDS
29
Alternatively, a number of report specifications can be used to each add data to an overall conclusion report. The knowledge base rules can control what report specifications are invoked and used. Each of the report command files could append data to an overall report. The details of the Report Generator language are in Chapter F.
OK Cancel
G - INTERNAL COMMANDS
30
Internal Command Qualifier / Variable THEN/ELSE Command File Report Generator Custom Screen
G - INTERNAL COMMANDS
31
The STOP command will terminate execution of rules and go directly to the report generator (if one is present) and then display the conclusions. This is quite useful in situations where, once a particular answer is known, there is no need to continue asking questions. The STOP command can only appear in the THEN or ELSE part of a rule or in the command file. The execution of the rules will immediately stop if a rule with a STOP command fires. Here is an example: IF The color is green THEN and Choice 1: Probability=10/10 STOP
If this rule fires, Choice 1 will be given a value of 10 and the running of the rules will be stopped, despite any other rules that are available on other choices. STOP can be used with the FORWARD and NOBACKWARD options.
G - INTERNAL COMMANDS
32
G - INTERNAL COMMANDS
33
Each way of running external programs uses basically the same syntax and command options. The external program can be any program which can be run from the operating system. The program can be written in any language or it can be an application. This ability to run any program provides the great flexibility. When EXSYS calls an external program, EXSYSP.EXE (or EDITXSP.EXE) remains in memory. Thus, there must be enough memory available for both EXSYS and the external program to run. If there is not enough memory, you will get an error message. In most GUI environments, memory is not a problem.
H1: Syntax
All versions of the RUN command have the same basic form: RUN(filename <data1> <data2> .... <options>) filename: The name of the program to run. This can be any program that can be run from the operating system. Instead of an actual filename, the first parameter can be a string variable whose value is the name of the program to run. If a string variable is used, the first parameter is the name of the variable in [ ]. Here's an example of an external program call. RUN([P] 1 [X]) In this case, the program would derive or ask the user for the value of the string variable P, which would be used as the name of the external program called. The program name can be a batch file in DOS if the /B option is used. Data can be returned to EXSYS through a file. Any program which can write an ASCII file can pass data back to EXSYS. data#: The call to an external program can pass a number of pieces of data. The list of parameters can include either text or variables. If text is used, it is just listed. If variables are used, the name of the variable must be placed in [ ]. The variable will be replaced with its value in the call to the program. For example, RUN(DEMO ABC [X] 1.2) would call the program DEMO and pass the string ABC, the value of [X] expressed as a string and the string 1.2. It is up to the program called to correctly accept and use these items of data. If an item is in quotes, it will be passed without change. This allows passing the strings such as, "[X]" or "/C" to a called program.
Options:
There are a variety of options that effect the external program call. /B Batch Mode / DOS programs EXSYS supports calls to batch files; or DOS commands; by adding a /B to a RUN( ) command. It is also possible to call a batch file by calling COMMAND.COM and passing the batch file name as a parameter. There may be a problem with this approach: depending upon the end user's computer configuration, it may not be easy to tell where COMMAND.COM is. With the /B option, EXSYS will determine where COMMAND.COM is and use it to call the batch file or DOS command. If the MS Windows version of EXSYS is being used, and a NON-Windows (DOS) program is being called, use /B. For example: RUN(XXX.BAT /B) will execute the batch file XXX.BAT. RUN(DIR C:*.C /B) will display a directory of the .C files on drive C. In this case, the program will not pause after displaying the directory. However, you could use 2 commands such as, RUN(DIR C:*.C >C:LIST /B) DISPLAY(C:LIST) The first command uses the ability of DOS to redirect the directory output to a file C:LIST, and the second command, displays the file created. (For information on redirection, see your DOS manual.)
/C and /# Passing Arguments on the Command Line This determines if the data arguments will be passed to the external program on the command line; or in a file. Data is passed to an external program by two methods: Passing data in a file Passing data on the command line The default method is to pass data in the file PASS.DAT. This is an ASCII file. Data parameters are written to this file and the file is closed before the external program is called. It is the responsibility of the external program to read the data from PASS.DAT. (The name of the file that the data is passed to can be changed with the option PASS= in the command line or configure file.) Passing data by using a file, is very general, but has some disadvantages. - It requires opening, writing/reading and closing a file twice which may be slow. Also, if a call is made to a program like BASIC, the name of the basic program must be specified (e.g. RUN(BASIC BASPROG) - we want the name of the basic program, BASPROG, passed to BASIC, not written to a file.) To avoid these problems, EXSYS can also pass the parameters on the command line when the external program is called. This is just like entering the parameters on the command line when a program is called from the operating system. Passing data on the command line is much faster since the data does not have to be written to a file and then read from a file. Instead, the data is immediately available to the called program. Unfortunately, not all programs can accept data as a command line argument. If it is desired to pass arguments on the command line, the /C option MUST be used or all arguments will be passed in PASS.DAT. The /C and /# options tell EXSYS to pass the arguments on the command line rather than in PASS.DAT. If you want to pass more than the program name as a command line argument, but still pass others in PASS.DAT, use /# - where # is the number of the argument to pass on the command line.
For example, BASIC will not usually accept command line arguments for data. Suppose we want to call a basic program TEST and pass it the value of [X] and [Y] in PASS.DAT. If we use RUN(BASIC TEST [X] [Y]) the program name TEST will not be passed as a command line argument. Instead, it will be written to PASS.DAT. The file PASS.DAT will contain the ASCII string TEST and the values of the variables [X] and [Y]. If we use RUN(BASIC TEST [X] [Y] /C) all of the parameters will be passed on the command line and the file PASS.DAT will not be created. Basic will not be able to use the values of [X] and [Y] passed this way. We could pass the values of [X] and [Y] using the REPORT( ) command, however, it is easier to use RUN(BASIC TEST [X] [Y] /2) This causes the first 2 arguments, BASIC and TEST, to be passed as command line arguments. PASS.DAT will be created with the values of [X] and [Y]. [X] and [Y] will be passed in PASS.DAT. When programs can accept data on a command line, this method is very fast. When programs make many calls, it is also much more efficient. NOTE: In DOS, data passed on the command line is limited to 127 characters in length. Since numeric variables are stored as floating points, each can use 10 characters and it is possible to fill up the command line. If this happens EXSYS will tell you and you must use the PASS.DAT method instead.
/R
Restart This option causes EXSYS to RESTART; at the beginning of the run, after calling the external program. This is very useful for expert systems that are monitoring a process. For example, an expert system could have a rule that fires to call an external program to do something and then restart the process again. If new data indicated some action was necessary, a different rule could call another external program (or the same program with different parameters passed) to alert someone or to correct the process. Do not use the /R option unless you want to restart the run after the external program is called. Returning Multiple Values Normally, a RUN( ) command associated with a particular qualifier or variable will only return data for that qualifier or variable. The /M option tells the program that multiple data items will be returned. If /M is not added, EXSYS will default to accepting only one item of data when an external program call is associated with a specific qualifier or variable. If data will be returned, the /M option must be used when calling external programs from the THEN/ELSE portion of a rule or a command file. Add Ctrl-Z Adding the /Z option to the run command, causes a CTRL-Z to be added to the end of the PASS.DAT file. This is necessary for compatibility with some external programs.
/M
/Z
Program Name: Data: Pass all parameters on the command line Pass first N parameters on command line N= Pass parameters in PASS.DAT
Return Mutliple data items Batch file or NON-WINDOWS program Restart after call Add Ctrl-Z to PASS.DAT Cancel OK
Enter the program name and any data to pass to the program. The data may contain EXSYS variables, text strings or quoted strings. Select how the parameters should be passed to the program and click on the appropriate radio button. If only some parameters are to be passed in PASS.DAT, enter the number of parameters to pass. If the program will return multiple data items, or if the call is not associated with a qualifier or variable, click on the Multiple data items box. If the program is running in MS Windows, and the called program is a Non-Windows (DOS) program, click on the NonWindows button. If a restart or Ctrl-Z is required, click on the appropriate button. Once all of the parameters are set, click on the OK button.
The sequence that should be used in the external program is: 1. Call the external program from EXSYS. If it is a nonWindows (DOS) program, be sure to set the /B option in the RUN( ) command. 2. Have the external program perform its operations. 3. If data is to be returned, have the external program open the return data file (usually RETURN.DAT), write the data and close the return file. 4. When the external program is finished, have it open the flag file for writing, immediately close the flag file and exit. For example: f = fopen("EXSYS_EP.FIN", "w"); fclose(f); exit(0); It is not necessary to write anything to the file. Its creation, even with 0 bytes length is adequate. It is very important to exit as soon as possible since EXSYS is checking for the existence of the file and will retake control as soon as it finds it. EXSYS is designed to allow a short time after it finds the file to allow your program to terminate, but the time is limited. If you already have a non-Windows program which you wish to call, you can also use a batch method. 1. Create a 1 byte file named xxx (or whatever you like). 2. Instead of directly calling your program, call the following batch file: copy xxx exsys_ep.xxx call your program here rename exsys_ep.xxx exsys_ep.fin The first line makes a dummy file. The second runs your program which should create the return data file, but NOT the flag file. The third line creates the flag file through a "rename" which is the fastest possible way to create it. Parameters can be passed into your program through batch file replaceable parameters. (See your DOS manual for information on replaceable parameters in a batch file.)
For variables:
V <var #> <value> or [var name] <value> C <choice #> <value> or C "text" <value >
For choices:
<qual #>, <var #> or <choice #> The number of the qualifier, variable or choice for which the data is being passed back "name" "text" <value> The name associated with the qualifier. A unique text sub-string in the choice. The data to assign, in the correct format. For numeric variables, a numeric value. For string variable, a text string. For qualifiers a string listing the numbers of the values to set. If more than one value is set, they must be separated by spaces or a comma. For choices, a value appropriate to the confidence system being used.
For example: 1. V3 2.1 2. [X] 2.1 means assign a value of 2.1 to variable 3 means assign a value of 2.1 to variable [X]
3. If qualifier #7 has four values: Qualifier #7 THE COLOR IS 1. RED 2. BLUE 3. GREEN 4. ORANGE and we have a line in RETURN.DAT, Q7 1,2 this means for qualifier 7, set values 1 and 2 as true, or "The color is red or blue". If more than one value is passed back, the values must be separated by a space or comma. If this qualifier has the associated name "COLOR", we could use Q "COLOR" 1,2
H - EXTERNAL PROGRAM CALLS
12
4. You can pass data back for as many variables, qualifiers or choices as you wish. For example, if RETURN.DAT contained: V2 1.7 [X] 6.3 V12 ABCD Q7 1,2 Q "TIME" 3 C "Part ABC" 8 EXSYS would assign a value of 1.7 to variable number 2; assign 6.3 to variable [X]; assign the string "ABCD" to string variable 12; select the first two values of qualifier 7; select the third value of the qualifier named "TIME" and assign a value of 8 to the choice containing the text "Part ABC'. 5. The multi-variable approach is useful if the external program can set several items of data at once. Suppose we want to have the user enter a list of variables and pass the number of data points and the average back to EXSYS, which stores the data in variables 1 and 6. We could use the following program written in BASIC. 10 COUNT = 0 20 SUM = 0 30 INPUT "DATA TO BE AVERAGED OR <ENTER> TO END", X 40 IF X <> 0 THEN COUNT=COUNT+1: SUM=SUM+X: GOTO 30 50 OPEN "RETURN.DAT" FOR OUTPUT AS #1 60 PRINT #1, "V1 ";SUM/COUNT 70 PRINT #1, "V6 ";COUNT 80 CLOSE #1 90 SYSTEM The program writes "V1 " and the average value on one line and "V6 " with the number of data points on the next line in the file RETURN.DAT. Note: The file compression utility SHRINKP removes unused formulas and variables. This can cause the number of a variable to change if there were unused variables preceding it. Be sure to check the numbers of your variables after running SHRINKP and make the appropriate corrections in your external programs. Likewise, deleting a qualifier can change the qualifier numbers. It is a good idea to pass data by name or text whenever possible.
13
When data is passed back for a choice, the value will be incorporated with any other values assigned to the choice by other rules. The value will NOT overwrite existing data; it will be combined with it as if it were assigned in a rule.
14
For example, if RETURN.DAT contained !WHY EXSYS would display the rules that caused the question to be asked.
16
1. Have a choice also in the THEN part of the rule. The system will backward chain on the choice IF [X] > 0 THEN RUN(TEST [X]) and Choice 1: Conf=5 2. Have a variable in the THEN part of the rule if the system will backward chain on the variable. IF [X] > 0 THEN RUN(TEST [X]) and [X] is given the value 1 3. Force the rule to fire through the command language RULES 5 /F 4. Use forward chaining. Since forward chaining is not goal driven, it will test all of the rules.
17
H8: Calling Programs from the Report Generator, Command File or Custom Screen File
Calling external programs from the report generator or other command files, is the same as calling a program from the THEN/ELSE part of a rule except, the command is put in the report specification file with an ASCII editor. It is not part of the EXSYS rules. Note, in the report generator, the command does not have to be in ( ). The ability to pass data and the options available are the same as in the above RUN ( ) command from THEN/ELSE. Remember, you must use the /C or /# option if the data is to be passed on the command line. Using the /M option causes EXSYS to read returned data. This should only be used for REPORT commands in rules. For example, the rule: IF ... THEN REPORT(XXX.RPT) where the report specification file XXX.RPT contained: FILE xxx.dat V CLOSE RUN TEST /M would be a way to call an external program, TEST, and make all of the data on the variables available to it. This would be a useful technique if there were too many variables to pass on the command line or list in the run call.
18
19
20
Since the program is being called to get a value for the variable, EXSYS expects data to be returned. The method of passing data back is in the file RETURN.DAT (unless changed to another filename with the RETURN= command). In this case, there are two options to the form in which the data is passed: 1. A single value passed back with no "address" information. It is assumed the value returned will be assigned to the variable that caused the program to be called. 2. Multiple values passed back with "address" information on each line. (The call to the external program must have used the /M option.) The first form is the standard way to get data for programs associated with a specific variable. In this case, just the value to be returned is written by the external program in the file RETURN.DAT. For example, if variable 7 called an external program which returned the value 4.5 as the value, the RETURN.DAT file could contain just 4.5 rather than V7 4.5, although the second form would also be valid if the /M option was used. If the /M option is used, data can be passed back for many variables, qualifiers and choices. But be sure to pass data back for the variable that caused the program to be called. The format of the data passed back with the /M option is the same as described in Section H6. CAUTION: Passing back multiple items from an external program call associated with a variable can overwrite existing data. Passing data back for a variable or qualifier that already has a value will OVERWRITE the existing value with the new one. This can result in changing the values input by the user or derived by the system. Note: Use care when passing data back to other than the calling qualifier or variable to prevent overwriting existing data.
21
22
with external programs associated with a variable, data can be returned in two forms: 1. A single value list passed back with no "address" information. It is assumed the value returned will be assigned to the qualifier that caused the program to be called. 2. Multiple values passed back with "address" information on each line. (The call to the external program must have used the /M option.) In the first case, the data is automatically assigned to the qualifier that called the program. The data returned is the number or numbers of the values that are to be selected. For example, if after the call to COLOR in the example above, RETURN.DAT contained: 1,3 the first and third values in the list would be set for the qualifier or: The color is red and blue If the /M option is used, data can be passed back for many variables, qualifiers and choices. Be sure to pass data back for the qualifier that caused the program to be called. The format of the data passed back with the /M option is the same as described in Section H6. Caution: As with variables, passing back multiple items from an external program call that is associated with a qualifier can cause problems. It is possible to overwrite existing data. Passing data back for a variable or qualifier that already has a value will OVERWRITE the existing value with the new one. This can result in changing the values input by the user or derived by the system. Note: Use care when passing data back to other than the calling qualifier to prevent overwriting existing data.
23
24
program must be specified. For example, suppose BASIC.COM is on disk C in sub-directory BAS and your basic program TEST.BAS is also in the same sub-directory. To run this program you would enter: RUN(C:\BAS\BASIC C:\BAS\TEST /C)
Also remember, the file called by the RUN( ) command as an external program MUST be an executable file. In DOS that is one that ends in .EXE or .COM, not a batch file. In UNIX or VMS, make sure the program can be run and that the access privileges allow running. If a batch file is used, the /B option must be used.
25
Multi-variable Approach
1. Called by indicating that an external program should be called at the start of EXSYS or by using the /M option with an external program call from a qualifier or variable. Returned data must include "address" information on what qualifier, variable or choice to assign the data to. 2. Data is returned in the file RETURN.DAT. Data is passed out in PASS.DAT or on the command line. 3. Allows data to be passed back for any number of variables, qualifiers or choices.
26
4. The return file has data in the form: For qualifiers: Q <qual #> <value(s)> or Q "name" <value(s)> V <var #> <value> or [var name] <value> C <choice #> <value> or C "text" <value >
For variables:
For choices:
27
28
This allows batch analysis of database records without user intervention and, with this technique, an expert system can be created to analyze raw data from an external source and produce a report of the analysis. For example, the report file might contain: FILE ACCTDUE.RPT /A FIRST "Accounts Overdue" C1 =10 /V2 RESTART This report will print the title "Accounts Overdue" and a list of account numbers (or names) contained in variable 2. Choice 1 would be set to indicate if the account was overdue. Only when choice 1 was set to a value of 10 would the value of variable 2 be printed to the file. The RESTART command tells EXSYS to immediately read the next set of data. The data passed in would include name or account number along with other data to determine the status of the account.
29
30
3. Hypertext
Providing multilevel custom help for key words in rules, qualifiers, notes, etc. Hypertext keywords are highlighted in blue and clicking on a hypertext word brings up an explanation of the word. The explanation screens are designed using the custom screen language.
I - USER INTERFACE
I - USER INTERFACE
I - USER INTERFACE
For example:
~Q 1 ~Q "DAY" ~V 4 ~[X] indicates the start of the custom screen for qualifier 1 indicates the start of the custom screen for the qualifier named "DAY" indicates the start of the custom screen for variable 4 indicates the start of the custom screen for variable [X]
I - USER INTERFACE
Likewise the confidence associated with a qualifier would start with: ~%Q "name" or ~%Q #
I - USER INTERFACE
In many cases, the returned information needs to contain a quote, ", character to designate a qualifier name or choice text string. Since the screen commands use " " to designate strings, a " character in the string will be incorrectly handled. To avoid this problem, within quoted strings a single quote character ' can be used. This will be converted to a " when the string is returned. For example, if we want to set value 1 of the qualifier named color, the normal return string is Q "COLOR" 1 but in a button command use: ~BUTTON("RED", "Q 'COLOR' 1", 200, 300, 60, 30 - I) notice that the word color is marked with ' rather than ". When the string is returned, the ' will be converted to " to return Q "COLOR" 1.
For example, if a button was defined as: ~BUTTON("Why?", "!WHY", 200, 300, 60, 30 - I) clicking on the button would display the rules that caused the question to be asked.
I - USER INTERFACE
If a mouse click was made in the specified regions , EXSYS would display the hypertext screen associated with the keyword "Part 23". Passing back !END will terminate a hypertext stack and return to the starting screen, even if there are several levels of hypertext screens.
I - USER INTERFACE
will make the overall window 400 pixels wide and 300 pixels high with the upper left corner at 50,50. If there is no SET_WIN command, the default window size is set to: 100,100,350, 250 It is the responsibility of the developer to make sure that all text, buttons, etc. are within the window size specified. The window created will start at the size specified, but can be resized and moved by the end user. If you do not want the end user to be able to move or resize the window, repeat the SET_WIN command twice at the start of the file. This will force the window to remain the same size. For example: ~SET_WIN ~SET_WIN 50,50, 400, 300 50,50, 400, 300
I - USER INTERFACE
~BACKGROUND color
Sets the background and foreground color. To set entire screen to a color, set background and then do ~CLS. For lines and rectangles, see ~LINE_COLOR and ~FILL_COLOR. color: RED GREEN BLUE CYAN MAGENTA YELLOW BLACK DKGRAY GRAY LTGRAY WHITE #, #, # red, green, blue values for custom colors
~BEEP
Causes a beep to sound.
Define a button. The button can be a push-button, check box or radio button. label return string label for the button, in " " the string to return if the button is pressed, in " ". If the button is pressed, this is the string that will be returned to EXSYS. The syntax of the string should be the same as that used for returning data from an external program into EXSYS. If the return string is "~command", pressing the button causes the specified command to execute immediately. Command can be any EXSYS GUI screen definition command (However ~PAUSE is NOT recommended, and should not be necessary). This is especially useful with ~GOTO commands. When the ~command form is used, normally the -X option will also be used. If more than one command is to be executed, separate commands with "|||" (Three vertical line characters). Note: If double quotes, " , are needed in the return prefix for data element identification, or to define a command string, replace " with ' . The ' will automatically be converted to " when the string is used. rct left side, top, horizontal size, vertical size
Options:
-I -C -R -S return immediately if this button is pressed. (option - default=NO) make button a check box (option - default=normal button) make button a radio box (option - default=normal button) for radio buttons only: Indicates START of the set of radio buttons. Only one item in this set can be selected at a given time. (default=include in current set)
I - USER INTERFACE
10
-E
-A -P -X -D
for radio buttons only: Indicates END of the set of radio buttons. Only one item in this set can be selected at a given time. (default=include in current set) Make active at start - make the button the default. Break a ~PAUSE. Write current data and continue with the next command after the PAUSE. No output in return file - use for command or information buttons. Delete command after executing it. Note: If the return string = ~command form is used, in some cases the command should only be executed once - even if the button is pressed multiple times. The -D option will prevent multiple calls to the same command. The command is again available for use after a reset, such as a ~PAUSE followed by a ~GOTO. Note: Radio buttons must be defined as a set with sequential BUTTON commands. If more than one set is defined, the -S and -E flags should be used to designate the individual sets. If there is only one set, the -S and -E commands flags are not necessary, but the BUTTON commands must be sequential.
Examples:
~BUTTON "RED" "Q1 2" 100, 100, 60, 30 -I will create a button labeled RED at pixel coordinates 100, 100 with a horizontal size of 60 pixels and a vertical size of 30 pixels. If the button is pressed, the string Q1 2 will immediately be returned to EXSYS to set qualifier 1 value 2. ~BUTTON "YELLOW" "Q1 1" 100, 100, 60, 30 -R -S -A ~BUTTON "RED" "Q1 2" 150, 100, 60, 30 -R ~BUTTON "GREEN" "Q1 3" 200, 100, 60, 30 -R -E will create a set of radio buttons button labeled YELOW, RED and GREEN. The starting active button will be the one labeled YELLOW. Since these are defined as a set, only one of the radio buttons can be selected at a given time. Clicking on one will reset the others. When the screen returns (due to some other button) the string associated with the last button pressed will be returned to set the qualifier.
I - USER INTERFACE
11
~CANCEL
Cancel all information already written to return file and empty file. After the ~CANCEL command, new information can be written to the return file. A ~CANCEL command is normally used as a button command or controlled by a GOTO command. To guarantee an empty return file, follow the ~CANCEL by a ~EXIT. For example: ~BUTTON "Cancel" "~CANCEL|||~EXIT" 100, 100, 50, 50 -I
~CLR_BUTTON
Delete all active buttons from the screen. Data on the buttons that were pressed prior to the execution of the ~CLR_BUTTON command, are written to the file before they are deleted.
~CLR_EDIT
Delete all active Edit regions from the screen. Information on the edit regions is written to the file before they are deleted.
~CLR_MOUSE
Delete all active Mouse regions from the screen. Information on the mouse regions that were selected is written to the file before they are deleted.
~CLR_SCROLL
Delete all active Scroll regions from the screen. Information on the scroll bars is written to the file before they are deleted.
I - USER INTERFACE
12
~CLS
Clear window to current pattern and background color. Does not clear buttons, scrolls, edit windows or mouse regions. See CLR_ .
~CURSET x, y
Sets x,y coordinates for next echoed text and sets starting point for a ~LINE or ~ARROW command. x,y - x and y coordinates in pixels.
Options:
I - USER INTERFACE
13
-F:filename Add the contents of file "filename" to the edit window -S:x Set text size. X = B - use big font S - Use small font F - Use fixed space font (Default is to use normal font) -M:# maximum number of lines to return. This is not the maximum that is accepted in the edit window. If more than # lines are entered, they will be ignored. This prevents creating undefined EXSYS variables with ## in the return prefix. Do not return data for this edit box. Information only. Even read only boxes will return data unless the -X option is used. read only box can be a convenient way to force a file of data into the return data file.
-X
Examples:
~EDIT "", 20,20, 300, 200 -F:stuff.txt -R -X
will make an edit region at 20,20 with horizontal size of 300 pixels and vertical size of 200 pixels. The text of file STUFF.TXT will be put in the edit region as a read only file the will not return any data.
~EDIT "[S]",
20,20, 300, 30 -V -1
will make a edit region that will accept one line of text without vertical scrolling. The string entered will be returned, preceded by [S] to indicate that the value is to be assigned to the EXSYS variable [S].
I - USER INTERFACE
14
First create the edit regions with ~EDIT commands, then call ~EDIT_FILL filename. The file specified should contain the values to put in the edit regions. The file should be have one value per line. The value on the first line will be put in the first EDIT regions defined in the screen commands, the second line will be put in the second region defined, etc. To skip an edit region, leave a blank line in the file. If there are more lines than in the screen file, the extra lines will be ignored.
~EXIT
EXIT immediately without writing any additional information to the return file. A CANCEL command is normally used as a button command, or controlled by a GOTO command. Data already written to the return file, will not be deleted. To guarantee an empty return file, follow the ~CANCEL by a ~EXIT.
~FILL_COLOR color
Sets color to use to fill shapes (rectangles and ovals). color: RED GREEN BLUE CYAN MAGENTA YELLOW BLACK DKGRAY GRAY LTGRAY WHITE #, #, #
I - USER INTERFACE
15
~FOREGROUND color
Sets the foreground color. Foreground applies to text echoed to the screen. For lines and rectangles, see ~LINE_COLOR and ~FILL_COLOR. color: RED GREEN BLUE CYAN MAGENTA YELLOW BLACK DKGRAY GRAY LTGRAY WHITE #, #, #
~GOTO:label
GOTO to line ~:label. The GOTO point must be in the originally specified screen, defined by the ~word. It is not possible to GOTO a section of the screen file for another ~word. GOTO should be used to go to a label point further DOWN in the file. This is always safe. GOTO can be used to go back in the file, however the action is not exactly the same. When going further down in the file, all current data is saved. When going UP in the file, GOTO resets the starting point for window updates to that new line. Consequently, when going up in the file, it may be necessary to restate some parameters such as color to make sure they are not lost in updates. All buttons, scrolls and edit windows active when a GOTO is called, will stay active. This is to allow screens which can ask additional information only when particular buttons are pressed. Moving up in the file makes it possible to make two copies of a button, scroll, or edit window. This can be a problem because each copy will write data back to the return file. In some cases, it is desirable to recreate buttons which have been cleared, but the screen designer must consider which buttons are active and which are inactive when moving UP the file. Use CLR_BUTTON, etc. and then redefine the button if necessary.
I - USER INTERFACE
16
~:label
GOTO branch point. Used from GOTO as a command or in return string from a button.
~LINE x, y
Draw a line from current point to x,y. End point sets new starting point for the next line. x,y - x and y coordinates in pixels.
~LINE_COLOR color
Sets the color to be used for drawing for lines and borders of shapes. color: RED GREEN BLUE CYAN MAGENTA YELLOW BLACK DKGRAY GRAY LTGRAY WHITE #, #, #
~LINE_WIDTH width
Set width, in pixels, for lines, arrows and the borders of shapes.
I - USER INTERFACE
17
Options:
-I -2 -P return immediately if the mouse is clicked in the region. (option - default=NO) Return immediately only if a Double Click is done in the region Break a ~PAUSE. Write current data and continue with the next command after the ~PAUSE.
I - USER INTERFACE
18
-X -D
No output in return file - use for command or information regions Delete command after executing it. If the return string = ~command form is used, in some cases the command should only be executed once even if the mouse is pressed multiple times in the region. The -D option will prevent multiple calls to the same command. The command is again available for use after a reset, such as a ~PAUSE followed by a ~GOTO.
~OVAL rct
Draws an oval or circle with current line color and type. Fill is current pattern and fill color. The RCT defines the maximum size of the oval. rct left side, top, horizontal size, vertical size
~PATTERN pattern
Defines the pattern to be used for filling solids, rectangles and ovals. pattern: NONE HOLLOW SOLID HORZ VERT FDIAG BDIAG CROSS DIAGCROSS no pattern empty solid horizontal lines vertical lines forward diagonals backward diagonals Crosshatch Diagonal Crosshatch
~PAUSE
Pause the screen and wait for input. The ~PAUSE is broken by a button with a -I or -P option or the EXIT line from the menu. All data elements selected will be written to file after the pause is broken. PAUSE can be used to create multiple part screens that write out some data, clear and ask additional data.
I - USER INTERFACE
19
~ROUND_RECT rct
Draws an rounded corner rectangle with current line color and type. Fill is current pattern and fill color. rct left side, top, horizontal size, vertical size
~RECT rct
Draws an rectangle with current line color and type. Fill is current pattern and fill color. rct left side, top, horizontal size, vertical size
~SAMEAS word
Often there are two or more keywords that should call the same hypertext screens. Sometimes this is due to grammar (plurals for example) or sometimes the words are just synonyms. When there are different keywords calling the same screen, you could just repeat the screen with the new keyword. However, that would waste space and be more difficult to maintain. The ~SAMEAS command allows one keyword to be defined as another. The word referenced must exactly match the ~~keyword line in the .SCR file. The ~SAMEAS command must be the first (and only) line in the set of screen commands for a keyword being referenced to another. Note: This command is ONLY used for hypertext screens. For example, to define WORD1 to use the same screen as WORD2: ~~WORD1 ~SAMEAS WORD2 would cause the WORD1 hypertext screens to be called if WORD2 was selected. Note: Be careful about loops!! In the above example, if we also had: ~~WORD2 ~SAMEAS WORD1 there would be a loop and the system would hang.
I - USER INTERFACE
20
Options:
-V -H -A:value -D:x,y -X Make slider vertical Make slider horizontal Initial value for the scroll thumb Display current value of scroll thumb at coordinate x,y in current font and color. Set the font and colors before calling ~SCROLL. No return value. Use to display info only.
~SET_WIN rct
Set window size and position - must be the first command. rct left side, top, horizontal size, vertical size
text
A text string with no starting ~ is echoed to the screen in the current text size and color. A screen position can be set with CURSET, and then sequential lines echoed to the screen. Line spacing will be set appropriately for the font size. All lines will have the left margins aligned at the point set by the CURSET column position.
I - USER INTERFACE
21
~TEXTSIZE size
Set the size of the text echoed to the screen, or displayed with a ~SCROLL -D option.
Size:
LARGE NORMAL SMALL
~VERIFY expression
The ~verify command allows user input for a variable to be verified against a boolean expression. It is used only for screens created to ask for user input for variables - not for custom help screens, hypertext or screens for qualifiers. The program will accept user input and then test it using the expression. The expression must be a boolean expression that will evaluate to TRUE for valid data. The expression can contain any valid EXSYS expression. The ~VERIFY command will be considered the last command in the screen definition for the variable. If the input passes the specified test, processing continues. However, if the input fails the test, the commands following the ~verify will be displayed and the original question asked again to get appropriate input. This allows a custom message to be displayed if the data was not appropriate. Data verification, beyond simple range checking, can be removed from the rules and put in the VERIFY statement. This is much simpler and easier to maintain. For example, suppose we have a variable [X] and only want to accept integer values between 0 and 10 and we wanted to display a message if the value was out of range. We could use: ~[X] screen commands for [X] ~VERIFY (([X]>=0) && ([X]<=10) && ([X]==INT([X])) ~SET_WIN 100,100, 300,200 ~PATTERN SOLID ~BACKGROUND RED ~CLS ~CURSET 20,20 The input provided is invalid. The value must be between 0 and 10 and be an integer. You input [[X]] which does not meet the criteria. ~BUTTON "OK", "" , 20, 165, 50, 25 -I ~END more custom screens
I - USER INTERFACE
22
The value input would be checked against the verify expression. If the VERIFY expression was true, the program would continue and use the data. If the expression was false, the custom screens commands following the ~VERIFY up to the start of the next screen would be displayed. The custom screen for [X] would then be redisplayed and new data requested. Note: the command lines following the VERIFY should have an OK button with a -I option or something equivalent to end the window. The VERIFY option can also be used for string variables. Suppose variable [S] can only have one of three acceptable names: ~VERIFY (([S]=="JOE") || ([S]=="SAM") || ([S]=="MIKE")) If the value for [S] is one of the three names it will be accepted, otherwise it will be rejected. VERIFY can also be used with the custom screens for confidence variables.
I - USER INTERFACE
23
/* draw accent box */ /* draw 2nd accent box */ /* draw main rectangle */ /* add buttons to ask
questions */ ~BUTTON "WHY", "!WHY", 60, 350, 80, 35 -I ~BUTTON "KNOWN", "!KNOWN", 160, 350, 80, 35 -I ~BUTTON "EXIT", "!EXIT", 260, 350, 80, 35 -I ~BUTTON "HELP", "!HELP", 360, 350, 80, 35 -I ~FOREGROUND BLACK ~TEXTSIZE LARGE ~CURSET 50,120 /* position cursor for text */ The WARNING light is ON: /* write text message */ ~BUTTON "YES", "Q 'light' 1", 100,175,100,50 -I ~BUTTON "NO", "Q 'light' 2", 300,175,100,50 -I ~END
I - USER INTERFACE
24
WHY
KNOWN
EXIT
HELP
Example 2: This screen has several check boxes. Multiple boxes can be checked and the screen will not return until the OK button is pressed.
~~Q "SOUND" /* screen for qualifier "SOUND" */ /* set window size */ /* make non movable */
~SET_WIN 30, 50, 500, 400 ~SET_WIN 30, 50, 500, 400 ~PATTERN SOLID ~BACKGROUND BLACK ~CLS /* fill with solid black*/ ~FILL_COLOR CYAN ~LINE_COLOR WHITE ~LINE_WIDTH 5 /* draw accent box */ ~ROUND_RECT 20,20,460, 300 ~LINE_WIDTH 2 ~FILL_COLOR WHITE ~ROUND_RECT 30,30,440, 280 ~TEXTSIZE NORMAL ~FOREGROUND BLACK ~CURSET 50,60 /* set position for following text */
Reconnecting CABLE A to the system, with the power on and a signal in the amplifier produces: /* define check boxes */ ~BUTTON "No Sound", "Q 'sound' 1", 75,100,150,40 -C ~BUTTON "Static", "Q 'sound' 2", 75,160,150,40 -C
I - USER INTERFACE
25
~BUTTON "Intermittent Static","Q'sound' 3", 75,220,150,40 -C ~BUTTON "Clicks", "Q 'sound' 4", 275,100,150,40 -C ~BUTTON "Loud POP", "Q 'sound' 5", 275,160,150,40 -C ~BUTTON "Good Sound","Q 'sound' 6", 275,220,150,40 -C ~BUTTON "OK", "", 225,270,50,30 -X -I ~END
Reconnecting CABLE A to the system with the power on and a signal in the amplifier produces: No signal Static Intermittent Static Clicks Loud POP Good Sound
OK
Example 3: This screen is almost identical to that in Example 2, but the check boxes have been changed to radio buttons. In Example 2, multiple boxes could be checked, while here only a single radio button can be selected. The screen will not return until the OK button is pressed. ~~Q "SOUND" ~SET_WIN 30, 50, 500, ~SET_WIN 30, 50, 500, ~PATTERN SOLID ~BACKGROUND BLACK ~CLS ~FILL_COLOR CYAN ~LINE_COLOR WHITE ~LINE_WIDTH 5 ~ROUND_RECT 20,20,460, ~LINE_WIDTH 2 ~FILL_COLOR WHITE ~ROUND_RECT 30,30,440, ~TEXTSIZE NORMAL ~FOREGROUND BLACK ~CURSET 50,60 400 400 /* custom screen for qualifier "SOUND" */ /* set window size */ /* make non movable */ /* fill with solid black*/ /* draw accent box */ 300 280 /* set position for following text */
I - USER INTERFACE
26
Reconnecting CABLE A to the system, with the power on and a signal in the amplifier produces: /* define check boxes */ ~BUTTON "No Sound","Q 'sound' 1", 75,100,150,40 -R -S ~BUTTON "Static", "Q 'sound' 2", 75,160,150,40 -R ~BUTTON "Intermittent Static","Q 'sound'3", 75,220,150,40 -R ~BUTTON "Clicks", "Q 'sound' 4", 275,100,150,40 -R ~BUTTON "Loud POP", "Q 'sound' 5", 275,160,150,40 -R ~BUTTON "Good Sound", "Q 'sound' 6", 275,220,150,40 -R -E ~BUTTON "OK", "", 225,270,50,30 -X -I ~END
Reconnecting CABLE A to the system with the power on and a signal in the amplifier produces: No signal Static Intermittent Static Clicks Loud POP Good Sound
OK
Example 4: In this case the radio buttons from example 3 have been rearranged and an edit filed has been added to provide explanation. The text input into the edit field is read only and not returned as data. ~~Q "SOUND" ~SET_WIN 30, 50, 500, 400 /* set window size */ ~PATTERN SOLID ~BACKGROUND BLACK ~CLS ~FILL_COLOR CYAN ~LINE_COLOR WHITE ~LINE_WIDTH 5 /* draw accent box */ ~ROUND_RECT 20,20,460, 300 ~LINE_WIDTH 2 ~FILL_COLOR WHITE ~ROUND_RECT 30,30,440, 280 ~TEXTSIZE NORMAL ~FOREGROUND BLACK ~CURSET 50,60 /* position for writing text */
I - USER INTERFACE
27
Reconnecting CABLE A to the system, with the power on and a signal in the amplifier produces: /* add radio buttons */ ~BUTTON "No Sound", "Q 'sound' 1", 65,100,150,20 -R -S ~BUTTON "Static", "Q 'sound' 2", 65,130,150,20 -R ~BUTTON "Intermittent Static","Q'sound'3", 65,160,150,20 -R ~BUTTON "Clicks", "Q 'sound' 4", 65,190,150,20 -R ~BUTTON "Loud POP", "Q 'sound' 5", 65,220,150,20 -R ~BUTTON "Good Sound", "Q 'sound' 6", 65,250,150,20 -R -E ~BUTTON "OK", "", 225,275,50,25 -X -I /* define edit region */ ~EDIT "", 275,100,180,170 -S:S -X -R -L /* echo text into the edit region */ Connecting the cable to the system should be done with care. First turn off all power to the system. Check that all lights are off. Make all connections and then turn power back on, starting with the preamp. Turn the amplifier on last. If the system makes a loud noise, turn it off immediately and check the fuses. ~LISTEND ~END /* end of edit region text */
Reconnecting CABLE A to the system with the power on and a signal in the amplifier produces: No signal Static Intermittent Static Clicks Loud POP Good Sound OK
Connecting the cable to the system should be done with care. First turn off all power to the system. Check that all lights are off. Make all connections and then turn power back on, starting with the preamp. Turn the amplifier on last. If the system makes a loud noise, turn it off immediately and check the fuses
Example 5: This screen shows a set of SCROLL controls that return values to a set of EXSYS variables simultaneously. The current value of the scroll is echoed beneath it.
I - USER INTERFACE
28
~SET_WIN 30, 50, 450, 320 /* set window size */ ~PATTERN SOLID ~BACKGROUND BLACK ~CLS ~LINE_COLOR BLUE ~FILL_COLOR BLACK ~RECT 10,10,430,300 /* draw a border */ ~TEXTSIZE NORMAL ~FOREGROUND WHITE ~CURSET 20,30 Select the filter pattern to apply to the signal: ~TEXTSIZE SMALL ~FOREGROUND YELLOW ~curset 25,60 2040 ~SCROLL "[F 20 40] ", 1, 100, 27,80,36,135 -D:27,235 -V ~curset 65,60 4080 ~SCROLL "[F 40 80] ", 1, 100, 67,80,36,135 -D:67,235 -V ~curset 105,60 80160 ~SCROLL "[F 80 160] ", 1, 100, 107,80,36,135 -D:107,235 -V ~curset 145,60 160320 ~SCROLL "[F 160 320]", 1, 100, 147,80,36,135 -D:147,235 -V ~curset 185,60 320640 ~SCROLL "[F 320 640] ", 1, 100, 187,80,36,135 -D:187, 235 -V ~curset 225,60 6401K ~SCROLL "[F 640 1K] ", 1, 100, 227,80,36,135 -D:227, 235 -V ~curset 265,60 1K2K ~SCROLL "[F 1K 2K] ", 1, 100, 267,80,36,135 -D:267,235 -V ~curset 305,60 2K4K ~SCROLL "[F 2K 4K] ", 1, 100, 307,80,36,135 -D:307,235 -V ~curset 345,60 4K8K ~SCROLL "[F 4K 8K] ", 1, 100, 347,80,36,135 -D:347,235 -V
I - USER INTERFACE
29
~curset 385,60 8K16K ~SCROLL "[F 8K 16K] ", 1, 100, 387,80,36,135 -D:387,235 -V ~BUTTON "OK", "", 180,260,90,40 -X -I ~END
50.5
50.5
50.5
50.5
50.5
50.5
50.5
50.5
50.5
50.5
OK
Example 6: This screen is a multiple text edit, radio button and check box window that could be used to enter a variety of information on a person. When all of the data is entered, clicking on the OK button would return the data entered. The [NAME##] form is used in the name and address field. Each line of the address will be returned as a separate EXSYS variable. The first line will be returned as [NAME1] the second as [NAME2] etc. The same is done for the comment field. This allows long addresses to be entered and used in EXSYS. It is the responsibility of the developer to make sure there are enough appropriately named EXSYS variables to accept the data. ~SET_WIN 30, 50, 500, 400 ~PATTERN SOLID ~BACKGROUND BLUE ~CLS ~BACKGROUND WHITE ~TEXTSIZE NORMAL ~FILL_COLOR BLUE ~LINE_COLOR CYAN /* set window size */
I - USER INTERFACE
30
~LINE_WIDTH 2 /* draw accent box */ ~RECT 10,10,480, 380 ~FOREGROUND WHITE ~CURSET 25,30 Name & Address ~EDIT "[NAME##]", 25,35, 200, 150 -W ~CURSET 25,205 Phone ~EDIT "[PHONE]", 25,215, 200, 30 ~CURSET 25,270 Social Security # ~EDIT "[SSN]", 25, 275, 200, 30 ~BUTTON "MALE", "Q 1 1", 130,320,75,30 -R ~BUTTON "FEMALE", "Q 1 2", 130,345,75,30 -R ~BUTTON "OK","",40,330,40,40 -I ~FILL_COLOR WHITE ~LINE_COLOR WHITE ~RECT 240,20,240,250 ~FOREGROUND BLUE ~CURSET 260,35 Experience ~BUTTON "Technical", "Q 2 1", 270,40,130,30 -C ~BUTTON "Sales", "Q 2 2", 270,65,130,30 -C ~BUTTON "Management", "Q 2 3", 270,90,130,30 -C ~BUTTON "Clerical", "Q 2 4", 270,115,130,30 -C ~BUTTON "Other", "Q 2 5", 270,140,130,30 -C ~CURSET 260,195 Highest College Degree ~BUTTON "HS", "Q 3 1", 260,200,60,30 -R ~BUTTON "BS", "Q 3 2", 260,225,60,30 -R ~BUTTON "MS", "Q 3 3", 340,200,60,30 -R ~BUTTON "PhD", "Q 3 4", 340,225,60,30 -R ~FOREGROUND WHITE ~EDIT "[COMNT##]", 240,275, 240, 100 -S:S -L COMMENTS: ~LISTEND ~END
I - USER INTERFACE
31
Experience Technical Sales Management Clerical Other Highest College Degree HS MS BS PhD Comments Male Female
Phone
Social Security #
OK
Example 7: This example shows the use of the ~PAUSE command. Part of the screen is displayed, and after pressing a button the rest of the screen is displayed. The "NOT within Spec" button will execute a GOTO command to display the rest of the screen and display the scroll bars. The "WITHIN spec" button will immediately return. ~SET_WIN 30, 50, 500, 400 /* set window size */ ~PATTERN SOLID ~BACKGROUND BLACK ~CLS ~FILL_COLOR CYAN ~LINE_COLOR WHITE ~LINE_WIDTH 5 /* draw accent box */ ~ROUND_RECT 20,20,460, 300 ~LINE_WIDTH 2 ~ROUND_RECT 30,30,440, 280 ~TEXTSIZE NORMAL ~FOREGROUND BLACK ~CURSET 50,70 The process temperature and pressure measurements are: ~BUTTON "WITHIN Specs", "Q 'spec' 1", 50,120,140,30 -I ~BUTTON "NOT within Specs", "~GOTO:spec", 50,180,140,30 -X -D ~PAUSE /* pause at this point */ ~:spec ~LINE_COLOR RED /* highlight box */ ~LINE_WIDTH 4 ~RECT 46,176,148,38
I - USER INTERFACE
32
/* temperature scroll */ ~FOREGROUND WHITE ~SCROLL"[TEMP]",170, 220, 220,120,215,10 -H -A:212 -D:350,110 ~CURSET 220,110 ~FOREGROUND BLUE TEMPERATURE /* add label */ ~CURSET 235,152 ~TEXTSIZE SMALL 170 180 190 200 210 220 /* pressure scroll*/ ~TEXTSIZE NORMAL ~FOREGROUND WHITE ~SCROLL"[PRESSURE]",2.0,4.1,220,200,215, 10 -H -A:2.8-D:325,190 ~CURSET 220,190 ~FOREGROUND BLUE PRESSURE /* add label */ ~CURSET 235,232 ~TEXTSIZE SMALL 2.0 2.5 3.0 3.5 4.0 ~TEXTSIZE NORMAL /* delete or move down */ ~FOREGROUND WHITE /* delete or move down */ ~BUTTON "OK", "", 235,245,80,50 -X -I ~END When the screen is first displayed it uses only the commands up to the ~PAUSE:
I - USER INTERFACE
33
If the NOT within Specs button is press, the rest of the screen is displayed:
The process temperature and pressure measurements are TEMPERATURE 212.0 WITHIN Specs 170 180 190 200 210 220 NOT within Specs PRESSURE 2.0 2.5 2.8 3.0 3.5 4.0
OK
I - USER INTERFACE
34
file containing the screens word to search for. Screen starts after ~~word in file Filename to use as the return data file. Default = return.dat.
EXSYS_CS will display the custom screen specified in the command line. If the program is called with no command line, it will ask for the name of the file and ~word to display. If EXSYS_CS is called with only a file name, it will display all of the screens in the file.
I - USER INTERFACE
35
I - USER INTERFACE
36
To make a custom screen file, start a file named <knowledge base name>.SCR. Use the screen commands described in Chapter I to build the custom screen. You can check the screens quickly with the EXSYS_CS utility. It may take some experimentation to get the screens the way you want them. The screens in this file will be called automatically when EXSYS needs information.
I - USER INTERFACE
37
I - USER INTERFACE
38
I13: Hypertext
EXSYS supports a hypertext help system. This system allows a series of explanatory screens to be created that can be called as needed by the user. The screens are indexed by keyword and can be called from most of the EXSYS screens. Hypertext is different from the custom help screens or the WHY command. The WHY command displays the logic of the rules that lead to an item of information being requested. The custom help screen displays detailed information on the question being asked and what the user is expected to do. Hypertext is not associated with a specific qualifier or variable, but with words. These words can appear in qualifiers, rules, choices, notes, etc. Whenever a hypertext keyword is displayed on the screen, it will be highlighted in blue and the user can ask for more information on what that word means by double clicking on it. It does not matter if the word is displayed as part of a question, part of a rule or in the conclusions. If the user does not understand the word, he can get help by double clicking. Most importantly, these hypertext keywords can appear in other hypertext screens. This allows one hypertext screen to call other hypertext screens to explain its keywords. This provides a multi-level help system that can be very complex. Hypertext screens can contain embedded EXSYS variables, so the explanation can be specific to the data input. (NOTE: If embedded variables are used, make sure that they have a value (DATALIST, rules, etc.) before the hypertext screen is called.
I - USER INTERFACE
39
40
starting with ~~thermothrocal (no ending S). Rather than repeat the screen, just add an entry: ~~thermothrocals ~SAMEAS thermothrocal This will cause the thermothrocal screen to be called.
I - USER INTERFACE
41
I13.5: Example:
Suppose we have a qualifier: The ^^thermothrocal^^ temperature is 1 above ^^threshold^^ 2 at or below ^^threshold^^ We would enter this just as it is displayed here, with the ^^. We might use this to build a rule: IF: The ^^thermothrocal^^ temperature is at or below ^^threshold^^ THEN: ...... When we run this system, any time the qualifier text is displayed, either to ask a question, display the rule, display the know data or display the conclusions, the words "thermothrocal" and "threshold" will be highlighted and the ^^ will not be displayed. Any time the keywords are displayed, the user could double click the highlighted word and select the hypertext screen for these words. A .SCR file would contain the hypertext screens in it: ~~thermothrocal screen commands . . . ~~threshold screen commands . . It is not necessary to have every screen call others, but the real power of hypertext is its ability to create hierarchical help systems that provide the proper level of detail for any user.
I - USER INTERFACE
42
EXSYS normally appends the text of the value(s) selected to the end of the qualifier text to create a condition. For example, if we have the qualifier: The color is 1 red 2 green 3 blue and we select 2, green will be added after the qualifier to make the condition "The color is green". For most situations this is suitable, however, there are times when it is desirable to put the value text in the middle of the sentence. EXSYS allows the value(s) to be put anywhere in a qualifier by inserting four underline characters, _ _ _ _ , at the point where the values are to be inserted. For example you could have: The______is red 1 house 2 car 3 boat If you selected 2, the condition "The car is red" would be built. Users are asked the question with the four underline characters as a fill-in-the-blank type question.
I - USER INTERFACE
43
ASCII control characters can be embedded in any text string by using the notation @@### where # is the three digit ASCII code for the character desired. There must be 3 digits following the @@ even for codes less than 100. For example: This @@013@@010 is will replace @@013 with an ASCII 13 and replace @@010 with an ASCII 10 and print a carriage return/line feed between "This" and "is". The ASCII conversion is only performed during the run mode, so editing of the codes can be done in the edit mode. WARNING: ASCII REPLACEMENT MUST BE USED WITH CAUTION!!! Many operations in EXSYS are designed to stay within certain screen boundaries if standard alphanumeric text is used. Embedding ASCII codes can cause the text to go out of those boundaries with undesirable effects. Embedded codes are best for simple formatting or printer control in the report generator.
I - USER INTERFACE
44
I16.1: Variables
Data on a variable is embedded in text by entering its name in double square brackets. The value of the variable will be used to replace the [[var name]] in the text. For example: Hello, [[NAME]], please enter the value of X would have [[NAME]] replaced by the value of the string variable [NAME]. If [NAME] had the value "John", the string would be displayed as: Hello, John, please enter the value of X EXSYS will usually backward chain during a run to derive the value for the variable in [[ ]] or will ask the user for a value. If WHY is used, or certain window operations are being performed, backward chaining is turned off, and only known values will be used. In this case, rules may be displayed with [[ ]] expressions if there is no data. The [[ ]] expressions can be used in: Qualifiers Qualifier values Choices Notes References Text associated with a variable Command File line Report generator commands Custom screen command Custom Help commands One powerful use of double brackets is to have the [[ ]] expression in a qualifier or variable text, contain a RUN ( ) command or other internal command.
I - USER INTERFACE
45
For example, suppose we have a qualifier: [[X]] The color is 1. Red 2. Green 3. Blue and we set the value of the string variable [X] to RUN(GETCOLOR). EXSYS will consider the text of the qualifier to be RUN(GETCOLOR) The color is and will call the external program GETCOLOR for the value of the qualifier. We could easily assign a different external program to the qualifier by changing the value of [X]. Another application is to embed variables in the note or reference text of a rule. This makes the note more precise to the data entered. For example, we might have an explanatory note: Since the length is [[LENGTH]] and ...... The value of the variable [LENGTH] will be used in the note to make a more precise statement explaining why the rule fired. The embedded variables will be used in the display of results or in text printed from the report generator.
I16.2: Formulas
In EXSYS, replacement of [[ ]] is also supported in formulas, allowing the rules to self-modify the formulas being tested. A formula is parsed for [[ ]] expressions before being evaluated. For example, the formula 3[[X]]2 could have [X] be replaced with "+" for a value of 5 or "-" for a value of 1 or "7" for a value of 372.
I16.3: Qualifiers
The text of a qualifier and its values can also be used as an embedded variable. The syntax is: [[*Q <qualifier number>]] [[*Q "<qualifier name>"]]
I - USER INTERFACE
46
Note: The * is required as the first character to indicate the name is not a variable name. The text of the qualifier/value will be placed in the string in place of the [[ ]] expression. For example, suppose qualifier 3 is "The color is" and values "RED" and "BLUE" are set. If we had text: The values set so far are: [[*Q 3]] it would be displayed as: The values set so far are: The color is RED and BLUE
However this embeds the text of both the qualifier and all of the values that have been set. There are times when it is desirable to embed only the value(s) or the number(s) of the value(s) which are set. To do this use: [[*QV #]] [[*QN #]] or or [[*QV "name"]] [[*QN "name"]]
The [[*QV...]] will be replaced by the text of only the values set for the qualifier. The [[*QN ...]] will be replaced by only the number of the values set. For example, suppose we have a qualifier 5: The 1 2 3 and value 2 is set: [[*Q 5]] [[*QV 5]] [[*QN 5]] would be replaced with THE COLOR IS WHITE would be replaced with WHITE would be replaced with 2 color is red white blue
I - USER INTERFACE
47
The expression can be any EXSYS expression, involving numeric or string variables. Any of the supported mathematical operators or functions can be used. The <? ?> syntax can be used to embed a value in any EXSYS text, including qualifiers, notes, references, choices, report generator commands, command files, etc. Any place that a [[ ]] can be used, a <? ?> can be used. This eliminates the need to create temporary variables to embed in data. For example, we could have a note: The sin of [[X]] is <? sin([X]) ?>
This would replace [[X]] with the value of [X] and then replace the <? ?> expression with the sin([X]). String variables can also be used: The part number is <? [str 1] + "-" + [str 2] ?> The strings will be concatenated and then displayed. Functions can also be embedded: The largest is <? MAX([X], [Y], [Z]) ?>
48
I - USER INTERFACE
49
EXSYS Professional provides a command language to control the execution of a knowledge base. The command language provides control mechanisms for the input of data, execution of rules, display of results, looping, branching, etc. The command language can be used in conjunction with the report generator specifications for even greater control. The command language is similar to DOS batch language in many respects. Most of the individual commands are quite simple; however, the combination of commands allows great power and flexibility. External programs, report specifications and named subsets of the rules can be accessed by single commands. The default command file for an expert system is in the following file: <expert system name>.CMD For example, if the name of the knowledge base file is TEST, the command file would be TEST.CMD. The command file must be in the same subdirectory as the .RUL and .TXT portion of the knowledge base. The command file is simply an ASCII file and can be created with any ASCII editor or word processor in ASCII mode. Note: Many word processors add special formatting characters that will not produce files that can be used as command files. If you are using a word processor, make sure it is in a mode that does not introduce special characters. To check if the file has formatting characters, print the command file to the screen with TYPE <filename>. If the display does not have unusual characters, it should work for command file editing. The command file is optional. If a command file is not present, EXSYS will default to the standard mode of a backward chaining system using all rules and displaying results at the end of the session. If the command file is present, EXSYS will use it automatically.
J - COMMAND LANGUAGE
J - COMMAND LANGUAGE
Command Language
Examples: ASK Q "COLOR" ASK Q "A*" ASK [TE*] ASK [?D] will ask the qualifier named COLOR. will ask all qualifiers whose names start with A. will ask all variables whose names start with TE. will ask all variables whose names are two letters ending in D.
J - COMMAND LANGUAGE
Command Language
The BEEP command in the command file behaves exactly like the BEEP command in the .CFG file.
J - COMMAND LANGUAGE
Command Language
J - COMMAND LANGUAGE
Command Language
J - COMMAND LANGUAGE
Command Language
Anything on a line following /* is ignored. This allows comments to be included in the command file. Starting spaces are ignored. The following example, /* This is a comment
would perform the ASK command and ignore the comment starting with /* A note to C programmers: The /* does not carry over to other lines and does not require a */ to end the comment.
J - COMMAND LANGUAGE
Command Language
The CLEAR command is the same as the internal CLEAR( ) command, except it lacks the ( ). The CLEAR command is used to clear qualifiers, variables, choices or rules for re-use. The "ALL" and range options for CLEAR work from the command file, but not the "THIS" option, which can only be used in the internal command form from a rule. Syntax: CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR CLEAR Q # Q "name" V # [var name] C # C "text" R # R "name" X a-b Clear qualifier number #. Clear named qualifier(s). Clear variable number #. Clear named variable. Clear choice number #. Clear choice containing "text." Clear rule number #. Clear named rule. Clear all items between a and b. The X can be Q, V, C or R for qualifier, variable, choice or rule. Clear ALL items. The X can be Q, V, C or R for qualifier, variable, choice or rule. Clear all qualifiers, variables and choices.
CLEAR X ALL
CLEAR ALL
When a qualifier or variable is cleared, it is reset to an unknown state and will be re-derived or re-asked if needed. If the confidence system is custom formulas, the confidence variables associated with the qualifier or variable will also be cleared. When a choice is cleared, it is reset to its initial state. When a rule is cleared, it is reset to unused and can be fired again.
J - COMMAND LANGUAGE
Here are some examples: CLEAR R 34-56 clears all rules from 34 through 56. clears the first 5 qualifiers. clears all rules. clears all variables. clears all qualifiers whose NAME starts with A. clears the rule named XXX. clears all choices that have the string "ZZZ" in them. clears all rules with 3 character names ending in "XX."
CLEAR Q 1-5 CLEAR R ALL CLEAR V ALL CLEAR Q"A*" CLEAR R"XXX" CLEAR C"ZZZ" CLEAR R"?XX"
J - COMMAND LANGUAGE
Command Language
J - COMMAND LANGUAGE
10
Command Language
Cause the Next Record of Data to be Read from a DATALIST File DATALIST <loop pt.>
The DATALIST command causes the next set of data to be read from the DATALIST file. The DATALIST option must still be specified as a command line option. Note: The first set of data is read from the datalist file before the .cmd file is started. The DATALIST command causes the next set of data to be read. After data is read, the program branches to the loop point specified. If there is no more data, the branch is not executed and the program falls through to the next command in the .cmd file. DATALIST does not clear any data. It should be preceded by whatever CLEAR commands are needed for the particular system, usually CLEAR ALL. The following example, :LOOP RULES ALL REPORT XXX CLEAR ALL DATALIST LOOP BEEP runs all rules and writes a report for each set of data. The CLEAR ALL prevents data from a previous run from being kept in the next run. The DATALIST command causes the next set of data to be read and then the program to branch to the line labeled :LOOP. When there is no more information, the DATALIST command does not go to LOOP, but rather falls through to the BEEP.
J - COMMAND LANGUAGE
11
Command Language
<var name>
J - COMMAND LANGUAGE
12
<address>
<rec #>
The item in which to store the data obtained. The item can be a variable, qualifier or choice. For a variable, use the name of the variable in [ ]. For a qualifier, use "Q" followed by the number of the qualifier or the name of the qualifier in quotation marks. For a choice, use "C" followed by the number of the choice or a unique text string in quotation marks. There must not be any spaces in the string between the C, V or Q and the number or quotation mark. The number of the db record to use.
The database file name, index name and index variable can be a variable. <var name> must be an EXSYS variable. Since the field name and associated variable can be repeated as many times as desired, multiple fields from the same record can be passed or returned on a single call. The data returned for qualifiers or choices, should be in the same form as if it were being returned for an external program call. For example, if the database call returned "1,2,3" to a qualifier, it would set the first three values of the qualifier to true. The following example, DB_PN(parts.dbf, 5, price, [X]) will WRITE the value of variable [X] into field "price" of record 5 of database "parts." DB_GN(parts.dbf, 5, price, [X], number, Q1) will READ the value of field "price" from record 5 of data base "parts" into variable [X] and the data in field "number" will be used to set the value(s) in qualifier 1. If needed, there could be additional field and variable pairs in the expression to get more data from the record. DB_PK(parts.dbf, part.ndx, A567, price, [X]) will WRITE the value of variable [X] into field "price" of the record in database "parts," indicated in the index file "part.ndx" by the value "A567." DB_GK(parts.dbf, part.ndx, A567, price, [X]) will READ the value of field "price" into [X] from the record in database "parts," indicated in the index file "part.ndx" by the value "A567."
J - COMMAND LANGUAGE
13
J - COMMAND LANGUAGE
14
Command Language
The DISPLAY command displays the contents of a file on the screen. The user can go forward or backward in the file. This is the same as the DISPLAY command in rules. Syntax: DISPLAY <filename> <options> DISPLAY [string variable name] filename - the name of the file to display. string variable name - a string variable whose value is the name of the file to display. <options>
Options
/C - File to display uses GUI Custom Screen Commands The /C option causes the DISPLAY command to parse the file for Custom Screen Commands. See Chapter I for a discussion of the GUI Custom Screen Language. /N - No wait after screen is displayed The /N option causes the DISPLAY command to display the requested file in a window and immediately continue processing. This can be useful for report files that are created and displayed. By using the /N option, you may have several report data windows simultaneously active. /S - Small text The /S option causes the DISPLAY command to display a text file using a small font. The default is to use a larger font. This applies only to ASCII files. /F - Fixed size font The /F option causes the DISPLAY command to display a text file using a fixed size font. This is useful for aligning columns of data. The /S and default fonts are proportionally spaced and aligning data can be difficult. This applies only to ASCII files.
J - COMMAND LANGUAGE
15
The following example, DISPLAY INTRO.MSG will display the contents of the file INTRO.MSG on the screen. DISPLAY scr1.scr will display the file scr1.scr on the screen using Custom Screen Language commands.
J - COMMAND LANGUAGE
16
Command Language
J - COMMAND LANGUAGE
17
Command Language
The EXIT command terminates the run and returns to the operating system. Syntax: EXIT The following example, commands.... IF [X]>[Y] EXIT ENDIF would exit to the operating system if the value of [X] is greater than [Y].
J - COMMAND LANGUAGE
18
Command Language
The GOTO command causes an unconditional branch to another line in the command file. Syntax: GOTO <label> <Label> is the text of the branch point to go to. The branch point must be a single line starting with a : and containing the text of <label>. The reference to the label in the GOTO command does not use the ":". The following example, :LOOP commands... GOTO LOOP will cause the program to return to the line :LOOP when the "GOTO LOOP" command is found.
J - COMMAND LANGUAGE
19
For example, the following are legal (In all cases IF/ENDIF can be replaced with WHILE/WEND). IF [X]>0 GOTO X ENDIF :X _________________ :X IF [X]>0 GOTO X ENDIF _________________ IF [X]>0 :X GOTO X ENDIF _________________ IF [X]>0 GOTO X _ :X ENDIF _________________
J - COMMAND LANGUAGE
20
IF [X]>0 IF [Y] < 10 GOTO X ENDIF _ :X ENDIF _________________ IF [X]>0 IF [Y] < 10 GOTO X ENDIF _ ENDIF :X The following is not legal because the GOTO jumps over an IF to a deeper nesting level. This will not be caught as an error, but may give incorrect results. IF [X]>0 GOTO :X IF [Y] < 10 :X ENDIF _ ENDIF
J - COMMAND LANGUAGE
21
Command Language
The IF command allows conditional execution of blocks of commands. Syntax: IF <expression> commands.... ELSE (optional) commands.... ENDIF (not optional) <expression> can be any mathematical expression that could be evaluated in the IF portion of a rule. If the expression is true, the commands immediately following are executed until an ELSE or ENDIF is encountered. If the expression is false and an ELSE is present, the commands following the ELSE will be executed. In either case, execution will continue with the line following the ENDIF. IF commands can be nested. Each IF must have a matching ENDIF, though. The following example, IF [X]>0 CLEAR [X] RULES 1-10 ELSE RULES 20-30 ENDIF will test if [X] is greater than 0. If it is, [X] will be cleared and rules 1 through 10 will be run. If [X] is less than or equal to 0, rules 2030 will be run.
J - COMMAND LANGUAGE
22
IF [NUMBER FOUND] = 10 GOTO END ENDIF commands..... :END commands.... will check if the variable [NUMBER FOUND] is equal to 10. If it is, the program will branch to the point :END.
J - COMMAND LANGUAGE
23
Command Language
The PAUSE command in the command language will cause the program to display a dialog box and wait until the OK button is pressed. There is no message displayed. This is usually used for debugging a command file.
J - COMMAND LANGUAGE
24
Command Language
J - COMMAND LANGUAGE
25
Command Language
The REPORT command calls and executes a report generator specification file. This is the same as the internal REPORT command and the REPORT command in the report generator itself. Syntax: REPORT <filename> The following example, RULES 1-200 REPORT FIRST.RPT would run the first 200 rules and then run the report specification file FIRST.RPT to produce a report to disk file or screen, depending on the contents of the report specification.
J - COMMAND LANGUAGE
26
Command Language
The RESULTS command displays the standard EXSYS results screen with options for change and rerun, etc. The same format and options as the final results display is used. Note: The results of a command file run will not be displayed unless the RESULTS command is used. Syntax: RESULTS <options> Two options are available: /C:<loop point> This is the point to loop to if a change/rerun is selected. Since the command file will have used one or more RULES commands to run the knowledge base, the starting point for a change and rerun must be specified. The new data input for the change and rerun will be done by EXSYS; the user must supply only the starting point. The following example, ASK [X] :LOOP RULES [Y] /F/N RULES 1-100 RESULTS /C:LOOP will run the rules using two RULES commands and then display the results. If change and rerun is selected, the program will allow the user to modify the data and branch back to :LOOP. The /C should always be used unless the change and rerun option has been disabled.
J - COMMAND LANGUAGE
27
Command Language
The default mode is backward chaining using all rules for derivation of information.
Options:
/F /N causes forward chaining. suppresses all backward chaining (like the NOBACKWARD option). This should only be used with /F.
J - COMMAND LANGUAGE
28
/L
forces all backward chaining to derive needed information to be limited to the same subset of rules. If /L is not present, backward chaining can invoke rules outside of the specified subset. clears all data out before starting the run. This is equivalent to CLEAR CLEAR CLEAR CLEAR RULES R ALL C ALL V ALL Q ALL .....
/C
If /C is not used, existing data from SET, ASK or previous runs will remain and be used. Rules are "relevant" to a qualifier, variable or choice if the qualifier, variable or choice appears in the assignment portion of the THEN or ELSE part of the rule. The rules relevant to qualifier 3 would be all rules with qualifier 3 in the THEN or ELSE portion. The rules relevant to [X] would be all rules with conditions that start [X] IS GIVEN THE VALUE ..., but not necessarily rules that have [X] as part of an expression assigned to another variable. For example, suppose there are 100 rules: RULES ALL RULES ALL /F would run all rules in backward chaining mode. would run all rules in forward chaining mode.
RULES ALL /F /C would CLEAR all existing data and then run all rules in forward chaining mode. RULES 5 RULES 1-10 would run rule 5. would run rules 1 through 10 in backward chaining mode, with all rules used for backward chaining to derive information needed. would run rules 1 through 10 in backward chaining mode, with only rules 1-10 used for backward chaining to derive information needed.
RULES 1-10 /L
J - COMMAND LANGUAGE
29
RULES Q 1-3 /F /N would run those rules that have qualifiers 1, 2 or 3 in their THEN or ELSE parts in a forward, NOBACKWARD mode. RULES Q "A*" would run all rules relevant to qualifiers whose names start with A in a forward chaining mode, with ALL rules used for derivation of information needed. RULES Q "A*" /L would run all rules relevant to qualifiers whose names start with A in a forward chaining mode, with ONLY the same sub-set of rules used for derivation of information needed. RULES [X] /F would run all rules that derive a value for [X] in a forward chaining mode. RULES [X] /F /C would CLEAR all existing data and then run all rules that derive a value for [X] in a forward chaining mode. RULES C 3 would run all rules relevant to choice 3.
RULES C "blue" would run all rules relevant to the choice with the word "blue" in it.
J - COMMAND LANGUAGE
30
Command Language
J - COMMAND LANGUAGE
31
Command Language
The SAVEDATA command saves the current state of the run in a file, just as if a QUIT command were executed. Syntax: SAVEDATA [filename] The optional filename is the name of the file to store the data in. If the file name is not present, the program will prompt the user for the name of a file. The following example, RULES 35-200 SAVEDATA PART1.DAT will run rules 35-200 and save the input provided in the file PART1.DAT.
J - COMMAND LANGUAGE
32
Command Language
The SET command is used to assign values to choices, variables and qualifiers at the start of or during a run. The SET command can be used anywhere in a command file, but it is usually used at the start to set starting values. Syntax: SET [var name] expression Assign the value of the expression to the named variable. SET V # expression Assign the value of the expression to the variable specified by number. SET Q # {list of values} Set the specified values of qualifier number #. SET Q "name" {list of values} Set the specified values of the name qualifier. SET C # expression Assign the value of the expression to the named choice. SET C "text" expression Assign the value of the expression to the choice specified by a unique text sub-string. Here are some examples: SET [X] 5 will assign the value 5 to variable [X] SET [X] ([Y]/2) will assign the value of one half [Y] to variable [X]. If the value of [Y] is not known, the program will invoke backward chaining to determine [Y] or ask the user. The variables in the expression must be valid EXSYS variables in the knowledge base.
J - COMMAND LANGUAGE
33
SET V 3 3.14159 will assign 3.14159 to variable number 3. SET Q 5 1,2 will set values 1 and 2 of qualifier number 5. If qualifier 5 was The color is 1. red 2. blue 3. green this SET command would set values 1 and 2 or "The color is red and blue." SET Q "COLOR" 1 will set value 1 of the qualifier named "COLOR." Using the same qualifier as above, the result would be setting "The color is red." SET C 7 1+2+3 will set the value of choice 7 to the expression 1+2+3 or 6. SET C "large" [X]+3 will set the value of the choice containing the sub-string "large" to the expression [X]+ 3. If the value of [X] were not known, it would be derived or asked.
J - COMMAND LANGUAGE
34
Command Language
K - RULE COMPILER
K - RULE COMPILER
K - RULE COMPILER
K - RULE COMPILER
K - RULE COMPILER
Print to PRINTER Print to FILE filename Standard Output Format Rule Compiler Format C Code Replacement for Rules
Cancel
Select Rule Compiler format and enter a filename for the output file. The file can have any name, but do not use a file with a .RUL or .TXT extension. The listing will include all of the qualifiers, variables, choices, etc. and will use the LIST ONLY command. If you add new qualifiers, variables or choices, they must be added to the starting lists or the LIST ONLY command (found on the first line of the listing) must be deleted. If the LIST ONLY command is deleted, the new item will automatically be added to the lists. If you print the rules to disk without specifying that they are for word processor editing, the syntactical information will not be added and the rules will not be able to be directly read back in with the rule compiler. To compile such a listing would require adding the syntactical information by hand.
K - RULE COMPILER
K5: Commands
The compiler has a number of reserved command words. These words have special meaning to the compiler only if they appear at the start of a line. In all cases, preceding spaces or tabs are ignored. These words should not be used in your rules since the compiler could misinterpret them. This should not be a problem since all reserved words 1. Must be the first text on the line; 2. End in a ":" , "=" or carriage return. For example, the word AUTHOR in your rules would not cause a problem since only AUTHOR: is a reserved word. Likewise AUTHOR: in the middle of a line would not be considered a reserved word. The meaning of the reserved command words will be discussed individually.
K - RULE COMPILER
In addition to the above reserved words, there are other command words that have meanings when they follow one of the reserved words. These are discussed in the sections on the individual reserved command words. Note: In all commands, the EXSYS Rule Compiler is case insensitive and preceding spaces or tabs are ignored. Text that is part of a qualifier, variable, etc. can go over several lines. There is no end of string delimiter. The program will recognize when a new command has been reached.
K - RULE COMPILER
In any line, text following a /* is treated as a comment and ignored. If the /* is part of a quoted string it will not be considered the start of a comment. Other text or commands on the line preceding the comment will be used. Any line can start with indenting spaces or tabs. For example: /* this is a comment QUALIFIERS: /* this is another comment
A note to C programmers: Unlike C, it is not necessary to have a closing */ and comments do not carry over to the next line.
K - RULE COMPILER
The text following the SUBJECT: command is used as the title for the expert system. All expert systems must have a title. The Title is limited to 200 characters; however the lines will be merged together. The text can be over multiple lines. The text is considered ended when there is a blank line or a line which starts another command. If you wish to embed special characters in the text, you can use the @@### control code as part of the text., where the ### is replaced with the THREE digit ASCII code of the character you wish to use. For example, @@013 will insert a carriage return. See Section I15 on @@### replacement for more details. For example: SUBJECT: This is the title of the expert system or SUBJECT: This is a subject line that continues over three lines. EXSYS will consider this all part of the subject.
K - RULE COMPILER
10
The text following the AUTHOR: command is the name of the author of the expert system. All expert systems must have an author. The author text is limited to 100 characters. The text can be on multiple lines; however the lines will be merged together. The text is considered ended when there is a blank line or a line which starts another command. If you wish to embed special characters in the text, you can use the @@### control code as part of the text, where the ### is replaced with the THREE digit ASCII code of the character you wish to use. For example, @@013 will insert a carriage return. See Section I15 on @@### replacement for more details. For example: AUTHOR: Your name
K - RULE COMPILER
11
The text following the STARTING TEXT: command is used as the text to display at the start of the expert system. The starting text is optional. The text is limited to 1800 characters. The text can be on multiple lines; however the lines will be merged together. The text is considered ended when there is a blank line or a line which starts another command. If you wish to embed special characters in the text, you can use the @@### control code as part of the text, where the ### is replaced with the THREE digit ASCII code of the character you wish to use. For example, @@013 will insert a carriage return. See Section I15 on @@### replacement for more details. For example: STARTING TEXT: This is the text that will be displayed on the screen when the expert system is run.
K - RULE COMPILER
12
The text following the ENDING TEXT: command is used as the text to display at the end of the expert system. The ending text is optional. The text is limited to 1800 characters. The text can be on multiple lines; however the lines will be merged together. The text is considered ended when there is a blank line or a line which starts another command. If you wish to embed special characters in the text, you can use the @@### control code as part of the text, where the ### is replaced with the THREE digit ASCII code of the character you wish to use. For example, @@013 will insert a carriage return. See Section I15 on @@### replacement for more details. For example: ENDING TEXT: This is the text that will be displayed on the screen at the end of the expert system run.
K - RULE COMPILER
13
Define an External Program to Call at the Start of a Run EXTERNAL PROGRAM: <text>
The text following the EXTERNAL PROGRAM: command is used as the name of the external program to call at the start of an EXSYS run. The external program is optional. The text is limited to 100 characters. The text can be on multiple lines. The text is considered ended when there is a blank line or a line which starts another command. The name of the external program and any arguments passed out to it follow the standard EXSYS syntax for external programs. A RUN( ) is not needed since this is the external call at the start of the program. The following example, EXTERNAL PROGRAM: TEST [X] /C will call the external program TEST and pass it the value of variable [X] on the command line.
K - RULE COMPILER
14
The value following the DISPLAY THRESHOLD: command is used as the threshold value for choice display at the end of the run. To be displayed, a choice must have a value greater than this value. The command is optional; however if it is not used, a default value of 0 will be used. The following example, DISPLAY THRESHOLD: 5 will cause only choices with a value greater than 5 to be displayed with the results of the run.
K - RULE COMPILER
15
The value following the PROBABILITY SYSTEM: command is used to set the probability confidence value system used in the expert system. The command is required and a confidence system must be specified before the rules are entered. The value must be an integer between 1 and 5. The values correspond to the confidence modes in EXSYS: 1. 2. 3. 4. 5. Yes / no system 0-10 system (O and 10 lock the values) -100 to +100 system Increment/ decrement system Custom formulas
See Chapters B and C on confidence systems for more information on the various confidence systems and their relative advantages. For mode 3, the number can be followed by a letter indicating how to combine confidence factors: A I D Average values Combine as Independent probabilities Combine as Dependent probabilities
Characters after the first letter are ignored. See Chapters B and C on confidence systems for more information on the method of combining confidence factors. If there is no letter following the "3," the default is to use "A" for the average mode.
K - RULE COMPILER
16
The following example, PROBABILITY SYSTEM: 2 will set the system in the 0-10 confidence mode. PROBABILITY SYSTEM: 3 I will use the -100 to +100 mode with probabilities combined as independent probabilities.
K - RULE COMPILER
17
Set the Initial Choice Confidence Value INITIAL CHOICE CONFIDENCE: <value>
This option applies only to confidence mode 5, custom formulas. In that mode, choices have an initial confidence value. The default value is 0; however in some cases, other values may be more desirable. The INITIAL CHOICE CONFIDENCE: command allows the default to be changed. The following example, INITIAL CHOICE CONFIDENCE: will set the starting confidence of all choices at 100. 100
K - RULE COMPILER
18
The value following the DISPLAY RULES: command is used to set whether or not rules will be displayed when the expert system is run. The command is optional; however if it is not used, a default value of "not displayed" will be used. The acceptable values are Y or YES, N or NO. The following example, DISPLAY RULES: YES will cause rules to be displayed during the run. The option to lock rule display off cannot be accessed from the rule compiler since the compiler does not provide for password encryption. To lock rule display off Compile the rules; Read the rules with the EXSYS Professional Rule Editor; Select parameters from the Options pull down menu; Select "Lock Display OFF" in the Rule Display Mode radio buttons and click on "OK; Select SAVE from the FILE pull down menu and select Password Protection.
K - RULE COMPILER
19
Set Option for How Many Rules to Use in Deriving Information DERIVATION: <value>
The value following DERIVATION: is used to set how many rules are used in the backward chaining to derive needed information. The value is a letter A F N all rules first rule only non-redundant rules
If there is no DERIVATION: command, the default mode is "A," use all rules. Characters after the first character are ignored. The following example, DERIVATION: F DERIVATION: First rule are both accepted and both mean use only the first rule that fires in backward chaining.
K - RULE COMPILER
20
This command allows inputting of a list of qualifiers with values and setting of parameters. The qualifiers and their values usually should be defined prior to their being used in the rules. However, the QUALIFIER: statement is optional and the list does not have to be complete. Unless the LIST ONLY command is used, the compiler will build the qualifier list from the qualifiers and their values found in the rules. If the LIST ONLY command is used, any qualifiers or values found in the rules that do not match ones in the list will produce an error message. It is recommended that the LIST ONLY option be used with a complete qualifier list whenever possible to catch any typographical errors that can occur when using text editors. Each qualifier has a number of parameters that can be set. These parameters control actions such as if the qualifier is displayed with the results, the number of values a user can input, how confidence for the qualifier is handled, etc. All parameter commands apply to the qualifier set by Q> previously. Most parameter commands have shorter alternate commands that can be used. The shorter alternates have the same function as the full command. They are just quicker to type. Most parameters have default values that are automatically set when the new qualifier is found. These defaults can be changed with the various parameter commands. It is not necessary to add the parameter command if the default value is appropriate. Multiple qualifiers can follow a single QUALIFIER command. The QUALIFIER list is optional and all qualifiers can be determined from the rules.
21
V> <text>
Indicates the start of a new value. The text that follows the V> will be used for the value. The text can continue over several lines. The text will be applied to the value until a blank line or another command is encountered. Up to 30 values can be assigned to a particular qualifier. (NO DEFAULT- at least one value required)
K - RULE COMPILER
22
K - RULE COMPILER
23
can be selected from the list. This is particularly useful in lists which have mutually exclusive values or Yes/No questions. The value is the maximum number of values that the end user can select. If this command is not used, the user can select all values. (For example, MAXIMUM ACCEPTABLE = 1 only allows the end user to select one value from the list). (Default = allow all values)
NAME=<name>
Sets the name that is assigned to the qualifier. This name is used to refer to the qualifier in other rules, the command language, etc. By being able to refer to a qualifier by name, rather than by number, you do not have to be concerned about rearrangements of qualifiers that may change the numbering. (For example, NAME=ABCD assigns the name ABCD to the qualifier. (Default=blank)
K - RULE COMPILER
24
The following example, QUALIFIERS: Q> The color is V> red V> white V> blue NAME= color DISPLAY AT END DEFAULT VALUE= 2 /* start of the qualifier list /* qualifier 1
Q> The day is /* qualifier 2 V> Monday V> Tuesday V> Wednesday V> Thursday V> Friday V> Saturday V> Sunday NAME= Day of week MAXIMUM= 1 sets up a qualifier "The color is" with values red, white and blue. The qualifier has an associated name COLOR, and is set to be displayed at the end. The DEFAULT VALUE is set to WHITE, so the end user will never be asked this question; it would be assigned the value WHITE if it could not be derived.All other parameters for qualifier 1 will be set to their default values. The second qualifier is "The day is" with a list of days for values. The associated name is DAY OF WEEK and the end user can select only 1 value from the list.
K - RULE COMPILER
25
K - RULE COMPILER
27
K - RULE COMPILER
28
TYPE = <value>
Sets the type of variable. The acceptable values are N for numeric, S for string, or T for text only. The default type for the variable is N (Numeric). Having the wrong type for a variable will produce an error message when the system is run. (For example, TYPE=S sets the variable type as string.) (Default = N)
K - RULE COMPILER
29
K - RULE COMPILER
30
[LENGTH] The length of the beam as measured in feet from the base to the top DISPLAY UPPER LIMIT = 1000 LOWER LIMIT = 0 [ERROR MSG] WARNING The materials may be unsuitable for the project planned DISPLAY TYPE = T [X] RUN(GETLTH) The length of .... /* next variable sets up a variable [LENGTH] with associated prompt "The length of ... ." The variable is set to be displayed at the end and the end user can only input values between 0 and 1000. All other parameters will be set to their default values. The second variable is a text note to the user. It is marked as a "text only" variable. The third variable is [X] with an associated prompt that includes a RUN( ) command.
Rule Compiler Command
K - RULE COMPILER
31
This command allows input of a list of choices the goals the system will try to derive values for. The choices usually should be defined prior to their being used in the rules. However, the CHOICES: statement is optional and the list does not have to be complete. Unless the LIST ONLY command is used, the compiler will build the choice list from the choices found in the rules. If the LIST ONLY command is used, any choices found in the rules that do not match ones in the list will produce an error message. It is recommended that the LIST ONLY option be used with a complete choice list whenever possible to catch any typographical error that can occur when using text editors. Multiple choices can follow a single CHOICE: command. The choice command is optional. The choices can be selected from the rules. Commands:
C> <text>
indicates the start of a new choice. The text that follows the C> will be used for the qualifier. The text can continue over several lines. The text will be applied to the choice until a blank line, another C> or another command is encountered. The following example, CHOICES: /* start of choice list
C> Choice 1 C> Choice 2 C> This is the text for choice number 3, it goes over two lines. C> Choice 4 sets up 4 choices with the text indicated.
K - RULE COMPILER
32
This command causes the rule compiler to use ONLY the qualifiers, variables and choices from the list specified with the QUALIFIER:, VARIABLE: and CHOICE: commands. If a qualifier, variable or choice is found in the rules that does not match one of the predefined values, an error message will be displayed. Even if this command is not used, the program will display a message notifying the user when a new qualifier, variable or choice is created if there was a starting list of acceptable items. LIST ONLY prevents the new item from being added to the list and causes the program to issue an error message.
K - RULE COMPILER
33
The RULE: command or the IF: command indicates the start of a new rule. There can be an optional name for the rule following the RULE: or IF:. The RULE: command is optional, but the IF: command must be used in each rule. The RULE: and IF: commands indicate the start of a rule which has the following structure: RULE: <optional name> /* this line is optional IF: <optional name> if_condition 1 AND: if_condition 2 AND: if_condition 3 AND: ..... THEN: AND: AND: AND: ELSE: AND: AND: AND: else_condition 1 else_condition 2 else_condition 3 ..... then_condition 1 then_condition 2 then_condition 3 .....
NOTE: < note text> REFERENCE: <reference text> The RULE:, NOTE: and REFERENCE: parts are optional. The IF: and at least either a THEN: or ELSE: part are required. It is not necessary to specify a rule name or number. Each condition in the rule, except the first condition in the IF, THEN and ELSE parts, must start with AND: or and:. Spacing and indenting is optional and the compiler will ignore it. The text of individual conditions can carry over multiple lines.
K - RULE COMPILER
34
The conditions that the program uses to build the IF, THEN and ELSE parts are the same as those created in the EXSYS Professional Rule Editor, but in some cases extra syntactical information must be added so that the compiler can tell if the condition is a qualifier, formula or choice. The conditions can wrap over several lines. All lines not starting with AND: or other command word are taken as part of the same condition. There are syntactical notations required in conditions. These have been kept to a minimum to have the rules for the compiler look as much as possible like the rules displayed in EXSYS. 1. Qualifiers with one or more values, must have each value enclosed in { }. 2. A Choice condition must start with >. 3. Text to be assigned to a text only variable must start with T> or ". 4. An EXSYS internal command not assigned to a text only variable (created with the <X> command in EXSYS) must start with X>.
K - RULE COMPILER
35
K - RULE COMPILER
37
K - RULE COMPILER
38
K - RULE COMPILER
39
K - RULE COMPILER
40
K - RULE COMPILER
41
X> command
There are two types of text conditions in rules. The most general is the text associated with a text only variable. This is text which will be displayed at the end of a run if a rule with the text in it fires during the run. Such text has an associated variable name. The EXSYS Rule Compiler can accept either the name of the text variable, if it has been pre-defined, or just the text starting with a T> or ". If the compiler finds text starting with T> or ", it will check to see if the text matches any existing text only variable. If there is a match, that variable will be used. If there is no match, the compiler will create a new variable named TEXTVAR#, where # will be a number, and assign it the text. The variable will be of type "text only" and set for display at the end of a run. A second type of text applies only to EXSYS. It is used only for the text of an EXSYS internal command. In EXSYS it is not necessary to have an associated variable with a command. Such text is indicated by preceding it with X> and then the command. See Chapters C and G on the <X> command for more information on internal commands. The allowable EXSYS commands are STOP end run RESTART start over DISPLAY(...) display file REPORT(...) run a report CLEAR(...) clear out data or rules DB_...(...) interface to dBase III files RUN(...) run an external program The X> form does not create an associated EXSYS variable and it is not downwardly compatible to standard EXSYS. If you use the X> form you will not be able to save data in the standard EXSYS format. For compatibility with standard EXSYS, you can use the T> form for commands in place of the X> form. This will associate a variable with the text. Unless the variable is predefined, it will be set for display at the end of the run.
K - RULE COMPILER
42
Text only variables can only be used in the THEN or ELSE part of a rule. To execute RUN( ) commands in the if part, include the RUN(..) as the first part of the qualifier or variable text without a T> or X>. For example: IF: RUN(GETCOLOR) The color is {red} THEN: T> this is a note that the color selected was red X> RUN(TEST2 [Y] /C) The IF condition has a RUN( ) command as part of the qualifier. This is not a text variable. The RUN( ) will cause the external program GETCOLOR to be run if the qualifier is needed. The returned value from GETCOLOR will set the value of the qualifier. The first THEN condition is a text only string which will be associated with a variable. It will cause the note to be displayed at the end of the run if the rule fires. The second THEN condition, with the X>, will cause the external program TEST2 to be run and passed the value of [X]. This will not be associated with a text variable since it uses the X> form rather than the T> form.
K - RULE COMPILER
43
K - RULE COMPILER
44
Special Cases
The EXSYS Rule Compiler can determine the type of almost all conditions by the following rules: (these rules are in order of precedence)
K - RULE COMPILER
45
However, in some cases it is possible to confuse the compiler. A formula that did not use variables, a formula using string expressions that started with a " or a qualifier that started with '>' might be misinterpreted. These are rare exceptions, but if a statement is being misinterpretwhich should produce an error message - you can override the normal parsing strategy. Starting a condition with Q> or M> forces the program to consider it to be a qualifier or Math/formula respectively regardless of other syntactical indications. The following example, M>"abc" <> [x] Q> > The ... >, will be considered a formula even through it starts with a ". will be considered a qualifier even though the actual text starts with a indicating a choice.
The Q> and M> should be very rarely needed. Their function is only to allow an override of the normal parsing in exceptional situations.
K - RULE COMPILER
46
K - RULE COMPILER
48
ERROR 10: Qualifier text too long A qualifier is limited to 1000 characters. Check for syntax errors such as no "AND: " causing subsequent conditions to be misinterpreted as part of the same qualifier. ERROR 11: Identical qualifier already exists Two qualifiers in the QUALIFIER: list have identical text. ERROR 12: No space for qualifiers The space reserved for qualifiers has been used up. The compiler will attempt to correct for this, but if it is unsuccessful, use the MAXIMUM QUALIFIER command to increase space. ERROR 13: Qualifier value text too long A qualifier value is limited to 500 characters. Check for syntax errors such as no "AND: " or no closing } causing subsequent conditions to be misinterpreted as part of the same value. ERROR 14: Unknown parameter Text was found that could not be identified. ERROR 15: No variable specified An attempt was made to set a parameter for a variable before the variable had been specified. All variable parameters apply to the variable that immediately precedes them. ERROR 16: Not legal TYPE The type command must be followed by an N, S or T. ERROR 17: No space for variables The space preserved for variables has been used up. The compiler will attempt to correct for this, but if it is unsuccessful, increase the MAXIMUM VARIABLES parameter. ERROR 18: No closing ] The variable specified did not have a closing ]. ERROR 19: Identical variable already exists Two variables in the VARIABLE: list have identical names. ERROR 20: No prompt following variable name The prompt text for the variable must follow the name. ERROR 21: Variable prompt text too long A variable prompt is limited to 500 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the prompt.
K - RULE COMPILER
49
ERROR 22: No space for choices The space reserved for choices has been used up. The compiler will attempt to correct for this, but if it is unsuccessful, use the MAXIMUM CHOICES command to increase space. ERROR 23: Choice text too long A choice is limited to 500 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the choice. ERROR 24: Subject text too long A subject is limited to 500 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the subject. ERROR 25: No subject An expert system must have a subject line. ERROR 26: Author text too long A choice is limited to 100 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the author. ERROR 27: No author An expert system must have an author line. ERROR 28: Starting text too long Starting text is limited to 1800 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the text. ERROR 29: Ending text too long Ending text is limited to 1800 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the text. ERROR 30: External program text too long The initial external program call is limited to 100 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the text. ERROR 31: Illegal probability mode The probability mode value must be an integer between 1 and 5. ERROR 32: Value not recognized Allowable values are Y, YES, N or NO. ERROR 33: Note text too long Note text is limited to 1000 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the text. ERROR 34: Reference text too long Reference text is limited to 1000 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the text.
K - RULE COMPILER
50
ERROR 35: Unrecognized text in rule Text in the rule could not be identified. Check for typographical errors in AND:, THEN:, ELSE:, NOTE: or REFERENCE: commands. ERROR 36: Not enough memory The program was not able to allocate enough memory. If there are "ram disks" or memory resident programs running, delete them. If that does not correct the problem, try setting the MAXIMUM parameters to lower values (or if they are not set, use them to set values lower than the default values). ERROR 37: Condition text too long An individual condition is limited to 1000 characters. Check for syntax errors causing subsequent text to be misinterpreted as part of the text. ERROR 38: Unidentifiable condition in rule The text could not be identified as either a qualifier, formula, choice or text condition. Check for syntax errors such as missing T> or no { } in a qualifier condition. ERROR 39: { not found with qualifier A condition was forced to be considered a qualifier with Q> but it does not contain any values in { }. ERROR 40: No closing } A value in a condition has a { without a matching }. ERROR 41: More than 127 conditions A rule can have a maximum of 127 conditions in the IF, THEN or ELSE part. ERROR 42: Qualifier not in list The LIST ONLY option was used with a QUALIFIER: list. A qualifier was found that did not match any in the list. If the qualifier is correct, add it to the list or remove the LIST ONLY command in the file. ERROR 43: Qualifier value not in list The LIST ONLY option was used with a QUALIFIER: list. A qualifier value was found that did not match any in the list. If the qualifier value is correct, add it to the list or remove the LIST ONLY command in the file. ERROR 44: Value list full A qualifier can only have 30 values in its list. There was an attempt to add more than 30 values.
K - RULE COMPILER
51
ERROR 45: No variable specified for assignment A formula in the THEN or ELSE portion must start with a variable to assign a value to, such as [X] IS GIVEN THE VALUE 5. ERROR 46: No closing ] in variable name A variable in the formula had a [ without a matching ]. ERROR 47: Incorrect assignment statement A formula in the THEN or ELSE part must have an assignment of a value such as "IS GIVEN THE VALUE", "IS GIVEN" or ":=". Check syntax. ERROR 48: Syntax error in Choice condition There is a syntactical problem with the choice. ERROR 49: Choice not in list The LIST ONLY option was used with a CHOICE: list. A choice was found that did not match any in the list. If the choice is correct, add it to the list or remove the LIST ONLY command in the file. ERROR 50: No test condition in Choice condition A Choice condition in the IF part of a rule must have a test condition. ERROR 51: Choice value out of range The value specified for the choice is not in the range allowed for the confidence system chosen. ERROR 52: Confidence can only be used in probability mode 5 A [%...] confidence variable was used in other than confidence mode 5. ERROR 53: Illegal confidence variable A [%...] confidence variable had an incorrect name. Check referenced variable. ERROR 54: Confidence variable not found The variable specified in [%...] could not be found. ERROR 55: Variable not found A variable was referenced in the rules that was not in the list. The variable cannot be automatically added to the rules since it does not have an associated prompt text. Add the variable and its associated prompt to the list of variables. ERROR 56: Not an internal command The command specified in the X> command is not a recognized EXSYS internal command.
K - RULE COMPILER
52
ERROR 57: Text conditions cannot be used in the IF part Text conditions can only be used in the THEN or ELSE part of rules. To add RUN( ) commands in the IF part make them the first part of the text of a qualifier or variable text. ERROR 58: Out of disk space The program ran out of disk space trying to write out the rule files. ERROR 59: Saving in standard EXSYS format impossible Features unique to EXSYS Professional were used. Rules cannot be saved in standard EXSYS form. ERROR 60: Saving in standard EXSYS format will result in loss of some data Features unique to EXSYS were used. Rules can be saved in standard EXSYS form but some parameter data will be lost.
K - RULE COMPILER
53
Note: It is legal to mix various types of data in a single table, as long as the search string defines an individual item. However, for speed of access and maintenance, it is usually better to maintain separate tables for each type of data.
L - FRAME / TABLE
1
The search string is compared to the first column entry. For TABLE, a match will return the rest of the line, minus starting spaces or tabs. For NTABLE, a match will return a numeric value of the rest of the line. Note: For NTABLE, the second column must be numeric data. In the examples above, assume the data is in a file "DATA.DAT": Function: Returns: TABLE("DATA.DAT" "A56TR4") 45.32 as a string NTABLE("DATA.DAT" "A56TR4") 45.32 as a numeric TABLE("DATA.DAT" "MA*") 555-5555 as a string NTABLE("DATA.DAT" "MA*") 555 as a numeric (rest lost) TABLE("DATA.DAT" "3") "copper pipe" as a string It is possible to use tables as a type of array. A series of tables can be accessed by their index to put parameters in a rule. For example: IF [PRICE] > TABLE("price.dat" [S]) and: [AMOUNT] > TABLE("amount.dat" [S]) By simply changing the value of the string variable [S], the values in the rule can be changed. It is also possible to use a numeric variable as the index by using [[ ]] replacement. For example: IF [PRICE] > TABLE("price.dat" "[[N]]") and: [AMOUNT] > TABLE("amount.dat" "[[N]]") The [[N]] will be replaced by the value of the numeric variable [N]. The quotation marks around it are necessary to make it a string in the TABLE function. The table referenced would have the sequential numbers in the first column and the data in the second column, such as 1 2 3 123.45 65.32 96.29
By indexing the value of [N] (either in the rules or the command language), the TABLE value will be replaced by successive table entries.
L - FRAME / TABLE
L2: Frame
FRAME provides a way to handle more complex data than can be handled with TABLE. The TABLE commands are basically limited to simple 2 column look-ups. FRAME allows multiple columns and much more complex search criteria with Boolean operators. FRAME also allows the data table to updated by the rules. Frame also provides inheritance which allows a hierarchical set of frames to be created with data in "parent" frames available to lower level frames.
Syntax:
To read from a frame:
FRAME("filename", test_expression, slot_reference)
To write to a frame:
FRAME("filename", test_expr, slot_ref :=expression)
The name of the FRAME data file. The filename must be in " ". The Boolean expression used to find the desired line in the frame. The desired column in the frame. FRAME looks in the file for a frame which matches the test expression and either writes or reads the slot referenced. This reference must be in $ or # to indicate if it to be handled as a string or numeric. The data to be written into the slot_reference.
Expression:
L - FRAME / TABLE
A frame is similar to a database record (or structure). A frame has slots which hold the data. These are similar to fields. If you have a group of frames with the same format, you can make one frame out of it.
Name Mike Dan Jill Bill Joe Peg Address 100 Memory Lane 201 Penny Lane 832 Jack La Lane 831 Rocky Rd. High Rd 2 Scotland I-40 Freeway Telephone (299) 458-9287 (298) 754-1489 (299) 572-9578 (298) 194-2374 (298) 278-9278 (299) 856-9274
The slots can have sub-slots. The sub-slots can have sub-sub-slots and so on. However, if a slot contains a sub-slot, it must contain at least 2 sub-slots. The slot or field definition part of the frame is called the header. This is everything up to the double lines. Everything following the double line is called the body. Each row of data in the body is called a frame row.
L - FRAME / TABLE
Example:
Item Price Our Cost Sale Price Diameter Dia Units Length Len Units HEADER
Screw
.01
1.90
1/4
inch
2 3/4
inch BODY
Pipe
50.00
150.00
.5
feet
yards
The names of the slots are the words used in the header. A sub-slot has both a name and a full name. The names are case insensitive, so if you have a slot "Inch," it will match with "inch" and "INCH." A full name consists of the name of the slot which the sub-slot is in, followed by a period and the name of the slot, for example, Price.Our Cost, Price.Sale Price, Diameter.Dia, Diameter.Units, Length.Len, Length.Units. To reference a slot of a frame, you can use just its name. However, if its name is not unique then you must use its full name. For example, in the table above, "Sale Price" is unique and it would not be necessary to use "Price.Sale Price." However, "Units" is not unique and it would be necessary to use "Length.Units" or "Diameter.Units." The value in the slot can be evaluated as string value or as a number. To tell the program how you want the value handled, the slot name is preceded and followed by a $ for a string or # for a number. For example, in the first row of the body, #Sale Price# would be a numeric value of 1.9. However, $Sale Price$ would be a string value of "1.90." For strings, leading and trailing spaces are dropped. These values are handled differently in EXSYS Professional operations and value assignments. Notice the 2 3/4 will be evaluated as 2.7500. FRAME will correctly handle fractional notation. Remember in the table above, $units$ is ambiguous since there are 2 slots with that name. You should, therefore, specify $diameter.units$ or $length.units$. You can also retrieve the value of slots which have sub headings. For example, $Length$ will have the value "2 3/4 inch" or "2 yards", depending on which row we select. The value will include all of the sub-heading values.
L - FRAME / TABLE
Notice that, in the frame, the separating lines are missing in the value of $length$. The separating lines have no function in the frame rows. They are crucial in the header. Where the separating lines appear in the header determines what columns hold the data for that slot. Note: The characters $, #, and . have special meaning in a slot reference; they cannot be used in the slot names in the header.
L - FRAME / TABLE
First Line:
The first line of a frame must be at least 3 characters long. It must be all +'s and -'s or a drawn line using extended graphics characters. The length of the space marked with + or - indicates the width of the frame. All other columns outside of the space marked will be ignored. This makes the first line very important.
Header:
The header lines must fit under the first line. Enter the names of the slots or sub-slots, with the field width indicated by the | character. It is important to make sure that the width is adequate to hold any data that may be entered. Continue entering lines with sub-slots until the header is defined. End the header with a line of = characters. The line using = must not have + or | characters in it.
Body:
The data in the body of the frame should line up under the slot names or sub-slot names. It is not necessary to mark the slot widths in the body with |, but it does make the frame easier to read.
Last Line:
The last line must be the same as the first line in the frame.
Comments:
Any data outside of the space marked off by the first line is ignored. Comments can be placed outside of the marked space. This syntax may seem unnecessarily complicated, but the resulting frame is easy to read and understand. The frame is maintained as tabular data and can be created by many database managers or spreadsheet programs. By using the header to define field widths, it is easy to change the frame and quite complex structures can be kept as simple ASCII files without additional field width data.
L - FRAME / TABLE
Notice the comments outside of the frame are ignored, both before and after the first and last line and outside the frame width. You can put anything outside the frame as long as it is not confused for the first line of the frame. 1. 2. 3. 4. The first line defines the width and is required. The vertical bars separating the slots are required. The double line separating the header from the body is required. The last line, which is the same as the first line, is required.
Notice that only the minimum syntax was used. The use of +'s and extra lines in the header make it easier to read and maintain.
+-------+--------------------+------------+-------------+ | item | price | diameter | length | | +---------+----------+-----+------+------+------+ | |our cost |sale price| dia |units | len |units | ========================================================= | screw | .01 | 1.90 | 1/4 inch |2 3/4 inch | | pipe | 50.00 | 1500.00 | .5 feet | 2 yard | +-------+---------+----------+-----+------+------+------+
L2.5: Inheritance
Inheritance is a powerful capability of FRAME. It allows you to specify a "parent" frame for any other frame. If a search on the test expression fails in all lines of the specified frame, the search will be repeated in the parent frame. This allows data to be split over a set of frames. One frame may have general, or default information while sub-frames have specific information. If a search of the specific information fails, the program will automatically return to the general frame.
L - FRAME / TABLE
8
Suppose you are storing information about animals in the frames. The vast amount of information demands a systematic method of storing that information. Much of the information is the same for groups of animals. For example, almost all mammals are warm blooded, have hair and give live birth instead of eggs. It would be nice if we didn't have to put every feature/attribute of the animal in the frame of that animal. It would be nice if there were a link from a dog frame to a mammal frame such that it could be determined that a dog is warm blooded and have that fact stored only in the mammal frame. This is accomplished using inheritance. To specify the frame you will inherit from, after the frame put ~INHERIT FROM <filename> Data not found in the current frame will be searched for in the file specified. Be sure it appears on a line occurring after the last line of the frame. You can have one file inherit from another file which inherits from yet another file etc. To continue with the mammal example above, we could have a frame MAMMAL with very general characteristics:
+----------------+------------------+---------------+ | Warm Blooded | Body Covering | Live Birth | ===================================================== | YES | Hair | YES | +----------------+------------------+---------------+
We have defined it to inherit from an even more general frame ANIMAL. We could now have the DOG frame:
+----------------+--------------+ | Number of Legs | Carnivore | ================================= | 4 | YES | +----------------+--------------+ ~INHERIT FROM MAMMAL
If we searched DOG for Number of Legs, we would get 4 directly, but if we searched for "Warm Blooded," there would be no such slot and the call would be repeated for the parent frame mammal. In this case, we have only one line in the body of each frame. But there could be many. Also, we might have a frame for Platypus that would over-ride the slots in the parent frame, by having a specific entry:
L - FRAME / TABLE
9
+----------------+--------------+-------------+ | Number of Legs | Carnivore | Live Birth | =============================================== | 4 | YES | NO | +----------------+--------------+------- -----+ ~INHERIT FROM MAMMAL
If we asked about Live Birth in the Platypus frame, we would find the slot and not inherit from the parent frame.
L - FRAME / TABLE
10
The name of the FRAME data file. The filename must be in " ". The Boolean expression used to find the desired line in the frame. The desired column in the frame. FRAME looks in the file for a frame which matches the test expression and either writes or reads the slot referenced. This reference must be in $ or # to indicate if it to be handled as a string or numeric.
L - FRAME / TABLE
11
The name of the FRAME data file. The filename must be in " ". The Boolean expression used to find the desired line in the frame. The desired column in the frame. FRAME looks in the file for a frame which matches the test expression and either writes or reads the slot referenced. This reference must be in $ or # to indicate if it is to be handled as a string or numeric. The data to be written into the slot_reference.
Expression:
Writing to a frame is very similar to reading except for the last parameter. Instead of just being a slot designator, there are both a slot designator and an expression to assign to that slot. The assignment can include data from other slots in that row. The assignment is indicated by :=.
L - FRAME / TABLE
12
L5: Examples
Here are some examples: Price Frame:
+-------+--------------------+------------+-------------+ | item | price | diameter | length | | +---------+----------+-----+------+------+------+ | |our cost |sale price| dia |units | len |units | ========================================================= | screw | .01 | 1.90 | 1/4 inch |2 3/4 inch | | pipe | 50.00 | 1500.00 | .5 feet | 2 yard | +-------+---------+----------+-----+------+------+------+
L - FRAME / TABLE
13
L - FRAME / TABLE
14
L - FRAME / TABLE
15
Note: The syntax of the parameters for each command is described in the command section of this chapter. When calling from the operating system, there is only a single command used, but it requires one additional parameter. The other parameters are the same as when calling from within EXSYS. There is also a stand alone executable program called EXSYSBB.EXE. Note: EXSYSBB as a separate executable is not supported in all operating systems. It can be called like any other executable program from the operating system. However, for the three different types of blackboard commands, an extra parameter must be added as the first parameter passed. The other parameters are the same in both calling methods. BB_RD(parameters) BB_WR(parameters) BB_DE(parameters) EXSYSBB(-Q parameters) EXSYSBB(-U parameters) EXSYSBB(-D parameters)
M - BLACKBOARD MANAGER
M - BLACKBOARD MANAGER
M - BLACKBOARD MANAGER
M - BLACKBOARD MANAGER
M - BLACKBOARD MANAGER
Optional Parameters: -B, -M, -V See the parameter section for details. If the Blackboard file does not already exist, it will be created. The default blackboard file GDB.DAT will be used unless the -B option is used.
M - BLACKBOARD MANAGER
M - BLACKBOARD MANAGER
M - BLACKBOARD MANAGER
If values are used with the read commands, the match will be made on both the attribute and value. For example, if there was a blackboard that contained the string "The color is red" and we used BB_RD(-A'The color is') then it would return "red." However, if we used BB_RD(-A'The color is' -V'red') the test would be true, but no data would be returned. In this case, you should use the -T and -F options to tell the program what to return if the test is true or false. In the following example, BB_RD(-A'The color is' -V'red' -T'1' -F'0') would return 1 if the attribute or value pair was found and 0 if it is not. See the Parameters section for details on the various commands parameters that can be used.
M - BLACKBOARD MANAGER
10
M9: Parameters
Post String -A'string expression'
The -A switch allows you to specify a string in the blackboard you want to post to the blackboard or to search for on the blackboard, such as "senior discount rate." You must always specify an attribute string when calling EXSYSBB. For example: BB_WR(-A'Process 1 complete') will write the string "Process 1 complete" to the default blackboard GDB.DAT. BB_RD(-Btest.bb -A'Process 1 complete') will check the blackboard file test.bb for the string "Process 1 complete." If it is found, any associated values will be returned in the file GDB.RTN. BB_DE(-Btest.bb -A'Process 1 complete') will check the blackboard file test.bb for the string "Process 1 complete." If the string is found, it will be deleted.
-A'green')
will use the file bbfile1.out as the blackboard file instead of the default blackboard GDB.DAT.
M - BLACKBOARD MANAGER
11
Delete -D
The -D switch tells EXSYSBB to delete an attribute from a blackboard with value information supplied by you through the use of the other command line switches. This parameter is only needed when calling EXSYSBB from the operating system. When calling from within EXSYS, use the internal command BB_DE Note: If a -V'(value)' is supplied only the specific attributes found with that specific value are deleted. For example: EXSYSBB -D -A'Problem Found' will delete the string "Problem Found" from the default blackboard file.
M - BLACKBOARD MANAGER
12
Note: -M is valid only if the blackboard already exists and may not be specified when creating a new blackboard. For example, suppose we have a blackboard with the line Pressure 555 We want to change the pressure value to 111. If we just use: BB_WR(-A'Pressure' -V'111') the blackboard file will contain Pressure 555 Pressure 111 There are some cases where such multiple reference information is useful, but in this case we will want a unique value. To do this we eliminate multiple references to the attribute with BB_WR(-A'Pressure' -V'111' -M) This will eliminate the old reference and the blackboard will now have just Pressure 111
M - BLACKBOARD MANAGER
13
For example, suppose you wanted to read the value of the attribute "Pressure" into variable [P]. Normally, you would just associate the blackboard call with the variable [P], but you could alternatively call EXSYSBB as an external program and use EXSYSBB -Q -A'Pressure' -P'[P] ' This if the blackboard contained the string "Pressure 546," this would return "[P] 546."
For example, if you want to append the string "XXX" to a value, you could use EXSYSBB -Q -A"The color is" -S'XXX' This option is rarely needed, but allows compatibility with the maximum number of applications.
M - BLACKBOARD MANAGER
15
M - BLACKBOARD MANAGER
16
M - BLACKBOARD MANAGER
17
Interactive Operation
Invoke EXSYSBB without command line parameters and it will turn on a trace function, display a sign-on message and prompt you for a command line.
M - BLACKBOARD MANAGER
18
M - BLACKBOARD MANAGER
19
M - BLACKBOARD MANAGER
20
N - LINDO INTERFACE
The following is the proper command syntax: LINDO(filename options) The "filename" is the name of the LINDO specification file. This file has the commands to build the LINDO model and to read data back into EXSYS variables. The model will be built and run automatically. The results will be read back into specified EXSYS variables. The "options" allow overriding the automatic sequence of the LINDO command. The following list describes what the LINDO options are and what they do: /I Causes LINDO to be run in an interactive mode. LINDO is normally run with no user interaction. The model automatically generates an output file and LINDO terminates. In interactive mode, the command file will be created and can be loaded and run, but all of the interactive LINDO commands will be available for examining the model. This is useful to examine results, make modifications in the model or test the system during development. Usually, once the development is completed, the /I would be removed. Causes the LINDO command file to be written, but not executed. The option /W=filename causes the command file to be created in the file "filename." The default file name is LINDOCMD.TMP. This option is useful for creating a model, using the model to run LINDO on another computer and then returning the results to the starting computer. Causes the LINDO results file to be read, but without building a command file or executing LINDO. The option /R=filename causes the data to be read from the file "filename." The default file name is LINDORET.TMP. This option is useful for reading data created if LINDO is run on another computer. UNIX Note: With UNIX computers, all / are replaced by -. For example, /I becomes -I.
N - LINDO INTERFACE
2
/W
/R
~TEMP=path
EXSYS will create two temporary files during the LINDO run. One contains the LP model and the other the results of the LINDO run. The names of these files are LINDOCMD.TMP and LINDORET.TMP. These names cannot be changed, but the directory they are in can be changed. If there is no ~TEMP command, the files will be created in the default directory. If there is a ~TEMP command, the files will be created in the directory specified by the path. This is useful for creating the temporary files on a RAM disk to improve performance. The ~TEMP command is optional, but if it is used, it must appear before any model commands. The following example ~TEMP=d: would create the temporary files on drive D, which could be a RAM disk.
N - LINDO INTERFACE
3
~LINDO=filename
EXSYS will call LINDO after the model is built. It expects LINDO.EXE to be in the default directory. If LINDO is somewhere else, or renamed, you must include a ~LINDO command to tell EXSYS where LINDO is. This is not a path, but a full file specification. The following applies, for example, if LINDO.EXE is in a directory called LINDO: ~LINDO=/LINDO/LINDO.EXE
N - LINDO INTERFACE
which would be converted to MAX 2X+5Y or MIN 2X+5Y depending on the rules in the expert system.
N - LINDO INTERFACE
N5: ~Results
The ~RESULTS command tells EXSYS 1. That the model is complete 2. To run LINDO on the model 3. That the commands that follow are data commands There must be a results command unless the /R option was used.
N - LINDO INTERFACE
N - LINDO INTERFACE
would return the DUAL PRICE for the row labeled "cost."
N - LINDO INTERFACE
would return the CURRENT RHS for the row labeled "cost."
would return the ALLOWABLE INCREASE for the row labeled "cost."
would return the ALLOWABLE DECREASE for the row labeled "cost."
ITERATIONS
Abbreviated forms: ITER This ID returns the number of iterations. For example: [I] = ITER
N - LINDO INTERFACE
10
NO SOLUTION
This ID returns 1 if no solution was found or 0 if a solution was found. This can be used as a check before displaying results. For example: [OK] = NO SOLUTION
N - LINDO INTERFACE
11
There are various constraints on manufacturing the products due to production capability. It takes 4 units of production capacity to manufacture an X product and 3 units of production capacity to manufacture a Y product. We have only 10 units of production available per day. In the LINDO model for the problem, this will be represented as 4X + 3Y < 10 where X and Y represent the number of product X and product Y we should manufacture per day under current market conditions. Also, because of supply limitations, we have another constraint on production of: 3X + 5Y < 12
To create an interface between EXSYS and LINDO 1. Write an expert system to derive the value of [PROFIT X] and [PROFIT Y] based on various factors. 2. Once the value is derived, call LINDO to find the optimum point of operation. There are many ways this could be done. One simple way is to use the command language to force executions of the rules to derive the values of [PROFIT X] and [PROFIT Y] and then call LINDO.
N - LINDO INTERFACE
12
The command file would look like RULES [PROFIT X] RULES [PROFIT Y] LINDO(FIND_OPT.LIN) REPORT(FIND_OPT.RPT) The first line invokes all rules that will derive a value for [PROFIT X]. The second does the same for [PROFIT Y]. The third line calls LINDO using the LINDO specification file FIND_OPT.LIN (this could have any name). We then call the report generator to display the results. 3. Write the LINDO specification file, in this case FIND_OPT.LIN. This contains the model and instruction on what data to return to EXSYS variables. In this case, the specification file would read MAX [PROFIT X] X + [PROFIT Y] Y ST 4X + 3Y < 10 3X + 5Y < 12 ~RESULTS [X PER DAY] = VAR VALUE X [Y PER DAY] = VAR VALUE Y [TOTAL PROFIT] = FUNCTION VALUE 1 The first line says to maximize the profit of X times the number of X produced plus the profit of Y times the number of Y produced. The EXSYS variables [PROFIT X] and [PROFIT Y] will be replaced automatically by the values calculated by the expert system before the model is run. The ST in the second line is LINDO notation that indicates the start of the constraints. Lines 3 and 4 are the constraints on manufacturing X and Y in LINDO notation (These lines could also contain EXSYS variables if desired). The ~RESULTS indicates the end of the LINDO model commands and the start of commands to return results to EXSYS. After the model is run, these commands will be used to parse the LINDO results file. The 6th line will assign the EXSYS variable [X PER DAY] the optimum number of X to be produced as calculated by LINDO, based on the model. This will be in the VARIABLE VALUE column of the LINDO results in the row X. We also do the same for the EXSYS variable [Y PER DAY]. The final line assigns the EXSYS variable [TOTAL PROFIT] the value calculated by LINDO for the maximum profit at the optimum point of operation. This is in the OBJECTIVE FUNCTION VALUE column of the LINDO results for formula 1.
N - LINDO INTERFACE
13
4. Write a report specification to format and display the values returned. A very simple one would be FILE TEMP "OPTIMUM POINT OF OPERATION" " " "Current Profitability:" [PROFIT X] [PROFIT Y] " " "Optimum Point of Production" [X PER DAY] [Y PER DAY] " " "------------------------------------" [TOTAL PROFIT] CLOSE DISPLAY TEMP This would output the profitability calculated by the expert system, the optimum number of X and Y to produce and the total profitability. It uses the technique of creating a file and then immediately displaying it. 5. Run the system. Suppose that the expert system calculates a value of 2 for [PROFIT X] and 3 for [PROFIT Y]. When we build the LINDO model, these values will be put in it to produce MAX 2X + 3Y ST 4X + 3Y < 10 3X + 5Y < 12 LINDO will use this model to calculate the optimum values for X and Y. This will be put in a temporary file, which EXSYS will parse for the information request to be assigned to EXSYS variables. The values 1.272727 and 1.636364 will be assigned to [X PER DAY] and [Y PER DAY], respectively. The [TOTAL PROFIT] variable will be given a value of 7.4545.
N - LINDO INTERFACE
14
Using the report generator to format these results, the end user will see the following: OPTIMUM POINT OF OPERATION Current Profitability: Profit from product X = 2 Profit from product Y = 3 Optimum Point of Production Number of X to produce per day = 1.272727 Number of Y to produce per day = 1.636364 -----------------------------------Total profit per day = 7.4545 The user did not have to build an LP model or understand the results file produced by LINDO. The user only had to answer the questions in the expert system. The EXSYS/LINDO interface did the rest.
N - LINDO INTERFACE
15
O - UTILITY PROGRAMS
It is possible to use FASTERP to find errors in the logic of the rules. If after running FASTERP, the same data produces different results, there is probably an error of logic that is in both the old and new rule arrangements. You may find FASTERP useful as a rule checking utility. Experiment with it. If speed is a major factor in your expert system, arrange the rules to use the FORWARD and NOBACKWARD options. This will be MUCH faster than any backward chaining arrangement, even if you optimized with FASTERP.
O - UTILITY PROGRAMS
O4: Pager
Note: PAGER is not supported on all operating systems PAGER is used in the report generator when you want to print or display a file with headers and page numbers and/or separated into pages. You would generate and close a file with the report generator. This file would contain the information used by PAGER. You would then call the PAGER program from the report generator to generate the file with the page breaks and headers. The syntax is PAGER input_file output_file left_margin body_length [page_length] PAGER reads the input file and generates the output file with page breaks and margins. input_file output_file left_margin File to read; generated with the report generator. File with page formatting. Column number where the first character of the line starts. Use a value of 1 for no margin. Number of lines to be printed in the body of the page. Must be greater than 0. Total number of lines on a page. If set, this will write blank lines to fill the rest of the page instead of form feeds. The page length must be greater than the number of lines in the header or it will print pages with only a header. The page length should be greater than the body length + header length. This parameter is optional.
body_length page_length
Commands can also be put in the input_file to change the parameters set during formatting. This allows sections of the report to be formatted in different ways. The page header and page number commands can only be set as commands in the input_file. The syntax for the commands in the input_file are
O - UTILITY PROGRAMS
Change the left margin. Change the body length. Start the definition of a page header. End the definition of a page header. Print page number.
Note: All commands must start at the beginning of a line except >>PAGE_NUMBER.
Right Margin
The right margin is not set by PAGER. It is up to you to make sure the lines are not too long. If you are using the report generator, you can insure this by using the WIDTH command in EXSYS.
Headers
If you do not define a header, PAGER will not insert any page breaks. You can define a header at any time. You can change it at any time. A header is defined when PAGER encounters text starting with >>start_page_header. The text following this command, up to a line starting with >>end_page_header, will be used as the header for each page. You can include the page number in the header by using the command >>page_number anywhere in the header text. The ">>page_number" will be replaced by the actual page number in the formatting. For example: >>start_page_header Expert System Report EXSYS Inc. PAGE: >>page_number ___________________________________________ _ >>end_page_header If you do not want a header printed but you do want page breaks then define a header that has no text or blank lines.
O - UTILITY PROGRAMS
If you do not specify a page_length or a header and print more than a page of text, then the page numbers will not be accurate. This is because PAGER cannot tell if it has reached the end of a page. It cannot go by body length because, without a header, there is no body. You can change the margins, header or body length at any time. If you change the body length, it will not go into effect until the next top of page.
Page Break
You can force a page break anywhere by putting a form feed in the file. To do this from the report generator use "@@012" (include the quotation marks). Do not put a form feed in a header (it causes an infinite printout). Do not put any text between a form feed and the end of that line (it will not be printed). You may put text before a form feed but if this file is viewed on the computer screen, it could have a line that runs off the screen. It will print correctly, however.
O - UTILITY PROGRAMS
O5: EX_TIME
Note: EX_TIME is not supported on all operating systems The Utility EX_TIME is used when you want a formatted time or date displayed. You can display the time as either a string or a numeric. You can control the format of the output time/date string by passing EX_TIME a format string. The reserved command words occurring in the format string will be substituted for the appropriate value. All the other characters in the format string will be unchanged. The syntax of the call is EX_TIME format_string [time_in_seconds] EX_TIME writes to the file return.dat. The output is the time value formatted by the format_string specified. format_string time_in_seconds The commands that specify how to format the output string. The time value to format in seconds. This parameter is optional. If it is not specified then the current time is used.
Format_strings are made up of command words and any other text which is not a command word. Command words are replaced by their value. All other text is repeated exactly as it appears and in the same place in the string. The following are command words recognized in the format string: Month month Mon mon Month# month# The full month name, capitalized. For example, August The full month name, not capitalized. For example, august The abbreviated month name, capitalized. For example, Aug The abbreviated month name, not capitalized. For example, aug The number of the month, with leading 0's. For example, 08 The number of the month, without leading 0's. For example, 8
O - UTILITY PROGRAMS
Weekday weekday Day day Day# day# year year# sec# seconds min# hour# hour am_pm Am_pm
The full day name, capitalized. For example, Tuesday The full day name, not capitalized. For example, tuesday The abbreviated day name, capitalized. For example, Tues The abbreviated day name, not capitalized. For example, tues The number of the day, with leading 0 if proper. For example, 05 The number of the day, without leading 0's. For example, 5 The full numbers for the year. For example, 1989 The shortened number of the year. For example, 89 The number of seconds past the last minute. For example, 05 The number of seconds since 1970. For example, 113457705 The number of minutes past the last hour. For example, 35 The number of hours. For example, 12 The number of hours military time. For example, 24 Either am or pm. not capitalized. For example, am Either AM or PM capitalized. For example, AM
For example, suppose the time is October 13, 1989 at 5:00pm. EX_TIME "hour#:min# month#/day#/year#" would return "5:00 10/13/89." EX_TIME "Month day#, year at hour#:min#" would return "October 13, 1989 at 5:00." EX_TIME "Weekday the day#, hour# am_pm" would return "Friday the 13, 5 pm."
O - UTILITY PROGRAMS
To use EX_TIME from within EXSYS, call it like any other external program. The formatted string will be returned in return.dat to a variable. For example, you could have a string variable [DATE] with an associated call to EX_TIME to get a formatted time string RUN(EX_TIME ......) This could be used from the report generator or anywhere the formatted string was needed. It could be embedded in other strings using the [[ ]] parameter replacement. EX_TIME can also be used with the results of the EXSYS function AGE which returns the number of seconds since a variable value was set.
O - UTILITY PROGRAMS
O6: Repeat
Note: REPEAT is not supported on all operating systems. The utility REPEAT will perform the command N times where you specify the command and N. The syntax of the call is: REPEAT num_times_to_repeat command_to_repeat
REPEAT will execute the command as many times as specified by num_times_to_repeat. Here is an example: REPEAT 3 "COPY REPORT.DOC PRN > NUL" This copies the report to the printer 3 times and doesn't print the "1 file(s) copied" message by redirecting it to NUL. One problem you may encounter is that DOS sometimes modifies parameters passed to programs. It will delete characters like ". It will change characters like ; into a space. It will convert a parameter with spaces into many parameters. To pass a string containing a space, put the entire parameter in quotes as shown above.
O - UTILITY PROGRAMS
10
Introduction
The purpose of EXSQ is to reformat and squeeze down reports generated by the EDITXSP expert system editor so that they are more readable and require less paper. The results are also suitable for formal documentation needs, including Copyright applications. EXSQ requires as input a report generated with the EDITXS "PRINT" option, which was directed to a disk file rather than straight to the printer. EXSQ supports Epson dot matrix printers, Hewlett-Packard laserjet printers and IBM dot matrix printers.
O - UTILITY PROGRAMS
11
Note: EXSQ never removes the SQ.PRN file; if the file exists, it always appends the existing file. Therefore, you can squeeze a bunch of rule bases and print them out all at once. It's up to you to delete the sq.prn file whenever appropriate. The SQ.PRN file can be copied to the printer. The format control codes for the printer are already embedded in the file. To print the file, just enter COPY SQ.PRN PRN
Demonstration
You may try out EXSQ on a sample rule base report by entering the following command line at the DOS prompt (replace "/p" with /E, /H, or /I, as explained in "How to use EXSQ"): EXSQ SAMPLE.PRN /p When EXSQ finishes, you may print the results either with the DOS PRINT command or via the COPY statement as below (put your printer in EPSON mode): COPY SQ.PRN PRN
O - UTILITY PROGRAMS
12
Note: EXSYS Products use third party libraries for the database support. The above list will grow. See the READ.ME on your distribution disks for the databases currently supported.
P1: Installation
The EXSYS interface to the databases is made through a third party library of functions from Intersolv (Q+E Software). The connection to the database is made through the Q+E DLL (dynamic link libraries) which must be installed on your computer. There are two groups of DLLs related to SQL. A base group of DLLs is required for EXSYS tools to load and run - even if a system does not call for an SQL interface. These DLLs are loaded during the normal EXSYS install procedure.
P - SQL COMMANDS
In addition to the DLLs provided with EXSYS, an ODBC compliant DLL for the specific database used is required. Because of licensing restrictions, this ODBC layer is NOT provided with EXSYS. The ODBC DLL layer may be obtained from Intersolv as their "ODBC Pack" which includes the DLLs for all the databases, or the DLL for a specific database may be obtained from Intersolv. ODBC compliant DLLs from other companies are also supposed to work that is the whole idea of ODBC - however, EXSYS Inc. recommends using the ODBC DLLs from Intersolv. An ODBC compliant DLL for the specific database being used must be present to make use of the SQL commands in EXSYS. Intersolv has a variety of licensing arrangements for distribution of the specific database DLLs within a company. Intersolv can be reached at:
Intersolv 5540 Centerview Drive, Suite 324 Raleigh, NC 27606 TEL: (919)859-2220
If your application does NOT make use of the EXSYS SQL commands, all required DLLs are provided with the EXSYS software and can be distributed with your application.
IMPORTANT NOTE: Unless specific arrangements are made with Intersolv, you are not licensed to distribute the Q+E "ODBC Pack" DLLs to others.
P - SQL COMMANDS
Installation:
Copy all DLL files from the EXSYS Professional Ver. 5.0 diskettes to the \WINDOWS\SYSTEM directory. Install the Q+E ODBC Pack software according to the manufacturer's instructions. To define a Data Source: Click on the ODBC icon in the WINDOWS Control Panel. Under DATA SOURCES, choose ADD. Under ADD DATA SOURCE, select database type. Under ODBC <database type> DRIVER SETUP: Enter <database type source name>* in DATA SOURCE NAME. Enter a working directory, if known. Enter other information as appropriate. CLOSE/EXIT all the way out. * Database type source names are found in the READ.ME on your distribution disks.
P - SQL COMMANDS
Reads a single value from a data base with an SQL call. This should be used when limited SQL access in needed, or to associate an SQL call with a variable. This command is also designed to return only a single value. Only the first column of the first record returned will be assigned to the variable - even if there are multiple records returned. For multiple record assignments, use the other SQL commands. This command is most useful when used as a data acquisition command associated with a variable. It is the only SQL command that is practical to use this way. Connection String The SQL connection string. This identifies the database, server, or password. This is currently the same connection string in the command SQL_CONNECT() command. The SQL command to issue. This must be a legal SQL command for the database that has been opened. See the Q+E Database Driver Reference for legal SQL commands for each supported database. The format string for the returned data. See the Intersolv documentation provided with their "ODBC Pack" on formats supported for specific databases.
SQL Command
Format String
P - SQL COMMANDS
EXSYS Variable
This is the EXSYS variable to assign the data to. If the EXSYS variable is a string variable, the data will be assigned as a string. If it is a numeric variable, the value will be converted to a numeric value and stored. The EXSYS variable name must be in square brackets.
The SQL_READ_ONE command can be associated with a variable by using it as a data acquisition command. To do this, precede the prompt text of the variable with the SQL_READ_ONE command. Be sure that the EXSYS variable specified in the SQL_READ_ONE command matches the variable it is a data acquisition command for. The command can also be used independently in the command language to assign data. Since this command, connects and disconnects from the data base each time, it is much less efficient than multiple SQL reads during a single connection. If many items of data are to be read, it is better to connect to the data base, make multiple reads and then disconnect.
These operations are performed in the EXSYS command languages, although step 5 can also be used as a data acquisition command associated with a variable. EXSYS supports simultaneous connections to multiple databases and simultaneous SQL commands. In order to specify which database or SQL command is being referred to, EXSYS variables are used to carry identifier information. When you connect to a database or issue an SQL command, a value is put in a special EXSYS variable. This variable is then used in other commands to specify the database or SQL command.
P - SQL COMMANDS
For example, suppose we were connecting to Oracle running on a server and we wanted to specify our user ID and Password: SQL_CONNECT("ORACLE -U:myname -P:mypass -S:server", [ID]) Many of the more powerful databases require the server, user ID and password. If you do not know the user ID, or do not want to hard code a password into the expert system, you can use the -DIALOG option. This will cause a dialog to appear when the SQL_CONNECT is executed. The dialog will prompt the user for their password, etc. The -DIALOG command can be used in conjunction with other options. For example, you might specify the server with a -S:server but not specify the user or password. This would look like: SQL_CONNECT("ORACLE -S:server - DIALOG", [ID])
Some databases may support other options in the connection string. These are added into the string with no prefix. For details on the specifics of connecting to each of the databases supported, see the Q+E Database Driver Reference.
P - SQL COMMANDS
7
SQL Command
P - SQL COMMANDS
This is an EXSYS variable that will be assigned a value of 0 if the command was successfully executed. A non-zero value indicates that there are no more records to read or an error occurred. If there was an error, a separate error message will be displayed. Testing for a non-zero value can be used in a WHILE loop in the command language to indicate that all records have been processed.
P - SQL COMMANDS
recnum
P - SQL COMMANDS
10
This is the EXSYS variable that identifies the specific SQL command that returned data. This identifier was set by the SQL_EXEC() command. This is an EXSYS variable that will be assigned the number of records returned by the specified SQL command.
P - SQL COMMANDS
column number
format
This is the EXSYS variable that will be assigned the data. If the variable is a string variable, the value assigned will be converted to a string. If it is a numeric, it will be converted to a numeric.
P - SQL COMMANDS
P5: Transactions
Many SQL databases support transactions. This allows a series of SQL commands to be executed that would modify the database, but not have the modification actually made until the commands are committed. If for some reason, a decision is made to not actually change the database, the commands can be canceled without changing the actual database. Note: Not all databases support transactions. To execute transactions: 1. Call SQL_BEGIN_TRANS() 2. Execute SQL commands. 3. If the changes are to be made execute a SQL_COMMIT before closing the database. If the changes are to be canceled, execute a SQL_ROLLBACK.
P - SQL COMMANDS
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1, 2, 3, 4, 5, 6,
CLEAR R ALL CLEAR Q ALL CLEAR C ALL RULES ALL REPORT SQLDEMO.OUT SQL_NEXTREC([CMD ID], [TEST FLAG]) WEND SQL_END_SQL([CMD ID]) SQL_DISCONNECT([DB ID]) Note: The line numbers are not part of the command file and are included here only to allow easy reference to a line.
In this example, line 1 connects to the Paradox database DLL. The variable set in line 1, [DB ID] will be used in subsequent SQL_EXEC commands. Line 2 executes an SQL SELECT command to return data. The EXSYS variable [CMD ID] will be used in subsequent commands to refer to this data. Line 3 sets the next (in this case the first) record of data returned by the select command. The test flag variable [TEST FLAG] will be set to 0 if there was data returned and the commands enter the While loop in line 4. Lines 5-10 assign data to specific EXSYS variables. Lines 11-13 clear out all previous data and the rules are run in line 14. A report of the results of the system for the first record of data is output by line 15. Line 16 attempts to make the next record of data active. If there was another record of data returned by the SQL command in line 2, the value of [TEST FLAG] will be set to 0 and the While loop in line 4 will repeat. When the last record of data had been analyzed, the value of [TEST FLAG] will not be 0 and the while loop will end. Line 18 releases the memory associated with the SQL command from line 2. Line 19 disconnects EXSYS from the database.
SELECT
The SELECT command is used to retrieve records from the database. All databases support this command to some extent. Paradox and dBase, among others, fully implement it. The basic form of the command is: SELECT {* | field, ...} FROM filespec [additional clauses] One or more fields can be specified. Additionally, clauses can be used to further refine the search. One common, and useful, clause is WHERE. For example: SELECT * FROM dbname WHERE field > x
This command will return all fields of all records where a specified field value is greater than x. SELECT supports aggregate functions such as MIN, MAX, and AVG. Thus, the total of a particular column, where certain conditions are met, can be returned.
INSERT
The INSERT command is used to add new records to the database. The basic form is: INSERT filespec (field, ...) VALUES (expr, ...) One or more fields and values (expressions) can be specified.
UPDATE
The UPDATE command is used to change records in the database. The basic form is: UPDATE [WHERE filespec SET | CURRENT OF] field=expr, ...
P - SQL COMMANDS
17
DELETE
The DELETE command is used to delete records in the database. The basic form is: DELETE FROM filespec [WHERE | CURRENT OF]
CREATE TABLE
This command is used to create new database files. The basic form is: CREATE TABLE def, ...) filespec (field def, field
DROP TABLE
This command is used to delete database files. The basic form is: DROP TABLE filespec
P - SQL COMMANDS
18
Q3.1: New
This menu option is used to create a new custom screen file. Until one or more screens are added to the new file, it will be empty. The first thing that ExDesign will require from the user in order to create this file, will be the filename. A window appears immediately after selecting this feature which contains an edit box provided for this purpose. If the filename is typed in with no extension, the program will provide the default .SCR extension. If it is desired that another extension be used, (for example .HLP when creating an EXSYS Custom Help file,) then it must be provided by typing the full name of the file to be created into the edit box. The Open button can then be selected to open a file with the name provided. If the user changes their mind, and decides not to pursue this option further, they can select the Cancel Button. ExDesign will display a message stating that no file was opened, and then return to the main work screen. If the user happens to select a filename that already exists in the current working directory, a window will appear with a message asking if they wish to erase the existing file or cancel the action and return to the main work screen. If they choose to erase the existing file, its contents will be lost. If the user wishes to check the contents of the file before it is erased, they must use the Cancel button to return to the main work screen and then resume by selecting the File Open Menu. If the user wishes to select another working directory in which to open the new screen file, then they should use the scroll bar to move to the end of the list of file and directory names in the list box. If the desired directory is a subdirectory of the current directory, select it when it appears and click on the Open button. That directory will now become the current directory. If the user selects the [..] listing and then clicks on Open, the current directory will be replaced by its parent directory. They can also switch to a directory on another drive by selecting the drive name in the list box and then clicking on the Open button. This process can be continued, even combining the above procedures, until the current directory is set to the one desired. However, when the desired directory is reached, the user will need to enter a valid filename in the edit box, before they can continue to the next step: entering a screen identifier for their first new screen. One may, at any time, exit the process and return to the main work screen by selecting the Cancel button. Once a valid filename has been entered and that file has been opened, then it is necessary to specify an identifier for the first screen that is to be created. A window will appear for this purpose, containing an edit box where the user will need to type in the correct syntax for the screen identifier. This syntax is described in Chapter I of the EXSYS Pro manual.
Q - ExDesign Custom Screen Design Program
2
NOTE: Make sure that the screen identifier begins with a "~" character. Once this screen identifier has been input, click on the OK button. ExDesign will then return to the main work screen where one may begin to create the new screen. It is possible, however, to abort the process by selecting the Cancel button, which will cause ExDesign to display an error message and then exit the program.
Q3.2: Open
This menu option is used to open a existing screen file. The first thing that ExDesign will require from the user in order to open this file will be the filename. A window appears immediately after this feature is selected which contains an edit box provided for this purpose. If the filename is typed in with no extension, the default .SCR extension will be added by the program before it attempts to load the file. If it is desired that another extension be used, (for example .HLP when creating an EXSYS Custom Help file), then it must be provided by typing the full name of the file to be created into the edit box. The Open button can then be selected to open a file with the name provided. If the user changes their mind, and decides not to pursue this option further, they can then select the Cancel Button. ExDesign will then display an message stating that no file was opened, and then return to the main work screen. The way to select another working directory, from which to open the new screen file, varies among the various operating systems. In MS-Windows, use the scroll bar to move to the end of the list of file and directory names displayed in the list box. If the desired directory is a subdirectory of the current directory, select it when it appears and click on the Open button. That directory will now become the current directory. If the user selects the [..] listing and clicks on Open, the current directory will be replaced by its parent directory. It is also possible to switch to a directory on another drive by selecting the drive name in the list box and then clicking on the Open button. This process can be continued, even combining the above procedures, until the current directory is set to the one desired. However, once the desired directory is reached, it will be necessary to enter a valid filename in the edit box. This must be done before one can continue to the next step: entering a screen identifier for the first new screen. Alternatively, the user may select any of the screen files listed in the list box and then select Open. In either case, ExDesign will then attempt to load the indicated file. Also, if, for example, the desired filename cannot be found and it is decided to exit the process before clicking on the Open button, one may return to the main work screen by selecting the Cancel button.
Once the user has entered a valid filename and that file has been opened, then it will be necessary to select an identifier from the list box of existing screens for the screen that one wishes to edit. If the screen identifier for an existing screen is selected, ExDesign will check the syntax of the custom screen commands as it attempts to execute each command and thereby display that screen object on the main work screen. If it finds a syntax error, it will display a window, indicating the line in the file that it was attempting to execute when it encountered the error. After the user clicks on the OK button, the program will be unable to continue with the selected screen, and ExDesign will abort. If one wishes to add a new screen to the screen file, then the entry "** ADD NEW SCREEN **" should be selected. This entry appears at the end of the screen identifier list. Once this entry is selected, a window will appear containing an edit box enabling the user to enter the new screen identifier. The syntax for EXSYS custom screen identifiers is described on pp. I-5 through I-7 of this manual. (NOTE: Make sure that the screen identifier begins with a "~" character.) Once this screen identifier has been input, select the OK button. ExDesign will then return to the main work screen where the user may begin to create the new screen. If, however, it is decided to abort the process by selecting the Cancel button before inputting a screen identifier, ExDesign will display an error message and then exit the program. If the user has been editing a particular screen file, and wishes to begin editing another screen in that file, (or add a new screen to the file,) then they should follow the above procedures, beginning with selecting the File Open Menu. Using either the procedure for the list of filenames or the edit box provided, give the name of the current file, just as it was originally entered. Then, at the Screen Identifier list box, select the Screen Identifier desired, or "**ADD NEW SCREEN**" to create a new screen and add it to the current file.
Q3.3: Save
This menu option will save the current file using the name under which it was opened. It allows no interaction, and will simply save the file, no questions asked. It is the quickest and easiest way to periodically save the work that has been done in the current ExDesign editing session.
Q3.4: SaveAs
This menu option enables the user to save the current file under a name that they specify. Either a new name or the current name can be used. By specifying a path that is different than the current directory, the file can even be saved in another directory, even on another drive. Simply, type the name that one wishes to use, with or without a new path, in the edit box in the window that appears. When this is completed, select the OK button. The process may be aborted by selecting Cancel and the program will return to the main work screen without saving the file.
Q3.5: Print
To print the screen file produced, save the screens created, exit ExDesign and print directly from the operating system.
Q3.6 Exit
This menu option enables the user to exit the program and return to the Windows Program Manager. If no changes have been made to any of the screens in the current screen file, it will immediately exit the program. If, however, any of the screens in the current file have been changed since the file was last saved, a dialog box will appear asking the user if they want to discard those changes and exit, or if they want to save them before exiting. The Cancel button will cause ExDesign to return to the main work screen and the user may resume editing, without any other effects upon the screens in the current screen file.
Q3.7: About
Selecting this option brings up a dialog box stating the current version number of the program. If the Help button on this dialog box is selected the Master System Help function will be requested.
2. Move the box Position the cursor inside of the rectangle. Push the left mouse button (or on Macintosh, the only mouse button) down and hold it down. Move the cursor. The box will follow the cursor. When the box is in the correct position, release the mouse button. 3. Change options When a item is selected, you can change its parameters by double clicking on the item. The options available depend on the type of item selected and are discussed under the individual items. 4. Align Items When multiple items are selected, they can be aligned by using the Align menu item. To select multiple items, hold down the shift key as you select the items. To better understand screen command syntax and for examples, see Section I on the Custom Screen Language.
The dialog box for setting the parameters for the object will have an edit field marked "Return String". Enter the string you wish to return in this edit field. Each control item selected may return only one line of data. However, a screen can return multiple items of data. In many cases, a particular button may indicate that the screen should terminate and return data. Sometimes clicking on any button will return data, in other cases multiple data items are set and then an OK button returns all of the data that was set.
Returning Commands
In addition to returning data, buttons and/or other controls. can return commands. The commands are the same ones that can be returned from an external program. !WHY !? or !HELP !KNOWN !EXIT !END Displays the current rules being tested Displays the custom help file associated with the qualifier or variable. Displays the known data Exits the program Terminate a hypertext stack - returns to the starting screen even if there are several levels of hypertext screens.
For example, if the return string for a button was defined as: !WHY clicking on the button would display the rules that caused the question to be asked.
For example, if a mouse region was defined: ~MOUSE("?Part 23", 200, 300, 60, 30 -I)
EXSYS would display the hypertext screen associated with the keyword "Part 23" if a mouse click was made in the regions specified. Passing back !END will terminate a hypertext stack and return to the starting screen, even if there are several levels of hypertext screens.
Q4.2 Rectangles
All custom screen objects use a rectangle to define the size. Usually you will set this rectangle by resizing and moving the manipulator boxes. However, you can also directly enter the rectangle parameters in the dialogs associated with the various objects. The size is specified by the horizontal and vertical coordinates of the upper left corner of the rectangle, the width of the rectangle and the height of the rectangle. Left side, top, horizontal size, vertical size. For example: 10,10, 100, 50 means a rectangle with the upper left corner at the coordinates 10,10, a width of 100 pixels horizontally, and height 50 pixels vertically .
Parameters
To change the parameters for a button double click on it.
Rectangle
The coordinates for the rectangle position can be directly set in the edit boxes or changed by clicking on the object and dragging the sides or corners to the correct size and position. See Q 5.2
Label
When a button is initially created, it is labeled BUTTON. This should be changed to reflect the function of the button. Different GUI operating systems use different size font for button labels. If the system will be run on multiple operating systems, be sure to leave enough room for the label to be written in the largest font.
Return String
The data string to return to EXSYS. See Q4.2.
No Output (-X)
The No Output option indicates that the return string does not contain data that is to be returned to EXSYS for assignment to a variable or qualifier. This is usually used for buttons that contain hypertext calls or commands.
11
The Radio Button is initially created with the label "RADIO BUTTON". This should be changed before the screen containing the object is used. This syntax and optional parameters for a radio button are the same as the Push Button with the following exceptions: 1. A radio button will add a -R to the button command: ~BUTTON ... -R 2. The "Return Immediate" option is legal for radio buttons but not recommended because it violates the style guidelines for the various operating systems. There should be a group of radio buttons to select a value and an "OK" Push Button to indicate that the correct value is selected. 3. Radio buttons support the -S and -E options to indicate multiple groups of radio buttons on a single screen. If only one group of radio buttons is used, the -S and -E options are not needed.
12
2. The "Return Immediate" option is legal for check boxes but not recommended due to the style guidelines for the various operating systems. There should be a one or more check boxes to select a value and an "OK" Push Button to indicate that the correct value is selected.
Parameters
To change the parameters for a slide bar, double click on it.
Rectangle
The coordinates for the rectangle position can be directly set in the edit boxes or changed by clicking on the object and dragging the sides or corners to the correct size and position. See Section Q 5.2 Some operating systems have a standard width for a slide bar. Even if you try to make the slide bar wider, the system default size will be used. However, not all operating systems behave the same way, and other operating systems (such as Macintosh) will make a slide bar as wide as the rectangle. It is a good idea to make the rectangle for the slide bar as close to the desired size as possible, even if the operating system draws the slide bar at a different width. This is especially true if you will be moving your custom screens between operating systems. Care should be exercised to make sure that different slide bar's reserved screen areas do not overlap.
Q - ExDesign Custom Screen Design Program
13
Return Prefix
This is an address prefix to identify where the data should be assigned in EXSYS. This should usually be an identifier for what EXSYS variable will receive the data. For example if the data is to be returned to the variable [X], the return prefix would be: [X] The value selected by the scroll will be appended to the prefix to make an EXSYS data assignment statement. Since scroll bars can return non-integer data, the value should not be assigned to a qualifier.
Starting Value
This is the low end value for the slide bars value range.
End Value
This is the high end value for the slide bars value range. The value that can be selected will be between the low and high end values.
14
Parameters
To change the parameters for an edit box double click on it.
Rectangle
The coordinates for the rectangle position can be directly set in the edit boxes or changed by clicking on the object and dragging the sides or corners to the correct size and position. See Section Q 5.2
15
Return Prefix
This is an address prefix to identify where the data should be assigned in EXSYS. This should usually be an identifier for the EXSYS variable to receive the data. For example if the data entered in the edit box is to be returned to the variable [S], the return prefix would be: [S] The value entered in the edit box will be appended to the prefix to make an EXSYS data assignment statement. Since edit boxes can return non-integer data, the value should not be assigned to a qualifier. If the prefix string includes ##, the ## will be replaced by the number of the line in the edit region being returned. For example if the edit box was for an address that might be up to 5 lines, we might have EXSYS string variables [ADDR1], [ADDR2], [ADDR3], [ADDR4] and [ADDR5]. The return prefix could be "[ADDR##]". The first line in the edit box would be assigned to [ADDR1], the second to [ADDR2], etc. Make sure to have enough EXSYS variables to accept the data returned.
16
17
Q4.8: Line
A line is a graphical object, and cannot be used for data entry. It is used for visually dividing different areas of the screen. It is also used for creating outlines around areas of text, groups of buttons or other objects. Other uses include creating complex borders, highlighting portions of text and in drawing. When this object is initially drawn on your work screen by ExDesign, it is drawn from the upper left corner. It can be moved to any part of the work screen and resized after converting it to a manipulator box.
Q - ExDesign Custom Screen Design Program
18
It is drawn as a black line one pixel wide. The locations of the FROM and TO ends of the line can be changed by a double click. The color of the line can be changed by clicking on the line to make it a manipulator box and selecting the menu Change and then Drawing. Select the Line Color and Line Width. The other color attributes do not apply to lines. The user should probably also refer to the syntax for the ~CURSET command in the EXSYS Custom Screen Command chapter before using a text editor to modify an adjacent ~LINE command line in the current EXSYS Custom Screen file.
Parameters
To change the parameters for a Line double click on it.
End Points
The coordinates for the from and to points of the line position can be directly set in the edit boxes.
Q4.9: Arrow
This is a graphical object, and cannot be used for data entry. It is commonly used for visually dividing different areas of the screen. It is especially useful for drawing attention to particular buttons or portions of text. When this object is initially drawn on your work screen by ExDesign, it is drawn from the upper left corner. It can be moved to any part of the work screen and resized after converting it to a manipulator box. It is drawn as a black line one pixel wide. The color of the Arrow can be changed by double clicking on the line and selecting the color button. This object and the syntax for its command line are described on p. I12 of this manual. The user should probably also refer to the syntax for the ~CURSET command before using a text editor to modify an adjacent ~ARROW command line in the current EXSYS Custom Screen file.
Parameters
To change the parameters for an Arrow double click on it.
Q - ExDesign Custom Screen Design Program
19
End Points
The coordinates for the from and to points of the line position can be directly set in the edit boxes.
Arrow Points
The arrow can have points at the from end, to end or both. Select the appropriate radio button.
Q4.10: Oval
This is a graphical object, and cannot be used for data entry. It is commonly used for visually dividing different areas of the screen. It is also used for creating outlines around areas of text, groups of buttons or other objects. Other uses include creating complex borders, as it can be used to create all sorts of circular objects. These objects can be combined with other objects, so that by overlapping these objects on the work screen, curved lines may be added to these objects. When this object is initially drawn on your work screen by ExDesign, it is drawn as a round circle. It can be "stretched" or moved to any part of the work screen and resized after converting it to a manipulator box. It is drawn as a black line with a white fill color. The color of the Oval can be changed by double clicking on the Oval and selecting the color button..
Parameters
To change the parameters for an Oval double click on it.
Rectangle
The coordinates for the rectangle position can be directly set in the edit boxes or changed by clicking on the object and dragging the sides or corners to the correct size and position. See the See Q 5.2
Q4.11: Rectangle
This is a graphical object, and cannot be used for data entry. It is commonly used for visually dividing different areas of the screen. It is also used for creating outlines around areas of text, groups of buttons or other objects. Other uses include creating complex borders and highlighting portions of text. It can be used whenever the effect of creating a "box" around another screen object is desired, especially when the effect of "boxes within boxes" is desired.
Q - ExDesign Custom Screen Design Program
20
When this object is initially drawn on your work screen by ExDesign, it is drawn as a square. It can be moved to any part of the work screen and resized after converting it to a manipulator box. It is drawn as a black line with a white fill color. The color of the Rectangle can be changed by double clicking on it and selecting the color button.
Parameters
To change the parameters for an Rectangle double click on it.
Rectangle
The coordinates for the rectangle position can be directly set in the edit boxes or changed by clicking on the object and dragging the sides or corners to the correct size and position. See Q 5.2.
Q4.13: Text
This object is used to add areas containing pure text to a screen. It can be used to put a label on a screen object, or for informational messages or explanations. When this object is initially added to your screen it is placed inside a box. It is given an initial label of Text. Which uses the Normal Font size, with black foreground color text and a white background. The color of the Text can be changed by double clicking on the Text and selecting the color button.
Parameters
To change the parameters for Text double click on it.
Rectangle
The coordinates for the text position can be directly set in the edit boxes or changed by dragging the text to the desired position. See Q 5.2
Q - ExDesign Custom Screen Design Program
21
Text
The text to display can be entered / modified in the edit box.
Text Size
The size of the text can be Large, Normal or Small. Select the appropriate radio button.
Parameters
To change the parameters for a mouse box double click on it.
Rectangle
The coordinates for the rectangle position can be directly set in the edit boxes or changed by clicking on the object and dragging the sides or corners to the correct size and position. See Q 5.2
Return String
The data string to return to EXSYS. See Q4.2.
22
No Output (-X)
The No Output option indicates that the return string does not contain data that is to be returned to EXSYS for assignment to a variable or qualifier. This is usually used for buttons that contain hypertext calls or commands.
23
Horizontal Offset
The number of pixels for the horizontal offset into the image. The default is 0, which is the left edge of the image.
Vertical Offset
The number of pixels for the vertical offset into the image. The default is 0, which is the top edge of the image.
24
Q4.16: Meters
Meters are used to display animated data about the state of EXSYS variables. Meters are not used for data input. Meters are most effective in systems that run repeatedly with constantly changing data, such as when EXSYS is connected to the PI process historian package. However, meters can also be used to display static data, or in cases where data is manually input. The meter displays the data in one of three forms:
Vertical
100 1.0 1.5 2.0 2.5 3.0 3.5 4.0
Horizontal
80
2.32 Dial 5 4 6
60
40
20
70.1 3 5.34 7
In MS-Windows, Meters can be placed over a PCX image created in a "paint" program to provide a background. Make sure that the ~IMAGE command occurs before the ~METER commands. Meters reflect the current value of the EXSYS variable that they are associated with. The meter value is updated when the UPDATE_METER command is encountered in the command file. One way to do this is to have a command file of the form: DISPLAY(meter.scr /C /N) WHILE ([X] < 200) RULES ALL UPDATE_METERS CLEAR(ALL) WEND In this case, the first line displays a screen that contains the meters. The /C and /N are needed to have the screen be displayed and then have EXSYS continue executing commands. The commands then
Q - ExDesign Custom Screen Design Program
25
enter a WHILE loop. In this case, if [X] is greater than or equal to 200, the WHILE loop terminates, possibly to do some additional analysis, or to run additional commands that might display an alarm. First we run the rules which may involve automatic data acquisition of variable values. Then the meters are updated to reflect the values used in that run. The data is then cleared and rerun. On each loop through, the meters will be updated to reflect the values on that run.
Parameters
To change the parameters for a mouse box double click on it.
Rectangle
The coordinates for the rectangle position can be directly set in the edit boxes or changed by clicking on the object and dragging the sides or corners to the correct size and position. See Q 5.2
Variable
A meter reflects the value of a specific EXSYS variable. Select the variable to use.
Shape
Select to have the meter be a Horizontal, Vertical or Dial meter.
Label
The meter can be given a label to identify it, such as "Pressure". If no label is desired, leave the edit box blank.
Scale
The scale for the meter is specified by the minimum value, maximum value and number of increments. Since each increment will be labeled, be careful to allow enough space between increments for the values. Also, select increments that divide the scale in to round numbers (or use the Scale Precision option below)
Alarm Thresholds
The alarm thresholds specify high and low threshold values. If the EXSYS variable value passes these values, the color of the meter will change to reflect an alarm condition. If no alarm values are desired, select values outside of the range of the meter.
Q - ExDesign Custom Screen Design Program
26
Bar Color
The default meter colors is a blue bar which becomes red when alarm thresholds are passed. The color of the bar can be changed to any other color desired.
Parameters
To change the parameters for a mouse box double click on it.
Rectangle
The coordinates for the rectangle position can be directly set in the edit boxes or changed by clicking on the object and dragging the sides or corners to the correct size and position. See Q 5.2 If the List Edit or List Button options are used, only a small edit region or button will be displayed. The width will be the width specified, but the height will be only about 20-30 pixels (depending on operating system). The position will be determined by the upper left corner. When the list is "pulled down" by the arrow, the list displayed will be the full size specified by the rectangle. Make sure that the rectangle defined is large enough to display a reasonable option of the list.
Return Prefix
The string to precede the return data. Usually "Q#" or "[...]" to identify the qualifier or variable. If the Q"name" form is preferred, replace the " with '. For example, to return data to the qualifier named "COLOR", we would use: Q 'COLOR' The text of the list item(s) selected will be preceded by the "ret prefix" string and must make a valid EXSYS data assignment statement. The default is to return the actual string selected. For qualifiers, it is usually necessary to return the number of the item selected. This is done by using the Return Number (-N) option.
Control Type
The default is to make a list box. This can be changed to two other forms of lists. LISTBUTTON Only a button will be displayed with an arrow next to it. A click on the arrow displays the full list to make a selection. The current selection is displayed on the button. LISTEDIT List edits a similar to list buttons, but the displayed value can be directly changed by typing into it.
Q - ExDesign Custom Screen Design Program
28
30
Position
This feature allows the user to modify the position attributes of a group of objects, from the values that are stored on the corresponding command lines in the screen file, to those of the groups manipulator. 1. Select the items to be aligned. 2. Under the "Align" menu, select "Move" 3. Select to align to the top edge, bottom edge, left edge or right edge of the last item selected. For example, if you select several items and select "Top Edge", all of the top edges will align.
Stretch
Stretch is the same as Move except each object stretches to the specified edge.
Q - ExDesign Custom Screen Design Program
31
Size
The size of the items selected can also be aligned. The size of the LAST item selected will be used as the size all other items are set to. 1. Select the items to be made the same size. 2. Select the item to be used as the guide LAST. 3. Under the "Align" menu, select "Size" 4. Select to set widths or heights the same.
Color
The color of the items selected can also be aligned. 1. Modify one of the objects so it has the desired color. 2. Select the items to be made the same color. 3. Under the "Align" menu, select "Color".
Spacing
The spacing between objects can be made the same. 1. Select the objects. 2. Pull down "Align Spacing". 3. Select horizontal or vertical.
32
R1: Introduction
Suppose you are building an expert system to control the temperature of hot water fed to a machine. In a non-fuzzy system, you might have a rule IF The input water is too hot THEN Mix cold water with the input stream When this rule is run, it will ask the end user if the input water is "too hot". Since this is a somewhat ambiguous question, you could add a rule to derive more specific information. IF [INPUT TEMP] > 180 THEN The input water is too hot Now the system will ask about the water temperature. This information might come from the end user or directly from instrumentation. The problem with this approach, is nothing happens at a temperature of 179.9999 and the system may add too much cold water at
R - FUZZY LOGIC 1
180.0001. This can result in the temperature being put into oscillation rather than being brought to the desired temperature smoothly. The situation would be improved by adding more rules IF The input water is a little too hot THEN The amount of cold water to add to the input is a little IF The input water is too hot THEN The amount of cold water to add to the input is medium IF The input water is way too hot THEN The amount of cold water to add to the input is a lot with temperature rules to derive the values IF [INPUT TEMP] <= 160 THEN The input water is OK IF and THEN IF and THEN IF [INPUT TEMP] >= 200 THEN The input water is way too hot This breaks up the single step function into three steps. As the input water gets a little too hot, you try adding a little cold water. If this is not enough, and the temperature of the input water continues to rise, at 180 you increase the amount of cold water added. If the temperature reaches 200, you increase the amount of cold water again.
R - FUZZY LOGIC 2
[INPUT TEMP] > 160 [INPUT TEMP] < 180 The input water is a little too hot [INPUT TEMP] >= 180 [INPUT TEMP] < 200 The input water is too hot
The three step system clearly is better at controlling the process and more closely reflects the way a human operator would react. A hard break point at 180 in the first system has been made slightly "fuzzier" by breaking it into three steps. But you had to write three times as many rules to do it. Suppose you want to break the process into 100 steps and have many functions to control. The number of rules needed would become enormous and impractical. What would be best, is to make it a continuous function rather than a series of steps. The solution is Fuzzy Logic.
The confidence for each of the three possible values is either 0 or 1 depending on the temperature. There is no overlap and the confidence changes abruptly at a specific break point. It would be better to gradually increase the confidence in each of the values as the temperature increases. As a graph, this would look more like:
1 C o n f 0 150 160 170 180 190 200 OK little too hot too hot way too hot
Temperature
In this system, as the temperature increases, the confidence in each of the three ranges will gradually increase (and in some cases, fall off) smoothly. At a temperature of 152, the confidence in "a little too hot" starts to increase from 0 and reaches 1 at 162. The temperatures between 152 and 162 give a continuous smoothly increasing confidence value. For any temperature, the graph shows the confidence in each of the values. Notice that for some
R - FUZZY LOGIC 3
temperatures, you have some confidence in two different values. At 175, "a little too hot" has a confidence of .8 and "too hot" has a confidence of .4. This is a great advantage, since you want the rules based on "too hot" to kick in gradually, rather than suddenly at a threshold value. It is very important to remember that in a fuzzy system, there is a confidence associated with EACH VALUE of a qualifier - not just the qualifier as a whole. These graphs of confidence in a qualifier value, versus a variable (temperature) are called "membership functions" and are the key to making an expert system "fuzzy". For a simple case like this, it would be possible to write a series of rules that calculated the confidence, but it would be very cumbersome, even for this simple problem. In EXSYS Professional, fuzzy logic is implemented by two simple techniques: 1. QUALIFIERS can be made fuzzy based on an EXSYS variable and membership functions. Membership functions are defined with a point and click graphical user interface that provides easy visualization. 2. VARIABLES can be "de-fuzzified" based on the weighted average of a qualifier's confidence values. This is how a fuzzy system ends up giving a precise recommendation. (More on this later.) Use of the existing EXSYS Professional data elements (qualifiers and variables) makes the addition of fuzzy logic to applications very easy. Returning to the example, in a fuzzy logic version you would have four simple rules.
IF The input water is OK THEN The amount of cold water to add to the input is none IF The input water is a little too hot THEN The amount of cold water to add to the input is a little
R - FUZZY LOGIC 4
IF The input water is too hot THEN The amount of cold water to add to the input is medium IF The input water is way too hot THEN The amount of cold water to add to the input is a lot Now you do not have to create a set of rules to convert a temperature to a qualifier value. Instead you simply click on the "Fuzzify" box when defining the qualifier. A screen is displayed that allows you to define the membership function. The membership function is defined by clicking on the graph to indicate the shape of the function, or point coordinates are directly entered into a table. Each value of the qualifier has a separate membership function, and each function is made up of as many as to 8 straight line segments. Therefore, complex membership function sets can be defined. A test function enables you to easily check the confidence of each qualifier value for any value of the variable. The graph window can be scrolled and rescaled to display the entire set of membership functions. For this problem, the membership functions are drawn to look like:
1 C o n f 0 150 160 170 180 190 Temperature 200 OK little too hot too hot way too hot
Once the membership function is defined for the qualifier, you do not need to add additional rules to derive the value for the qualifier. When the qualifier value is needed, EXSYS Professional will automatically ask the value of the associated variable "temperature". The confidence of the appropriate qualifier values will then be set, based on the temperature. This confidence is automatically passed through to the items set in the THEN part. For example, at a temperature of 175, "a little too hot" has a confidence of .8 and "too hot" has a confidence of .4. Based on the rules, "add a LITTLE water" would get a confidence of .8 and "add MEDIUM water" would get a confidence of .4. If the rules had more than one IF condition, the confidence of the IF parts would be combined before assigning the confidence to the THEN part. The
R - FUZZY LOGIC 5
way the IF confidence is combined is handled automatically by EXSYS. In an actual system, many factors would be taken into account to determine the confidence values of the "amount of water to add".
R1.2: Defuzzification
Now you have a system that gives levels of confidence in the various amounts of water to add. The problem has been made fuzzy, and the answer we get is certainly fuzzy. In a plant environment, we do not want to tell the operator that "a little water should be added with .8 confidence and a medium amount of water should be added with .4 confidence". The operator just wants to know how much water to add. This is "de-fuzzification" - taking a fuzzy statement and converting it back to a precise number. In EXSYS Professional, to make a qualifier fuzzy, you associate a variable. To de-fuzzify a value for a variable you associate a qualifier. This is typically a weighted average of the various confidences assigned to the qualifier values. For example, suppose you have a variable [WATER TO ADD] and you base its value on the de-fuzzification of the "add water" qualifier. You could use the formula: [WATER TO ADD] = 2 * (confidence in "add a LITTLE") + 5 * (confidence in "add MEDIUM") + 10 * (confidence in "add ALOT") In this example, it would be (2*.8) + (5*.4) = 3.6 This is about what you would expect. It is more than "add a LITTLE" amount of 2 but less than the "add MEDIUM" amount of 5.
R - FUZZY LOGIC 6
W a t e r 150
160
190
200
Clearly a very crude control. With three rules, but without Fuzzy Logic, the graph improves to:
But when you add Fuzzy Logic, you easily obtain a continuous graph:
W a t e r 150 160 170 180 190 Temperature 200
This is a much better way to control the process since it will tend to make corrections smoothly. The exact shape of the graph is determined by the shape of the membership functions.
R - FUZZY LOGIC 7
2. Change the confidence mode to fuzzy: PROBABILITY SYSTEM: 6 3. Fuzzy does not support ELSE - any rule with ELSE must be deleted and the logic modified to handle the ELSE. (ELSE parts can always also be described as the THEN part of a rule.) 4. Modify all choice confidence value to the Fuzzy system (a value between -1 and 1) 5. Compile the system with the EXSYS Rule Compiler Version 5.0 or later. 6. Edit the system to add fuzzy membership functions, etc. with the EXSYS Professional Rule Editor Version 5.0 or later. It is strongly recommended that a few small fuzzy systems be built and printed in rule compiler format before attempting to move a larger existing system to Fuzzy confidence mode.
R - FUZZY LOGIC 9
The text of the qualifier is displayed in the top of the dialog box. Each of the qualifier's associated values are in the list button just under it. To select a value, click on the value list button. It drops down to display all of the values. Click on a value and it becomes the currently active value. Each value should have an associated membership function defined for it. All of the functions are displayed on the graph simultaneously, but in different colors. The graph for the currently selected value is in bold yellow and has small boxes at each vertex. Only the currently selected value can have its membership function edited. The graph represents the confidence (0 to 1) on the vertical axis, versus the value of an EXSYS variable on the horizontal axis. The variable used to set the fuzzy confidence values is selected in the upper right of the dialog. Click on the variable list button. A drop down list of the variables in the system will be displayed. Click on the variable to use to fuzzify the qualifier. If none of the variables are appropriate, click on the "New" button to add another variable. The variable selected must be a numeric variable. The scale of the graph is displayed in the edit boxes at the lower corners of the graph. In the example above, the graph displays values from 0 to 100. There are several ways to change the scale displayed: 1. Click on the UP / DOWN arrow under the lower and upper values. This will increase or decrease the value by an amount dependent on the existing values and redraw the graph.
R - FUZZY LOGIC 10
2. Click on the UP / DOWN arrow under the middle of the graph. This will scroll both values up or down by 1/3 of the window but will keep the width of ranges the same. For example if we start with a range of 0 to 100, a click on the UP button will produce a range of 33 to 133. 3. Directly enter values in the upper or lower edit box and click on the UPDATE button. This allows any range desired to be set. Note: No change will be displayed until the UPDATE button is clicked. 4. Clicking on the "Zoom In" button halves the scale and zooms in on the center of the graph. Clicking on the "Zoom Out" button doubles the scale and zooms out on the center of the graph. A membership function graph is made up of up to 8 line segments. The segments are continuous and are defined by up to 7 vertices. The left most vertex is considered to go horizontally to the left infinitely. The right most vertex is considered to go horizontally to the right infinitely. Each vertex is entered by pointing and clicking with the mouse, or by entering values in the table at the right of the dialog box. To add a membership function with the mouse: 1. Select a qualifier value in the top list button. 2. Move the cursor onto the graph area. 3. Press the left mouse button (or on Macintosh, the single button ) down. While the mouse button is held down, two numbers will be displayed under the graph. The first is the horizontal position at the cursor position and the second is the confidence at the cursor position. As the cursor is moved, these values will change. 4. When the cursor is at the position desired, release the mouse button. (If you do not want to add a vertex, move the mouse off the graph are before releasing the button.) A small box will be displayed at the vertex point and the membership function line will connect to that vertex. 5. To move a vertex, click down in the box at the vertex. As you move the mouse (with the button down) the vertex will be dragged on the graph. When the vertex is positioned correctly, release the mouse button. When a vertex is being moved, it can not be dragged off the graph area. If a vertex is moved past its neighbor vertices, EXSYS will automatically reorder the numbering of the vertices when the mouse button is released.
R - FUZZY LOGIC 11
6. To delete a vertex, click down on the vertex and drag it to the box of another vertex. Release the button while in the box of the other vertex. All vertices between the two will be deleted. 7. When adding a vertex between vertices, EXSYS will automatically connect it to the two adjacent vertices. As vertices are added with mouse, their values are automatically added to the table. The other way to define the membership function graph is to directly enter the coordinates of the vertices in the edit boxes on the right of the window. This is often easier than using the mouse. When using the mouse, the finest resolution on the graph is one pixel. The range of the graph is divided by the number of pixels. This limits the possible values that can be selected. If the value desired can not be selected, enter the closest value with the mouse and edit the value later. The values entered in the table will NOT take effect until either a button is clicked, a new value selected, the ENTER key pressed or a mouse click on the graph region. Most functions will have a vertex that starts and ends with a confidence of either 1 or 0. The confidence value of the first vertex is used for all values less than the position of the first vertex. The confidence value of the last vertex is used for all values above the position of the last vertex. Values other than, 0 or 1 can be used for the first or last values, but would be somewhat unusual. Once membership functions have been added, they can be tested in two ways. 1. Position the cursor in the red rectangle just under the graph window. Press the mouse button down. A white vertical line will be drawn on the graph. The horizontal position of the line is displayed under the graph. At each point where the vertical line crosses a membership function, the confidence value will be displayed. The vertical line can be moved around on the graph by moving in the red rectangle while holding the mouse button down. Values of 0 and 1 are not displayed due to overlap problems.
R - FUZZY LOGIC 12
OK
A value slightly lower than the lowest vertex position will be in the edit box at the top of the dialog. The confidence values for each qualifier value are displayed. To test a specific value, enter the value of the variable that you wish to test in the edit box at the upper left and click on the "Do Test" button. The associated confidence for each qualifier value will be displayed in list box. this may be repeated as often as desired. To test a series of values, use the scroll bar under the edit region. Clicking on the arrows moves the test value up/down by 1% of the range of vertex position values. Clicking between the arrow and thumb moves the test value by 5%. The entire range of values, can be examined by clicking to the right of the thumb 20 times or on the right arrow 100 times. If a value is entered in the edit region and "Do Test" selected, the thumb is repositioned. When done testing, click on the "OK" button.
Example:
To use the example in the introduction. We could have a qualifier: The input water is 1. OK 2. a little too hot 3. too hot 4. way too hot
R - FUZZY LOGIC 13
We would select the "Fuzzify" button and build the membership functions.
1 C o n f 0 150 OK little too hot too hot way too hot
160
170
200
First select the "OK" value and enter a vertex of 155 with a confidence of 1 and a second vertex at 160 with a confidence of 0. All temperatures less than 155 will give the "OK" value a confidence of 1. Next select the "a little too hot" value and enter a vertex at 152 with a confidence of 0. Then enter vertices at 162 with confidence 1, 175 with a confidence of 1 and 182 with confidence 0. Then select the third value by clicking on the value list button and clicking on the "too hot" value. The membership function we entered for the first value is still on the graph, but is now thin red line. The current value is always a bold yellow line. We would enter vertices of 172 with confidence 0, 179 with confidence 1, 198 with a confidence of 1 and 203 with confidence 0. Then select the last value "way too hot" and enter vertices 195 with confidence 0 and 202 with confidence 1. This last function only requires two vertices since we want the confidence of 1 to apply to all value above 202. We then create an EXSYS variable named TEMPERATURE as the variable to use for the function. We then only need to add the four rules we had defined: IF The input water is OK THEN The amount of cold water to add to the input is none IF The input water is a little too hot THEN The amount of cold water to add to the input is a little IF The input water is too hot THEN The amount of cold water to add to the input is medium
R - FUZZY LOGIC 14
IF The input water is way too hot THEN The amount of cold water to add to the input is a lot When EXSYS needs the value of the qualifier "The input water", instead of asking the user to select a qualifier value, it will automatically ask for the value of the variable TEMPERATURE. The value of temperature will determine which qualifier values are selected and what confidence is assigned to them. This confidence will be propagated to the THEN parts of the associated rules. It is important to make sure some value for the qualifier will be assigned for any value of the variable that may be input. This usually means that at least one membership function should have a confidence of 1 going infinitely to the left and at least one function should have a membership function going infinitely to the right. In our example we accomplished this with the "OK" and "way too hot" functions which extend to cover all temperatures.
way too hot
1 C o n f 0 150
OK
too hot
160
170
200
The other option is to constrain the possible value of the variable [TEMPERATURE]. There could be a rule that says if the temperature is less than 150, to do something else.
For example, if we have a rule: IF The color is red THEN Choice 1: Confidence = 1 If we know with absolute certainty (confidence = 1) that the color is red, we can be sure that Choice 1 is valid. However, in a fuzzy system, the confidence that the color is red may not be 1. If that qualifier had an associated membership function, it is likely to have a value other than 1. It will all depend on the qualifier's associated fuzzy variable and membership function. EXSYS multiplies the confidence of the IF part by the confidence associated with the choice in the THEN part and combines it with the current confidence for the choice. This allows the propagation of the fuzzy confidence. The confidence assigned to the choice is the product of the confidence of the IF part and the confidence assigned to the choice in the rule. If we have the rule: IF The color is red THEN Choice 1: Confidence = .8 and the confidence in the qualifier was 0.6, the confidence assigned to the choice in this rule would be .6 * .8 = .48 If multiple rules assign confidence to an individual choice, the values combine. The algorithm used is described later, but basically: 1. Any positive confidence value increases the final confidence. 2. Any negative confidence value decreases the final confidence. 3. When a choice has a low confidence value, a high value significantly increases the confidence. However, once a choice has a fairly high confidence value, additional high values only increase the final value slightly. 4. Equal positive and negative confidence values cancel. The same applies to qualifiers that are assigned values in the THEN part of a rule. Using our rule: IF The input water is a little too hot THEN The amount of cold water to add to the input is a little
R - FUZZY LOGIC 16
If the confidence the input water is a little too hot is .7, the confidence assigned to "The amount of cold water to add to the input is a little" will be given a confidence of .7 by this rule, which will be combined with any other confidence assigned to this qualifier value. For the details on the mathematical algorithms used to calculate and combine confidence values see Section 6. One of the biggest differences between the EXSYS Fuzzy mode and other EXSYS modes is that in Fuzzy, there is a distinct confidence associated with each VALUE of the qualifier, not just the qualifier as a whole (as in confidence mode 5). When a qualifier is displayed in the "Known Data" window or in a report, it will have the confidence of each value displayed whenever the confidence is less than 1. For example, suppose we have the qualifier "The color is Red and Blue" with the confidence of "Red" at .8 and "Blue" at .4. It would be displayed as: The color is Red (Conf=.8) and Blue (Conf =.4) If the confidence of Blue was 1, the confidence value would not be listed: The color is Red (Conf=.8) and Blue
R - FUZZY LOGIC 17
R - FUZZY LOGIC 18
3. A dialog is displayed:
Qualifier
OK
Cancel
the
4. Click on the Qualifier list button. A list of all qualifiers in the system will drop down. Select the desired qualifier. 5. Select the first value by clicking on the Qualifier Value list button. It will drop down to display each value and the associated weighting factor. 6. Enter the weighting factor desired for this value in the "Weighting Factor" edit box and click "Set New Value". The weighting factor can be any numeric value. Repeat 5 and 6 for each of the qualifier values. 7. If you wish to normalize the weighting factors, so that the weighted sum is divided by the sum of the factors, click on "Normalize" button. (This is equivalent to forcing the sum of the weighting factors to be 1, and is not normally necessary.) 8. Click OK.
Now when the expert system runs, the value of the variable will be calculated from the weighted sum. A few things to note: 1. To be calculated, the variable MUST be either: A. Used in the rules B. Flagged for display with the results C. Forced to be calculated in the command language with a command such as:
R - FUZZY LOGIC 19
2. Do NOT use the same variable to fuzzify a qualifier as you use to defuzzify based on the qualifier. If qualifier 1 is fuzzified based on [X], do not defuzzify [X] based on qualifier 1. It is OK to defuzzify [X] based on some other qualifier or to defuzzify some other variable based on qualifier 1.
R - FUZZY LOGIC 20
R - FUZZY LOGIC 21
3. It is not necessary for the end user to be able to easily trace every step of the logical process that resulted in the answer. The complexity of confidence assigned by membership functions and the ways in which confidence is combined and propagated by the rules make it much more difficult for an end user to trace the steps in the logic. In fuzzy systems, usually the results are presented to the end user with less explanation.
R4.2: How
If the three criteria are met, fuzzy may be an excellent solution to a problem. Each problem is different, but the following is a good approach to building fuzzy systems: 1. Define qualifiers that describe the problem with values stated in general terms such as: low, normal, high safe, getting near threshold, over threshold cool, warm, hot, very hot Do not create membership functions yet. 2. Define qualifiers that will be used for the defuzzification. These are the conclusions that the system will reach. Again these should be in general terms such as: The amount to add is none low normal high The machine speed should be low normal fast Do not create defuzzifying functions yet. 3. Write rules that uses the qualifiers defined in #1 to describe the logic of the process and to arrive at conclusions which assign values to the qualifiers in #2. For example: IF The temperature is high and The pressure is normal THEN The amount to add is high
R - FUZZY LOGIC 22
This type of rule should be written for each possible case. This can be done in EXSYS Professional or, for many systems, it is may be faster to do it in EXSYS RuleBook. To use RuleBook: A. RuleBook does not directly support the Fuzzy confidence mode, but no choices will be added, so start a new system in any of the available confidence modes. B. Add the qualifiers described in #1 and #2. C. Build trees using the qualifiers from #1 in the IF part and from #2 in the THEN part. These trees should be complete and represent the logic of the decision making process. D. Save the RuleBook system for future use, and print the rules in EXSYS Rule Compiler format to a file. E. Edit the text file of rules and change the line: Probability System: x to Probability System: 6 F. Compile the edited file with the EXSYS Rule Compiler. The resulting .rul and .txt files can be read by EXSYS Professional. The system will be set for fuzzy logic and all of the qualifiers and rules will be defined. This can then be further edited with EXSYS Professional. 4. Once the rules are built, run the system to make sure that it gives correct answers. In this mode, the end user will be asked for the values of the qualifiers. It is important to make sure the system is working at this level before fuzzy membership functions are added. 5. Edit the rules to add additional weighting factors in some rules, choices where needed in the rules, messages, etc. Test that these additions are working as expected. Add choices to force backward chaining or run in a FORWARD chaining mode by adding FORWARD and NOBACKWARD to the .cfg file for the system. 6. For each qualifier in #1 that can be fuzzified based on a variable, define the variable and create fuzzy membership functions for the qualifiers. - THIS IS THE DIFFICULT PART. Rules are a typical way to represent the facts we know. Telling someone "if.. then.." is done frequently. It is the way we think. However, building membership functions representing the simultaneous confidence of different options is not something most people have experience doing. Also,
R - FUZZY LOGIC 23
except for the rare case where there is statistical data, the exact form of the membership function is undefined. It must be created based on the human experts opinion of how much confidence to give each option. It takes some practice to learn how to do this well. Do not be surprised if the membership functions defined will have to be modified later when we test the system. Do not associate data acquisition commands with the variables yet. 7. Define the output variables and the defuzzifying weighting functions for the qualifiers in #2. 8. Run the system to make sure the variables defined are correctly setting values for the qualifiers. If a qualifier is being directly asked and it should have gotten a value from a fuzzy variable, check the qualifier fuzzy parameter definition and trace file. 9. When the system appears to be giving good results for individual sets of data, run a systematic validation test of the system. A. Select Validation from the Options menu. B. Click on Systematic (System.) C. Set ALL qualifiers that have a fuzzy membership function and variable to be Derived. Other qualifiers may be tested or derived depending on the details of the system. D. Set each of the fuzzy variables associated with a qualifier to be tested across a range of values that covers the expected input values. Set the output variables that are defuzzified to be Derived. E. Run the validation test. Depending on the size of the system, this may take some time or be finished quickly. F. Select to see the branched tree diagram. While this contains all of the data we want, it is difficult to pull the pieces we need together. To make it easier to view the data, click on the Graph button. G. Now we can graph the data many ways. Select a graph axis variable, and optionally some other constraints. Click Done. H. In the right side of the graph window, pull down the list button labeled "None" and select one of the output variables. The possible values will be graphed. This can be repeated for up to 3 output variables or choices on the same graph.
R - FUZZY LOGIC 24
I. The graphs may show a band of values indicating the high and low values found. The exact value is determined by the parameter in the upper left box. Double click on one of the items in the box. It will be set for its lowest value and the graph will be redrawn. Clicking on the Up and Down buttons allows the value of this parameter to be changed. Each change will redraw the graph. J. By manipulating the parameter values chosen to graph and the value of individual parameters, it is possible to take a 2 dimensional slice of the data even though the data may be ndimensional. Stepping through on one parameter allows the 2 dimensional slice to be moved through the n-dimensional space in any direction. This gives tremendous flexibility to view the data. Look for places where the graphs do not appear as expected. If you would expect a function to continuously increase, and at some point it dips - there is a problem. If values do not change as a parameter is varied, and you expect it to - there is a problem. 10. If any problems are detected, they are probably due to errors in the definition of the membership function. If the cause is not immediately obvious, run the system by hand around the point where the problem occurs. If modification of the membership function is needed, make changes and rerun the validation test. 11. When the system tests properly and all the graphs appear correct, add any required data acquisition commands to automatically get data for variables or any command files to control repetitive execution of the system.
R4.3: Demos
Several demo fuzzy logic systems are provided with EXSYS Professional. Examine these systems. Use the "Examine Tree Diagram" option under the Options menu to examine graphs of the systems.
R - FUZZY LOGIC 25
This window is used to set the parameters for the graph. The graph produced has an axis variable which can be any input variable used
R - FUZZY LOGIC 26
in the system. Outputs for other variables or choices can be graphed against this variable for any combination of constraints. For example, suppose a system uses a variable TEMPERATURE (plus other data) to determine the confidence in a choice "ADD WATER". We could select TEMPERATURE as the graph variable. If we did not add any other constraints we might get a graph:
90
100
110 TEMPERATURE
120
130
This graph has a band of values that indicate the possible range of values of the choice ADD WATER for each temperature tested in the validation test. Remember that in the system there are other factors besides temperature that determine the final results. For example, at a temperature of 120, all possible combinations of input which produced a confidence for ADD WATER were taken from the validation test tree. The maximum and minimum values are displayed and combined for each temperature to make the graph.
For example, if the line in the tree file is: Q1:2 Q3:1 [TEMPERATURE]:100 >>> C1:5 C2:8
This means that this particular test used input data of qualifier 1 value 2, qualifier 3 value 1 and a temperature of 100. For this data, the output choice 1 got a value of 5 and choice 2 got a value of 8. If there were no constraints specified, and we were graphing choice 1, the value of 5 would be saved as a possible value for a temperature of 100. After each line in the file is read, the minimum and maximum values for each possible temperature are graphed. If constraints are applied, less of the lines in the file will be used. Suppose qualifier 1 is a type of material being processed. To see the graph for only material 2 we would select qualifier 1 in the "Undefined Constraints", select value 2 and click on set. Now the graph would still include the above line, but would not graph the line: Q1:1 Q3:1 [TEMPERATURE]:100 >>> C1:7
because this line uses qualifier 1 value 1 which does not match out constraint. Note: the Axis Variable is really a defined constraint, but values are displayed for all possible values. The graph can be constrained to examine results for any possible combination of input conditions.
R - FUZZY LOGIC 28
Graph Item 2
Setup GRAPH
Graph Item 3
Auto Scale
DONE
The axis of the graph will be the variable selected in the setup window. The actual data that is graphed is selected in the list boxes on the right side of the Validation Graph window. Up to three items can be simultaneously graphed. The items which can be selected are: 1. Choices set by the system 2. Variables assigned values in the rules 3. In a Fuzzy Logic system, variables assigned values through defuzzification of a qualifier value. To select an item, click on the list button pull down and select an item. If the same item is selected in multiple lists, it will only be displayed in the first. To select nothing, click on "NONE", the first time in each list. As each item is selected, EXSYS will redraw the graph.
Only values which were used in the validation test can be displayed. This is because only these values have been tested. For example, if the validation test allowed [TEMPERATURE] to go from a minimum of 90 to a maximum of 130 in 10 degree increments, we can only test on 90, 100, 110, 120 and 130. The other values are not known in the validation test. To examine the value at 105, the validation test would have to be done again with different parameters to hit this value.
The IF part can be made up of 3 types of data items. 1. Qualifiers - These may have multiple values ORed in a single qualifier, or may represent an OR block in a rule. 2. Mathematical expressions - these may have multiple variables. 3. Choice tests. It is important to understand how confidence is combined for each of these items, but it should be remembered that in an actual system, EXSYS takes care of all of the math automatically.
= .8
The formula is then repeated for "blue" Combined_Conf = .8 + .6 * ( 1 - .8) = .92 The final combined confidence is 0.92. This formula has the advantages that 1. It never exceeds a value of 1.0. 2. Each positive confidence increase the final confidence. 3. It does not matter what order is used (Try the calculation with "red"=.6 and "blue"=.8 and it gives the same answer.) If only "red" had been set, or if "blue" had a negative confidence value, only the confidence for "red" would have been used. Maximum Method of Calculating Qualifier Confidence An alternate method for calculating the overall confidence of a qualifier with multiple values is also available. This alternate method is chosen by using the EXSYS configuration option USE_FUZZY_MINMAX which can be set in the .CFG file or passed on the command line. In this system, the maximum confidence for the values set is used. In the example above, the maximum would be the 0.8 for "red". No other value would be combined with it. This system is appropriate for some problems. OR Blocks in a Rule If there are multiple qualifiers in the IF part of a rule in the form of an OR Block, the overall confidence of the block is calculated the same as the values in a single qualifier. The default is to combine the confidence for each of the qualifiers in the OR Block using the same formula as above: Combined_Conf = Combined_Conf + (Value_Conf * (1 Combined_Conf)) For example, if we had three qualifiers in an OR Block: OR OR The color is red or blue The temperature is high Today is Monday
and the confidence of "The color is red or blue" is 0.92, the confidence of "The temperature is high" is .85 and "Today is Monday" is not true (confidence = 0):
R - FUZZY LOGIC 32
the combined confidence for the OR block would be: The Combined_Conf is initially 0. Adding in "The color is red or blue" Combined_Conf = 0 + (.92 * (1 - 0)) = .92
Adding "The temperature is high" Combined_Conf = .92 + (.85 * (1 - .92)) = .988 The confidence for "Today is Monday" is not used since it's value is not greater than 0. If the configuration option USE_FUZZY_MINMAX is set, the combined confidence would be the maximum confidence of any of the qualifiers in the OR Block. In this example, it would be the 0.8 for "The color is red or blue". Assigning Confidence to a Qualifier Qualifier data has confidence assigned in three ways: 1. If the qualifier is directly asked of the end user, or set by and external source, the confidence in the data is taken to be 1. 2. If the qualifier value(s) are set by a fuzzy membership function and associated variable, the confidence is set by the membership function. 3. If the qualifier is assigned a value in the THEN part of a rule, the confidence is propagated from the IF part of the rule, and combined with any confidence in the THEN part.
In those cases where variables must be given confidence less than one, the default confidence for any formula that has multiple variables is to multiply the confidence for each variable that has a value greater than 0. If any variable has a confidence of 0 or less than 0, the confidence for the formula will be 0. If the USE_FUZZY_MINMAX configuration option is set, the confidence for a formula will be the minimum confidence of the variables used in the formula.
Using the default mode, first we would calculate the confidence of the OR Block: The color is red or blue OR The temperature is high OR Today is Monday This is .988 (same as the example above)
The confidence of the formula [X] > [Y] is 0.7 * 0.8 = .56 The confidence of "Choice 1" is .9 The combined confidence for the IF part would be .988 * .56 * .9 = .498 Using the same example, with the USE_FUZZY_MINMAX option: First we would calculate the confidence of the OR Block: OR OR The color is red or blue The temperature is high Today is Monday
This is .8 (maximum value of The color is red or blue) The confidence of the formula [X] > [Y] is 0.7 (minimum value) The confidence of "Choice 1" is .9 The combined confidence for the IF part would be the minimum of .8 , 0.7 and .9, for a overall confidence of 0.9.
R - FUZZY LOGIC 35
Choices Overall IF
R - FUZZY LOGIC 36
THEN PART
When a rule fires in the Fuzzy Mode, the IF part will be TRUE. This means that each qualifier, formula, choice condition and qualifier OR block in the IF part is TRUE and has confidence greater than 0. The overall IF confidence is calculated and applied to the items assigned in the THEN part. The confidence assigned to an item depends on: 1. The confidence of the IF part 2. The confidence assigned in the rule 3. The item's previous confidence The calculation of the IF part confidence is described in Section 6.1 through 6.4.
If either IA or CC is negative, but not both, CMIN = minimum of the absolute values of IA and CC New choice Confidence is ( IA + CC) / (1 - CMIN) For example, suppose we have a rule with the IF confidence of .75 and we assign three choices: THEN Choice 1: Conf = .8 Choice 2: Conf = -.3 Choice 3: Conf= -.7 Where the current choice confidence values set are: Choice 1 .55 Choice 2 .4 Choice 3 -.6 For choice 1: IA = .75 * .8 = .6 CC = .55 Since both are positive: New Choice 1 Conf = .6 + (.55 * ( 1- .6)) = .82 For choice 2: IA = .75 * -.3 = -.225 CC = .4 Since one is positive and one is negative: CMIN = minimum absolute value = .225 (NOTE: positive value) New Choice 2 Conf = ( -.225 + .4) / (1 - .225) = .226 For choice 3: IA = .75 * -.7 = -.525 CC = -.6 Since both are negative: New Choice 3 Conf = -( .525 + (.6 * ( 1- .525))) Choice 1 Choice 2 Choice 3 Previous .55 .4 -.6
R - FUZZY LOGIC 38
-.81
The rules for combining confidences may seem complicated (mostly because they are), but the good news is that EXSYS does all the work for you. The main points to remember are: 1. Any positive confidence value increases the final confidence. 2. Any negative confidence value decreases the final confidence. 3. When a choice has a low confidence value, a high value significantly increases the confidence. However, once a choice has a fairly high confidence value, additional high values only increase the final value slightly. 4. Equal positive and negative confidence values cancel.
R - FUZZY LOGIC 39
R - FUZZY LOGIC 40
S - SCREEN TEMPLATES
S - SCREEN TEMPLATES
S - SCREEN TEMPLATES
Template Style 1
TEMPLT1.SCR
Allows a single qualifier value to be selected. Up to 6 qualifier values are allowed. The qualifier value text must be short enough to fit on the button.
Template 1 - Qualifier
Template 1 - Variable
S - SCREEN TEMPLATES
Template Style 2
TEMPLT2.SCR
Allows multiple qualifier values to be selected. Up to 5 qualifier values are allowed. The qualifier value text must be short enough to fit on the check box line.
Template 2 - Qualifier
$T$
Template 2 - Variable
S - SCREEN TEMPLATES
Template Style 3
TEMPLT3.SCR
Allows a single qualifier value to be selected. Up to 5 qualifier values are allowed. The qualifier value text must be short enough to fit on the radio button line.
Template 3 - Qualifier
$T$
Template 3 - Variable
S - SCREEN TEMPLATES
Template Style 4
TEMPLT4.SCR
Allows selecting from qualifier values displayed in a list box. Up to 30 qualifier values are allowed. The qualifier value text must be short enough to fit on one line in the box.
Template 4 - Qualifier
Template 4 - Variable
S - SCREEN TEMPLATES
Template Style 5
TEMPLT5.SCR
Allows a single qualifier value to be selected using a mouse region. Only 2 qualifier values are allowed. The qualifier value text must be short enough to fit on the mouse region. It will wrap to fit.
$Q$
Template 5 - Qualifier
$Q$
OK
Template 5 - Variable
S - SCREEN TEMPLATES
Template Style 6
TEMPLT6.SCR
Allows a single qualifier value to be selected. Up to 3 qualifier values are allowed. The qualifier value text must be short enough to fit on the button.
Template 6 - Qualifier
Template 6 - Variable
S - SCREEN TEMPLATES
Template Style 7
TEMPLT7.SCR
Allows a single qualifier value to be selected. Up to 3 qualifier values are allowed. The qualifier value text must be short enough to fit on the button.
$Q$
Template 7 - Qualifier
$T$
OK
Template 7 - Variable
S - SCREEN TEMPLATES
10
Template Style 8
TEMPLT8.SCR
Allows multiple qualifier values to be selected. Up to 4 qualfier values are allowed. The qualifier value text must be short enough to fit on the check box.
$Q$
$V1$ $V2$ $V3$ $V4$ OK
Template 8 - Qualifier
$T$
OK
Template 8 - Variable
S - SCREEN TEMPLATES
11
Template Style 9
TEMPLT9.SCR
Allows a single qualifier value to be selected. Up to 6 qualifier values are allowed. The qualifier value text must be quite short to fit on the buttons.
$t$
S - SCREEN TEMPLATES
12
Template Style 10
TEMPLT10.SCR
Allows selecting from qualifier values displayed in a list box. Up to 30 qualifier values are allowed. The qualifier value text must be short enough to fit on one line in the box.
$Q$
OK
Template 10 - Qualifier
$T$
OK
Template 10 - Variable
S - SCREEN TEMPLATES
13
Template Style 11
TEMPLT11.SCR
Allows a single qualifier value to be selected. Up to 4 qualifier values are allowed. The qualifier value text must be short enough to fit on the button.
$Q$
$V1$ $V2$ $V3$ $V4$
Template 11 - Qualifier
$Q$
OK
Template 11 - Variable
S - SCREEN TEMPLATES
14
is pressed. Alternatively, radio buttons can be used with an "OK" button. In that case, only the OK button should have a return immediate (I) option. If multiple items can be selected, use check boxes and an "OK" button. Only the OK button should have a return immediate (I) option. Mouse regions can also be used, but should only be used when all qualifiers have the same number of values. If there are more buttons than qualifier values, the extra buttons will not be created. If mouse regions are used, the decoration for the mouse region will still be drawn. To put the values in a list box, use the ~LIST command and use the -Q option to load the list with the qualifier values. Make the list box wide enough to hold the qualifier values. For example: ~LIST "", 130, 130, 260, 150, -Q -N -M -G -I ~BUTTON "OK", "", 220, 220, 60, 40 -I -X would create a list box and allow multiple items to be selected. When the OK button is pressed, the selected items would be returned as the selected values of the qualifier. 5. Create a screen labeled ~~V_DEFAULT (note there are TWO ~, just like a hypertext key word). This is the template screen for variables. 6. Define a variable screen. Usually this screen will have a similar design, color and border as the ~~Q_DEFAULT screen. It may be easier to copy parts of the ~~Q_DEFUALT screen with a text editor rather than re-building it. 7. Wherever you would want the variable prompt text, use the text $T$ - this must be used as a text statement (no command on the line) and must be the only text in the command. If you wish the text to wrap after a specific number of pixels, the -W option can be used. For example: ~CURSET 155, 70 $T$ -W:400 would position the cursor to 155, 70 and write the prompt text for the variable. The variable text would word wrap at 400 pixels, so no text would extend beyond the horizontal pixel 555 (155 + 400).
S - SCREEN TEMPLATES
16
8. Add an edit region to allow the end user to enter a value for the qualifier. The edit region should have no text in the return string prefix. For example: ~EDIT "", 125, 160, 150, 30 -B ~BUTTON "OK", "", 220, 220, 60, 40 -I -X would add an edit region to enter the value. When the OK button is pressed the value will be accepted. NOTE: The template screen must: 1. Return data for only a single qualifier or variable. 2. Use the $Q$, $V#$ and $T$ for prompt text. If there are more buttons or mouse text regions defined than are needed for a specific qualifier, the extra buttons/mouse regions will not be activated. If there are too many values for the available buttons, the extra values will be ignored - with no error message. 3. The return string should be only the value, not the address information. For example, suppose qualifier 3 has 3 values, the return string associated with buttons or mouse regions would be "1", "2" and "3" - NOT "Q3 1", "Q3 2" "Q3 3". The template screen must be generic. Likewise an edit region in a variable input screen should have no prefix - only the data input should be returned. EXSYS will automatically associate it with the variable being asked with the template screen.
S - SCREEN TEMPLATES
17
For example, suppose you use the screen developed in the Parameter Replacement section for all of the qualifiers in the system.
Text of qualifier
You add the screen code for a qualifier default screen: ~~Q_DEFAULT ~SET_WIN 20, 20, 470, 265 ~TEXTSIZE LARGE ~CURSET 55, 48 $Q$ -W:300 ~BUTTON "$V1$", "1", 93, 90, 300, 42, -I ~BUTTON "$V2$", "2", 93, 145, 300, 42, -I ~BUTTON "$V3$", "3", 93, 200, 300, 42, -I ~END Now whenever a qualifier is to be asked, this custom screen will be used (unless the qualifier has another custom screen specifically associated with that qualifier). Each qualifier will be asked the same way. If some qualifiers only have 2 possible values, only two buttons will be displayed. However, if any qualifier has more than 3 values, only the first 3 values will be displayed. Make sure that you have enough buttons or mouse regions for the maximum number of possible values in any qualifier.
S - SCREEN TEMPLATES
18
Common Modifications:
Problem: The template uses buttons, and your system allows multiple values to be selected. Solution: Convert buttons to check boxes and add an OK button. Problem: The template allows multiple values to be selected, but your system only allows a single value. Solution: Convert check boxes to buttons with a returm immediate -I option, or a list box that only allows a single item to be selected. Problem: The template does not have enough buttons. Solution: Add buttons or convert to a list box. Problem: The system must run in monochrome and the template only looks good in color. Solution: Edit the colors with Exdesign on a monochrome computer to make an acceptable combination.
To make an individual screen that maintains the templates design style: 1. Open the .SCR file with a text editor. 2. Copy the ~~Q_DEFAULT or ~~V_DEFAULT screen and give it a name for a specific qualifier (e.g. "~Q 4") 3. Edit the new screen using ExDesign or a text editor to add whatever special modifications are needed for the individual qualifier or variable. When the system runs the individual screens will be used for the special cases and the template will be used for the rest.
S - SCREEN TEMPLATES
20
will create a mouse "hot spot" and label it "Click Here" using the current text size and colors. The $V#$ replaceable parameter can also be used as the mouse region label, in which case the text will be picked up from the appropriate qualifier's value text.
EXSYS Professional
ADDENDUM - 1
For example, the text line in a custom screen: This is a text string with embedded text from [[X]]. -W:300 would be word wrapped at 300 pixels regardless of the final length of the string after the value of [X] was inserted.
Horizontal
80
2.32 Dial 5 4 6
60
40
20
70.1 3 5.34 7
EXSYS Professional
ADDENDUM - 2
Syntax:
Horizontal Meters: ~METER-H var, rct, "label", scale_min, scale_max, num_incr, alarm_high alarm_low Vertical Meters: ~METER-V var, rct, "label", scale_min, scale_max, num_incr, alarm_high alarm_low Dial Meters: ~METER-D var, rct, "label", scale_min, scale_max, num_incr, alarm_high alarm_low
Parameters
var The name of the EXSYS variable whose value will be displayed by the meter. The display of the meter will force EXSYS to derive a value for the variable. Usually a data acquisition command would be associated with the variable so that data would be automatically fed into the meter. The variable should be in [ ], and not in " ". rct The outer rectangle for the meter. This is given as 4 values in the standard EXSYS syntax for rectangles in custom screen: top column, top row, width in pixels, height in pixels label This is a label for the meter. If no label is desired, use "". If a label is specified, make sure that it is small enough to fit on the meter. scale_min The low value for the scale on the meter. scale_max The high value for the scale on the meter. num_incr The number of increments on the meter scale. When selecting the number of increments remember that the increments will be labeled, so it is better to select a value that will divide the range between scale_min and scale_max into segments that have easily represented values. For example, if
EXSYS Professional
ADDENDUM - 3
scale_min = 0 and scale_max=1, choosing num_incr=3 will result in repeating decimals: .3333333.. and .666666... Choosing num_incr=4 would be better to get .25, .5 and .75. If it is necessary to chose num_incr that result in repeating decimals, use the /S#.# option to make the display fit on the meter. alarm_high The threshold value where the alarm color is set. In horizontal or vertical meters, values over this alarm threshold will change the bar color from blue to red. In dial meters the alarm range is displayed as a red "pie" section on the dial. The alarm threshold does not actually send any alarm - it just changes the display color. If no high alarm is desired, set the alarm_high to be a value above the maximum possible value. alarm_low The threshold value where the alarm color is set. In horizontal or vertical meters, values less than this alarm threshold will change the bar color from blue to red. In dial meters the alarm range is displayed as a red "pie" section on the dial. The alarm threshold does not actually send any alarm - it just changes the display color. If no low alarm is desired, set the alarm_low to be a value below the minimum possible value. Example: ~METER-V [Z], 120, 95, 85, 180, "TEMP", -1, 1, 8, .8, -.4 will draw a vertical meter displaying the value of EXSYS variable [Z]. The meter will have the upper left corner at coordinates 120, 95. It will be 85 pixels wide and 180 pixel high. The label will be TEMP. The scale will go from -1 to 1 divided into 8 equal segments. A high alarm threshold is set for .8 and a low alarm threshold is set for -.4
Options
/AC:color Alarm bar color. The default alarm bar color is red. Using /AC: color allows the color to be changed. The color can be: RED GREEN BLUE CYAN MAGENTA YELLOW BLACK DKGRAY GRAY LTGRAY WHITE For example: /AC:BLACK changes the alarm bar color to black.
EXSYS Professional
ADDENDUM - 4
/MC:color Bar color. The default meter bar color is blue. This can be changed to any of the colors listed above in /AC. This command has no effect on dial meters which have no bar. /NS Do not add a scale. The meter is displayed, but no scale is added. The value displayed at the bottom of the meter is still displayed. /V#.# Value Precision. The size and precision of the value displayed at the bottom of the meter can be controlled with /Va.b. The a value is the total number of digit to use. The b value is the number of digits to display right of the decimal point. For example, if the value should be displayed to only 2 digits right of the decimal point using /V4.2. /S#.# Scale Precision. This is the same as the /V option, but applies to the labels on the scale of the meter.
The first line, displays the screen with the meters. In this case we assume that the meter variables are set to automatically get values through data acquisition commands. The WHILE loop will continue until [X] > 200. Each time through the WHILE loop, the UPDATE_METERS command is encountered and the meters on all displayed screens will be updated with new data. The rules are run to analyze the values and possibly warn of some developing problem, etc.
Syntax:
~LIST "ret prefix" rct options "ret prefix" The string to precede the return data. Usually "Q#" or [variable] to identify the qualifier or variable. If the Q"name" form is preferred, replace the " with '. For example, to return data to the qualifier named "COLOR", we would use: ~LIST "Q 'COLOR'" rct
The text of the list item(s) selected will be preceded by the "ret prefix" string and must make a valid EXSYS data assignment statement. The default is to return the actual string selected. For qualifiers, it is usually better to return the number of the item selected. This is done by using the -N option.
EXSYS Professional
ADDENDUM - 6
rct The rectangle for the list specified as an EXSYS rectangle. The rectangle will specify the size and position of the list box. This is given as 4 values in the standard EXSYS syntax for rectangles in custom screen: top column, top row, width in pixels, height in pixels If the -E or -B options are used, only a small edit region or button will be displayed. The width will be the width specified, but the height will be only about 20-30 pixels (depending on operating system). The position will be determined by the upper left corner. When the list is "pulled down" by the arrow, the list displayed will be the full size specified by the rct.
Options:
Control Types: The default is to make a list box. This can be changed to two other forms of lists. -B Make the list a LIST BUTTON. Only a button will be displayed with an arrow next to it. A click on the arrow displays the full list to make a selection. The current selection is displayed on the button. Make the list as LIST EDIT. List edits a similar to list buttons, but the displayed value can be directly changed by typing into it.
-E
Putting Data in the List: Data can be added to the list several ways. Note: because the list text display is controlled by the operating systems and not directly controlled by EXSYS, hypertext can NOT be used in the elements in the list. -L List of data follows. Read all following lines of text into the list until a ~LISTEND is encountered. If this option is used, list the strings to add to the list immediately after the ~LIST command, one item per
EXSYS Professional
ADDENDUM - 7
line. After the last line, add ~LISTEND. All lines will be added to the list. For example, ~LIST "Q 1", 100, 50, 150, 200 -L Red Blue Green White ~LISTEND will create a list box and put the values Red, Blue, Green and White in it. -F:file Read contents of the text file into the list. The file should have one item per line. For example: ~LIST "Q 1", 100, 50, 150, 200 -F:colors.dat will create a list box and add the contents of the file "colors.dat" into the list. -Q# Add the list of possible values from qualifier # to the list. The list of the values for the qualifier are the values defined when building the expert system. This is useful for template screens or when parameter replacement is desired. If there is no # specified, the qualifier associated with the screen will be used. For a ~~Q_DEFAULT screen, use only -Q. If the screen is associated with a specific qualifier, only the -Q is needed. If the qualifier is not indicted by the screen name, or if there are multiple list boxes from different qualifiers, use the -Q# form. The values will be added one per line, so make sure that the list is wide enough to hold the longest value text. For example: ~LIST "Q 1", 100, 50, 150, 200 -Q1 will create a list box and add the values associated with qualifier 1 into the list.
EXSYS Professional
ADDENDUM - 8
Other Options:
-N Return the number of the element selected. The usual default is to return the text of the item(s) selected. The -N option should be used for lists associated with qualifiers. Lists associated with variables will usually return the actual string selected from the list. For example: ~LIST "Q 1 " 100, 75, 200, 180 -F:zzz.dat -N
would create a list box and put the values from file zzz.dat in it. The return string would be "Q 1 " followed by the number of the value selected. NOTE: If either the return prefix string starts with 'Q' or the -Q option is used, EXSYS will assume that the number of the item should be returned and will automatically add the -N. In these cases the -N is not really needed. Return the string value. This is normally the default, however if either the return prefix string starts with 'Q' or the -Q option is used, EXSYS will assume that the number of the item should be returned. To override this, use the -S (This should rarely be needed.) Make the list box READONLY. This can be used for displaying data that is to be read but not selected by the end user. This option can not be use with the -E or -B options. Return Immediately on Double Click (-I) By default EXSYS will not return from a list box until a button or mouse region with a Return Immediate flag set is clicked. In some cases where a screen has a single list box, it is convenient to have a double click on a list box item indicate that the data should be processed immediately, without clicking on an OK button. This option applies only to list boxes and not list button or list edits. Allow multiple selections. The default in list boxes is to allow only one item to be selected. The -M allows multiple items to be selected. If the -M# form is used, EXSYS will allow multiple items to be selected, but will check that not more than # have been selected. This option can not be used with the -B and -E options. Some item in the list MUST be selected. If nothing is selected, EXSYS will display an error message and require the user to select something. Do not return data for the item. This is usually only used with the -R option.
EXSYS Professional
ADDENDUM - 9
-S
-R
-I
-M
-G
-X
-D
Set starting selected value. The default is for EXSYS to make the first item in the list the starting selected value. This can be changed. The command has several forms: -D -D# value. -D"string" For List Edits (-E option) the string in the edit box is set to string. This form applies only when the -E option is used. Do not select any item at startup. Make item # in the list the starting selected
-N<id>,<id>...
-J<type><id>,<type><id>... Selection of this button enables items specified by <type><id>. -K<type><id>,<type><id>... Selection of this button disables items specified by <type><id>. -Y -LABEL:"string" String is the label used to refer to this button in Enable and Disable commands. <type>: <id>: B,E,M, or S for Button, Edit, Mouse, or Scroll Region. Number or Label of another item. Number is the position of the item of that particular type in the custom screen definition. Label is the string defined by the LABEL:"string" option on another item. Double quotes must be used. For example: -JM"abc" on a selected button will enable the mouse region that has the label "abc". -JM2 will enable the same mouse region if it is the second mouse region defined in the custom screen.
EXSYS Professional
ADDENDUM - 10
Brings this button up inactive. It must then be enabled by another button with a J option.
Image Command
EXSYS Professional for MS-Windows can display graphic images in the .PCX format. This is done through the Custom Screen command ~IMAGE. The format of this command is: ~IMAGE "filename.PCX" rct -V# -H# where the filename is in double quotes and rct is the usual X,Y, Width and Height coordinates. Since the PCX image is not resized to fit the rectangle, only that portion (starting at the upper left corner of the image) that fits inside is displayed. You can use the -V# and H# switches, where # is the number of pixels, to offset the PCX image within the rectangle.
EXSYS Professional
ADDENDUM - 11
This command can be used in a custom screen specification (.SCR file) for a variable or qualifier input screen. It can also be used in a custom screen file (other than the .SCR file) that can be displayed with the DISPLAY command in the command file, report generator, or the THEN part of a rule. The DISPLAY command has the following format: DISPLAY(filename -C -R -N) where filename is the name of the custom screen file you created with a text editor or the report generator. The options are as follows: -C -R -N Indicates that the file is in custom screen format. Allows data to be returned to EXSYS from a custom screen file. EXSYS continues processing without waiting for the displayed file to close.
Note: When using the MS-Windows Paint program to create a PCX image, you must first save it as a .BMP file then reopen it and save it as a .PCX image. This insures that the palette is stored in the image file.
4. Note_Only
When an application is delivered to end users, sometimes it is desirable to allow the user ask for some explanation about a rule, but not see the actual rule. The "NOTE_ONLY" configuration option enables this to be easily implemented. When the end user asks to see the rule through "why" or "how", only the note associated with the rule is displayed. The note can provide a readable text explanation of what the rule means. End users do not need to learn EXSYS rule syntax. They receive an easily readable explanation of even complex rules. Also, since the note can contain replaceable variable and qualifier values, the note can reflect the actual data used during the run. Hypertext can also be included in the note to assist users in the terminology. Add the NOTE_ONLY configuration option to the application's .CFG file or on the command line. For each rule that might be displayed, add a complete explanation in the NOTE field for the rule. The note can contain hypertext and [[ ]] expressions to explain the rule.
5. Hypertext in References
Hypertext can now be used in the reference associated with a rule. Previously the reference was displayed in a dialog box and hypertext was not supported. Now the reference is displayed in a true window. The hypertext in the reference can be associated to other documents that display additional information on the source of the rule.
6. Concatenate files
One expert system technique that can be used to build documents is to have the rules select predefined paragraphs (files) and concatenate them together. This is very useful for building many types of documents. In many operating system, the concatenation could be done by running a operating system command to concatenate the files as an EXSYS external program. This was not the most efficient technique, and was not possible at all on the Macintosh. A new CONCAT function enables you to easily concatenate files using only EXSYS internal commands. The CONCAT command is an EXSYS internal command. The syntax is : CONCAT(file1, file2) The contents of file 2 will be added at the end of file 1.
EXSYS Professional
ADDENDUM - 13
8. ODBC Interface
Current Databases Supported: ALLBASE Betrieve Clipper Database Manager DB2 DB2/2 DB2/6000 dBase II, III, IV,V Excel 5.0 Excel .XLS files FoxBase FoxPro Gupta SQLBase IMAGE/SQL INFORMIX INGRES InterBase Microsoft SQL Server NetWare SQL Oracle Paradox PROGRESS SQLBase SQL/400 SQL/DS Sybase SQL Server Sybase System 10 Teradata Text files XDB
Installation
Copy all .DLL files from the EXSYS Professional v5.0 diskettes to the \WINDOWS\SYSTEM directory. Install the Q+E ODBC Pack software according to the manufacturer's instructions. To Define a Data Source: Click on the ODBC icon in the WINDOWS Control Panel. Under DATA SOURCES, choose ADD. Under ADD DATA SOURCE, select database type. Under ODBC <database type> DRIVER SETUP: Enter <database type source name>* in DATA SOURCE NAME. Enter a working directory, if known. Enter other information as appropriate. CLOSE/EXIT all the way out. * Database type source names are in the READ.ME on your distribution disks.
EXSYS Professional
ADDENDUM - 14
DLL Distribution: The ODBC DLLs distributed with EXSYS Professional v5.0 are: ODBC.DLL QEMDSxx.DLL QELIB.DLL QEGUIxx.DLL QESQLxx.DLL QEQRYxx.DLL QEUTLxx.DLL
** xx might be 03 or 06 depending on your software revision. All other general DLLs you use will be distributed with your Q+E ODBC Pack. These DLLs will be looking for the particular DLL of your database (shipped with your database software). For example, the file PXENGWIN.DLL is shipped with PARADOX. In order to access your PARADOX files, this DLL must be present in either your working directory or in \WINDOWS\SYSTEM. You can purchase the ODBC drivers individually from your database vendor. Alternately, you can order the entire set, or individual drivers (per seat) from the following vendor: INTERSOLV 5540 Centerview Drive, Suite 324 Raleigh, NC 27606 (919) 859.2220
the Data Acquisition dialog box. For example, the variable [X] could have the function EVAL( [Z] / 2) associated with it. This would set [X] to the value [Z]/2.
V /M
C/Q/V /A"xxx" Put xxx after each choice, qualifier or variable printed. Use with /S to make list of items on one line. /A", " /S makes comma delimited text file. C/Q/V /A123 Put ASCII character 123 after each choice, qualifier or variable printed. Use with /S to make list of items on one line. Wraps text at column #.
NOTE /W:#
EXSYS Professional
ADDENDUM - 17
EXSYS Inc.
1720 Louisiana Blvd. NE Suite 312 Albuquerque, NM 87110 USA
EXSYS Professional
ADDENDUM - 18