Keywords

1 Introduction

In the last twenty years, technology has advanced considerably, with the proliferation of connected devices of different computational capacities and on a scale that will reach a total of 50 billion connected devices in 2020 [5]. IoT systems have become an important and even essential part of our daily lives. Smart homes are good examples of where such systems can be found. However, the development of IoT systems is a difficult task because it involves multiple areas of computing, such as software engineering, artificial intelligence, and distributed systems [21].

Due to the fast grown of IoT computing, an increasing number of contextual data is continuously generated from different sources, formats, or semantics which is needed to be evaluated together to identify situations of interest to context-aware applications [12].

In this aspect, context awareness becomes an essential approach for providing adaptive and autonomous services. It can be used, for example, to select the most appropriate services according to the context information that is relevant to the user or to change operational parameters of services in execution. Thus, context-aware applications must be able to adapt their changing behaviors reducing human intervention, introducing to this, several challenges to developers [10].

In order to build and execute context-aware applications, some features need to be provided, ranging from the acquisition of contextual information from heterogeneous and distributed sources, representation of this information, storage, processing, and reasoning for their use on decision-making [2].

Given the importance of the context reasoning to obtain the context awareness, diverse strategies for that have recently been proposed. However, they are not versatile enough to individually meet the reasoning requirements for different IoT applications. Thus, the need for a combination of different methods for context reasoning is identified by means the hybrid strategies [3, 12].

Although several proposals on hybrid context reasoning are innovative, they are not able to deal with the dynamic needs from actual IoT demands. Thus, the goal of this work is the conception of an IoT software architecture, providing an approach to hybrid context reasoning. For this, we propose a compositional approach for context reasoning that enables the composition of different strategies. Consequently, the context-aware applications can choose among different reasoning strategy, and if they will be used individually or in combination, considering the contexts that will be treated. Considering this, we provide flexibility for the application to customize the context awareness provided, according to their demands.

The proposed compositional approach for context reasoning is an extension of the Context Recognition and Adaptation Subsystem of the EXEHDA middleware [14]. EXEHDA consists of a situation-aware middleware to IoT, which aims to create and manage a widely distributed computing system environment, as well as to promote the implementation of applications on it.

The remainder of this paper is organized as follows. Section 2 reviews some related works. We describe the compositional reasoning proposed in Sect. 3. In the fourth Section, we discuss the evaluation of the proposal, exploring a use case with the use of a dynamic strategy for context reasoning. Finally, the Fifth Section presents our conclusions and future work.

2 Related Work

In the literature, several papers explore hybrid strategies for context reasoning in IoT. To identify these papers, we performed a Systematic Literature Review (SLR) analyzing papers published between 2012 and 2017, more details can be found in [16]. SLR is a research methodology that foresees the execution of some procedures to generate a literature review in an area, to identify a set of papers that bring a precise prospection of the addressed state of the art [11]. With the execution of the SLR, we selected seven papers. In the following, we present aspects regarding reasoning strategy, as well as main functionalities about the seven works.

The paper [15] proposes a software architecture for context awareness called DynamiCC. The proposal focuses on the conception of a context model and a software architecture that allow the interpretation and the dynamic composition of the information acquired by sensors positioned in different locations of the ubiquitous environment. A hybrid strategy for reasoning was proposed to perform the processing of contextual information. DynamiCC uses semantic reasoning provided by the ontology, through axioms and rules to infer new knowledge based on the ontology instances. In addition to this, DynamiCC uses reasoning based on rules such as ECA (Event-Condition-Action), which performs the processing of contextual information provided by a relational model.

In [24] is proposed a software architecture called CASP (Context-Aware Service Platform). This platform has as main characteristics to be context-aware and deal with the aggregation and abstraction of context information using ontologies to represent them. CASP platform uses two reasoning strategies in the context processing stage, one based on ontological rules and the other in cases. The ontological rules represent general knowledge of the domain, while the cases capture specific knowledge. Ontological reasoning evaluates the rules provided and adds the inferred information to the knowledge base. Case-based reasoning recovers similar situations and uses the corresponding solutions to update the data in the knowledge base represented by the ontological model.

The paper [25] presents the architecture of a framework for hybrid reasoning developed for the CARA (Context-Aware Real-time Assistant) system. The authors use hybrid reasoning based on cases and fuzzy rules, making it more robust and adaptable to an environment subject to change. Case-based is used to detect conditional anomalies for residential automation, and the fuzzy rules to deal with exceptions, as well as case retrieval and adaptation of query-sensitive cases.

