Hi Wolfgang, thanks for the proposed solution. My case is a little more complex than this.
Because of the data skew and possibility of missing events, i keep the initial facts in working memory for a long period of time (48hrs at current settings, to allow delayed comms) So the computation would become burdensome as each new open close fact entered working memory and was tested against every existing fact. I was hoping to have one list type construct that each new fact can be judged against and then included in that construct, then when the 48hrs are up, pairs can be picked off the construct like removing the head of a list, at which point the initial facts can be retracted. So pseudo code ---- assert OPEN 0845 open is added to list, no computation as list is empty assert OPEN 0815 open is added to the list, ahead of OPEN 0845 as time0815 < time0845 (same happens for close on its list construct) (48 hrs pass) rule fires to remove head of both lists, assert an access fact and retract the open and close facts that generated the initial list entries ---- I have been perusing this idea and trying to relate it to multislots or have an extra slot for an index number to represent the elements of the list, but i'm new to multislots Any help would be appreciated. Thanks Gary Wolfgang Laun wrote:
As you state it, there is no need to sort all open and close events so that you can combine an OPEN to ist closest CLOSE. The conditions that define, for any OPEN, the matching CLOSE are simple enough: deftemplate Open (slot time)) (deftemplate Close (slot time)) (deftemplate Access (slot begin)(slot end)) (defrule MatchOpenClose "For any matching OpenClose, create an Access" ?open <- (Open (time ?otime)) ; a matching CLOSE must not be earlier ?close <- (Close (time ?ctime &:(>= ?ctime ?otime))) ; there must not be a closer CLOSE (not (Close (time ?xtime &:(< (- ?xtime ?otime)(- ?ctime ?otime))))) => (retract ?open) (retract ?close) (assert (Access (begin ?otime)(end ?ctime))) ) (deffacts Opcl (Open (time 845)) (Open (time 1045)) (Close (time 900)) (Close (time 1115)) (Open (time 1215)) (Close (time 1215)) ) (reset) (run) (facts) f-0 (MAIN::initial-fact) f-7 (MAIN::Access (begin 845) (end 900)) f-8 (MAIN::Access (begin 1045) (end 1115)) f-9 (MAIN::Access (begin 1215) (end 1215)) For a total of 4 facts in module MAIN. Regards Wolfgang On Fri, May 9, 2008 at 8:41 PM, Gary Napier <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: My basic problem is this. I have two events, OPEN and CLOSE, both timestamped I would like to relate an OPEN and CLOSE to generate a new fact X However with data skew, there may be a mix of OPEN and CLOSE facts mixed, such that OPEN 7:15 CLOSE 9:00 CLOSE 8:00 OPEN 8:15 Would there be any way of sorting these facts (possibly in a multi slot or using an extra slot) so that they were ordered.
-------------------------------------------------------------------- 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] --------------------------------------------------------------------
