|
I am new to Jess so there may be something I am missing but
here goes. The modify function is defined as
"Modifies the given unordered fact in the fact list. The fact
must be an unordered fact. Each list is taken as the name of a slot in this fact
and a new value to assign to the slot. A new fact is asserted which is similar
to the given fact but which has the specified slots replaced with new values.
The original fact is retracted. The fact-ID of the new fact is returned.
Modifying a definstance
fact will cause the appropriate object properties to be set as
well."
Thus according to the documentation a new fact should be
asserted but with slot value changes. Unfortunately in jess 6.0 on Nt 4.0 (Jdk
1.2) it does not. I have included some simple code that illustrates the
"problem".
;;;===========================================================
;;; Simple modeling of the state of something ;;;=========================================================== (deftemplate state "Model the current state of requests" (slot current) (slot last) ) ;;; a process has a reference to a state
object
(deftemplate process (slot myname) (slot mystate) ) ;;; transition the state if we find a transition for a
particular process and the current states match
;;; retract the transition and change the current and last
state of the process
(defrule transition ?p <- (process (myname ?name) (mystate ?s)) ?t <- (transition ?p ?c ?n) (test (eq (fact-slot-value ?s current) ?c)) => (retract ?t) (printout t (fact-slot-value ?s current) crlf) (modify ?s (current ?n) (last ?c)) (printout t (fact-slot-value ?s current) crlf) ) ;;; create a state
(bind ?s1 (assert (state (current start) (last nil) ))) ;;; let process p1 reference the state s1
(bind ?p1 (assert (process (myname "foo") (mystate ?s1)))) ;;; issue a transition for p1 to go from start to
active
(assert (transition ?p1 start active)) ;;; issue a transition for p1 to go from active
to blocked; this one triggers
;;; only after the first
transition
(assert (transition ?p1 active blocked)) If I retract the fact and then assert a modified version of
the fact, it works as expected - the final state of the process should be
"blocked".
Sukesh Patel
|
- Re: JESS: Modify function Bug Sukesh Patel
- Re: JESS: Modify function Bug ejfried
