A Machine-learning-enabled Context-driven Control Mechanism for Software-defined Smart Home Networks

To address the challenges of autonomous capability enhancement in a smart home scenario, in this paper, we present a context-driven smart home control mechanism (SHCM) following software-defined network (SDN) design principles and a context cognition process. SHCM has three SDN-based layers: a control plane, a fog computing plane, and a data plane. We integrate a machine learning (ML) algorithm and an ontology model into the context cognition process, which will be leveraged to enhance the context-awareness-enabled automation level of smart home control systems. In the control plane, a controller adopts a ML-based tool to make connotative clustering and association rules via mining multiattribute context features inherent in diverse sensing applications, and utilizes an ontology model to automate integrated context management. Additionally, the fog computing plane applies edge-computing-supported context middleware to perform compressive sensing (CS)-based cross-layer context fusion. Furthermore, smart home devices implement context feedback in the data plane instructed by context-driven control strategies, which are mapped into the parameter matrix and matching rules in the lightweight flow-table mode. The effectiveness of this proposed control mechanism is validated by experiments using a context-oriented smart home prototype platform, which implements a closed-loop context-oriented feedback control from cognition-deduced knowledge generation to knowledge-driven cooperation in a cyber-physical smart home scenario. It is observed that the control mechanism can improve smart home automation and outperform baseline schemes.


Introduction
The advancement of science and technology has greatly improved the living standard of human beings and boosted the growing needs for an intelligent home control system.A home network system controlled by the Internet of Things (IoT) and ubiquitous computing (1,2) is becoming increasingly smart with the advances of sensing, computation, and communication technology.
Smart home systems (SHSs) with intelligent control mechanisms are evolving toward pervasive systems, (3) which can typically be designed as a network with a cyber-physical system (CPS).In smart home application scenarios, a growing number of heterogeneous smart devices communicate and cooperate with each other using various wireless technologies for providing personalized services, which will create a dynamical home environment and lead to diversified complex context features in SHSs (e.g., heterogeneous, reusable, redundant, delay-sensitive, reconfigurable, and human-centered features).Therefore, it will raise the critical problem of how to unearth and manage the multiattribute features of an integrated context in smart home networks.On the other hand, owing to various heterogeneous devices, communication protocols, and context characterization models, the integration of interdisciplinary technologies from different fields in smart home application scenarios (e.g., the coexistence of various technologies for achieving cross-layer communication) is very important.It presents several big challenges in the network functional infrastructure with heterogeneity-compatible, reconfigurable, and self-manageable capabilities.
To tackle the above challenges and efficiently support interacting diverse home services including machine-to-person and machine-to-machine intercommunications, we need to design appropriate methods to achieve integrated context cognition and management in SHSs.Featuremining operations using machine learning (ML) (4) have been widely used in various functional designs of a self-aware control mechanism to achieve self-configuration and self-adaptive control.
Note that a context model helps to construct smart home control strategies in a convenient and flexible manner.Ontology (5) can be formalized as a rule-based management tool to reveal semantic relationships in a pervasive system via describing the context at high-level abstraction.An ontology-based context model (6) has the advantage in meeting the fundamental context management requirements of the growing and interacting human-centered applications in SHSs.The inherent vulnerabilities of non-software-defined network (SDN) infrastructure (7) are limited in achieving the autonomous capabilities (e.g., reusability and interoperability) of context processing for addressing the above challenges.A flexible network functional framework is needed for standardizing various protocols and supporting diversity in smart home services.SDN (8) technology facilitates network management and enables programmatically efficient network configuration in order to improve network performance and monitoring.It seeks to be suitable for improving the multiattributed context processing capacity by decoupling network control and forwarding functions in network function architecture.SDN also has the advantages of providing virtualization network resources and programming models for distributed heterogeneous context processing.
With the emergence of handheld mobile terminals in SHSs, many multilevel context services are often located at the edge of a home control center and should be processed nearby.Traditional service delivery methods based on cloud computing (9) will lead to a high network load and a transmission delay caused by context exchange between home devices and remote cloud servers.Therefore, the requirement of middleware technology using edge computing is put forward to achieve cross-layer context sharing and localized context processing in smart home scenarios.Fog computing (10) viewed as SDN middleware inherits the advantages of not only cloud computing but also edge computing, which can give full play to the cross-layer capability and provide an effective way for local context processing in home scenarios.
Nowadays, many existing studies based on the above technologies have been applied to the design of a smart home control system.The context-aware mechanism that infers user preferences and achieves user behavior pattern recognition has been studied in many different fields.Allègre et al. (11) proposed a context-aware system to provide adaptive services based on the semantic analysis by defining user-system interactions to home automation.Li and Liu (12) proposed a certain information management system for constructing context integration rules to achieve activity pattern recognition.Owing to the increased cost and demands in SHSs, context-sensitive energy efficiency becomes a key requirement for developing smart homes.Andrade et al. (13) proposed an energy-aware management mechanism for SHSs using a fuzzy technique to reduce power consumption.However, the above context awareness studies are focused on optimizing the gathering, processing, and transferring processes in smart home performance based on an isolated and environment-oriented context.This will lead to some shortcomings in conventional context-processing schemes, which ignore the following functions including the device interoperability and human-oriented rule mining, and thus not adaptive to evolving environments and personalized habit profiles (personal intention).Additionally, these context-aware frameworks focus on environment-oriented rather than human-oriented functions, which are relatively negligible for an end-user habit-profile-related context, which can be associated with the intention to use corresponding context-oriented services.
As an ML-based mechanism, practical context cognition models using unsupervised and/ or supervised learning algorithms can help to analyze the evolving dynamic environment and diverse inhabitant activities, thus increasing the context-aware capability of a home control system.Acting as unsupervised ML, K-means (4) is a clustering method for the mining of characteristics in a context classification situation and Apriori (14) helps to mine the priori nature in a frequent item and an association rule over transactional databases.They can help to imply the connotation relevance of the context integrated in SHSs.Reinforcement learning (RL) (15) is inspired by behavioral psychology and focuses on how software agents take actions in an environment to maximize cumulative reward.Consequently, RL can enhance the self-learning ability of an unsupervised ML to mine the connotative behavior characteristics in the collected multiattributed context.Wan et al. (16) proposed a dynamic sensor segmentation approach to achieve a better representation of activities and extract context features for real-time activity recognition using ML techniques.
An ontology-based context learning system (17) is an efficient tool for context management.Cheng et al. (18) designed an ontology-based smart home reasoning system (ASBR) using support vector machines (SVMs) for rebuilding knowledge according to user preferences.Middlewarebased gateway technology has been adopted by WSN-based smart homes (19) to collect data and learn the user behavior for accomplishing essential daily activities.The advent of SDN (20) has the potential to revolutionarily improve the existing home control schemes by enabling distributed cyber-physical control.Recently, the integration of smart home networks and SDN has attracted the interest of researchers.Yang et al. (21) designed a two-tier architecture, in which a logic control layer for data analysis and a cloud logic layer are utilized to handle the everincreasing data traffic in SHSs.Xu et al. (22) designed an SDN-based smart home architecture that can be connected to other platforms via an open interface.However, the existing SDNbased research studies are limited in cross-layer and localized processing capabilities of an integrated multiattributed context, thus resulting in an unacceptable response delay and a low heterogeneity compatibility in SHSs.
Motivated by the above research progress in context-oriented technologies, we developed a novel context cognition prototype, by integrating ML-based context learning, fog-enabled context computing, and ontology-driven context management in an SDN architecture, to improve the context-driven autonomy ability in the smart home control mechanism (SHCM).The proposed prototype will be leveraged to enhance the ubiquitous context awareness processing in a smart home control system.
The main contributions of our proposed prototype can be summarized as follows to further optimize smart home control.
• A novel context-driven cognition prototype adopting ML-enabled multiattributed feature mining schemes under an ontology structure is designed to optimize the human-oriented adaptive interoperability of heterogeneous devices in dynamic SHSs.
The proposed SHCM can enhance the human-centered environment adaptability of SHCM, which considers the preferences of different end-users under the ever-changing situation of SHSs.In this paper, the adaptive interoperability of SHCM is instantiated as the energyaware context sampling of sensors and the user-profile-oriented output of actuators in SHSs.
• The use of a flow-table-driven context feedback mechanism in the SDN functional framework with fog computing middleware is proposed in SHCM to improve the energy efficiency and heterogeneity compatibility on cross-layer context processing.SHCM adopts a f low-table matching mode to obtain ML-enabled control strategy outputs, which are mapped into a rule-based parameter matrix and instantiated as serial lightweight operations including context fusion and seamless heterogeneous communication protocol switching in the paper.
The rest of the paper is organized as follows.In Sect.2, we elaborate the context-cognitionbased system model with an ML-enabled SDN functional architecture prototype.Section 3 shows the construction of a specific context-driven control strategy in SHCM using the proposed prototype.In Sect.4, the proposed SHCM is evaluated through experiments.Finally, conclusions and future work are presented in Sect. 5.

