On Rules

Over the last few weeks nights and weekends I’ve played around with Jess studying up on rules engines and expert systems. The approach of focusing on the limited reality defined by the facts and rules in the universe of the engine along with letting go of control of sequencing are surprisingly freeing. Memories of event loops, OOAD, OOP, multimethods, state machines, horribly hand-written code, and event handlers all come to mind. It is fascinating to see how well some things can be simplified. It makes me wonder why we ever choose one approach over another. Supposedly we always use the best tool for the job; but in practice most of us learn one halfway decent approach (“tool”) once and end up using it forever. I suppose that is a human trait and not unique to problem solving with programming languages.

Installing Jess 71p2 in Eclipse 4.2

  1. Downloaded “Eclipse IDE for Java Developers”.
  2. The file name is “eclipse-java-juno-SR1-win32.zip”.
  3. This is release number 4.2 (Juno).
  4. Extracted the archive. Started Eclipse and stopped it.
  5. Extracted Jess plugins to the desired dir.
  6. Started Jess. Verified it’s presence.
  7. Installed GEF by using the built in “Juno” repository and searching for “GEF”. It showed up under “Modeling”. The installation took 10 minutes.
  8. Restarted Eclipse.

When you run this sample program:

(reset)
; define the counter
(deftemplate counter
  (slot count (type integer) (default 0)))
; define the rule
(defrule switchme
  ?p <- (counter {count < 10})
  =>
  (printout t ?p.count crlf)
  (bind ?p.count (+ ?p.count 1)))
; initialise counter
(deffunction init ()
  (assert (counter (count 1))))
;initialise program
(init)
;run program
(run)

Then you get a nice structure breakdown and syntax-highlighting:

You can set breakpoints and get debug information:

Here is the Rete network:

Good to know it is available, not that I know the value of it yet! I’m just investigating the plugins.
Next step is to do the studying!