[rules-users] Frequently updated facts and truth maintenance

bill simms sitrious at gmail.com
Fri May 7 10:02:45 EDT 2010


Thanks for replying.

1.  Yes isDeltaFlag(flag) should eventually return false.  But when it does
so is dependent on when the Sensor's flag value changes.  If the Sensor
remains flagged for long periods of time, the rule will continue to activate
for each update to the Sensor.  There are several
other types of flags, which may also exist for long periods of time.

2.  The truth to be maintained here is simply that a Sensor has a particular
flag, in this case a Delta flag, set on it.  I'm using such rules to reduce
the need to eval() in other rules that react to the presence of a flag in
more meaningful ways.  I'm using eval() with a function because the flags
are originally encoded by setting bits at specific positions to 1.  I have
not seen a better way of doing this yet.

3.  The ultimate purpose for DeltaFlagged, and other similar facts, is to be
used for triggering other rules which take more complicated actions.  Again,
I have taken this approach to avoid repeating eval() in many different
rules, and to abstract what a flag is.

rule "Example Flag Rule"
>     when
>         $station:    Station($stationId : stationId)
>         $test:        DeltaFlaggedTest(stationId == $stationId, $sensorId :
> sensorId)
>         $flag:        DeltaFlagged($sensor : sensor)
>                         Sensor(this == $sensor, station == $stationId, id
> == $sensorId)
>     then
>         //  Send messages, make database changes, etc.
> end
>

By using insertLogical() I was hoping to ensure that one and only one
DeltaFlagged fact was inserted for a Sensor, and was automatically
retracted, using only one rule.  In addition, I have used logical inserts
for other possibly-long-running facts.  Based on my research so far, I will
need to alter my approach to avoid any long-term logically asserted facts
that are frequently updated.  My original email was to ask about how fact
equality plays a role in logical inserts.  But now I think I have clarified
to myself that equality was not the problem.  Using logical inserts under
these long-term scenarios was my problem.

-B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100507/a08df5f2/attachment.html 


More information about the rules-users mailing list