Example of advisory system

The most common rule-based programs are advisory systems. When I was learning Jess, I created system that helps with purchasing a new Peugeot car. The system is based on collected froum user informations of size, the required engine power, consumption, expectations relating to equipment and prices. User can easily choose the specific model from Peugeot catalogue.

The entire system is contained in one file. I created also a version enriched with graphical user interface, its description can be found on the next page. The program uses almost 60 rules based on 6 facts collected from the user. I would recommend to download the source code file, which I will describe below.

Download link

The system uses most of the features described in previous chapters of the course. If the tracking code below seems incomprehensible you have to go back to previous lessons, before starting to build systems with a graphical interface.

Below I describe some parts of the code:

(deftemplate carType (slot type)) ; tworzenie slotu na fakt
(printout t "Wybierz rodzaj samochodu " crlf)
(bind ?a (read))
(assert (carType(type ?a))) ;przypisanie wybranego rodzaju do zmiennej

After the acquisition of all the informatio inference engine starts work. Code includes a number of rules created using schemes given earlier in training section.

(run) ;uruchamia

(if (= ?*zmienna* 0) then
(printout t " " crlf
"Niestety dla wybranych przez Pana/Pania parametrow " crlf ))
;Konstrukcja informująca o braku dopasowań