SDN-based CPS model
SHS is modeled as a three-tier CPS-based functional architecture as shown in Fig. 1, where cognition-context-driven control strategies are optimized using a closed-loop cyber processing system in a SDN system, which is composed of the data, fog computing, and control.
SHS is abstracted into CPS with context semantics processing and a context transmission topology.In CPS, the context transmission topology is abstracted into a weighted directed graph, G(V, L, W), which constructs the context topology model based on graph theory and is formed as a reverse multicast tree rooted at the controller in the cloud.Each smart home device is embedded with sensors and actuators in V with a hierarchical cluster and a heterogeneous supporting protocol.Various communication technologies provide wire/wireless connectivity services on L for building an IoT-based topology on home service platforms.W is the set of weights, which represents the diverse crucial levels of home devices in V.
A software-defined wireless network (SDWN) (23,24) enables programmable and virtualized control in network equipment via the decoupling control and data planes.The SDWN-based architecture (25) can separate complex control functions from the forwarding devices and develop a centralized control plane to improve the operability of managing the entire smart home network.It also seeks to be suitable for the mining dynamic and heterogeneous nature of contexts in smart home scenarios, which would improve the scalability of context-oriented multitasking and the compatibility of heterogeneous protocols in SHCM.The CPS network architecture in SHSs is constructed using SDN-based programmable planes.In the control plane, the controller unifies the entire home network and plays an important role in optimizing network management by decoupling control and forwarding functions provided by smart devices in the data plane.Cyber learning functions for context awareness achieved with MLbased algorithms will be leveraged to enhance the context cognition ability of the controller in SHSs.Additionally, contexts are modeled as ontology in the cyber cognition module (CCM) for semantically applied context reasoning.
In our work, an ML-based ontology context model is applied as an effective tool to design a context-driven prototype of the SHS control mechanism.It can facilitate the smart home services driven by semantics-based logics and feature-based rules, thus extending the contextoriented cognition and management capabilities of SHCM.Fog computing (26) -enabled context middleware is introduced into SHCM to take advantage of the edge computing capability and proximity processing superiority, and meets the requirements of delay-sensitive scenarios by providing more localized services and context fusion.According to the context characteristics of the distribution generation and cross-layer communication mode, we take compressive sensing (CS) (27) as a context fusion tool to achieve energy efficiency in the fog computing plane.
On the basis of the above three-tier functional planes, SHCM is endowed with an ML-based cyber learning capability and a fog-based cyber-computing capability in the SDN functional framework to optimize the context-oriented SHCM.It will facilitate the cross-layer context integration and automatically provide satisfying home services for users in CPS-based SHSs.

