I think Waldek Jaronski wrote: > Hello, > > is it possible to trace the name of the rule(s) which triggered assertion of > a need-XXX fact? It would be very handy to know it for debugging purposes > when you apply backward chaining. >
Well, as you know, Jess compiles rules into a network of pattern-matching nodes. It doesn't explicitly keep a list of every rule that contributes to a given node. Jess does, however, keep a list of all the nodes that a given rule contributed to; the package-protected method "getNodes" in HasLHS returns this list. The method askForBackchain in jess/Node2.java is the method that creates the backward-chaining facts, so if you wanted to add this debugging capability, here's what you could do: 1) in Node2.askForBackchain(), call Rete.getEngine().listDefrules() to get an Iterator over all the rules 2) For each rule, call getNodes() to get the list of nodes for that rule 3) In the list, search for "this" (the Node2 object) 4) If found, print a debugging message for this rule. This would be slow, but for debugging this shouldn't matter. --------------------------------------------------------- Ernest Friedman-Hill Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 Org. 8920, MS 9012 [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 (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
