4.5 Solution Details
In order to instantaneously monitor energy, we have
designed building-level, floor-level and meter type-
level queries that are fired simultaneously,
additionally configuring floor-level, building-level
and meter type-level thresholds and meter-floor,
floor-building, and meter-type relationships in the
background knowledge.
Continuously streamed dynamic knowledge is
converted into triples that give us information
regarding the meters and their readings. These
triples could have been constructed in a number of
different ways:
<meter, hasValue, value>: This triple creates a
direct association between a meter and its power
consumption at a given point in time. However,
for two readings of the same meter which have
the same value, the system overwrites the
reading with the most recent reading observed
in the stream. For our purpose, we need
readings of each meter separated by time.
<reading, hasMeter, meter>, <reading,
hasValue, value>: Here, we are using two
triples to separately store a meter and its
reading. With each new event, the value of
“reading” (which is a resource in this case)
serves as an iterator which helps us identify the
chronological order of events. Reading values
are stored as “reading1”, “reading2”, …
“reading n”. This ensures that the subject is
unique for every event, therefore, preventing the
overwriting problem we faced with the previous
triple.
Now that we have both static as well as dynamic
knowledge, let us dive into the reasoning part of this
solution. In addition to the background knowledge,
we have written a number of rules that the stream
reasoner uses to reason on:
Rule 10002: Building Meter Rule
(?meter isOnFloor ?floor)
(?floor isInBuilding ?building)
→(?meter hasBuilding ?building)
In this rule, if a meter is located on a particular floor
and that floor is located in a particular building,
there is a direct association created between the
meter and the building. Both the triples are obtained
from the background knowledge.
Rule 10003: Building Reading Rule
(?meter hasBuilding ?building)
(?reading hasMeter ?meter)
→ (?reading hasReadingBuilding ?building)
In this rule, we condense the combination of two
triples into one. Here, if a meter is located in a
certain building, then the reading resource adopts its
value as the building's value. It should be noted that
the first triple is an entailment of Rule 10002
described earlier in this section. Therefore,
executing this rule will automatically execute the
Building-Meter Rule.
rule10005: Reading Meter Type Rule
(?meter hasMeterType ?type)
(?reading hasMeter ?meter)
→ (?reading hasReadingMeterType ?type)
This rule builds an association between the reading
and type of meter that is being reported. Here, if a
meter has a certain type, then the reading resource
adopts its value as the meter type's value.
Rule 10006: Floor Value Rule
(?meter isOnFloor ?floor)
(?reading hasMeter ?meter)
→ (?reading hasReadingFloor ?floor)
Here, if a meter is located on a particular floor, then
the reading resource adopts its value as the floor's
value. Thus, this rule builds an association between
the reading and the floor on which it is recorded.
Rule 10001: Remove Meter Value Rule
(?reading hasMeter ?meter)
(?reading hasValue ?value)
(?reading removeMeter ?meter)
(?reading removeValue ?value)
→ remove(0) remove(1) remove(2) remove(3)
When we wish to delete an event, we simply add the
corresponding “remove” triples to the working
memory. An example of a remove triple is:
<reading1, removeMeter, meter1>. These newly
added “remove” triples in the working memory
match the meter and value of an existing reading.
Once the appropriate triples with the specific ?me-
ter and ?value have been found, they (including the
corresponding “remove” triples) are removed from
the working memory and are no longer included in
any computations, facilitating the “slide”.
Now that we have our repertoire of rules, we
can implement them in queries at the different
levels:
Query 01: Building-level Query
SELECT ?building ?threshold
(SUM(xsd:float(?value)) as ?sumBuilding) WHERE
{
?reading hasReadingBuilding ?building.
?building hasBuildingThreshold ?threshold.
?reading hasValue ?value.