Context-driven functional framework in SHCM
The intelligence of SHSs depends on the context-aware and ubiquitous computing capabilities in home control strategies.The control plane acting as a fog server can manage network services according to the SDN protocol, perform the cyber learning function by mining the context features, and optimize control strategies, which can be downloaded into the data plane in the flow-table mode.
An ML-based ontology context model is introduced into the CCM to generate knowledge for revealing the variety in evolving ambient and the diversity in end-user habit profile.CCM exploits the methodology of context cognition, which has been recognized as the core element of the context-driven prototype shown in Fig. 1.In the SDWN-based smart home network, the control plane can take logically centralized control to facilitate network management and enable programmatically efficient network configuration.
We take the fog computing plane to be functionalized as virtualized middleware, which can perform edge computing and localized processing to achieve CS-based cross-layer context fusion in SHCM, where the context computing and storage are performed at the edge of a smart home network, i.e., as close as possible to the end-user devices in the data plane.This helps to reduce the total network load and network latency while improving the scalability to expand new context source devices into a smart home network.We take the fog computing plane as context middleware in the SDN-based network framework to achieve seamless cross-layer context switching and compatible localized context fusion.
The data plane in the physical system in SHSs is composed of actuators and sensors to execute context gathering and context feedback operations instructed by control strategies, which are yielded from the policy decision (PD) module.Each sensor or actuator in the data plane plays the role of a logical switch to disassociate the context forwarding process obeying flow-table rules.The duties of the data plane focus on specifically realizing the environmental adaptation and energy-efficient interoperability of home devices in SHSs.
The data processing function executed in CPS-based SHCM includes context generation, context fusion, and context feature extraction.Specifically, the adaptive sampling method obeying the Nyquist sampling theorem is adopted by each sensor for context generation.The flow-table-driven rules for context forwarding and routing are followed by each actuator.Heterogeneous context fusion is achieved in the fog node by CS.The controller considered as the brain of the SDN is responsible for context feature extraction and context management using ML and ontology model data management.
The control mechanism adopts the ontology-driven context management and ML-based context learning in SHCM.CCM in the cyber system of the control plane performs contextdriven operations (including context reconstruction, recognition, and training) to optimize the control strategy of the home system.CCM adopts the ML mechanism to mine context features while revealing implicit environmental states and end-user habit profiles, which finally can be mapped into context-driven control operations.Supervised learning (e.g., RL) and unsupervised learning functions using ML are embedded in the CCM of the control plane to improve the context-aware capability in SHCM, thus resulting in knowledge discovery on context reasoning in smart home appliances.The ontology context model shown is used in CCM to optimize context management.It encompasses the representation and definition of context categories to draw a logical chain diagram.According to the output of CCM, PD constructs control strategies, which include optimal actions deduced by ML.SHCM in the data plane is responsible for translating the control strategies (obtained by PD) into a control parameter matrix in the SDN-based flow-table mode, which is instructed by the 'action field' and subjected to the 'match field' shown in Fig. 1.Then, the SHS physical system performs specific control operations based on the control parameter matrix in the over-the-air provisioning (OTAP) (28) -based wireless reconfiguration mode.
On the basis of the proposed SHCM, a closed-loop control strategy can be optimized by context cognition and context feedback in a smart home scenario, which essentially constructs a context-driven prototype shown in Fig. 1.

ML-based context cognition in SHS control plane
ML is adopted to rationalize the law inherent in a dynamic environment and evaluate the performance on individual activity recognition for promoting context-oriented personalized services.We develop a context-cognition-driven control strategy in CCM to enhance the autonomy of SHCM by ML-based feature mining and ontology-based management, which finally helps to enhance the interoperability and adaptability of smart devices in applicationoriented smart home scenarios, finally improving intelligent performance in SHCM.

Definition 1: Contexts
are defined as functional states emerging from the interaction between diversity sensory information and corresponding functional structures realized by smart devices (sensors and actuators) with a computational ability in distributed and heterogeneous networks.Each context will consist of both the environmental evolution information and the adaptive user profile in a smart home scenario.
During a specific context gathering round B, the multiattributed context generated by the data plane can be modeled as a multidimensional matrix in the equation where each component , x denotes the single-attribute context vector, B is the temporal dimension, i and j respectively represent the spatial dimension [i.e., hierarchical cluster structure Cluster(i)] and application-oriented dimensions, such as temperature, humidity, lighting, and location in x B .The cyber status pool built by x B in the control plane tracks how the operational environment evolves with B, where new context states can be mined and new actions should be discovered.Definition 2: Situation s B is defined as a high-level context integrated to maintain the hierarchical knowledge structure and provide reasoning at low-level context abstraction in a smart home environment.The situation used as the practical context model is heavily related to cognition modelling and understanding, especially in human activities and evolving environments.
Ontology is a useful concept tool supporting a nonintrusive context-aware system to achieve context-driven local service activation.An ontology-based context model is utilized to analyze context-related services and reveal corresponding context driving rules according to the connotative features mined in the situation.Definition 3: The context ontology Σ ontology formalized by using a 4-tuple structure is defined as Eq. ( 2) to describe, assess, and manage contexts as hierarchical structures for smart home applications.

