Re: JESS: Another rule that doesn't fire

2007-06-28 Thread Wolfgang Laun

Robert Kirby wrote:


Since the accumulate-NextTo pattern
 (accumulate (bind ?xcount 0) (++ ?xcount) ?xcount (NextTo (room1 ?rid)))
doesn't include a room2 match, shouldn't the pattern be matched just once for 
any one ?rid instantiation?  The documentation is not clear about what a token 
means: a match to a fact or a node in the Rete network.
 

Moving the (reset) down, just before (run), produces the expected 
result; so I guess my (naive?) expectations with respect to accumulate 
aren't entirely wrong:

--- 103 has 1 connections.
--- 102 has 2 connections.
--- 101 has 2 connections.
=== Suite 100 has 1 neighbours.
--- 100 has 1 connections.
5

Notice that NextTo is not meant to be symmetric, although common sense 
would indicate that forall x, y | x  y : NextTo(x,y) = NextTo(y,x). 
(This is a *very* mathematical hotel; you might say a mathel ;-)



Incidentally, deftemplate Room includes a default of false for a boolean slot.  Due to 
case sensitivity, the default should probably be FALSE.
 

OK, but not relevant for the problem. (I've changed things as compared 
to the original source.)

-W


Bob Kirby

At 08:39 AM 6/27/2007, Wolfgang Laun wrote:
 


Perhaps this is of interest: The original code had two rules - the only ones 
with accumulate - as the fifth and sixth rule between (reset) and (run), and 
the problem didn't surface until I added number 6.
-W

Ernest Friedman-Hill wrote:

   

This appears to be an incremental reset bug. The term incremental  
reset refers to the special processing that has to be done to bring  
a rule up to date if it's added to an already-populated working  
memory. Jess expects you to do things the other way around: compile  
the Rete network by defining all the rules, and then push the data  
through it; and indeed, if you move your reset to after the rules  
are defined, they both fire correctly.


Thanks for the report; we'll look into this further and get it fixed.

On Jun 27, 2007, at 10:34 AM, Wolfgang Laun wrote:

 

In the program below, Jess will only fire the second rule if both  
are uncommented, but each of them fires if the other one isn't  
there. If the order of rule definitions is reversed, the second one  
wins again.


Jess Version 7.0p1

Kind regards
Wolfgang

(clear)

(deftemplate Obj
 (slot id   (type STRING))
)

(deftemplate Room extends Obj
 (slot occupied (type SYMBOL)(default false)) ; Boolean
)

(deftemplate Suite extends Room
 (slot rooms (type INTEGER)))

(deftemplate Single extends Room)
(deftemplate Double extends Room)


(deftemplate NextTo
 (slot room1 (type STRING))
 (slot room2 (type STRING))
)

(deffacts fact-23
 (Suite  (id 100) (rooms 3))
 (Single (id 101))
 (Double (id 102))
 (Double (id 103))

 (NextTo (room1 100)(room2 101))
 (NextTo (room1 101)(room2 100))
 (NextTo (room1 101)(room2 102))
 (NextTo (room1 102)(room2 101))
 (NextTo (room1 102)(room2 103))
 (NextTo (room1 103)(room2 102))
)

(reset)

;;/***
(defrule oneNext
 Check that a suite has exactly one neighbour.
 (Suite (id ?rid))
 ?sn - (accumulate (bind ?xcount 0) (++ ?xcount) ?xcount
(NextTo (room1 ?rid)))
 (test (= ?sn 1))
 =
 (printout t === Suite  ?rid  has  ?sn  neighbours. crlf)
)
;;***/

;;/***
(defrule maxNext
 Check that no room is next to three or more.
 (Room (id ?rid))
 ?nc - (accumulate (bind ?count 0) (++ ?count) ?count
(NextTo (room1 ?rid)))
 (test (= ?nc 2))
 =
 (printout t  ---  ?rid  has  ?nc  neighbours. crlf)
)
;;***/

(run)



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 owner-jess- [EMAIL PROTECTED]

   


-
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com


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]

   



 




To unsubscribe, send the words 'unsubscribe jess-users 

JESS: Another rule that doesn't fire

2007-06-27 Thread Wolfgang Laun
In the program below, Jess will only fire the second rule if both are 
uncommented, but each of them fires if the other one isn't there. If the 
order of rule definitions is reversed, the second one wins again.


Jess Version 7.0p1

Kind regards
Wolfgang

(clear)

(deftemplate Obj
   (slot id   (type STRING))
)

(deftemplate Room extends Obj
   (slot occupied (type SYMBOL)(default false)) ; Boolean
)

(deftemplate Suite extends Room
   (slot rooms (type INTEGER)))

(deftemplate Single extends Room)
(deftemplate Double extends Room)


(deftemplate NextTo
   (slot room1 (type STRING))
   (slot room2 (type STRING))
)

