expert system etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
expert system etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

12 Haziran 2009 Cuma

An example expert system with CLIPS - domain: ballistics

ast night, i developped a rule based system for balistics domain with clips. actually, i had developped an analog project with ESB (Expert System Builder) and the post is here: http://hilaltarakci.blogspot.com/2009/05/how-to-develop-expert-system.html

this is just a simple project to discover usage of rule based systems and expert system tools. this post includes the steps of development and the project files..

clips is a tool for building rule based systems and can be downloaded fromhttp://clipsrules.sourceforge.net/
i do not want to reinvent the wheel, so read this tutorial for using clips :http://iweb.tntech.edu/bhuguenard/ds6530/ClipsTutorial/CLIPS%20tutorial%201.htmthe tutorial consists of 6 parts. (try the addresses ....02.htm to ...06.html) a short and disciplinary tutorial, it helped me a lot..

the domain of the proposed system is balistics and the decision tree for the system is as follows:

In the above tree, rectangles represent the questions and triangles are the -probable- answers.

The .clp file for the above decision tree is:

(defrule compare-object
=>
(printout t "What do you want to compare (cartridge-case or bullet)?")
(assert (object-to-compare (read))))


(defrule comparable-ejector-mark
(object-to-compare cartridge-case)
=>
(printout t "Are the ejector marks comparable (yes or no)?")
(assert (ejector-mark-comparable (read))))


(defrule similar-ejector-mark
(and (object-to-compare cartridge-case)
(ejector-mark-comparable yes))
=>
(printout t "What is the similarity ratio of the ejector marks (high or low)?")
(assert (ejector-mark-similarity (read))))

(defrule comparable-pin-mark
(object-to-compare cartridge-case)
=>
(printout t "Are the pin marks comparable (yes or no)?")
(assert (pin-mark-comparable (read))))


(defrule similar-pin-mark
(and (object-to-compare cartridge-case)
(pin-mark-comparable yes))
=>
(printout t "What is the similarity ratio of the pin marks (high or low)?")
(assert (pin-mark-similarity (read))))

(defrule similar-breech-face
(object-to-compare cartridge-case)
=>
(printout t "What is the similarity ratio of the breech faces (high or low)?")
(assert (breech-face-similarity (read))))

(defrule comparable-set-mark
(object-to-compare bullet)
=>
(printout t "Is there a comparable set mark (yes or no)?")
(assert (set-mark-comparable (read))))


(defrule similar-set-mark
(and (object-to-compare bullet)
(set-mark-comparable yes))
=>
(printout t "Is there a highly similar set mark on the other bullet (yes or no)?")
(assert (set-mark-similarity (read))))

(defrule similar-other-set-marks
(and (object-to-compare bullet)
(set-mark-similar yes))
=>
(printout t "What is the similarity ratio when all the set marks are compared to their matching set marks taking the previously similar set mark as pivot (high or low)?")
(assert (other-set-marks-similarity (read))))

(defrule related-cartridge-cases1
(and (ejector-mark-similarity low)
(pin-mark-similarity low)
(breech-face-similarity low))
=>
(printout t "The cartridge cases are not related.")
(assert (related-cartridge-cases no)))

(defrule related-cartridge-cases2
(and (or (ejector-mark-similarity high)
(pin-mark-similarity high) )
(breech-face-similarity high))
=>
(printout t "The cartridge cases are highly probable that related, but better to consult an expert.")
(assert (related-cartridge-cases highly-probably-yes))))


(defrule related-cartridge-cases3
(and (or (ejector-mark-similarity high)
(pin-mark-similarity high) )
(breech-face-similarity low))
=>
(printout t "The cartridge cases are possible related, but better to consult an expert.")
(assert (related-cartridge-cases possibly-yes)))

(defrule related-cartridge-cases4
(and (ejector-mark-similarity low)
(pin-mark-similarity low)
(breech-face-similarity high))
=>
(printout t "The cartridge cases are possible not related, but better to consult an expert.")
(assert (related-cartridge-cases possibly-no)))

(defrule related-cartridge-cases5
(and (ejector-mark-similarity high)
(pin-mark-similarity high)
(breech-face-similarity low))
=>
(printout t "The cartridge cases are highly probably related, but consult to an expert for breech face differences.")
(assert (related-cartridge-cases highly-probably-yes))))

(defrule related-cartridge-cases6
(and (ejector-mark-similarity high)
(pin-mark-similarity high)
(breech-face-similarity high))
=>
(printout t "The cartridge cases are definitely related")
(assert (related-cartridge-cases yes)))

(defrule related-bullets1
(and (other-set-marks-similarity high)
(set-marks-similarity yes) )

=>
(printout t "The bullets are definitely related")
(assert (related-bullets yes)))

(defrule related-bullets2
(set-marks-similarity no)
=>
(printout t "The bullets are definitely not related")
(assert (related-bullets no)))


Open CLIPSWin.exe and load the above .clp file. You can examine facst and rules by (facts) and (rules) commands. Then type (run). The system will ask questions and generates the facts base according to the questions. You can examine the facts base after the run and you will see a set of facts are asserted during the run.. Here is a screenshot from CLIPS:

the end :)

27 Mayıs 2009 Çarşamba

How to develop an expert system

I am developing an expert system for a homework project. It is not a serious project, just a warm up :)

1.) download esb4 from http://www.esbuilder.com/esb4.zip (freeware) and set up.
2.) download javaESB v1 from http://www.esbuilder.com/JavaESB-v1.zip (freeware, but v2 is commercial)

esb4 includes a question editor, a knowledge acquisition and a user interface module. ( http://www.esbuilder.com/standard_esb.htm )

javaESB v1 is for web deployment, it uses the question files produced with esb4 through an applet. ( http://www.esbuilder.com/internet_esb.htm )

I hope to develop a decision supporting system about my domain, balistics.. The system will ask the user some questions about the domain and direct him/her according to the answers.


3.) Developing the program ->
- Enter the questions to the system with the ESB Question Editor. Assign importance of the questions and specify their dependency with each other. Save the .qst file which includes the questions. The interface is user friendly.

- Populate the knowledge base with ESB Knowledge Acquisition. This is accomplished by adding records to the system. At the end of a path of question, add the result. It may be an html file etc. When the user answers questions, it will get the most matching results (records saved with this program). Save the .dat file which includes the records.

- Examine the program with ESB User Interface. This is what the end user sees, a simulation of the program.

4.) JavaESB Instructions.doc document under JavaESB-v1 (downloaded at step 2) explains how to use the given applet. The document is pretty clear. Give the.qst and .dat files (prepared in the previous step )as QFile and DatFile parameters to the applet. Unfortunately the addon applet depends on crashed :( So, i tested my system with ESB User Interface module..