In [23] is proposed the software conception of a group recommendation system for concerts for groups of users. The prototype is context-aware and takes into account the user’s location and timing when giving recommendations. In order to perform the reasoning of contextual data, the authors propose a hybrid strategy that implements two algorithms, which take advantage of the historical information of the users: a collaborative lineage algorithm (K-Nearest Neighbor) and a matrix-factorization algorithm. The algorithms can be used individually or in combination.

The paper [1] proposes software that individually classifies the retail products on a shop shelf. The authors propose two different hybrid strategies. The first combines SVMs (Support Vector Machines) with HMMs (Hidden Markov Models). In the second, the SVMs are combined with CRF (Conditional Random Fields) aiming to form a new context. Probabilistic models are trained by learning from context-free classifier errors (SVMs) and neighboring relationships between retail products.

In [19] is proposed a framework for a hybrid strategy for context reasoning for the Mining Minds, which offers personalized support for health and well-being. In order to perform the context reasoning, a new conjunctive approach is proposed, based on ontology and machine learning. The machine learning strategy supports the inference by classifying high-level contexts based on the data set instantiated in the ontology.

The paper [13] proposes a framework that uses a hybrid strategy for context reasoning to middleware SWARMs (Smart and Networking Underwater Robots in Cooperation Meshes). The approach consists of three reasoning: (i) ontology axioms to infer knowledge related to the classes contained in ontology; (ii) ontology rule that process the contextual data contained in the ontology, using SWRL (Semantic Web Rule Language) for the design of the rules; and (iii) Multi-Entity Bayesian Network, which consists of a logical system that integrates first-order logic with Bayesian probability theory.

Table 1 presents a comparative analysis of the seven papers selected. This analysis was based on the steps followed to obtain context awareness [12]: (i) types of sensors used in the acquisition step; (ii) models used to perform the context representation; (iii) model used to store the contextual data; and (iv) strategies to implement the context reasoning.

Table 1. The comparison performed among related work.

Based on Table 1, we can observe that, in the acquisition step, only two papers do not present how they collect contextual data. The remaining works have support to deal with different types of sensors, allowing the treatment of different applications.

Regarding the modeling step, we can see that four papers use the ontology-based model, mainly due to its semantic representation characteristic. It is worth mentioning that [15] proposed the use of hybrid modeling, combining ontological and relational models.

Issues related to contextual information storage are not discussed by the majority of the papers, although it is essential for context-aware applications. The work of [25] uses the markup scheme model XML (eXtensible Markup Language), mainly because it can be utilized to transmit information between different components. The work of [15] uses a relational model of storage, which is not considered a satisfactory model for the storage of data provided by the ontologies [4]. Besides, the work of [19] proposes the use of the triple model along with Jena TDB, being a more indicated model to perform the persistence of information provided by ontologies.

We believe that mechanisms with different characteristics are required for context storing since the current context-aware applications tend to deal with diverse types of data, semantic levels, among other aspects. In turn, the efficiency of these mechanisms is a significant aspect, considering the scalability of the volume of contextual data involved, and its constant updating or search.

Regarding context reasoning, despite using hybrid strategies, the solutions do not allow the application to choose a strategy that better fits their needs. Besides, we note the absence of an approach that enables the combination of the different strategies for context reasoning. In this research, we propose the creation of compositional reasoning that could increase the flexibility for the use of contextual data, facilitating the identification of interest situations. Moreover, with the development of this strategy, applications can choose whether these different reasoning strategies will be utilized individually or combined, depending on application demand and the contextual data treated.

3 Software Architecture Proposed

The differential of our proposal is to allow the applications to choose among the strategies offered to context reasoning. Thus, providing greater flexibility for the application to customize the context awareness provided, according to their demands. Figure 1 gives an overview of the proposal, where we can see the software components necessary to offer a dynamic strategy for context reasoning. The main features of these components are discussed below, highlighting the Reasoning Component focused on this paper.

Fig. 1.
figure 1

Overview of proposal