,
, , Here, Σ context denotes the multiattributed context x B produced by different actuators and sensors in a data plane.Σ situation (i.e., s B ) represents the integrated context, and it can construct a set of information classes (i.e., contextual cases) with corresponding functional properties.Σ interpreter is used as a feature-mining tool using ML-based technologies for context reasoning and Σ assigner obtains SDN-mode outputs, which are mapped into a parameter matrix in the action domain of the flow table and achieve context-driven interoperations among smart devices.
The ontology-based context model (i.e., Σ ontology ) in CCM is adopted to generate knowledge for revealing the variety in evolving ambient and the diversity in end-user habit profile.ML algorithms including autoregressive moving average (ARMA) (29) models, K-means as well as the Apriori algorithm are utilized in Σ interpreter to mine the multidimensional attributes in x B .This will enhance the context cognition ability in SHCM.ARMA with sliding window techniques can capture the statistical characteristics of a time series, and it is commonly used in environment monitoring event assessment and user behavior event segmentation.The ARMAbased value factor , B i j F [defined in Eq. ( 3)] is designed as a context prediction tool in Σ interpreter to capture the time-correlation statistical characteristics of , Here, , ˆB i j x denotes the ARMA result of , B i j x and ||•|| l is the normalized Frobenius norm. (30)On the basis of information entropy theory, (31) the greater fluctuation in , B i j F will indicate a larger average amount of information contained in arriving , B i j x and a higher probability of important events occurring under the premise of no external influence.This helps to underlie the temporal aggregation law of an evolving environment in SHS.Besides revealing the above , the situation element s B B ontology ∈Σ x can be used to provide reasoning on the context integrated in a smart home scenario.The K-means and Apriori algorithm are introduced into Σ interpreter to excavate the attribute-dimension characteristics including clustering and association rules in s B .This can contribute to the analysis of the dynamic environment and diverse personalized habit profiles in a cyber system of a smart home.K-means is used as a context-clustering tool in Σ interpreter to classify cases with situation s B .Specifically, the similarity calculation with the nearest mean in a target context space is performed following Eq.( 4) to find the most similar k cases and serve as a prototype of a context cluster.Here, , denotes the rank of the context matrix. ; Through an iterative method, the value of each cluster center will be successively updated until the best clustering , B i j C are obtained by Eq. ( 4), which can construct the most similar contextual cases.According to the partitioning results of K-means, the context space should be divided into case-based cells built by context clustering.This helps to identify end-user habit profiles and provide corresponding personalized services in SHSs.
Furthermore, the strong association rules inherent in , C can be revealed by Eq. ( 5) using Apriori to achieve knowledge-based context reasoning over situation s B .Viewed as a context association tool in Σ interpreter , Apriori is used for frequent item set mining and association rule learning over situation s B .Specifically, by accumulating the candidate frequent items on , B i j C while meeting the minimum support degree (i.e., min_conf ) and minimum confidence threshold (i.e., min_conf ), strong association rules , B i j A of s B can be used to mine a connotative situational relation and drive human-oriented cooperation among smart devices.Accordingly, optimal control strategies instructed by association rules , B i j A will be implemented by Σ assigner to guide the output behavior of smart devices in the data plane.
, , ; P: S × A × S denotes the state transition probability, which is given by Eq. ( 9) to drive specific control operations.
The reward function R: S × A → R indicates the environmental reward to the corresponding action.The local reward function , B i j r ∈ R is designed as the third constraint term in Eq. (7).It is deduced by a temporal-attributed redundant or multiattributed interactive degree to optimize context-driven control operations in the encouragement or punishment mode.Then, global reward is accumulated by maximizing local reward in each context mining round using the Q function (32) by CCM.The policy Γ shown in Eq. ( 7) should be constantly updated to match state-event pairs with optimal actions.After the B th iteration, , B i j Ψ is obtained according to the comparison of the Q-value between the B th and (B -1) th rounds.
Each state element , B i j situation s ∈Σ shown as Eq. ( 6) is composed of multidimensional attributes in ∑ ontology , and it is updated in each context gathering round for Q-learning.
], ; Here, λ and γ denote the learning and discount factors, , On the basis of the policy Γ produced by PD in Fig. 1, a controller will produce optimal actions with a local maximum Q-value according to the equation . .
( ) max( , ); , ; Here , Then, the optimal action set { } , B i j a ⊂ A will be fed into the switch flow table in the data plane and executed according to the transfer rule given by , , ) , where , , ( ) is the state assessment for action and , B i j a under state , B i j situation s ∈Σ using Γ.
Consequently, as a training result of Q-learning, ,