(deffacts fact-23
   (Suite  (id 100) (rooms 3))
   (Single (id 101))
   (Double (id 102))
   (Double (id 103))

   (NextTo (room1 100)(room2 101))
   (NextTo (room1 101)(room2 100))
   (NextTo (room1 101)(room2 102))
   (NextTo (room1 102)(room2 101))
   (NextTo (room1 102)(room2 103))
   (NextTo (room1 103)(room2 102))
)

(reset)

;;/***
(defrule oneNext
   Check that a suite has exactly one neighbour.
   (Suite (id ?rid))
   ?sn - (accumulate (bind ?xcount 0) (++ ?xcount) ?xcount
  (NextTo (room1 ?rid)))
   (test (= ?sn 1))
   =
   (printout t === Suite  ?rid  has  ?sn  neighbours. crlf)
)
;;***/

;;/***
(defrule maxNext
   Check that no room is next to three or more.
   (Room (id ?rid))
   ?nc - (accumulate (bind ?count 0) (++ ?count) ?count
  (NextTo (room1 ?rid)))
   (test (= ?nc 2))
   =
   (printout t  ---  ?rid  has  ?nc  neighbours. crlf)
)
;;***/

(run)



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]




Re: JESS: Another rule that doesn't fire

2007-06-27 Thread Ernest Friedman-Hill
This appears to be an incremental reset bug. The term incremental  
reset refers to the special processing that has to be done to bring  
a rule up to date if it's added to an already-populated working  
memory. Jess expects you to do things the other way around: compile  
the Rete network by defining all the rules, and then push the data  
through it; and indeed, if you move your reset to after the rules  
are defined, they both fire correctly.


Thanks for the report; we'll look into this further and get it fixed.

On Jun 27, 2007, at 10:34 AM, Wolfgang Laun wrote:

In the program below, Jess will only fire the second rule if both  
are uncommented, but each of them fires if the other one isn't  
there. If the order of rule definitions is reversed, the second one  
wins again.


Jess Version 7.0p1

Kind regards
Wolfgang

(clear)

(deftemplate Obj
   (slot id   (type STRING))
)

(deftemplate Room extends Obj
   (slot occupied (type SYMBOL)(default false)) ; Boolean
)

(deftemplate Suite extends Room
   (slot rooms (type INTEGER)))

(deftemplate Single extends Room)
(deftemplate Double extends Room)


(deftemplate NextTo
   (slot room1 (type STRING))
   (slot room2 (type STRING))
)

(deffacts fact-23
   (Suite  (id 100) (rooms 3))
   (Single (id 101))
   (Double (id 102))
   (Double (id 103))

   (NextTo (room1 100)(room2 101))
   (NextTo (room1 101)(room2 100))
   (NextTo (room1 101)(room2 102))
   (NextTo (room1 102)(room2 101))
   (NextTo (room1 102)(room2 103))
   (NextTo (room1 103)(room2 102))
)

(reset)

;;/***
(defrule oneNext
   Check that a suite has exactly one neighbour.
   (Suite (id ?rid))
   ?sn - (accumulate (bind ?xcount 0) (++ ?xcount) ?xcount
  (NextTo (room1 ?rid)))
   (test (= ?sn 1))
   =
   (printout t === Suite  ?rid  has  ?sn  neighbours. crlf)
)
;;***/

;;/***
(defrule maxNext
   Check that no room is next to three or more.
   (Room (id ?rid))
   ?nc - (accumulate (bind ?count 0) (++ ?count) ?count
  (NextTo (room1 ?rid)))
   (test (= ?nc 2))
   =
   (printout t  ---  ?rid  has  ?nc  neighbours. crlf)
)
;;***/

(run)



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 owner-jess- 
[EMAIL PROTECTED]




-
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com


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]




Re: JESS: Another rule that doesn't fire

2007-06-27 Thread Wolfgang Laun
Perhaps this is of interest: The original code had two rules - the only 
ones with accumulate - as the fifth and sixth rule between (reset) and 
(run), and the problem didn't surface until I added number 6.

-W

Ernest Friedman-Hill wrote:

This appears to be an incremental reset bug. The term incremental  
reset refers to the special processing that has to be done to bring  
a rule up to date if it's added to an already-populated working  
memory. Jess expects you to do things the other way around: compile  
the Rete network by defining all the rules, and then push the data  
through it; and indeed, if you move your reset to after the rules  
are defined, they both fire correctly.


Thanks for the report; we'll look into this further and get it fixed.

On Jun 27, 2007, at 10:34 AM, Wolfgang Laun wrote:

In the program below, Jess will only fire the second rule if both  
are uncommented, but each of them fires if the other one isn't  
there. If the order of rule definitions is reversed, the second one  
wins again.


Jess Version 7.0p1

Kind regards
Wolfgang

(clear)

(deftemplate Obj
   (slot id   (type STRING))
)

(deftemplate Room extends Obj
   (slot occupied (type SYMBOL)(default false)) ; Boolean
)

