I think Olivier Causse wrote:
>
> Here is my problem with (facts) function :
> (I use color to differenciate execution traces in black from comments in
> blue.
> I hope it is convenient ;-)
Actually, not for me; I read my mail via telnet to a UNIX
box. HTML-only mail is a bad idea to mailing lists, I think. HTML plus
plain-text is a much better choice. plain-text only is, of course,
the best choice :)
> -------------------Execution trace
> >java jess.Main
>
> Jess, the Java Expert System Shell
> Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
> Jess Version 5.0a4 3/18/99
>
> Jess> (deffacts idle-fact (idle))
> TRUE
> Jess> (facts)
> For a total of 0 facts.
> Jess>
> --------------------------------
>
> Why (idle) fact is not taken into account ?
The facts in a (deffacts) are not asserted until a (reset). Whenever
you cal (reset) again, all the facts on the fact-list are removed, and
then all the facts in deffacts are reasserted. That's just how it works.
>
> Second try :
> -----------------------------------
> Jess> (defrule facts-try
> ?idle <- (idle)
> =>
> (facts)
> (retract ?idle)
> )
>
> TRUE
> Jess> (run)
> 0
> Jess> (assert (idle))
> <Fact-0>
> Jess> (run)
> f-0 (idle)
> For a total of 1 facts.
> 1
> Jess>
Do you see something wrong with this? THis is fine.
> --------------------------------
>
> Third try , the same rule "facts-try" is used in a bigger program, in which
>
> several user-modules are loaded using the suggested method :
>
> ------------------
> String [] packages = { "jess.StringFunctions",
> "jess.PredFunctions",
> "jess.MultiFunctions",
> "jess.MiscFunctions",
> "jess.MathFunctions",
> "jess.BagFunctions",
> "jess.reflect.ReflectFunctions",
> "jess.view.ViewFunctions" };
>
> for(int i=0; i< packages.length; i++) {
> try {
> rete.addUserpackage((Userpackage)
> Class.forName(packages[i]).newInstance());
> } catch (Throwable t) {
> /* Optional package not present */
> System.err.println("WARNING : package " + packages[i] + "not
> present.");
> }
(facts) is now implemented in Jess code in the script library
(jess/scriptlib.clp). This is mentioned in the manual, but the manual
doesn't yet describe the need to load this library if you're embedding
Jess in your own Java program. See the method jess.Main.initialize()
for the current correct initialization sequence. You are encouraged to
use this class rather than cutting and pasting the code.
new Main(new String[] {}, rete);
gives you everything you do above, and more. One of the neat things
that Main.initialize() does is install an event handler so that if the
Rete engine executes (cl;ear),the script library is
reloaded. Otherwise it would make these functions (bing Jess
deffunctions) disappear.
> -----------------------
> And it produces the following trace :
> -----------------------
> FIRE facts-try f-1
> Rete Exception in routine Context::expandAction while executing defrule
> facts-try.
> Message: Unimplemented function facts at line 0: ( run 1 ) .
> at java.lang.Throwable.<init>(Compiled Code)
> at java.lang.Exception.<init>(Compiled Code)
> at jess.ReteException.<init>(ReteException.java:29)
> at jess.Context.expandAction(Compiled Code)
> at jess.Defrule.fire(Compiled Code)
> at jess.Activation.fire(Activation.java:60)
> at jess.Rete.run(Compiled Code)
> at jess.HaltEtc.call(Funcall.java:1591)
> at jess.Funcall.simpleExecute(Funcall.java:341)
> at jess.Funcall.execute(Compiled Code)
> at jess.Funcall.execute(Funcall.java:201)
> at jess.Jesp.parseAndExecuteFuncall(Jesp.java:1413)
> at jess.Jesp.parseSexp(Jesp.java:171)
> at jess.Jesp.parse(Compiled Code)
> at jess.Rete.executeCommand(Rete.java:1347)
> at InteractionManager.run(Compiled Code)
> ------------------------------------
>
> Any hints are welcome,
> Olivier Causse
>
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9214 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
>
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------