Upload
irma-brennan
View
27
Download
0
Tags:
Embed Size (px)
DESCRIPTION
ESTA - OVERVIEW. ESTA – Expert System for Text Animation ESTA can be used to create an expert system for any subject area by building the knowledge base in that domain. ESTA + Knowledge Base = Expert System. System interface. External Programs. Working memory. Knowledge Base. - PowerPoint PPT Presentation
Citation preview
ESTA - OVERVIEW
• ESTA – Expert System for Text Animation
– ESTA can be used to create an expert system for any subject area by building the knowledge base in that domain.
ESTA + Knowledge Base = Expert System
Inference Engine
Working memory
Explanation FacilityKnowledge Base
User Interface Developer’s interface
UserKnowledge
Engineer
System interface External Programs
Overview
• ESTA is a rule based system that has the facilities for – Knowledge base– Inference engine– Graphic user interface– Graphic developer interface– Explanation– Uncertain reasoning– Debugging– interface to system programs
Knowledge base
• The knowledge base in ESTA is represented by two distinct kind of objects:
– Sections
– Parameters
KnowledgeBase - Sections
• Each section describes both how to decide whether any advice should be given to the expert system user, and to which section ESTA should go next.
– Consultation begins with the start section.
– All knowledge bases in ESTA must begin with a section called start.
– Sections can be modified from the section tree.
– Updates are dynamically reflected on the section tree.
Parameters
• Parameters are variables which determine the flow of control between the sections.
• Example – car.kb
section start : 'main section‘
if (problem='starting_problem') do starting_problemif (problem='overheating') do overheatingif (problem='smell_of_gasoline') do smell_of_gasolineif (problem='vibration') do vibrationdo other
/* An alternative is to write : do_section_of problem */
Parameters
Sections and parameters within a knowledge base can be listed.
Parameters that are not yet assigned a value appears with a ? Mark.
Section List of car.kb
alternative_transport : Investigation of other transport possibilities
another_battery : start the car using another battery
bad_idling_section : the engine idles badly
bad_running : the engine runs badly
battery_dead : the battery is dead
brakes : problems with the brakes
electrical : check the electrical system
gasoline_help : what to do when there is no gasoline on the car
horn_problem : problems with the horn
lack_of_power_section: the engine feels lacking in power
light_problem : problems with the lights
other : other problems not dealt with in the start section
overheating : the engine gets overheated
push_start : push-start the car
recharge : recharge the battery
smell_of_gasoline : the car smells of gasoline
start : main section
starting_problem : starting problems
vibration : vibrations in the car
wet_weather: the weather is wet
wiper_motor: problems with a wiper moto
Parameter list of car.kb
acceleration_noise : there is a noise during acceleration( ? )
another_battery : you can use another battery( ? )
bad_idling : the engine is idling badly( ? )
battery_dead : the battery is dead( ? )
brake_long_travel : the brake has a long travel( ? )
brake_nonoperative : the brakes do not work at all( ? )
brake_otherproblem : the brakes have unclassified problems( ? )
brake_poor : stopping ability is poor( ? )
brake_spongy : the brakes feel spongy( ? )
brake_springy : the brakes feel springy( ? )
brake_veer: car veers to one side when the brakes are applied( ? )
car : the kind of car( ? )
close_to_fueltank : you are close to a gasoline station( ? )
engine_vibration : the engine vibrates excessively( ? )
gasoline_can : you have a spare can with gasoline( ? )
gasoline_ok : there is gasoline in the car( ? )
horn_badnoise : the horn is not working properly( ? )
Knowledge Representation
Knowledge representation in ESTA is based on the following items:
• Parameters
• Sections
• Title
Knowledge Representation
NumbersNumbers are either integers or decimal numbers/
Examples:
12 45 234.54 -898.7e3
StringsStrings are a sequence of characters between two single quotes.
‘This is a string.’
SymbolsComparison symbols: < > <> <= >= =
Arithmetic operators: * - + /
Other symbols : () .. , . /* */
Knowledge Representation
Comments
Comments are enclosed within /* */
Expresions
There are three types of expressions in ESTA
Text expression
Number expression
Boolean expression
Text Expressions
• Text expressions can be used in the explanation field, in the question field, or in the text rules of parameter declerations.
• In sections text expressions are used as advice.
• The & character can be used to insert new lines into the text.
• The text functions are:
– concat(X,Y) returns the string X concatenated with Y
– startstr(N,X) returns the first N characters from the string X
– endstr(N,X) returns the last N characters from the string X
Text Expressions
• startstr(1, name_of_day) = ‘t’ /* days starting with ‘t’ are accepted*/
• ‘The favorite food of the ’ animal ‘is’ favorite_food ‘.’
(The above string is composed of strings and values of parameters.)
Number Expressions
Number expressions are used in the rule fields of a number parameter declaration, or in boolean expressions. The usual operators are:• + addition• - subtraction• * multiplication• / division
Functions• ESTA includes a full range of mathematical functions
ExamplesSalary – tax5 * 8 / x – 7 + y(sqrt(cos(x)*cos(x)+sin(x)*sin(x)) + 3) / 2
Boolean Expressions• Boolean expressions guide the logic of ESTA’s dialogThey consist of :
– boolean parameters– comparisons between number expressions– comparisons between strings– compound boolean expressions
• A boolean parameter may evaluate to true, false or unknown
• Examples– number_of_days_required / 7 < weeks_required– has_retired or is_unwell– date_of_birth < 1960 and owns_a_car
Parameters
• Parameters are like variables which determine the flow between the sections.
• A parameter can be any of the following four types:
– boolean parameter
– text parameter
– number parameter
– category parameter
• Any parameter can obtain a value in one of the following ways:
– From an answer to a question
– As a result of applying some rules
– An assignment resulting from an assign action
Parameters
The Decleration Fieldparameter <parameter-name> [:]<description text>
The description text is used to generate replies when a user ask HOW a certain value was established or WHY a certain piece of advice was given.
For boolean parameters ESTA phrase is:THE OBJECTIVE IS TO FIND OUT WHETHER <DESCRIPTION TEXT>
For number, text or catagory parameters, ESTA phrase is:THE OBJECTIVE IS TO ESTABLISH THE VALUE OF <DESCRIPTION TEXT>
Parameters
The Decleration Field
parameter owns_car ‘you own a car’
type boolean
ESTA will generate
THE OBJECTIVE IS TO FIND OUT WHETHER YOU OWN A CAR
Parameters
The Explanation Field• Text in the explanation field is reflected to the user upon ‘explain the
question’ request
parameter marital_status ‘the people are married’type category
explanation‘Marital status is determined by whether’ &‘there exists a marriage certificate for’ &name ‘and’ name_of_partner ‘ or not’
optionsmarried,unmarried.
question ‘What is the marital status of’ name ‘?’
Parameters
The Question Field• The question field is used when the value of a parameter is to be
determined by an answer to a question.
• If the question text is omitted, ESTA will generate a default text for the question, based on the description text of the decleration field and type of the parameter.
• For boolean parameters the default question text is:IS IT TRUE THAT <DESCRIPTION TEXT>
• For text, category and number:WHAT IS THE VALUE OF <DESCRIPTION TEXT>
Parameters
The Rules Field
• The rules field is used when a parameter’s value should be determined by rules and not by a question
• Examples
rules
‘blue’ if frequency < 1000,
‘orange’ if frequency >= 1000 and frequency < 2000,
‘red’ if frequency > 2000 and frequency < 3000,
‘invisible’.
Parameters
The Picture Field
The picture field is used to specify a picture that will be shown during the consultation.
The picture can be specified by the name of the picture from the picture database or the name of a parameter.
picture ‘cars’
/* cars is a picture name from the pictures db. */
picture car
/* car is a parameter name */
Boolean Parameter
parameter wet_weather ‘the weather is wet’
type boolean
explanation ‘It has been raining within the last few days or it is foggy’
question ‘Is the weather wet?’
• If the question is not provided ESTA will generate it as:IS IT TRUE THAT THE WEATHER IS WET?
Number Parameter
parameter height_cm ‘your height in cm’
type number
range 100 250
question ‘What is your height in cm?’
ESTA verifies if the input is a number and if range is given further validates if the number is within the range.
Text Parameterparameter name ‘the name of the user’type textquestion ‘What is your name?’
Category Parameterparameter car ‘the kind of car’type categoryexplanataion ‘Identify your car with one of the listed types’option
ambulance,policecar,sedan,van.
question ‘Which kind of car do you have?’picture ‘cars’
Sections
The actions that can be defined within a section are:
advice
assign
call
chain
do
exit
stop
Sections
section start : ‘the first section to be executed’if car_color = ‘red’(advice
‘your car is red, try to sell it to the fire brigade’,call sound(200, 100))
if car_color <> ‘red’ and car_color <> ‘blue’advice ‘Your car is not one of our favourite colors!’
advice ‘That’’s all folks!’
parameter car_color ‘the color of the car’type textquestion ‘What is the color of your car?’
Sections
AssignThe assign action is used to assign values to parameters.Examples
section start ‘a very short section to illustrate assign’assign n := 7 + 8 / 2advice ‘evaluation of 7 + 8 / 2 gives’ nassign n := (7 + 8) / 2advice ‘evaluation of (7 + 8) / 2 gives’ n‘as / has higher priority than +.’ &‘Notice that the parameter changed the value’
parameter n ‘n’type number
Sections
Chain
The chain action enables ESTA to consult new knowledge bases
Example
section start : 'Start section in the demo knowledge base'
if esta = 'information'(call display('uk_inf.txt'),chain '')
if esta = 'car' chain 'car.kb'
if esta = 'sanocor' chain 'sanocor.kb‘
Sections
parameter esta : ''type categoryexplanation 'You can choose to get information about
ESTA or to consult a knowledge base.'options information - 'Information about ESTA', car - 'Knowledge base about cars', sanocor - 'Knowledge base about health'./* rules */question 'Choose a subject to explore.'picture 'estademo'
Sections
Do
The do action transfers control to another section.
Example
section start : ‘first section to be executed’
if answer = ‘yes’ (do positive_section, do next_section)
if answer = ‘no' do negative_section
SectionsDo_section_of
section start : 'main section'do_section_of problem
parameter problem : 'the problem with your car'type categoryexplanation'Identify the problem with your car as closely as you can. Only those listed are dealt with in this
knowledge base.'options starting_problem - 'starting problems' overheating- 'the engine gets overheated' smell_of_gasoline - 'the car smells of gasoline' bad_running- 'the engine runs badly' brakes- 'the brakes' vibration- 'excessive vibrations' wiper_motor- 'the wiper motors' light_problem- 'the lights' horn_problem- 'a faulty horn'. question 'What is the problem with your ' car ' ?'picture car
SectionsExit
The exit action terminate consultation with the current knowledge base
StopThe stop action may be used to optimize rules written in a section. Execution
of a stop action indicates that no more actions are to be executed in the containing section.
SectionsCall
The call action is used to call one of the built in procedures in ESTA.
call clear_all() – clears all the parameter values in the current knowledge base
call clear_value (<parameter_name>) clears a particular parameter value in the current knowledge base
display(<filename>) displays the content of a text file in a window on the screen
Examples
call display(‘inform.txt’)
call display(‘c:\\info\\inform.txt’)
SectionsCall
Hyperadvice enables to activate a specific node in a Windows helpfile.The node is shown as a topic in the Windows hypertext help system.
Examplesection brakes 'problems with the brakes'
if brake_long_travel call hyperadvice('hypercar.hlp',8)if brake_poor call hyperadvice('hypercar.hlp',13)if brake_veer call hyperadvice('hypercar.hlp',14)if brake_spongy call hyperadvice('hypercar.hlp',17)if brake_springy call hyperadvice('hypercar.hlp',15)if brake_nonoperative call hyperadvice('hypercar.hlp',16)if brake_otherproblem (advice'This is a difficult problem, but perhaps one of the following is the cause: Maybe the shoes are installed incorrectly with do to leading and trailing ends Broken shoe return spring. Try to find the answer in the car manual',call hyperadvice('hypercar.hlp',5))
SectionsCall
Restore_values restores the ESTA parameters to settings previously saved in a data file.
This procedure is used in combination with chaining to other knowledge bases or communicating with external programs called within ESTA.
Example
call restore_values (‘c:\\esta\\setup.dat’)
Save_values(<filename>) saves in a datafile the settings of all parameters currently bound to a value.
Example
call save_values (‘c:\\esta\\setup.dat’)
SectionsCall
showpic(<picture-name>) displays a picture from the picture database.
Examplecall showpic (‘cars’)
sound (<number>, <number>) generates a sound through the computer’s loud speaker lasting the given duration, and with the given frequency.
Examplecall sound (10, 100)
System(command_string) is used to call other applications from ESTA Example
call system(‘myprog.exe’)
TitleTo represent the whole knowledge base a title can be used. The title can
either be a plain text or a picture.
Example
You can specify a picture as a title
*cars*
or
you can specify plain text as a title
Car Knowledge Base
Reasoning With Uncertainty
Certainty Factor• cf_and(P1, P2) -> P3
P3 is the lowest of the P1 and P2
• cf_or (P1, P2) -> P3P3 is the biggest of the P1 and P2
• cf_not(P1) -> P3P3 is (1-P1)
• cf_add(P1, P2) -> P3P1+P2*(1-P1) both P1, P2 > 0(P1+P2)/(1- min(abs(P1), abs(P2)) one of P1 or P2 <0-cf_add(-P1, -P2) both P1, P2 < 0
Reasoning With Uncertainty
section weather ‘example section’advice
‘The statement “it is very cold weather’’ is true with a certainty factor of’ cold_weather_cf
parameter cold_weather_cf ‘certainty factor for cold weather’type numberrange –1.0 1.0rules cf_add(cold_because_of_snow, cold_because_of_ice).parameter cold_because_of_icetype numberrange –1.0 1.0rules 0.8 if ice_on_the_river,-1.0.
Reasoning With Uncertainty
parameter cold_because_of_snow
type number
range –1.0 1.0
rules
0.7 if it_is_snowing,
-1.0.
parameter it_is_snowing ‘It is snowing’
type boolean
question ‘Is it snowing?’
parameter ice_on_the_river ‘there is ice on the river’
type boolean
question ‘Is part of the river frozen over?’
Reasoning With Probability
parameter prob ‘probability’type numberrules
1 if weight_loss and appetite_loss and fever and itching,0.67 if weight_loss and fever and itching,0.75 if weight_loss and appetite_loss and fever,0.6 if appetite_loss and fever and itching,0.5 if weight_loss and fever,0.5 if weight_loss and appetite_loss,0.35 if weight_loss and itching,0.5 if appetite_loss and fever,0.1 if itching.
parameter hodga ‘hodgin a’type booleanrules true if prob > 0.6.
Debugging
• Log of the consultation can be taken by opening a dialog box before consultation begins.
• File – new- new dialog– Begin consultation
– .......
– Stop consultation
– Investigate the consultation log
– Continue consultation
Pictures in ESTA
• Pictures are stored in PICTURES.DBA
• The ESTA system includes hotspot editor allowing the specification of selectable subfields in a picture
• This feature is used in conjunction with category parameters in which the options correspond to fields in the attached picture
DDE Communication
• DDE (Dynamic Data Exchange) is a Windows protocol that lets applications talk.
• ESTA can be interfaced to all Windows applications that support DDE.
• You can send data to applications, you can receive information from the application, you can even execute commands in the applications.
DDE Communication
• A conversation with a DDE server is created by the function:
dde_initiate(Application, Topic)
• This function returns a channel number used to identify the conversation
dde_execute(Channel, Command)
• Sends the commands in Command to the server for execution.Channel is the number returned from dde_initiate.
DDE Communication
dde_poke(Channel, Item, Data)
sends data to the server. Item specifies the destination.
• dde_poke(CH, “R1C1”, “hello”) inserts hello to row1, column1
dde_request(Channel, Item)
is used to retrieve a data item from the server.
DDE Communication
Example:
CH := dde_initiate(‘excel’, ‘file_a.xls’)
dde_poke_number(CH, ‘R2C4’, 546)
dde_execute(CH, ‘[OPEN(\034file_b.xls\034)]’
VAL := dde_request_number(CH, ‘R1C2’)
dde_terminate(CH)
Note: 034 is the ASCII code for “. Thus the command is [OPEN(“file_b.xls”)]
Homework
• Implement the following “A Medical Diagnosis Expert System” problem found on the link provided using ESTA.
http://www.comp.rgu.ac.uk/staff/khui/cm3016/coursework/CM3016%20coursework%200708.pdf