<?xml version="1.0"?>

<faq>

<entry>
<question>What is Jess?</question>

<answer>Jess is a tool for building a type of intelligent software
called Expert Systems. An Expert System is a set of <i>rules</i> that
can be repeatedly applied to a collection of <i>facts</i> about the
world. Rules that apply are <i>fired,</i> or executed. Jess uses a
special algorithm called <i>Rete</i> to match the rules to the
facts. Rete makes Jess much faster than a simple set of cascading
<i>if.. then</i> statements in a loop. Jess was originally conceived
as a Java clone of <A
HREF="http://www.ghg.net/clips/CLIPS.html">CLIPS</A>, but nowadays has
many features that differentiate it from its parent. You can learn
more about expert systems from the <a
href="http://www.cs.cmu.edu/Groups/AI/html/faqs/ai/expert/part1/faq.html">Expert
Systems FAQ</a> (which hasn't been updated in quite a while.)</answer>
</entry>

<entry>
<question>Who wrote Jess?</question>

<answer>Jess was written by Ernest Friedman-Hill at <a
href="http://www.sandia.gov">Sandia National Laboratories</a> as part
of an internal research project. The first version of Jess was written
in late 1995, when Java was very, very new. Jess has evolved
considerably since then! A large number of Jess users have contributed
code, suggestions, and patches; many of them are thanked by name in
the <a
href="http://www.jessrules.com/jess/docs/changes.html">Jess
Manual.</a></answer>
</entry>


<entry>
<question>What are the licensing issues surrounding Jess?</question>

<answer>Jess is and will always be available at no cost for academic
use worldwide, with an appropriate license. Commercial users can
purchase a Jess license by contacting Craig Smith at Sandia's
Technology Transfer office (email: <a href="mailto:casmith@sandia.gov">casmith@sandia.gov</a>.) The
licensing fees are negotiable and generally quite reasonable. You can
also purchase an inexpensive "Home Office" license.  
<P/> 
Jess is not licensed under the GPL, the LPGL, the BSD license, or any
other free software or open source license. Redistribution of the Jess
source code under any free software or open source license is
prohibited.
</answer>
</entry>

<entry>
<question>What versions of Jess are there?</question>

<answer>Often there is one "released" version and one "test" version
available for download at any one time. As of this writing, version
7.0p2 is the stable version, and 7.1b3 is the test version. Jess 6.1,
which works with JDK 1.2, Jess 5.2, an older release that works with
JDK 1.1, and Jess version 4.5, an even older release that is
compatible with JDK 1.0.2, are also available, but are not
supported. You are always encouraged to download and try out the test
version, if available.  </answer> </entry>

<entry>

<question>Where can I download Jess?</question>
<answer>From the official Jess home page at
<a href="http://www.jessrules.com/jess/">http://www.jessrules.com/jess</a>. 
There are no authorized mirror sites.</answer>
</entry>

<entry>
<question>
      How do I know if a rule-based solution is appropriate for my problem?
</question>
<answer>
      <a href="guidelines.shtml">An essay</a> by George Rudolph
      attempts to answer this question.
</answer>
</entry>

<entry>
<question>
      How can I learn to program with Jess?
</question>
<answer>
      <a href="zen.shtml">This essay</a> by Jason Morris
      is a great place to start.
</answer>
</entry>




<entry>
<question>Where can I get more information about Jess?</question>

<answer>From the official Jess home page at
<a
href="http://www.jessrules.com/jess/">http://www.jessrules.com/jess</a>. 
To work with Jess, it helps to know <a href="http://www.javaranch.com/">Java</a>, although it's not an absolute requirement.</answer>
</entry>

<entry>
<question>How do I make Jess run forever?</question>

<answer>The (run) function will stop running as soon as there are
no activated rules. This is not appropriate for some applications; for
example, an intelligent agent probably should keep running at all
times. Jess 5 introduces the (run-until-halt) function which will
run until (halt) is called. If there are no rules to fire,
run-until-halt suspends the calling Thread until new rules are activated.

<p/>
To keep the <tt>(run)</tt> command from ever returning in earlier
versions of Jess, you merely need to write a rule that will always be
activated. Mine generally looks like this:
<pre>
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; This fact will be used to sleep when idle

  (deffacts idle-fact
    (idle))

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; This rule will always be on the agenda! Make the salience
  ;; lower than any other rule.

  (defrule sleep-if-bored
    (declare (salience -100))
    ?idle &lt;- (idle)
      =&gt;
    (retract ?idle)
    (call java.lang.Thread sleep 100)
    (assert (idle)))
</pre>
This "idle rule" technique is useful in other contexts, too -- for
instance, as a way of updating a "timestamp" fact.

</answer>
</entry>

<entry>
<question>I'm having problems compiling an older verion of Jess. Why?</question>

<answer>The following are all the known issues with compiling older versions
of Jess. Please <a href="mailto:ejfried@sandia.gov">let me know</a>
of any others.

<ul>

<li> <b>Warnings about keyword <tt>assert</tt> in JDK 1.4</b>. Jess's
          Java code has included an important public member function
          named <tt>assert()</tt> since the first version. JDK 1.4
          introduces a new Java keyword, <tt>assert</tt>. These names
          conflict, so there is a warning. The JDK has a compatibility
          mode, though, and it compiles code that uses this function
          name just fine -- it just complains a little. Jess's
          <tt>assert()</tt> method is deprecated in Jess 6.1 and has
          been removed in Jess 7.</li>
        <p/>

<li> <b>Errors mentioning keyword <tt>assert</tt> in JDK 1.5</b>. The
        warnings given by JDK 1.4 turn into errors in JDK 1.5. To
        compile Jess 6.1 and earlier with JDK 1.5, you need to use the
        "-source 1.3" switch to javac. If you're building with the
        supplied Makefile, just add "-source 1.3" to the JAVAFLAGS line.</li>
        <p/>

<li> <b>Jess 5 and JBuilder.</b> Apparently JBuilder has problems with
some of the nested classes in the jess.RU class in Jess 5 and up. Here
is a suggested procedure from
<a href="mailto:barton@zeus.cas.suffolk.edu">Professor Louis Barton:</a>
<ol>
 <li> Build the project.</li>
 <li> The compiler will issue an error in RU.java; re-build RU.java <i>only</i>.</li>
 <li> Then run the applet.</li>
 <li> If the project source code subsequently changes, do a <tt>make</tt> only.</li>
</ol>
</li>
</ul>
</answer>
</entry>

<entry>
<question>Are there any known bugs in Jess?</question>

<answer>
<b>Delays with multiple <tt>jess.Rete</tt> objects in Jess 5.2.</b> In
      Jess 5.2, all <tt>Rete</tt> objects inadvertently share a single
      String object for use as the activation semaphore; this causes
      interference between multiple engines. To fix this, change line
      713 in jess/Rete.java to look like this:
<pre>
      private Object m_activationSemaphore = new String("ACTIVATION LOCK");
</pre>

Also have a look at the release notes in the development version of
Jess for news about any problems being addressed in new releases.

</answer>
</entry>

<entry>
<question>My expert system is slow. How do I speed it up?</question>

<answer>The performance of a Rete-based system depends not so much on
the number of rules and facts but on the number of partial matches
generated by the rules. The Jess manual mentions this briefly, but
there is a much better treatment in the Giarratano and Riley book
(also mentioned in the Jess Manual.) The classic example of writing
efficient rules looks like this: this rule

<pre>
(defrule match-1
  (item ?x)
  (item ?y)
  (item ?z)
  (item ?w)
  (find-match ?x ?y ?z ?w)
  => )
</pre>

is HORRIBLE, because it must form all possible permutations of 'item'
facts before finding the one permutation that matches the 'find-match'
fact. If there are 10 'item' facts, this is 10x10x10x10 = 10,000
partial matches are sent to the last join node - a lot of                      
bookkeeping! If you rewrite the rule like this:

<pre>
(defrule match-2
  (find-match ?x ?y ?z ?w)
  (item ?x)
  (item ?y)
  (item ?z)
  (item ?w)
  => )
</pre>

Then there is precisely one partial match sent to the last join
node - actually only one is sent to each join node. Whereas the first
rule might take several minutes to reset on a slow machine, the second
rule resets instantaneously.                                                                   
<p/>

The jess (view) command can be used to explore the efficiency of your
rules.</answer>
</entry>

<entry>

<question>Can Jess do fuzzy logic like FuzzyCLIPS?</question>

<answer>Bob Orchard, the creator of FuzzyCLIPS, has developed
a Fuzzy Java Toolkit and used it to create a fuzzy extension for
Jess. His FuzzyJess extension works with Jess 5.0 and later and
is available at
<a href="http://ai.iit.nrc.ca/IR_public/fuzzy/fuzzyJToolkit.html">http://ai.iit.nrc.ca/IR_public/fuzzy/fuzzyJToolkit.html</a> .)</answer>

</entry>

<entry>

<question>Can Jess do backwards chaining?</question>

<answer>Jess version 5 and up have built-in support for efficient backwards
chaining. See the <a
href="http://www.jessrules.com/jess/docs/52/language.html#chaining">Jess
manual</a> for details. Jess's backward chaining is a bit unorthodox,
so you may need to experiment to get used to it.</answer>

</entry>

<entry>
<question>How do I loop over all the facts my rule LHS matches?</question>

<answer> You're still thinking procedurally; that's not how you do
things in rule-based languages. Instead of trying to write this using
a loop in a rule that fires once, simply write a rule which matches
one fact on the LHS and processes that fact on the RHS. When you run
your program, the rule will fire once for each matching fact.</answer>
<P/>
If you <i>really</i> want to do this, however, have a look at
<tt>defquery</tt> in the Jess manual.
</entry>

<entry>
<question>
When I try one of the code examples in the Jess manual, I get an
exception. 
</question>
<answer>
The Jess manual is automatically tested, just like the rest of
Jess. Every code example in the manual is automatically executed and
the results compared against the manual for 100% accuracy before each
Jess release. If something you read in the manual is wrong, most of
the time what's happening is that you're using the wrong version of
the manual for the software you have. 
</answer>
</entry>

<entry>
<question>
I wrote a rule with a function call on the LHS, and it never fires. Why?
</question>
<answer>
The things on the left-hand side (LHS) of a rule aren't function
calls, they're patterns to be matched. So if you write the following
rule:

<pre>
(defrule rule-1
  (number ?x)
  (&lt; ?x 3)
  =>
  (printout t ?x " is less than 3." crlf))
</pre>

it won't work the way you expect. Instead of comparing ?x to 3, the
line (&lt; ?x 3) is a pattern that matches facts like (&lt; 2 3) and (&lt; 27
3). Since you probably don't have any such facts, this rule will never
fire. If you want to write a pattern that consists solely of a
function call, use the <tt>test</tt> CE. 

<pre>
(defrule rule-2
  (number ?x)
  (test (&lt; ?x 3))
  =>
  (printout t ?x " is less than 3." crlf))
</pre>
</answer>
</entry>

<entry>
<question>
I wrote a rule with a function call on the LHS, and it fires even when
it shouldn't. Why?
</question>

<answer>
See the previous question. You've probably written a function call
surrounded by a <tt>not</tt> conditional element:

<pre>
(defrule rule-3
  (number ?x)
  (not (&lt; ?x 3))
  =>
  (printout t ?x " is not less than 3." crlf))
</pre>

the second pattern is true whenever there are no facts that look like
(&lt; 39 3). Since you probably don't have any such facts, this condition
will always be met, and the rule will always fire. You can rewrite
this with a <tt>test</tt> conditional element:

<pre>
(defrule rule-4
  (number ?x)
  (test (not (&lt; ?x 3)))
  =>
  (printout t ?x " is not less than 3." crlf))
</pre>
</answer>
</entry>

<entry>
<question>
      I get a stack trace with the error message "Error during
      execution" or "Called method threw an exception." What's going
      on? 
</question>
<answer>
      While Jess was running, it called a Java method that threw an
      exception other than <tt>JessException</tt>. Because Jess's
      methods are declared to only throw <tt>JessException</tt>, Jess
      had to wrap the foreign exception inside a
      <tt>JessException</tt> and rethrow it. Thus the exception you're
      looking at is just a wrapper for the real problem exception.

       <p/>

      The <tt>JessException</tt> class has a method <tt>getCause</tt>
      which returns non-null when a particular <tt>JessException</tt>
      is a wrapper for a foreign
      exception. <tt>JessException.getCause()</tt> will return the
      real exception that was thrown. Your <tt>JessException</tt>
      handlers should always check <tt>getCause()</tt>; if your
      handler simply displays a thrown exception, then it should
      display the return value of <tt>getCause()</tt>,
      too. 
</answer>
</entry>
<entry>
<question>
      When I try to use Jess in my Java program, I get a stack trace
      that includes the method "Rete.loadScriptLib()." What's wrong?
</question>
<answer>
      There's a file "scriptlib.clp" inside the "jess" package --
      i.e., it's in the same directory as Rete.class . If you're
      compiling and deploying your own copy of Jess from source, then
      you must include this file along with the .class files when you
      deploy Jess. It must remain in the "jess" directory.
</answer>
</entry>

<entry>
<question>
Why doesn't <tt>jess.jar</tt> have a <tt>Main-Class</tt> attribute so
that I can double-click it and launch Jess?
</question>
<answer>
This is deliberate. If you launch Jess that way, the Java classloader
will not load any classes from outside jess.jar; Jess will be a closed
system. This doesn't happen if you run it the way we suggest.
</answer>
</entry>

<entry> <question> When is the next version of Jess coming out?
</question> <answer> Jess 7.1b3 was released on April 2nd,
2008. We expect Release Candidate 1 for Jess 7.1 to follow
in a few weeks.  </answer> </entry>

<entry>
<question>
I have the JessDE installed. I upgraded some other Eclipse plugins and
installed some new ones using the automatic update feature, and now
the JessDE has completely disappeared! I don't see any "clp" file
icons, no "clp" file editor, nothing. What's going on?
</question>
<answer>
Some users have reported that updating other Eclipse features can
cause the JessDE plugins to be disabled. We don't know why this
happens, but we know what to do: open the dialog box at Help > Software Updates >
Manage Configuration in Eclipse, and enable the JessDE feature.
</answer>
</entry>



</faq>
