Hello Ernest and all,

I'm unable to resolve my problem with (not) CE, and I
really need this functionality ASAP, so I would
appreciate any advice you could provide. Here's the
situation:

I use backward-chaining to assert (count) facts to the
engine while it runs. Rules, which require (count)
facts to be calculated and asserted, may have
different patterns. One example of such a pattern
would be (count 0). Unfortunately, logic which
calculates and asserts (count) facts does not assert
any fact if the count is <1. 

So I need to modify my rules so, that in case (count
0) is required by rule pattern, I also use "absence of
(count) fact" criteria as a part of rule LHS:

(defrule myrule
    (or (not (count ?)) ((count ?X) (test (eq ?X 0))))
=>
...

Right?

Unfortunately, this (not (count ?)) kind of pattern 
does not work for me. Here's real debug information,
so you can see what actually happens:

<attached file>

As you can see, there is two matches even though I
expected just one, for "john.smith". On the other
hand, if I remove (not) CE and use just (count ?)
pattern, it does match just one person:
"igor.gorbunov".

Could you tell me why (not) doesn't work as I expect?

Thank you very much,
Igor


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
(defrule rule_name_IDS_58_42 ?F_33<-(USER_TEMPLATE (USER_GENDER ?GENDER) 
(USER_FIRSTNAME ?FIRSTNAME) (USER_ID ?USERID) (USER_DOB ?DOB) (USER_ZIPCODE ?ZIPCODE) 
(USER_SUBSCRIPTIONS $?U_S) (USER_ETHNICITY ?ETHNICITY) (LOCATION_ID ?LOCATION) 
(DEPENDENT_FLAG ?DEPENDENT_FLAG) (USER_ACTIVE_STATUS ?ACTIVE_FLAG) ) (test (member$ 58 
$?U_S))    
 (test  (and (neq ?GENDER  "sfdhj" ) (eq ?GENDER  "M" ) ) )
 (not (count (userID ?USERID) (messageID 42) (since "08/08/1990") (till 
"(current_date)") (count ?))) 
 => (assert (MessageMatch ?USERID 42)) )

***(facts) before:
DUMPING FACTS:
f-0   (MAIN::initial-fact)
f-1   (MAIN::USER_TEMPLATE (USER_ID "[EMAIL PROTECTED]") (JOB_CLASS_ID nil) 
(USER_FIRSTNAME "Jane") (USER_LASTNAME "Smith") (USER_GENDER "F") (USER_DOB 
<External-Address:java.sql.Timestamp>) (USER_SSN nil) (USER_ZIPCODE "22554") 
(USER_EMAIL "[EMAIL PROTECTED]") (USER_PHONE_NO nil) (USER_ETHNICITY nil) 
(PLAN_ID nil) (LOCATION_ID nil) (USER_CONSENT nil) (DEPENDENT_FLAG nil) 
(USER_ACTIVE_STATUS "0") (PROFILE_UPDATE_FLAG nil) (USER_SUBSCRIPTIONS 31 58))
f-2   (MAIN::USER_TEMPLATE (USER_ID "[EMAIL PROTECTED]") (JOB_CLASS_ID 
nil) (USER_FIRSTNAME "Priya") (USER_LASTNAME "Chandra") (USER_GENDER "F") (USER_DOB 
<External-Address:java.sql.Timestamp>) (USER_SSN nil) (USER_ZIPCODE "20102") 
(USER_EMAIL "[EMAIL PROTECTED]") (USER_PHONE_NO nil) (USER_ETHNICITY nil) 
(PLAN_ID nil) (LOCATION_ID nil) (USER_CONSENT nil) (DEPENDENT_FLAG nil) 
(USER_ACTIVE_STATUS "0") (PROFILE_UPDATE_FLAG nil) (USER_SUBSCRIPTIONS 49 58))
f-3   (MAIN::USER_TEMPLATE (USER_ID "[EMAIL PROTECTED]") (JOB_CLASS_ID nil) 
(USER_FIRSTNAME "John") (USER_LASTNAME "Smith") (USER_GENDER "M") (USER_DOB 
<External-Address:java.sql.Timestamp>) (USER_SSN nil) (USER_ZIPCODE "22767") 
(USER_EMAIL "[EMAIL PROTECTED]") (USER_PHONE_NO nil) (USER_ETHNICITY nil) 
(PLAN_ID nil) (LOCATION_ID nil) (USER_CONSENT nil) (DEPENDENT_FLAG nil) 
(USER_ACTIVE_STATUS "0") (PROFILE_UPDATE_FLAG nil) (USER_SUBSCRIPTIONS 58))
f-4   (MAIN::USER_TEMPLATE (USER_ID "[EMAIL PROTECTED]") (JOB_CLASS_ID 
nil) (USER_FIRSTNAME "Igor") (USER_LASTNAME "Gorbunov") (USER_GENDER "M") (USER_DOB 
<External-Address:java.sql.Timestamp>) (USER_SSN nil) (USER_ZIPCODE "21122") 
(USER_EMAIL "[EMAIL PROTECTED]") (USER_PHONE_NO nil) (USER_ETHNICITY nil) 
(PLAN_ID nil) (LOCATION_ID nil) (USER_CONSENT nil) (DEPENDENT_FLAG nil) 
(USER_ACTIVE_STATUS "0") (PROFILE_UPDATE_FLAG nil) (USER_SUBSCRIPTIONS 38 58))
f-5   (MAIN::need-count (class nil) (count nil) (messageID 42) (since "08/08/1990") 
(till "(current_date)") (userID "[EMAIL PROTECTED]") (OBJECT nil))
f-6   (MAIN::need-count (class nil) (count nil) (messageID 42) (since "08/08/1990") 
(till "(current_date)") (userID "[EMAIL PROTECTED]") (OBJECT nil))
For a total of 7 facts.

***RUN...
***calculating and asserting count fact

Dumping count fact...
UserID: [EMAIL PROTECTED]
MessageID: 42
Count: 1
Since: 08/08/1990
Till: (current_date)

***(facts) after:
f-0   (MAIN::initial-fact)
f-1   (MAIN::USER_TEMPLATE (USER_ID "[EMAIL PROTECTED]") (JOB_CLASS_ID nil) 
(USER_FIRSTNAME "Jane") (USER_LASTNAME "Smith") (USER_GENDER "F") (USER_DOB 
<External-Address:java.sql.Timestamp>) (USER_SSN nil) (USER_ZIPCODE "22554") 
(USER_EMAIL "[EMAIL PROTECTED]") (USER_PHONE_NO nil) (USER_ETHNICITY nil) 
(PLAN_ID nil) (LOCATION_ID nil) (USER_CONSENT nil) (DEPENDENT_FLAG nil) 
(USER_ACTIVE_STATUS "0") (PROFILE_UPDATE_FLAG nil) (USER_SUBSCRIPTIONS 31 58))
f-2   (MAIN::USER_TEMPLATE (USER_ID "[EMAIL PROTECTED]") (JOB_CLASS_ID 
nil) (USER_FIRSTNAME "Priya") (USER_LASTNAME "Chandra") (USER_GENDER "F") (USER_DOB 
<External-Address:java.sql.Timestamp>) (USER_SSN nil) (USER_ZIPCODE "20102") 
(USER_EMAIL "[EMAIL PROTECTED]") (USER_PHONE_NO nil) (USER_ETHNICITY nil) 
(PLAN_ID nil) (LOCATION_ID nil) (USER_CONSENT nil) (DEPENDENT_FLAG nil) 
(USER_ACTIVE_STATUS "0") (PROFILE_UPDATE_FLAG nil) (USER_SUBSCRIPTIONS 49 58))
f-3   (MAIN::USER_TEMPLATE (USER_ID "[EMAIL PROTECTED]") (JOB_CLASS_ID nil) 
(USER_FIRSTNAME "John") (USER_LASTNAME "Smith") (USER_GENDER "M") (USER_DOB 
<External-Address:java.sql.Timestamp>) (USER_SSN nil) (USER_ZIPCODE "22767") 
(USER_EMAIL "[EMAIL PROTECTED]") (USER_PHONE_NO nil) (USER_ETHNICITY nil) 
(PLAN_ID nil) (LOCATION_ID nil) (USER_CONSENT nil) (DEPENDENT_FLAG nil) 
(USER_ACTIVE_STATUS "0") (PROFILE_UPDATE_FLAG nil) (USER_SUBSCRIPTIONS 58))
f-4   (MAIN::USER_TEMPLATE (USER_ID "[EMAIL PROTECTED]") (JOB_CLASS_ID 
nil) (USER_FIRSTNAME "Igor") (USER_LASTNAME "Gorbunov") (USER_GENDER "M") (USER_DOB 
<External-Address:java.sql.Timestamp>) (USER_SSN nil) (USER_ZIPCODE "21122") 
(USER_EMAIL "[EMAIL PROTECTED]") (USER_PHONE_NO nil) (USER_ETHNICITY nil) 
(PLAN_ID nil) (LOCATION_ID nil) (USER_CONSENT nil) (DEPENDENT_FLAG nil) 
(USER_ACTIVE_STATUS "0") (PROFILE_UPDATE_FLAG nil) (USER_SUBSCRIPTIONS 38 58))
f-5   (MAIN::need-count (class nil) (count nil) (messageID 42) (since "08/08/1990") 
(till "(current_date)") (userID "[EMAIL PROTECTED]") (OBJECT nil))
f-6   (MAIN::need-count (class nil) (count nil) (messageID 42) (since "08/08/1990") 
(till "(current_date)") (userID "[EMAIL PROTECTED]") (OBJECT nil))
f-7   (MAIN::MessageMatch "[EMAIL PROTECTED]" 42)
f-8   (MAIN::MessageMatch "[EMAIL PROTECTED]" 42)
f-9   (MAIN::count (class <External-Address:java.lang.Class>) (count 1) (messageID 42) 
(since "08/08/1990") (till "(current_date)") (userID "[EMAIL PROTECTED]") 
(OBJECT <External-Address:com.vitalspring.broadcaster.core.CountFact>))
For a total of 10 facts.
# of matches produced: 2

Reply via email to