Hi Dan,
This certainly looks like a bug, but alas, I can't reproduce it here;
after mant runs, I haven't seen the exception.
Perhaps you could help me out. At about line 165 in
jess/NodeNot2.java, you'll see the exception in question being
thrown. Could you insert print statements as follows before the throw:
System.out.println(lt);
System.out.println(rt);
and mail whatever gets printed out back to me? I'd be much obliged.
The lack of removePropertyChangeListener -is- a bug, but one I knew about.
I think Larner, Dan wrote:
>
> I'm not sure whether I've hit a bug, misunderstand what I'm
> doing (it's happened before!-), or misunderstand what's
> legal to do in Jess 5.0a2. (I'm using MS Visual J++ 6).
>
> Basically I'm trying to have a running rete (actually calling
> (run 1) repeatedly from Java), and be able to add and remove
> java objects (definstances) from it.
>
> To experiment with this, I modified the pumps example,
> MainInJava.java file as shown at the end of this message.
> [and to speed things up, I changed
> line 72 in Tank.java to addWater(-20);
> and
> line 36 in pumps-fromjava.clp to (set ?pump flow (+ ?flow-rate 1))
> ]
>
> I run for a while with the main tank and pump. Then, after
> a bit, I add another tank and pump using definstance.
>
> Sometimes, but not always, after I do these additions,
> I'll get an exception (see below) while calling rete.executeCommand("(run
> 1)");
>
> Rete Exception in routine NodeNot2::RunTestsVaryLeft while executing rule
> LHS:
> [NodeNot2 ntests=1 [Test2:
> test=EQ;tokenIdx=0;leftIdx=2;leftSubIdx=-1;rightIdx=2;rightSubIdx=1]
> ;usecount = 1] while executing defrule raise-rate-if-low.
> Message: Corrupted Negcnt (< 0) at line 0: ( run 1 ) .
>
> After a bit more, I remove the main tank and pump from rete using
> undefinstance [ It's interesting to note that the tank and pump
> removePropertyChangeListener don't get called during this -- shouldn't
> these get called?]
>
> After the undefinstance sometimes, but not always, I'll get (the same)
> exception on
> the next call to rete.executeCommand("(run 1)");
>
> Rete Exception in routine NodeNot2::RunTestsVaryLeft while executing rule
> LHS:
> [NodeNot2 ntests=1 [Test2:
> test=EQ;tokenIdx=0;leftIdx=2;leftSubIdx=-1;rightIdx=2;rightSubIdx=1]
> ;usecount = 1] while executing defrule raise-rate-if-low.
> Message: Corrupted Negcnt (< 0) at line 0: ( run 1 ) .
>
>
> Sometimes I'll actually run to completion. Now I'm sure the 'sometimes'
> parts are due
> to thread timing. I was thinking that my running the rete by
> repeated calls to (run 1) would be safe. My best guess (without really
> diving into the Jess code) is that this is possibly wrapped up in rule
> agendas/activations.
>
> Any thoughts?
>
>
> -- Dan
>
>
> public class MainInJava
> {
> public static void main(String[] argv) throws ReteException
> {
> Rete rete;
> Tank t, t2 = null;
> Pump p, p2 = null;
> Funcall f;
> int i_count = 0;
> Value pv;
>
> try {
> rete = new Rete();
> rete.addUserpackage(new MiscFunctions());
> rete.addUserpackage(new
> jess.reflect.ReflectFunctions());
>
> // Read in the rules
> rete.executeCommand("(batch
> /larner/jesspumps/pumps-fromjava.clp)");
> rete.executeCommand("(reset)");
> // Create the Beans
> t = new Tank("MAIN");
> p = new Pump("MAIN", t);
>
> // Tell Jess about them
> f = new Funcall("definstance", rete);
> f.add(new Value("pump", RU.ATOM));
> f.add(new Value(p, RU.EXTERNAL_ADDRESS));
> pv = f.simpleExecute(f, rete.getGlobalContext());
>
> f = new Funcall("definstance", rete);
> f.add(new Value("tank", RU.ATOM));
> f.add(new Value(t, RU.EXTERNAL_ADDRESS));
> f.simpleExecute(f, rete.getGlobalContext());
>
> while (true) {
> rete.executeCommand("(run 1)");
> i_count++;
> if (i_count == 10) {
> t2 = new Tank("Secondary");
> p2 = new Pump("Secondary", t2);
> // Tell Jess about them
> f = new Funcall("definstance",
> rete);
> f.add(new Value("pump", RU.ATOM));
> f.add(new Value(p2,
> RU.EXTERNAL_ADDRESS));
> f.simpleExecute(f,
> rete.getGlobalContext());
>
> f = new Funcall("definstance",
> rete);
> f.add(new Value("tank", RU.ATOM));
> f.add(new Value(t2,
> RU.EXTERNAL_ADDRESS));
> f.simpleExecute(f,
> rete.getGlobalContext());
> System.out.println("--- Secondary
> tank and pump added to rete ---");
>
> }
> if ((t != null) && (t.getLevel() < 200)) {
> // remove main tank and pump from
> rete
> f = new Funcall("undefinstance",
> rete);
> f.add(new Value(p,
> RU.EXTERNAL_ADDRESS));
> pv = f.simpleExecute(f,
> rete.getGlobalContext());
> // return from simpleExecute is true
>
> f = new Funcall("undefinstance",
> rete);
> f.add(new Value(t,
> RU.EXTERNAL_ADDRESS));
> f.simpleExecute(f,
> rete.getGlobalContext());
> // return from simpleExecute is true
> System.out.println("--- Main tank
> and pump removed from rete ---");
>
> t = null;
> p = null;
>
> }
>
> if ((t2 != null && !t2.isIntact()) ||
> i_count > 500)
> break;
> }
> }
> catch (Exception e) {
> System.out.println("Exception thrown\n" + e);
>
> }
> System.out.println("DONE");
> }
>
> }
>
>
>
> Dan Larner, [EMAIL PROTECTED]
> Xerox PARC, 3333 Coyote Hill Rd., Palo Alto, CA, USA 94304
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
>
>
---------------------------------------------------------
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]
---------------------------------------------------------------------