Hi all,
I wonder if I can get some help with the following problem. I am trying to
do event aggregation through Jess rules. For example, I want to determine
when 2 users are spotted at the same time by a camera. For that I have
defined a rule that looks like this:
(defrule peopleToguether "Indicates when there are two people toguether"
(TRIPevent (eventAtomID ?eventID1) (TRIPcode ?user1) (cameraID
?camera1))
(TRIPevent (eventAtomID ?eventID2&~?eventID1) (TRIPcode
?user2&~?user1) (cameraID ?camera1))
(targetPosition (eventAtomID ?eventID1) (x ?x1) (y ?y1) (z ?z1))
(targetPosition (eventAtomID ?eventID2) (x ?x2) (y ?y2) (z ?z2))
(test (> 5 (sqrt (+ (* (- ?x1 ?x2) (- ?x1 ?x2)) (* (- ?y1 ?y2) (- ?y1
?y2)) (* (- ?z1 ?z2) (- ?z1 ?z2))))))
=>
(printout t ?user1 " is in company of " ?user2 " " ?eventID1
" " ?eventID2 " " ?camera1 crlf)
(bind ?distance (sqrt (+ (* (- ?x1 ?x2) (- ?x1 ?x2)) (* (- ?y1 ?y2) (-
?y1 ?y2)) (* (- ?z1 ?z2) (- ?z1 ?z2)))))
(printout t "Distance: " ?distance crlf))
The problem is that given two facts, such as:
"Diego seen by camera1" and "John seen by camera1"
, the above rule fires twice, the first time associating ?user1 with Diego
and ?user2 with John and the following time the other way around. A
workaround to sort out this problem would be to assert a new fact to
indicate that this rule has triggered and append to the LHS of the rule
something like: (not (people-toguether ?user1 ?user2))
However, I wonder if there is another more smarter way to do it. Moreover
I can not fully comprehend why the rule fires twice and not simply
once. Any reasons please?
On the other hand, I tried to modify the above rule in order to sort out
my problem by using the following OR logical patter in the lhs of the
rule:
(defrule peopleToguether "Indicates when there are two people toguether"
(or (and (TRIPevent (eventAtomID ?eventID1) (TRIPcode ?user1) (cameraID
?camera1))
(TRIPevent (eventAtomID ?eventID2&~?eventID1) (TRIPcode
?user2&~?user1) (cameraID ?camera1)))
(and (TRIPevent (eventAtomID ?eventID2&~?eventID1) (TRIPcode
?user2&~?user1) (cameraID ?camera1))
(TRIPevent (eventAtomID ?eventID1) (TRIPcode ?user1) (cameraID
?camera1))))
(targetPosition (eventAtomID ?eventID1) (x ?x1) (y ?y1) (z ?z1))
(targetPosition (eventAtomID ?eventID2) (x ?x2) (y ?y2) (z ?z2))
(test (> 5 (sqrt (+ (* (- ?x1 ?x2) (- ?x1 ?x2)) (* (- ?y1 ?y2) (- ?y1
?y2)) (* (- ?z1 ?z2) (- ?z1 ?z2))))))
=>
(printout t ?user1 " is in company of " ?user2 " " ?eventID1
" " ?eventID2 " " ?camera1 crlf)
(bind ?distance (sqrt (+ (* (- ?x1 ?x2) (- ?x1 ?x2)) (* (- ?y1 ?y2) (-
?y1 ?y2)) (* (- ?z1 ?z2) (- ?z1 ?z2)))))
(printout t "Distance: " ?distance crlf))
When I parse this rule the Jess engine complains saying:
Jess reported an error in routine Jesp.parsePattern.
Message: Bad slot value .
Program text: ( defrule peopleToguether "Indicates when there are two
people toguether" ( or ( at line 166
Could any of you please let me know what is not right in the OR pattern
with nested ANDs? I don't get it. I hope my questions are not too basic.
Thanks a lot for all your help in advance,
-----
Diego Lopez de Ipina
http://www-lce.eng.cam.ac.uk/~dl231
---------------------------------------------------------------------
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]
---------------------------------------------------------------------