Well, indeed. The changes to the ?security object happen outside of Jess's knowledge. Nothing informs Jess that the state of that object has changed, so there's no reason to reevaluate the test. This is actually exactly like your other problem, and the solution is the same; the ?security object itself needs to be added explicitly to working memory.

On Mar 18, 2009, at 4:07 AM, nikita shah wrote:


I have a rule which fires if some values are empty and fecthes those values
from database.
Here I will store the fetched values as Fact so as to prevent the same
values to be fetched again and again.
The other rule will fire if it finds macthing fact and so it will set values
from the Fact.

The second rule has higher salience.
The problem here is when a fact that matches second rule, it fires first and
fills the missing information.
But immediately after the first rule also fires even though the missing
values are now filled.
The test condition in the first rule is not evaluated again.

Please find the skeleton of rules below:
; Fetch details from the Security master
(defrule EnrichInstDetails_NoSecurityFact
   (declare (salience ?*CONTENT_SPECIFIC_RULE*))
   ?trade <- (TradeCaptureReport (rptTyp ?*SUBMIT*)(RRNumLocation
?repLocation&~?*BARRACUDA*)
                (instrmt ?security))
   (test (checkIfSecurityDetailsEmpty ?security))
   =>
(log-info " Missing Security Details .. No Security facts.. Get from
Security master .. ")
            (bind ?secArray (getSecurityFromDb ?security))
            .......
   ;Assert the Fact for future use
   (assert_SecurityDetails_Fact ?secArray)
)

; Fetch details from the Security Facts
(defrule EnrichInstDetailsFromFacts
   (declare (salience ?*CONTENT_SPECIFIC_RULE_2*))
   ?trade <- (TradeCaptureReport (rptTyp ?*SUBMIT*)
                                (instrmt ?security)(RRNumLocation 
?repLocation&~?*BARRACUDA*))
   ?sec <- (SecurityDetails (isin ?isin) (cusip ?cusip) (bbid
?bbid)(prodType ?prodTyp)
                (name ?name)(coupon ?cpn)(matDate ?matDate)(ticker ?ticker))
(test (or (eq (get ?security ID) ?isin) (eq (get ?security ID) ? cusip)
(eq (get ?security ID) ?bbid)))
   (test (checkIfSecurityDetailsEmpty ?security))
   =>
(log-info " Missing Security Details .. Filling from Security Facts ..
")
   ;set all values

)

Any idea on why it is behaving this way ?
Please provide some other way to do this.
--
View this message in context: 
http://www.nabble.com/test-condition-evaluated-only-once-tp22574277p22574277.html
Sent from the Jess mailing list archive at Nabble.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] .
--------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, 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].
--------------------------------------------------------------------

Reply via email to