Further to the last message ...  it appears that just doing a second reset is enough to
have the definstance created facts deleted.

Bob.
 

The following was observed (Jess50a2) when 'playing' with Jess.

After running the pumps.clp example ... and doing some other things like asserting
the non-ordered fact (a b) ...

(facts)
f-0   (a b)
f-1   (pump (class <External-Address:java.beans.PropertyDescriptor>) (name pump1) (flow <External-Address:java.beans.PropertyDescriptor>) (OBJECT nil))
f-101   (tank (level 0) (low TRUE) (intact FALSE) (class <External-Address:java.lang.Class>) (high FALSE) (name "tank1") (OBJECT <External-Address:jess.examples.pumps.Tank>))
f-201   (tank (level 0) (low TRUE) (intact FALSE) (class <External-Address:java.lang.Class>) (high FALSE) (name "tank2") (OBJECT <External-Address:jess.examples.pumps.Tank>))
For a total of 4 facts.
TRUE
Jess> (reset)
 ==> (initial-fact)
 ==> (tank (level 0) (low TRUE) (intact FALSE) (class <External-Address:java.lang.Class>) (high FALSE) (name "tank2") (OBJECT <External-Address:jess.examples.pumps.Tank>))
 ==> (tank (level 0) (low TRUE) (intact FALSE) (class <External-Address:java.lang.Class>) (high FALSE) (name "tank1") (OBJECT <External-Address:jess.examples.pumps.Tank>))
TRUE

   ;;;;;;;;;; the definstance facts remain after reset as per Jess user guide

Jess> (facts)
f-0   (initial-fact)
f-1   (tank (level 0) (low TRUE) (intact FALSE) (class <External-Address:java.lang.Class>) (high FALSE) (name "tank2") (OBJECT <External-Address:jess.examples.pumps.Tank>))
f-2   (tank (level 0) (low TRUE) (intact FALSE) (class <External-Address:java.lang.Class>) (high FALSE) (name "tank1") (OBJECT <External-Address:jess.examples.pumps.Tank>))
For a total of 3 facts.
TRUE
Jess> (agenda)
For a total of 0 activations.
Jess> (retract 1)
 <==  (tank (level 0) (low TRUE) (intact FALSE) (class <External-Address:java.lang.Class>) (high FALSE) (name "tank2") (OBJECT <External-Address:jess.examples.pumps.Tank>))
TRUE

   ;;;;;;;;;;; after retracting one of these definstance facts

Jess> (facts)
f-0   (initial-fact)
f-2   (tank (level 0) (low TRUE) (intact FALSE) (class <External-Address:java.lang.Class>) (high FALSE) (name "tank1") (OBJECT <External-Address:jess.examples.pumps.Tank>))
For a total of 2 facts.
TRUE
Jess> (defclass simple jess.examples.simple.Simple)
jess.examples.simple.Simple
Jess> (defrule r2 (tank (level ?l)) => (printout t "Tank rul r1 fired ... level = " ?l crlf")
)
))
")))             <--- bad definition here --- ignore this
r2: +1+t
==> Activation: r2 :  f-2
TRUE
Jess> (defrule r2 (tank (level ?l)) => (printout t "Tank rul r1 fired ... level = " ?l crlf)))
<== Activation: r2 :  f-2
r2: +1+t
==> Activation: r2 :  f-2
TRUE
Jess> (run)
FIRE r2 f-2
Tank rul r1 fired ... level = 0
1

   ;;;;;;;;;;;;;; after proper definition of a rule it matches and fires OK

Jess> (reset)
 ==> (initial-fact)
TRUE
Jess> (facts)
f-0   (initial-fact)
For a total of 1 facts.
TRUE

   ;;;;;;;;;;;;;; what happened to the definstance fact? It was not retracted and reset
   ;;;;;;;;;;;;;; is supposed to preserve it.
 

On this same topic is the question ... Why does a reset NOT retract definstance facts?
I expect that one can argue for both sides of this. Certainly if I write a simple jess
program that has a 'startup' rule (as in the example pumps.clp) which creates some
definstance facts and then execute the program via (reset) and (run) and then
try to execute it again via (reset) and (run) it will (may) not behave as I expect it to.
The leftover definstance facts will be created again with new objects. This would lead
me to want the reset to clear the definstance facts. Presumably the objects created by
in the definstance calls will no longer have a reference and they will be gc'd at some
point by Java. Any comments on this or clarifications to my understanding of this?

Thanks, Bob.
 
 
 
 

Reply via email to