Temporal Rules

Temporal rules are Activations which fire after a given time if they are still true; ie if a room is empty for five minutes then turn off the light.

The <duration> element within rules allows a unit of time to be assigned before the rule, if it is still on the Agenda, is fired:

<duration seconds="2" />

The units of time can be specified in any combination of days, hours, minutes and seconds as shown in the following xsd code snippet:

<xs:element name="duration" minOccurs="0" >
  <xs:complexType>
    <xs:attribute name="days"    type="xs:nonNegativeInteger"/>
    <xs:attribute name="hours"   type="xs:nonNegativeInteger"/>
    <xs:attribute name="minutes" type="xs:nonNegativeInteger"/>
    <xs:attribute name="seconds" type="xs:nonNegativeInteger"/>
  </xs:complexType>
</xs:element>

When a <duration> is specified a class is created implementing the Duration interface. While units can be specified in an combination internally they are stored as a long representing the time in miliseconds.

The Agenda uses the standard java.util.Timer class to schedule Activations specified time and as such does not offer any guarantees of real-time performace - from Sun's javadocs:

  • This class does not offer real-time guarantees: it schedules tasks using the Object.wait(long) method.

Currently no Conflict Resolution strategy is assigned to temporal rules - so if several rules with the same durations are all activated with the same assertion/modify action they will be fired in the order in which the Activations are created.

Labels

 
(None)
  1. Mar 25, 2005

    Olu Oni says:

    Two questions: 1 Can you use the duration construct to delay the evaluation of a...

    Two questions:
    1 - Can you use the duration construct to delay the evaluation of a condition?
    2 - Can you then use greater than or less than i.e. <duration seconds &gt=2>

    Where i am going is this-
    If you have facts a and b and you want to define a rule1 such that
    rule1 is fired if a.someCondition()==True and b occurs within 2 seconds of a and b.someCondition()==True

    i can see how you can simulate this by splitting this into two or more rules and keeping some sort of sequencing map in working memory that is modified in the consequence of one rule and included in the conditions of subsequent rules, but i wondered if there was a simpler construct available to do this, and if duration could be used in some way for this.