B i j situation
s ∈Σ should be utilized to optimize the context-driven outputs obtained by Σ assigner .
Owing to ML-based context mining and feature training, SHCM can be endowed with a context recognition ability to gain knowledge of human-oriented events and environmentoriented evolving laws in dynamic and evolving smart home environments.Cloud-computingbased SHCM usually places computing and storage functions on a distant cloud platform.It increases the transmission delay and bandwidth cost, and is not suitable for delay-sensitive and energy-constrained smart home applications.Therefore, we adopt edge computing technology in this study to address the above challenges in the cloud-computing mode.
Fog computing acting as an edge computing platform can optimize data processing at the edge of the network, near the data source.It significantly decreases the communication load between the control and data planes, thereby reducing transmission costs and shrinking latency.
Motivated by the advantages of fog computing, the fog computing plane in Fig. 1 is introduced into the SDN-based network functional framework to realize redundancy compression, heterogeneity fusion, and localized processing of the context.To keep the realtime response and guarantee reliable transmission for smart home applications (e.g., the urgent alarming response), embedded sensors and actuators in smart devices should frequently collect environmental data and record huge historical operations.This leads to the huge transmission cost and unacceptable transmission delay caused by the dense distribution of spatial-temporal redundant loads in a smart home network.To address this issue, CS is adopted in the fog computing plane and used as a context-compressing tool in interpreter ontology Σ ∈Σ to achieve the sparsity and reconstruction on x B .
Consequently, SHCM can adaptively adjust the sensor sampling frequency and actuator's cooperative probability according to the dynamic environment statuses (nonmetal states) and various end-user habit profiles (metal states) in the data plane, respectively.The design of optimal control strategies essentially reflects the context feedback process from a cyber system to a physical system in SHCM.
The SDN-based network function framework in the fog computing plane can improve the heterogeneity tolerance of SHSs through gateway middleware technology and a loosely coupled network structure.In the proposed SDN-FC framework, the heterogeneous fusion function in the fog computing plane is achieved by adopting the SDN-based network functional framework to enable programmatically efficient network configuration and decouple network control forwarding functions.It contributes to seamlessly manage heterogeneous physical resources and establishes compatible connectivity and interface between various types of home devices.In home scenarios, mobile smart terminal devices frequently operated by end users in the data plane have characteristic random mobility and position sensitivity.Thus, we need home applications to pay more attention to the context surrounding the local environment for enhancing the localized service quality.Fog computing technology adopts the edge computing and localized context storage and processing mode.It can timely process contextual service requests from the mobile terminal user surrounding areas and meet the requirements of delaysensitive applications such as real-time alarm on emergent events and a low-latency response in a mobile service situation accordingly.
In essence, CS-based redundancy compression and fog-based local decision in the edge computing mode rationally optimize context resource allocation (i.e., context-related computing and storage resources), thus contributing to energy saving and localized service quality.Consequently, the total system response delay and energy cost are significantly reduced on the premise of quality of services in SHSs.