In Fig. 1, Medium Access Component is responsible for sending and receiving information from the applications. It performs the context acquisition from distinct types of sensors, such as events about the use of operating system resources and log files internal to the system, and can receive contextual data from different devices. Moreover, it performs the configured actions based on the identified situations. These actions can be alerts by email, instant messaging service, or commands execution, which results in the nonfunctional adaptation of the environment at runtime.

Storage Component is formed by two storage models offering: (i) a relational model, which has a satisfactory behavior in many situations, being used to store the configuration necessary to perform compositional approach for context reasoning, providing an easy data access and facilitating it’s modification if required; (ii) a triple model, which allows the manipulation of ontological data more efficiently compared to its manipulation in memory or using a relational model [20].

Distribution Component communicates with context-aware applications, being responsible for the configuration of the proposal, for receiving the requests made by the applications, and for the visualization of the stored contextual information.

In the middle of Fig. 1, the Reasoning Component has a module called Compositional Strategy Manager, which provides a dynamic strategy for context reasoning. Reasoning Component allows the applications to choose which strategy or strategies they want to use, being the Compositional Strategy Manager responsible for making the composition of the strategies that will be used to context reasoning. This component receives data collected from sensors of Medium Access Component, transmits the data and situations detected to Storage Component, and sends a notification to the Medium Access Component for the execution of determined actions.

In order to offer multiple reasoning strategies, Reasoning Component provides the Strategies Repository. Each reasoning strategy is cataloged in the repository with a unique Uniform Resource Identifier (URI). Thus, allowing access to a specific strategy that a context-aware application wishes to use.

Among the strategies available to perform the context reasoning, we can mention the use of three of the main strategies [18]:

  • rules-based following the event-condition-action pattern. This strategy is used to allows the conception of the compositional approach for context reasoning;

  • ontology-based strategy, which can be used in two forms, in the first, the internal axioms in the ontology are used to infer knowledge about the classes represented in the ontology. In the second form, external rules written in the SWRL language are applied, allowing the system to infer new context information exploring the ontology instances;

  • supervised learning provides several techniques to be used. In the first step, this strategy uses a training set, where, in this set, the data are categorized [9]. After training, in the second step, exploring the learning acquired is possible to classify new context data.

The dynamic strategy is conceived based on compositional rules, allowing the use of different strategies for reasoning in a combined way. Each rule can contain three different methods: compositional rules, learning techniques, or ontology-based strategy. Each method is represented by marking tags, in which is used a specific tag for each one.

Marking tags begin with the “#” symbol followed by an identifier and a number, thus allowing to recognize the desired composite rule. When the tag has to be replaced by another compositional rule, the “M” identifier must be used. The identifier “A” will be replaced by a supervised learning strategy. Also, identifier “O” can be used to represent an ontology-based strategy.

In order to support the use of the dynamic reasoning strategy, we include specific tables in the relational database in the Storage Component. Figure 2 presents the ER (Entity Relationship) diagram that represents the compositional approach concepts and how it can be modeled to enables their conception.

Fig. 2.
figure 2

ER diagram of compositional rules

As presented in Fig. 2, we create an entity to model the strategy used called “Reasoning”. This entity contains the “id” attribute, responsible for identifying the rules, this attribute being the primary key of the table. Applications can identify which rule will be used by searching for “id” and “rule” attribute referring to the compositional rule that will be applied. Also, the “category” attribute is used to find out what kind of strategy will be used, whether it is learning or ontology-based.

Considering that, context reasoning can be composed of several strategies. Thus, we define a “Strategy” entity with the “id” attribute responsible for identifying strategies. In Fig. 2, the strategies based on supervised learning and ontologies are modeled in independent entities, being a specialization from “Strategy”.

“Learning” entity has the “uri” attribute, which is responsible for identifying which learning technique should be used. Besides, this entity has the “training” attribute, which specifies which training set should be used to train the chosen learning technique. Also, “flag” attribute is designed to determine the need to perform the training of the selected technique, so when the training step is necessary, its value will be “1”, otherwise “0”.

“Ontology” entity has the “reasoner” attribute, which specifies which statement should be executed to perform the ontology’s reasoning. The “select” and “insert” attributes refer to the SPARQL queries that must be executed to search the data present in the ontology and to insert the data into the triple model of Storage Component. Also, this entity has the “local” attribute, which specifies the location on the disk of the OWL description file of the ontology used.

