Installation of Jess:

 

1)      Unpack the file Jess71p2.zip in its own folder, let’s assume that is c:\Jess71p2

2)      You have a subfolder there, called “eclipse”. The files from it are zip files, which must be extracted directly in the base folder of eclipse. Let’s assume that is c:\eclipse. Then you should unpack the files on that folder. Inside the archives are subfolders and files which follow the structure of eclipse’s folders. So, at the end you should have in the c:\eclipse\plugins some folders which start with “gov.sandia.jess”. If you have that, then you unpacked it correctly.

3)      Start Eclipse. Create a new project in Eclipse. Create a new file (Right click the project’s name, choose New, then file, then name the file unu.clp) You will thus create your first JESS file.

4)      The editor will help you with the syntax. You can run your project as you do normally with Java projects.

5)      Your JESS program, unless it ends with the (run) predicate does nothing

 

Installation of CLIPS:

 

1)      Unpack the file clipswin_executable_6241.zip into it’s own folder. Let’s assume it is: c:\CLIPS

2)      Enter the folder and run CLIPSWin.exe, and you have a Windows program application in which you can write yout CLIPS programs

 

Observations:

1)      Both CLIPS and JESS are Expert System creation tools, the language syntax is the same.

2)      CLIPS is free JESS is a trial version, usable for 30 days

3)      The documentation for CLIPS (which is god also for JESS, since it has the same syntax) is in the CLIPS folder.

4)      Other documentation about Expert Systems is in the book by Giarratano and Riley located in the documentation folder.

 

Alternative way of testing simple Jess programs: http://www.jessrules.com/jessdemo/

On that site is a demo of the sticks game, you can end the game and enter your programs in the following manner:

1)      You are asked to respond to the question who moves first? The answer:    h

2)      Next question: how many sticks in the pile? The answer: 1

3)      You lose, play again? The answer: n

4)      Now you have the Jess> prompter and you can enter your own facts, rules and run them

 

For today’s lab, from the Giarratano-Riley book from the documentation folder,  CLIPS is described starting with page 327 (338 in the text box for inputting the page number).

Also, you can consult the file “User’s Guide” (ug.pdf) from the documentation that comes with CLIPS (the CLIPS subfolder)

For today we should learn:

  1. How to write facts (using assert and using deffacts)
  2. How to define simple rules (defrule)
  3. The use of the (reset) predicate
  4. The use of the (run) predicate
  5. The use of the (printout t "message") command
  6. The use of the (retract ) command
  7. (save-facts) and (load-facts)
  8. Variables (page 41 (51) from ug.pdf)
  9. A concise primer of today’s work can be found at: http://www.csie.ntu.edu.tw/~sylee/courses/clips/intro.htm
  10. There it is about CLIPS. For loadind and running jess programs stored in a file you should use the (batch <filename>) construct instead. Examples:
    1. (batch 1.clp)   

Will load the file 1.clp from the same folder as Jess (or from the project’s folder if you can use eclipse)

2.      (batch c:\\temp\\unu.clp)

Will load the file from the specified folder (in Windows). Remember to dDouble the backslashes, as in the example.

3.      (batch /tmp/doi.clp)

4.      Will load the specified file (under linux). The path is a absolute one, it starts with /

An example of a simple Jess/CLIPS “program” is:

(deffacts set-de-fapte

(culoare alb)

(culoare violet)

(culoare verde)

)

(reset)  /*erases the facts from the working memory, adding the above ones */

(defrule print-colors

(culoare ?x)

=>

(printout t :culoare: “ ?x)

)

(defrule retract-colors-not-violet

?address <- (color ?x)   /* locates a fact and stores it’s address */

(test (neq ?x violet))  ; if ?x is not violet */

=>

(retract ?address)  /* retracts the fact that matches the condition

)

(run) /* matches the facts with the rules , thus “running” the program */

(facts)

 

 

Observation: When you copy/paste some code, the quotation marks (from the HTML file) generally are incorrect and are not recognized by CLIPS/Jess, so you need to correct them.

Some other examples can be found here:

lab1.zip

Exercise:

1)      Model in CLIPS (JESS) the vacuum cleaner world described in [R 3/ slide 8], writing:

a.       Facts describing: the world, the vacuum-cleaner position;

b.      Rules for the vacuum-cleaner actions, as a side-effect the rules will print what happens

2)      Model in JESS the wumpus world described in [R 7 / slide 5] writing:

a.       Facts describing: the world, the vacuum-cleaner position;

b.      Rules for the vacuum-cleaner actions, as a side-effect the rules will print what happens