(deftemplate Suite extends Room
   (slot rooms (type INTEGER)))

(deftemplate Single extends Room)
(deftemplate Double extends Room)


(deftemplate NextTo
   (slot room1 (type STRING))
   (slot room2 (type STRING))
)

(deffacts fact-23
   (Suite  (id 100) (rooms 3))
   (Single (id 101))
   (Double (id 102))
   (Double (id 103))

   (NextTo (room1 100)(room2 101))
   (NextTo (room1 101)(room2 100))
   (NextTo (room1 101)(room2 102))
   (NextTo (room1 102)(room2 101))
   (NextTo (room1 102)(room2 103))
   (NextTo (room1 103)(room2 102))
)

(reset)

;;/***
(defrule oneNext
   Check that a suite has exactly one neighbour.
   (Suite (id ?rid))
   ?sn - (accumulate (bind ?xcount 0) (++ ?xcount) ?xcount
  (NextTo (room1 ?rid)))
   (test (= ?sn 1))
   =
   (printout t === Suite  ?rid  has  ?sn  neighbours. crlf)
)
;;***/

;;/***
(defrule maxNext
   Check that no room is next to three or more.
   (Room (id ?rid))
   ?nc - (accumulate (bind ?count 0) (++ ?count) ?count
  (NextTo (room1 ?rid)))
   (test (= ?nc 2))
   =
   (printout t  ---  ?rid  has  ?nc  neighbours. crlf)
)
;;***/

(run)



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 owner-jess- 
[EMAIL PROTECTED]





-
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com


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]




Re: JESS: Another rule that doesn't fire

2007-06-27 Thread Robert Kirby
Since the accumulate-NextTo pattern
  (accumulate (bind ?xcount 0) (++ ?xcount) ?xcount (NextTo (room1 ?rid)))
doesn't include a room2 match, shouldn't the pattern be matched just once for 
any one ?rid instantiation?  The documentation is not clear about what a token 
means: a match to a fact or a node in the Rete network.

Incidentally, deftemplate Room includes a default of false for a boolean 
slot.  Due to case sensitivity, the default should probably be FALSE.

Bob Kirby

At 08:39 AM 6/27/2007, Wolfgang Laun wrote:
Perhaps this is of interest: The original code had two rules - the only ones 
with accumulate - as the fifth and sixth rule between (reset) and (run), and 
the problem didn't surface until I added number 6.
-W

Ernest Friedman-Hill wrote:

This appears to be an incremental reset bug. The term incremental  
reset refers to the special processing that has to be done to bring  
a rule up to date if it's added to an already-populated working  
memory. Jess expects you to do things the other way around: compile  
the Rete network by defining all the rules, and then push the data  
through it; and indeed, if you move your reset to after the rules  
are defined, they both fire correctly.

Thanks for the report; we'll look into this further and get it fixed.

On Jun 27, 2007, at 10:34 AM, Wolfgang Laun wrote:

In the program below, Jess will only fire the second rule if both  
are uncommented, but each of them fires if the other one isn't  
there. If the order of rule definitions is reversed, the second one  
wins again.

Jess Version 7.0p1

Kind regards
Wolfgang

(clear)

(deftemplate Obj
   (slot id   (type STRING))
)

(deftemplate Room extends Obj
   (slot occupied (type SYMBOL)(default false)) ; Boolean
)

(deftemplate Suite extends Room
   (slot rooms (type INTEGER)))

(deftemplate Single extends Room)
(deftemplate Double extends Room)


(deftemplate NextTo
   (slot room1 (type STRING))
   (slot room2 (type STRING))
)

(deffacts fact-23
   (Suite  (id 100) (rooms 3))
   (Single (id 101))
   (Double (id 102))
   (Double (id 103))

   (NextTo (room1 100)(room2 101))
   (NextTo (room1 101)(room2 100))
   (NextTo (room1 101)(room2 102))
   (NextTo (room1 102)(room2 101))
   (NextTo (room1 102)(room2 103))
   (NextTo (room1 103)(room2 102))
)

(reset)

;;/***
(defrule oneNext
   Check that a suite has exactly one neighbour.
   (Suite (id ?rid))
   ?sn - (accumulate (bind ?xcount 0) (++ ?xcount) ?xcount
  (NextTo (room1 ?rid)))
   (test (= ?sn 1))
   =
   (printout t === Suite  ?rid  has  ?sn  neighbours. crlf)
)
;;***/

;;/***
(defrule maxNext
   Check that no room is next to three or more.
   (Room (id ?rid))
   ?nc - (accumulate (bind ?count 0) (++ ?count) ?count
  (NextTo (room1 ?rid)))
   (test (= ?nc 2))
   =
   (printout t  ---  ?rid  has  ?nc  neighbours. crlf)
)
;;***/

(run)



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 owner-jess- [EMAIL PROTECTED]



-
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com


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]