In Fig. 2 the entity “Action” can also be visualized, which has the “id” attribute that is responsible for the identification of the actions, the value of this attribute is used in the compositional rule to identify which action will be performed. Besides, the entity has the “action_performed” attribute, which specifies the actions to be performed. These actions are transferred to Medium Access Component, which is responsible for carrying out the necessary action. The commands are represented in the compositional rules by the “#C” tag followed by an identifier, which is the “id” attribute of the “Action” table.

Compositional Strategy Manager performs the execution of the compositional rule according to a specific execution flow, as we can see in Fig. 3. Initially, the desired compositional rule is obtained in the Storage Component, and Compositional Strategy Manager performs the identification of other rules present in the initial compositional rule. After, strategy categories explored are recognized. If learning techniques are used, it is necessary to search the “uri” attribute. Also, it is identified which training set should be used for training the technique, and the value of the “flag” attribute is verified to confirm the need to execute the training step.

Fig. 3.
figure 3

Execution flow of compositional rule

If the use of ontology-based reasoning was detected, it is necessary to search for the “local” attribute, which contains the location on disk of the ontology, allowing it to be loaded. After that, the Compositional Strategy Manager identifies the mechanism of reasoner chosen, being represented by the “reasoner” attribute. Also, the Compositional Strategy Manager searches the “select” attribute representing the SPARQL query that must be run to fetch the instances that were inferred during the reasoner process. Lastly, the “insert” attribute representing the SPARQL query that will insert the new instances into the triple model of Storage Component is identified.

After the identification of the strategy used and their processing, the Compositional Strategy Manager identifies the command represented in the compositional rule and sends a notification of the need for action to the Medium Access Component.

4 Evaluation

Several evaluation methods are present in the literature, among them, this work highlights the scenario-based assessment, which is considered a mature alternative to be used in context-aware environments [17]. Scenario-based methods evaluate the ability of the software architecture to deal with the demands of a set of interest scenarios [22]. Thus, to evaluate our proposed architecture, we use a scenario-based method.

This scenario is based on work [6], where our architecture monitors the vital signs of patients in cardiac rehabilitation and generates early alerts with the use of scores. For this, we proposed a compositional rule combining a rule-based and supervised learning strategy with the use of regression techniques. Thus, making it possible to predict possible situations of a collapse of a patient and anticipate the activation of the rapid response teams to the action.

With the use of compositional rules, unlike other studies, it is possible to combine the scores generated by different vital signs. Moreover, even the rules used to produce the scores are customizable and can be adapted to distinct patterns of patient behavior. Table 2 shows the values analyzed, in this scenario, to generate the early alerts based on the vital signs obtained.

Table 2. Early alerts score.

Figure 4 shows the compositional rule used in this scenario. We can see that the compositional rule is composed of two other rules, which are represented by #M1 and #M2, and they have conditionals to be evaluated, resulting in an action to be performed.

First, the Compositional Strategy Manager performs the identification of rules contained in the compositional rule. In this way, the rules M1 and M2 are identified, making it necessary to search for the rules described by the id with values 1 and 2 in the reasoning table, and the substitution of the tags that represent the rules in the compositional rule. After, Compositional Strategy Manager verifies if the rules have other rules represented by #M or if they have some tag #A referring to the learning technique or #O for ontology-based.

Fig. 4.
figure 4

Compositional rule used in evaluation scenario.

With the verification performed, the tags #A1 and #A2 are identified, making necessary find which techniques are present in the Learning table that have the ids with values 1 and 2. After the search, the Compositional Strategy Manager substitutes the tags by the URIs referring to the techniques. As learning strategies are used, the concatenation of the URI with the string “predict” is done, thus allowing to predict the data passed by parameter.

In Fig. 5 is shown the rule referring to tag #M1, which has the id field with value 1, which is used to treat the vital sign heart rate. Figure 6 shows the rule referring to tag #M2, with the id with value 2, which processes the data provided by the vital sign O\(_{2}\) saturation.

Fig. 5.
figure 5

Rule that replaces the M1 tag.

Fig. 6.
figure 6

Rule that replaces the M2 tag.

Figure 7 shows the rule resulting from the substitution of tag #A1 by the learning technique chosen to perform the reasoning. Where can be visualized the choice of linear learning technique LarsFootnote 1. This rule refers to the generation of alerts based on the data collected from the heart rate, creating the values of the score to be analyzed in the compositional rule.

Fig. 7.
figure 7

Rule with A1 tag replaced.

