Ernest,
could I ask to have a quick look at the code below meant to print the name
of the rule(s) which contributed to assertion of the pending need-xxx fact?
The problem I have with this code is that it generates the following error
after I modify a slot in a fact
Error during LHS execution
Jess reported an error in routine Node1TEQ.call
while executing rule LHS (TEQ)
while executing rule LHS (TECT)
while executing (modify 9 (troubling yes)).
Message: Error during LHS execution.
Program text: ( modify 9 ( troubling yes ) ) at line 1.
Here is my code:
Iterator my_itr = Rete.getEngine().listDefrules();
while (my_itr.hasNext() )
{
Defrule my_rule = (Defrule) my_itr.next();
ArrayList my_al = my_rule.getNodes();
for (int ij = 0; ij < my_al.size(); ij++)
{
if (my_al.get(ij) == this)
{
System.out.println("Rule that contributed to assertion of this
following need-xxx fact is : " + my_rule.getName());
}
}
}
I insert this code at the very end of the askForBackChain() method. Do I
make any mistake in it? Is there a better place to insert this code in this
method perhaps?
Thank you very much for your great help in advance,
Waldek
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of [EMAIL PROTECTED]
> Sent: 8 paYdziernika 2002 14:17
> To: [EMAIL PROTECTED]
> Subject: Re: JESS: Assertion of need-xxx facts
>
>
>
> 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]
> --------------------------------------------------------------------
>
--------------------------------------------------------------------
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]
--------------------------------------------------------------------