Flow-table-driven context feedback in SHS data plane
We achieve the optimal context feedback control in the data plane in the flow-table mode.On the basis of the functional modules in CCM for context cognition and context management, we design control strategies in SHCM using ontology-based context management and ML-based context mining under the SDW-FC framework (shown as Fig. 1).Then, the optimal strategies produced by CCM can be correspondingly transformed into a lightweight control parameter matrix and matching rules to achieve context-feedback cooperation.
Specifically, ∑ assigner adopts the flow-table matching mode to let context-driven outputs [produced by Eqs. ( 8) and ( 9)] and context-mining features [produced by Eqs. ( 4) and ( 5)] be mapped into a parameter matrix (i.e., π 1 ), which involves the cooperative output behaviors of smart devices stored in the action field of the flow table.Each element in π 1 contains the specific functional control parameters of various smart devices (e.g., the output level of the heater, the brightness grade of the lamp, the switching value scale of an air conditioner or a refrigerator, the frequency range of sampling rate, and the setting values of temperature and humidity for an environment sensor.Matching rules (i.e., π 2 in the match field) involve the clustering and strong association rules deduced by ML in multiattributed joint contexts in smart home scenarios.Furthermore, the control parameter matrix [π 1 , π 2 ] should be downloaded into the action and match fields in the corresponding flow table entry of the switch.
Consequently, the context-driven control operations instructed by the action field and subjected to the match field are executed via smart devices (embedded with actuators and sensors) in the OTAP-based wireless reconfiguration mode.Results indicate that the services constructed by the optimal cooperative outputs of smart devices can improve the interoperability and self-adaptation capabilities with low latency, and also enhance the energy saving effect in SHCM.

Experimental Results and Analysis
The experiments are designed to evaluate the smart home control strategies performed by a context-driven prototype in SHCM.The proposed prototype is simulated to test network performance and feasibility in a smart home environment using the SDN-based architecture shown in Fig. 1.
The implementation environment constructs a SHS with several network technologies (including WIFI, Ethernet, Bluetooth, and Zigbee) and has three types of devices (i.e., controller, fog node, and smart devices) that interact with each other to generate experimental data.The smart home has been equipped with 43 smart devices (constructed by programmable actuators or sensors) that monitor light, humidity, temperature, and location to obtain raw context descriptions of user behaviors.A controller with a lightweight OpenFlow platform (33) (i.e., POX) is responsible for constructing optimal control strategies and making smart devices in the data plane lightly carry out corresponding control operations in the flow-table mode.The fog node is used as an ARM-embedded intelligent gateway (i.e., Arduino Raspberry Pi with 64-bit 1.4G CPU) to communicate with the control plane and wirelessly reconfigure smart devices in the data plane using OTAP (e.g., programmable thermostats, heater, air conditioner, humidifier, and lamp).The network simulator NS3, (34) network building tool Gephi, (35) and ontology language tool Protégé 4.1 (36) are used to construct the experiment verification platform and analyze the performance of the proposed SHCM using a cognitive context-based prototype.We implement the case-based context ontology using the ontology language OWL, Protégé 4.1.The evaluation criteria focus on validating the performance of the context-ontology-driven control mechanism including adaptability and interoperability in SHCM.

Performance evaluation on ML-based context reasoning
On the basis of the software defined network framework, SHCM adopts ML technologies to mine context connotative characteristics and generate knowledge-based context reasoning in a smart home.It excavates environmental evolving laws and end-user habit profiles, constructs a context-reasoning-based control strategy, and achieves context-feedback-driven cooperative actions on a smart home physical system.The specific parameters of the ML-based context cognition algorithm are shown in Table 1.
K-means is adopted as an ML-based context interpreter in ∑ ontology [formalized by Eq. ( 2)] to mine the connotative clustering characteristic in the multiattributed context [modeled as Eq. ( 1)].Specifically, the context reasoning procedure can be performed using Eq. ( 4) to cluster the k service cases in the context space and classify the service objects closest to them, which finally help infer end-user intention and support personalized services.
On the basis of the context records accumulated, unsupervised learning is adopted to deduce clustering and strong association rules and correspondingly drive environment-adaptive and personalized services.These experiments are designed to verify the effectiveness of the K-means clustering method in identifying the interaction between an evolving situation and corresponding services.
The procedure is designed on the basis of the K-means algorithm to cluster the k service cases in the context space and classify the service objects closest to them.Through this iterative method, the center of each cluster is updated successively until the best clustering result is obtained.K-means is utilized to effectively manage context instances and take similarity calculation to infer end-user intention and support personalized services depending on the inhabitants' related context by mining the connotative clustering characteristic in the integrated context.The circular spots in Fig. 2 denote the cluster centers obtained by K-means, which can be applied by a centroid classifier to classify new contexts into existing ones, thus identifying some personalized habit profiles.Figures 2(a)-2(c) indicate the statistical association between the inhabitant favorite preferences in a smart home context (e.g., temperature, light intensity, and humidity) and the corresponding output settings of actuators (i.e., thermostats) in an   The simulation results in Fig. 2 imply that SHCM can improve the situational awareness ability through ML-based feature mining, which contributes to providing appropriate services associated with user preferences.
The environment-oriented adaptability and human-oriented recognition ability can be further augmented by supplementing the position dimension in the context mining.Therefore, we use context clustering results with location-aware reasoning to further enhance the humanized effect in SHCM.Simulation results in Fig. 3 are produced by K-means to evaluate the nearest centroid classifier and produce clustering rules, which are then mapped into the corresponding It can be seen from Fig. 4 that the end-user preferences can be deduced from the knowledgebased rules using a context-association Σ interpreter (i.e., Apriori algorithm) according to Eq. ( 5), and this can generate strong association rules to mine the connotation relevance in situation s B , so as to infer the inhabitant behavioral law and instruct rule-based user-system interactions.Specifically, we can excavate the end-user habit profiles and the evolving law of the dynamic environment, and use them to motivate the self-adaptive cooperation driven by the output parameter matrix (related to customary preferences) and executed by smart devices in the data plane according to the association rules produced by integrated context mining.According to the analysis of the output of strong association rules and the frequent item calculation of the transaction set, Fig. 4 shows the ranked results where the ordinate denotes the confidence and the support belongs to the connotation of association rules.Some association operations [e.g., 'close door -> close window (40%, 66.6667%)', 'Turn on air conditioner -> Turn on humidifier (30%, 100%)'] are mined to infer end-user habit profiles and finally to improve the humanorient interoperability of smart devices in the data plane.The experimental results in Fig. 4 indicate that the context-driven strong association rules deduced using Eq. ( 5) can efficiently guide the cooperative operations of smart devices in the data plane.As can be seen from the results, the optimal set of actions obtained using Eq. ( 8) should improve the interoperability of smart devices via achieving context feedback (denoted by action field π 1 and matching field π 2 in the flow-table-driven mode) on the physical system of a smart home.
The above experiment results can be utilized to infer end-user preferences or intentions and provide corresponding suitable services, which can be exploited to further improve the contextdriven cooperative ability of smart devices.By introducing ML into CCM, output operations in SHCM will be automatically adjusted to make the scenario be more suitable to end-user requirements.

Verification of adaptive sampling-based context feedback
Figure 5 shows a comparison of the instantaneous energy consumption between the adaptive sampling strategy and the fixed sampling mechanism in SHCM.The result shows that the proposed adaptive sampling strategy [shown as Eq. ( 8)] can automatically capture the time window containing the abnormal time series (e.g., emergency or alarm events taking place) and accordingly increase the sampling frequency to guarantee the reliability of the valuable sampled context.Additionally, this adaptive sampling adjustment method can automatically reduce the sampling frequency when the context flow fluctuation occurs smoothly, therefore observing the effect of filtering on the temporal redundant context.Figure 5 also suggests that the adaptive sampling mechanism consumes more energy than the fixed sampling one during the specific monitoring periods of 20 and 30 s when high-application-value events occur.In contrast, the energy cost in the fixed sampling strategy remains stable, which is insensitive to the evolving situation of the environment.However, the average energy consumption of the control system is lower than those obtained by the fixed sampling strategy in a longer period.It is important to reduce the average latency time (ALT) between the control and data planes in the application of SHCM.We define ALT as the average transmission latency from the data plane to specific controllers in the control plane during the given period, which is calculated as where min delay(v d ,v s ) denotes the minimal transmission delay between any sensor As can be seen from the results in Fig. 6, with the decrease in distance between fog nodes and the event center and the increase in the number of fog nodes, ALT will be significantly reduced.ALT reaches its maximal value when the number of fog nodes is zero, which shows that the control system does not adopt the fog computing mode.The main reason for this is that more storage and computing resources can be allocated for localized context processing, while SHCM adopts the fog computing mode to enhance the context processing ability.It will be beneficial to delay-sensitive smart home applications (e.g., alarming for emergency), which need a small delay for achieving a real-time system response.
Figure 7 shows a comparison of the average cumulative energy costs of a temperature context monitor with different energy saving mechanisms in the living room during a period of time.The results of the corresponding statistical analysis of the context set are shown in Table 2.These results include the average test results for environmental monitoring application with 200 experimental tests.The ordinate in Fig. 7 denotes the normalized energy consumption ratio (i.e., the ratio to the corresponding maximal energy consumption).The diagram indicates that, compared with the fixed sampling mechanism, the CS-based adaptive sampling mechanism can reduce the total energy consumption from 21 to 48% during the monitoring periods of 1 and 110 s under the premise of QoS in the monitoring application.With time, the total energy cost gap between the different context processing methods (i.e., context sampling, compressing, and transmitting) continues to expand.On the basis of the principle of CS, the raw context can be converted into sparsity and reconstruction-based knowledge, which can be used to reduce the transmission energy and delay caused by context communication in SHSs.The result shows that the CS-based adaptive sampling method has a higher performance in terms of the energy saving effect than the fixed sampling method adopted in the same smart home scenario.

Evaluation of ontology-based context management
In the control plane, the ontology-based context model plays a key role in supporting an efficient context management, which is utilized to perform context interpretation, drive contextrelated services, and reveal context-event relations (ERs) based on the connotative feature mining in a certain situation.The ontology-based context management in SHCM is evaluated by semantic analysis to verify logical conflicts and determine the relationship in Fig. 8 for a home situation at runtime.An ontology function interface based on a context-driven ER model in SHCM is illustrated in Fig. 8, which can essentially embody the context interaction process driven by association rules and clustering results obtained using Eqs.( 4) and ( 5) from the perspective of context management.The ER model bears the main function of database management for building the context pool in Fig. 1, which includes eight entities, namely, users, user preferences, sensors, sensor context, device, device operation records, alarm rules, and triggering records.
The specific context entities in the relationship model of SHCM are constructed by context mining and context reasoning performed with the ML mechanism using Eq.(7).Consequently, the ontology-based model in SHCM can be converted into a relationship context entity model to guide the cooperation of smart devices in the data plane, thus finally improving the contextdriven autonomous management ability in SHCM.

Comparison of context-driven adaptability with linebase
To analyze the performance adaptability of the proposed SHCM, the performance of the controller system, which includes the adaptability of heterogeneous communication protocol switching and the dynamic context-case matching, was observed.Figure 9 presents the results of the analysis of the compatibility of the cross-layer heterogeneous communication protocol (i.e., environment-related context) switching.According to the link switching case shown in Fig. 9, we observed a change in throughput with a nearly seamless response time (less than 1).It is produced by the impact of redirection flows on heterogeneous communication switching, while SHCM adopts fog computing middleware in the SDN functional framework.
In SHCM, the controller initially creates rules on the favorite wireless communication technology for the end user, and thereafter, it updates the rules on the use of WIFI interfaces whenever a new link is available as shown in Fig. 9 To evaluate the robustness-related adaptability for an ever-changing context (i.e., context events with diverse arriving rates), we synthesize the following indicators (including links failures, packets loss, and network latency) of different control mechanisms in a dynamic smart home environment.We define the context-oriented unfitness degree η unfitness as where η PLR and η LFR represent the average packet loss rate (PLR) and link failure rate (LFR) of a network, respectively.η ALT denotes ALT in Eq. (10).η PLR is calculated using different sensors in different rooms of a smart home scenario.The comparison of the η unfitness [defined as Eq.(11)] of SHCM with schemes 1 (11) (i.e., baseline), 2 , (37) 3, (38) 4, (18) and 5 (i.e., SHCM without fog computing) is shown in Fig. 10.We consider scheme 1 as a baseline scheme, because it is not provided with the context-driven processing capability and SDN-based functional framework in a SHCM.The system performance in scheme 1 can be improved by respectively utilizing the ML algorithm (adopted in scheme 2) and ontology classes (used for scheme 3) to enhance context learning and context management capabilities.Furthermore, scheme 4 is supported by the SDN-based platform to develop the ability of processing the cross-layer and heterogeneous context.Results in Fig. 10 indicate that the proposed SHCM performs better than the baseline schemes with respect to different context-event arrival rates due to the context cognition capabilities of CCM, which are produced by ML, the ontology model, and fog computing.

Conclusions and Future Work
In this study, we developed a context-driven prototype to achieve the intelligent control and management of a SHS by integrating ML-driven context learning, fog-enabled context computing, and ontology-based context managing in the SDN architecture.This architecture is divided into three functional layers including control, fog computing, and data planes.The controller in the control plane produces optimal control strategies using ML-based approaches, which perform unsupervised-learning-based context feature extraction and reinforcementlearning-driven context feature training.Additionally, we apply an ontology-driven context model to reveal rule-based semantic relationships implied in context management and facilitate context-aware smart home services, thus finally improving the capability of context cognition and context management in SHSs.Furthermore, we design the fog computing plane as a cross-layer context middleware to achieve context fusion by CS for low-dimension context reconstruction in the edge computing mode.Finally, the control strategy is mapped into the corresponding parameter matrix and matching rules in the lightweight flow-table mode.It guides the interoperations among smart devices in the data plane by sensor-related adaptive sampling and actuator-related cooperation.Experimental results indicate that the proposed context-driven system control mechanism can enhance the autonomous ability in SHCM while being automatically adapted to personalized habit profiles and an evolved environment.It contributes to improving the autonomous capability (including adaptability, heterogeneity compatibility, and interoperability) of SHCM, which can create environment-adapted and userfriendly home services, thus prompting its usage in other distributed user-system interaction control systems.The evaluation results also prove that SHCM can outperform the baseline schemes.
Some concrete future research directions and novel technologies, which can open new vistas for the future, have been added in our study.Our research results would be integrated with some advanced research directions including cybersecurity, (39) green communication, (40) cognitive radio, (41) and optical mobile communications technologies (42) to further improve energy efficiency and autonomy in SHCM.
The future technical prospects of the paper are illustrated as follows.
• Green communication provides the next densification solutions for IoT-based networks, which process essential data, applications, and services directly in their routers in order to be autonomous from the central cloud and to preserve the Internet bandwidth from local communications.It can help to further greatly reduce the system energy cost in SHCM and essentially embody the green communication effect.• Cognitive radio (CR) is an intelligent radio frequency technology that can be programmed and configured dynamically to detect available wireless channels in its vicinity to avoid interference and congestion.CR-based technology can be introduced into OTPA to achieve flow-table-driven context feedback in the data plane, which can further improve the detection capability of the available wireless spectrum and optimize the reconfiguration of control parameters in SHCM.
The proposed control mechanism SHCM has some limitations in the following aspects.• As in IoT-based SHSs, a context is shared among home devices, imposing severe security challenges.SHCM lacks cybersecurity considerations on the control mechanism in a smart home system.Recently, cyber-hacker attack has frequently appeared and threatened home networks; thus, it is important to add security services in SHCM to protect end-user privacy.
In our future work, we should design architectural systems to manage security assessment and mitigate hostile attacks according to the current context of a smart home network.• SHCM is limited in human-centered control strategies.Psychological factors can affect the patterns of end-user service usage.However, SHCM has not achieved the level of human experts and only investigates a single human-oriented context by ML-based feature mining.Our future research will extend the findings of the present study to provide a more comprehensive understanding of motivation and promote the human-oriented smart home services by adopting psychology and microculture knowledge.

AAA
correlation degree between the context vectors , x represents the threshold of minimum support count while meeting the frequent item set constraint.indicates a set of context-driven rules, which can satisfy both min_ supp and min_conf instructed by Eq. (5).In CCM, , are utilized to construct a context-aware model for analyzing end-user habitual preferences and driving corresponding interoperation services, therefore adding more convenience for smart home users.Furthermore, we utilize RL-based Q-learning to train context characteristics obtained by ∑ interpreter to further enhance the intelligence of a smart home control strategy, thus improving the self-adaptability of SHCM.Through interactions (in terms of reward or punishment) between agents and a home environment, a context-characteristic space can be mathematically modeled by RL.Consequently, an automatic control strategy acquisition problem in SHSs is formulated as a Q-learning problem.The RL-based environment of a smart home is characterized by a 4-tuple (S, A, P, R), where situation ⊂ Σ S denotes the context-characteristic space including , .A is the action set produced by the PD module in SHCM and injected into the data plane in the flow-table mode for the execution of the control strategy.Action selections in PD are performed by explicitly estimating the state transition in the context-characteristic space of the smart home environment.

a
are the state and action in the Bth context gathering round, and ε and ζ represent the tuning step sizes for updating , and lower bounds of sampling frequency regulated by a sensor, respectively., B i j p indicates the cooperative probability observed among actuators.The reward function R: S × A → R can generate a positive reward or a negative punishment to adjust the step size at the sampling frequency , air conditioner.For example, when the indoor temperature falls into the range indicated in Refs. 5 and 15, the air conditioner will adjust the actuator output at 35 to meet the customary preferences, which essentially reflect the context-aware service produced by rule-based context reasoning in the CCM of SHCM.

Figure 2 (
d) denotes a case-based context mining situation in the sleeping schedule profile, in which a metal-state-related activity pattern represented as personalized daily routing is recognized by an activity recognition model construct by clustering in the lighting context.

Fig. 3 .
Fig. 3. (Color online) Analysis of user-system interaction with the location dimension.(a) Habit profile with humidity.(b) Habit profile with light intensity.(c) Habit profile with temperature.

Fig. 4 .
Fig. 4. (Color online) Strong association-rule-driven cooperative operations in SHCM.(a) Confidence rate on cooperation and (b) support on cooperation.(a) (b) represents the accumulated number of reachable communication paths from sensor v d to controller v s .
(a).Similarly, Fig. 9(b) shows the seamless rerouting of flows during the link switching between Ethernet and WIFI.With the contextadaptable SHCM, a home device can maintain the original communication connection or achieve seamless communication protocol conversion following a change in the ubiquitous communication environment.For example, a mobile handheld device can adaptively switch into a suitable protocol according to the changing communication environment in a smart home.

Fig. 9 .
Fig. 9. (Color online) Adaptive context switching for heterogeneous communication protocol.(a) Adaptive protocol switching with Zigbee and WIFI, and (b) adaptive protocol switching between Ethernet and WIFI.(a) (b)

Table 2
Results of statistical analysis of context set.