In Fig. 8 is shown the rule resulting from the substitution of the tag #A2 by the learning technique chosen to carry out the reasoning. Where can be visualized the choice of linear learning technique LassoFootnote 2. This rule refers to the generation of alerts based on the collected data of the O\(_{2}\) saturation, creating the values of the score to be analyzed in the compositional rule.

Fig. 8.
figure 8

Rule with A2 tag replaced.

It is important to note that the same parameter is passed for the two reasoning techniques because, in this scenario is always predicted the next expected value for that signal. The values of vital signs are passed to each technique during the training phase, which in this scenario occurs with each new vital sign collection.

Figure 9 presents the compositional rule that is applied in this scenario, where all markup tags have already been replaced, both by other rules and by learning techniques. Also, the action that should be executed, if the rule is evaluated as true, has already been inserted in the place of the #C1 tag. This action refers to sending a message by the instant message application to the responsible doctor, where the patient’s name and the situation of critical prediction are passed on in the message.

Fig. 9.
figure 9

Rule applied for alert generation.

In order to analyze the performance of learning techniques when predicting the next value of vital sign reading, it was decided to use measurements made available by the MIMIC databaseFootnote 3 (Multiparameter Intelligent Monitoring in Intensive Care). The MIMIC database includes data from more than 90 patients registered in an Intensive Care Unit (ICU), collected between 1992 and 1999, containing an average of 40 hours of physiological signal records [7].

Performance verification was based on the accuracy metric that is the proportion of instances predicted correctly. The use of this metric is justified by the fact that it is widely used to evaluate the quality of the results in several areas of artificial intelligence research with an emphasis on machine learning [8].

In this scenario, it is treated as a correctly classified instance, when the technique accurately predicts which score the future value of vital sign reading will have. In order to analyze the performance of the learning strategy, the prediction of the categories of the next vital sign value was performed using ten patients from the MIMIC database.

Tables 3 and 4 shows the accuracy achieved by the learning techniques employed, both for heart rate and SO\(_{2}\) saturation. Note that in some cells of the table is contained the character “– ”, which represents that for that patient no instance of that category was analyzed.

Table 3. Accuracy of strategy for heart rate.
Table 4. Accuracy of strategy for O\(_2\) saturation.

As we can see in Tables 3 and 4, the performance of learning strategies was satisfactory, reaching more than 0.95 % of hits in the total number instances of each patient. Note that in some cases all the predictions were correct, and these cases happened for the patients that have all the instances of the same score category. The worst accuracy rates obtained were 0.5 %, where it can be analyzed that they are of categories that had few instances, and still, it is of cases that the vital signs change rapidly among the score categories.

5 Conclusion

In this paper, we considered the challenges faced by context-aware applications in IoT, dealing with an increasing number of contextual data from different sources, formats, or semantics. In order to process these contextual data, works present in literature have explored hybrid reasoning strategies. Although many papers propose a hybrid reasoning strategy, we can note the absence of an approach that enables the processing of context information from different reasoning strategies stands out.

Considering these challenges, the following contributions have been achieved with the development of this work: (i) the design of an IoT architecture that supports hybrid context reasoning; (ii) the proposal of a Reasoning Component that provides multiple reasoning strategies; (iii) the conception of a compositional approach for context reasoning that enables the use of different reasoning strategies in a dynamic form, allowing the strategies utilization both individually or in a combined way.

With the conception of the compositional approach for context reasoning, the context-awareness services of the EXEHDA middleware have been updated, and now the middleware can provide different reasoning strategies. Thus, increasing the flexibility of acquired contexts reasoning, improving the identification of situations of interest, and facilitating decision-making.

The proposal was evaluated through one scenario that explores the use of the compositional strategy for context reasoning on the scope of current relevance, which is context awareness in healthcare. In this scenario, the compositional strategy was applied to process the vital signs of heart rate and SO\(_2\) saturation. We used two supervised learning techniques, and combine the results into a single compositional rule to identify risk situations with anticipation. With the use of compositional rules, we possibility the combination of scores of different vital signs, and the creation of rules customizable and adaptable to distinct patterns of patient behavior.

As future work, we highlight: (i) the interfaces developing using data visualization techniques to facilitate the interpretation of the stored contextual information and identified situations; (ii) explore the compositional strategy in different use cases, which can benefit from the features offers for context reasoning.