Re: JESS: Rule firing twice
I think Nicolas Fortin wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > Hi everybody, > > I have a rule which fires twice and I just can't see why. So any hint would > be appreciated. The details suggest to me that there are two Controller facts. Are you sure there's only one? - 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://herzberg.ca.sandia.gov 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: Rule firing twice
Hello, Thanks for your quick answer. I know it's hard to debug a program when you're not in front of it. The details suggest to me that there are two Controller facts. Are you sure there's only one? I have just rewritten the rule as following : (defrule PROCESS::process-entity ?fact1 <- (MAIN::Station (disabled FALSE) (processing FALSE) (OBJECT ?station&: (canBeginProcessing ?station))) ?fact2 <- (MAIN::Controller(time ?time)) => (printout t "process-entity fired" crlf) (printout t "Station fact is " ?fact1 crlf) (printout t "Controller fact is " ?fact2 crlf) ..) And according the console windows it seems there is only one Controller fact, it's displayed : process-entity fired Station fact is Simulation fact is process-entity fired Station fact is Simulation fact is But don't bother to much with my problem if you don't have time. After all, as I said in the previous message, it is functional if I use pattern binding. But I still wondering why ... Cheers ! Nicolas 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: Rule firing twice
Dr. Friedman-Hill, I've been curious and I've had another idea. Just before to call the Rete.run() method in my Java program, I have checked the agenda activations. It has strengthened my doubt about something wrong, since for the troublesome rule (process-entity), there are two activations with the same facts : PROCESS: [Activation: PROCESS::process-entity f-15, f-42 ; time=45 ; salience=0] [Activation: PROCESS::process-entity f-15, f-42 ; time=45 ; salience=0] STATUS: For a total of 7 activations in all modules. Is it really abnormal ? Thanks in advance, Nicolas 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: Rule firing twice
I went back and looked over your first message and this time paid attention to the deffunction canBeginProcessing. Holy corrupted data structures, Batman! You can't modify a fact on the *left* side of a rule! The Rete network is *not* re-entrant, which is why it's carefully protected against interference from other threads. But that protection doesn't help if a predicate function changes the object it's working on, sending a PropertyChangeEvent which modifies the fact that's being pattern-matched! This is something like writing a Java equals() method that changes the object and its hashCode() when you call it. Try to store such an object in a HashMap! Change canBeginProcessing to be a pure predicate function; call setProcessedEntity (and beginProcessing) on the *right* side of the rule, after you've made this decision. (deffunction canBeginProcessing(?station) (if (and (neq ?station nil)) then ;; Get the entity that can be processed. (bind ?entity (call ?station beginProcessing)) ;; Assign the entity to the current station. (call ?station setProcessedEntity ?entity) ;; Return true if there is an entity. (return (neq ?entity nil)) else (return FALSE))) I think Nicolas Fortin wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > Dr. Friedman-Hill, > > I've been curious and I've had another idea. Just before to call the > Rete.run() method in my Java program, I have checked the agenda activations. > It has strengthened my doubt about something wrong, since for the > troublesome rule (process-entity), there are two activations with the same > facts : > > PROCESS: > [Activation: PROCESS::process-entity f-15, f-42 ; time=45 ; salience=0] > [Activation: PROCESS::process-entity f-15, f-42 ; time=45 ; salience=0] > STATUS: > For a total of 7 activations in all modules. > > Is it really abnormal ? > > Thanks in advance, > > Nicolas > > > 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] > > - 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://herzberg.ca.sandia.gov 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: Rule firing twice
Hello, Holy corrupted data structures, Batman! You can't modify a fact on the *left* side of a rule! Thank you for your answer. Yes I agree with Robin, it's a big mistake to change something while the Rete network is working on it. Sorry, I am learning with my errors and I won't do that again :( Nicolas 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: Rule firing twice
Title: RE: JESS: Rule firing twice On a related subject, if I have a multi-threaded program in which one thread modifies facts in real time according to some external events and another thread call run() on the engine periodically, do I have to synchronize the two threads so that no facts are modified when the engine is inside run()? Thanks. Regards, Shan Ming Woo -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, September 02, 2005 6:17 AM To: jess-users@sandia.gov Subject: Re: JESS: Rule firing twice I went back and looked over your first message and this time paid attention to the deffunction canBeginProcessing. Holy corrupted data structures, Batman! You can't modify a fact on the *left* side of a rule! The Rete network is *not* re-entrant, which is why it's carefully protected against interference from other threads. But that protection doesn't help if a predicate function changes the object it's working on, sending a PropertyChangeEvent which modifies the fact that's being pattern-matched! This is something like writing a Java equals() method that changes the object and its hashCode() when you call it. Try to store such an object in a HashMap! Change canBeginProcessing to be a pure predicate function; call setProcessedEntity (and beginProcessing) on the *right* side of the rule, after you've made this decision. (deffunction canBeginProcessing(?station) (if (and (neq ?station nil)) then ;; Get the entity that can be processed. (bind ?entity (call ?station beginProcessing)) ;; Assign the entity to the current station. (call ?station setProcessedEntity ?entity) ;; Return true if there is an entity. (return (neq ?entity nil)) else (return FALSE))) I think Nicolas Fortin wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > Dr. Friedman-Hill, > > I've been curious and I've had another idea. Just before to call the > Rete.run() method in my Java program, I have checked the agenda activations. > It has strengthened my doubt about something wrong, since for the > troublesome rule (process-entity), there are two activations with the same > facts : > > PROCESS: > [Activation: PROCESS::process-entity f-15, f-42 ; time=45 ; salience=0] > [Activation: PROCESS::process-entity f-15, f-42 ; time=45 ; salience=0] > STATUS: > For a total of 7 activations in all modules. > > Is it really abnormal ? > > Thanks in advance, > > Nicolas > > > 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] > > - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov 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] - Additional information is available upon request Copyright (c) 2005 CLSA Asia-Pacific Markets. The information and statistical data herein have been obtained from sources we believe to be reliable but in no way are warranted by us as to accuracy or completeness. We do not undertake to advise you as to any change of our views. This is not a solicitation or any offer to buy or sell. CLSA Asia-Pacific Markets has produced this information for private circulation only. All information and advice is given in good faith but without any warranty. CLSA Asia-Pacific Markets, its affiliates or companies or individuals connected with CLSA Asia-Pacific Markets may have used the information set forth herein before publication and may have positions in, may from time to time purchase or sell or may be materially interested in any of the securities mentioned or related securities. This information is subject to the terms and conditions of use set forth on the www.clsa.com website. Any disclosure(s) in this report, for the purpose of paragraph 16 of the HK SFC Code of Conduct, only reflect(s) the position(s) of the CLSA B.V. Group but do(es) not include the position(s) of Calyon and/or its affiliates. MITA (P) 105/12/2004. V.050101. This email is only for the use of the addressee an
Re: JESS: Rule firing twice
I think Locksley Woo, CLSA wrote: > On a related subject, if I have a multi-threaded program in which one thread > modifies facts in real time according to some external events and another > thread call run() on the engine periodically, do I have to synchronize the > two threads so that no facts are modified when the engine is inside run()? No, no worries. Jess takes care of this for you. - 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://herzberg.ca.sandia.gov 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]