Mathematical Modeling of Smart Space for Context-Aware System: Linear Algebraic Representation of State-Space Method Based Approach

A smart space is embedded with several components such as sensors, actuators, and computing devices that enable the sensing and control of the environment, and the inhabitants interact with the devices in the smart space whenever they need to. To model a smart space, a dynamic relationship needs to be established among the elements of the space whereby the interactions with devices are considered a dynamic-process state. In this paper, a linear model of a smart space is presented using a state equation, where the two coefficient matrices L andH need to be defined to model the smart space, and the coefficient matrix L is used to determine the states of the devices; similarly, the situation of the smart space is determined using coefficientH. An algorithm is presented tomake a linear model from the logical functions that are used to describe the system. This model is flexible in terms of the control of the smart-space environment because the environmental factors are represented by a matrix element.This linear smart-space model is helpful for the control of a context-aware system, and we use an example to illustrate the effectiveness of the proposed model.


Introduction
The mathematical modeling of a system is the most important step in the design of a control system, as it represents the behavior of a system in response to the changes of states and inputs.The following are the two modeling approaches for linear systems: the transfer-function approach and the statespace approach [1].Out of the two approaches, the state-space approach is used to represent a dynamic system.The important feature of the state-space approach is the usage of firstorder differential/difference equations to represent systems.The behavior of the system can be predicted by solving the differential/difference equations that are used for modeling.
A smart space is composed of a number of components such as sensors, actuators, and computing devices that enable the sensing and control of the environment.The goal of the smart space is to collect the environmental information and provide service automatically for user's comfort and safety [2].In a smart space, users generally interact with various devices according to their needs, and these interactions can be considered a dynamic-process state.The next states of the devices can be described using the information regarding the current states of the devices and control inputs; in terms of the smart space, its situation can be described according to the current device states.The aim of this paper is to generalize the smart-space domain through linear modeling by using a state equation.This linear model describes the relations between the next states of devices and the current states of devices along with the control inputs and between the current states of devices and the situations.Several algorithms were proposed to implement context-aware systems using knowledge and resources such as production rules (if-then relationships), neural networks, support vector machines, fuzzy logic, Bayesian networks, and Hidden Markov Model [3][4][5][6].In [7], the author proposed a unified and mathematically compatible method for logic-based intelligent system.However, this method requires special knowledge on mathematical logic and most of the deductions are tricky.Logic-based system used the logical function sets to show the relations between the states of devices and the control inputs and between the 2 Mathematical Problems in Engineering states of devices and the smart-space situation.The matrix expression is very convenient in logic inference because it converts the problem to solving linear algebraic equation.In this paper, we have presented an algorithm to convert these logical functions into a linear algebraic equation using the Sum of Products (SOP) canonical form and logic vector.The proposed smart-space linear model can be helpful for the control of a context-aware system because all of the variables are expressed by a matrix element and the relation between every variable is expressed by a coefficient matrix.
The rest of the paper is organized as follows: Section 2 presents an algorithm to convert a logic function into a linear algebraic equation; Section 3 illustrates the mathematical modeling of a smart space; and Section 4 presents an example to illustrate the effectiveness of the smart-space model, followed by the conclusion and a discussion of future work in Section 5.

Linear Algebraic Representation of Logic Function
Generally, a smart space can be described by logic expressions and logic related special knowledge needs to control the environment.If logic expressions are converted into algebraic equation, then control can be done effectively by manipulating matrix elements.To develop a linear model, we need conversion of logic expression into algebraic equations.Edwards uses a canonical form to express Boolean functions in matrix algebra [8].This approach is different from "conventional" matrix algebra, as it requires the "unit" matrix [] UNIT for multiplication operations.Authors in [9] proposed the usage of a semitensor product to represent Boolean functions in an algebraic form.In this paper, we have proposed an algorithm using Sum of Products (SOP) canonical form and logic vector (th column of an identity matrix) as logic value to represent the logic functions in the algebraic equations.Using this approach, the logic function has been represented similarly to its representation in conventional algebra, as follows: where  is called the coefficient matrix that defines the logic function(s) and  and  are the input and output vectors, respectively.

Single Logic Function.
In this section, a single logic function has been converted into a linear algebraic equation.Consider the following Boolean-logic function: Any Boolean function can be expressed as a Sum of Products (SOP) in a canonical form, as follows: Equation ( 3) can be represented in a matrix form, as follows: where ] is the coefficient matrix that holds the values of all of the minterms of the logic function, while the ] vector holds all of the minterms.The order of the matrix and vector terms must be adhered to.
The th column of an identity matrix (  ) is used to represent the logic value in the logic equations [9].Considering the identity matrix,  = [ 1 0 0 1 ] in terms of Boolean values.True (1) and False (0 respectively.If there are  variables, then the Boolean function is a logical mapping from a set of Assuming that  1 and  2 are two logic variables that are represented as with  and  ∈ {0, 1}, then the Kronecker product (⊗) of the two logic variables is calculated in the following way: Equation (5) shows that the Kronecker product between two logic variables represents all of the minterms; similarly, the following can also be shown: The coefficient matrix elements where   ∈ {0, 1} and  = 1, 2, . . ., 2  are the substituting values, and the dimension of the coefficient matrix  is equal to 2-by-2  , where  is the number of logic variables: From (4), and using (6), it can be written as the following: where  = [   ] with  ∈ {0, 1}.In the previously mentioned section, a single logic function is converted into an algebraic equation, whereas the next section will present multiple logic functions.

Multiple Logic Functions. Consider the following Boolean-logic functions:
Equation ( 8) can be expressed as the SOP in a canonical form: Equation ( 10) can be represented by  linear equations akin to (4): All of the elements of the coefficient matrix and   in (10) By applying the Khatri-Rao product ( * ) between all of the coefficient matrices, we can obtain the coefficient matrix  for (12) [10].The dimensions of coefficient matrix  are equal to 2  -by-2  , where  is the number of logic functions and  is the number of logic variables, as follows: Applying the Kronecker product (⊗) on the left side of (12), From ( 12), the usage of ( 6), (13), and ( 14) can be written as the following:

Linear Modeling of a Smart Space
Smart space is set up with the sensors and several devices.In this section, we have presented the linear model of a smart space.In a smart space, an inhabitant interacts with several devices through the combinational state of devices, and each device can be operated in two states.The next state of a device can be described by the logical function of  the current states of the device and its input information about the environment.The situation of a smart space at any time is described by the combination of the states of the devices at that time.The sensor network in a smart space is used to collect the input data about the environment which is needed to represent a space state.The next states of the devices can be expressed as the following:  1 ( + 1) =  1 ( 1 () , . . .,   () ,  1 () , . . .,   ()) ,  2 ( + 1) =  2 ( 1 () , . . .,   () ,  1 () , . . .,   ()) , . . .  ( + 1) =   ( 1 () , . . .,   () ,  1 () , . . .,   ()) , where   :  + → ,  = 1, 2, . . ., , and   ∈ ,  = 1, 2, . . ., , are the states of the devices and   ∈ ,  = 1, 2, . . ., , are the inputs that represent the environment.
Using the procedure described in Section 2, the multiple logical functions expressed by ( 16) and (17) can be converted into standard discrete-time dynamic systems, as follows: where the matrices  and  are called the coefficients of the logical functions of ( 16) and (17), respectively.One has The input-state coefficient matrix () and the statesituation coefficient matrix () are matrix representations of the SOP of a logic variable that is used in logic expressions.Input (), state (), and output () vectors represent the possible control inputs, the states of the devices, and the situations in the smart space, respectively.A block diagram of the proposed linear model is shown in Figure 1.

An Example of a Smart Space
In this example, we assume that a smart space which is composed of a sensor network and four devices will be operated by sensor data.The input data about the environment  1 ,  2 ,  3 ,  4 , and  5 are formed on the basis of the sensor data and the four devices' states are considered as  1 ,  2 ,  3 , and  4 .The next states of the devices are determined based on the current states of the devices and the input information about the environment.The situation of a smart space at any time is dependent on the combinational states of the devices at that time.Two different logical functions are used to describe the relations between the information about the environment and device states and the device states and situations.All of the variables are considered Boolean logical variables ("ON," "OFF").If the current states of the devices are known, then the next device states are updated according to the current states and input information about the environment [11].The next states of the devices can be represented by ( 16) and we can express the function by logic rules (if-then relationship) as tabulated in Table 1.These logic rules can be assumed as the following: There are four current states and five input variables on the right-hand side of (19).We consider that 2 9 = 512, SOP for the expression of the logical function (19) into a canonical form.When we calculated the minterms, we used variable  4 as MSB and  1 as LSB. Figure 2 shows the variable minterm format.
Equation ( 19) can be expressed as the SOP in canonical form, as follows:   20) can be represented in a matrix form as the following: From ( 21), the first matrix on the right-hand side is the coefficient matrix that holds all of the minterms values of each function of (20), and the ] vector holds all of the 512 minterms of the logic functions of (20).All of the elements of the coefficient matrix are substituted by True (1) = [ 1 0 ] and False (0) = [ 0  1 ].By applying the Khatri-Rao product ( * ) between all four of the coefficient matrices in (21), the following coefficient of matrix  can be obtained: The dimension of the coefficient of matrix  is equal to 16by-512.The minterm vector can be calculated by () ⊗ (), where  =  1 ⊗  2 ⊗ ⋅ ⋅ ⋅ ⊗  4 and  =  1 ⊗  2 ⊗ ⋅ ⋅ ⋅ ⊗  5 , as follows: By substituting   (+1) by   = [     ] with   ∈ {0, 1}, followed by the application of the Kronecker product (⊗) on the lefthand side of (21), the following can be derived: From the use of ( 22) by ( 21), ( 23) and ( 24) can be written in the following way: The situation of this smart space can be expressed by ( 17), and we can express the function by logic rules (if-then relationship) as shown in Table 2.These logic rules can be assumed as the following: Similarly, a logical function that describes the situation can be represented by a linear algebraic equation in the following way: where  is the coefficient matrix and  and  are the output and input vectors, respectively.The dimensions of , , and  are 16-by-1, 16-by-16, and 16-by-1, respectively.
In this example, a total of nine variables (sum of device states and environmental information) are used.Using these nine variables, there are 2 9 = 512 different input sequences available.These 512 input sequences are used to determine next states of devices.Then, smart-space situations can be calculated from combination of different devices states.We have calculated smart-space situation in two ways: firstly using logic rules and secondly using linear model.In logic rules method, we used rules for state change (Table 1) and rules for situation (Table 2) to infer the situation of smart space and considered the outcomes as manipulated data.In terms of the linear model, ( 25) and ( 27) represent the state equation and situation equation, respectively, and these matrix expressions generalize the logical operations that are convenient in logical inference.Control can be complete effectively by matrix calculations using this linear smartspace model.The situation of smart space can be inferred using Algorithm 1. Outcomes of Algorithm 1 are considered as linear-model data.
Using manipulated data, a plot was drawn for the "ON" states of the devices with a corresponding situation, while the linear-model data is presented for the purpose of comparison, as shown in Figure 3; every situation is composed of a set of device states.In Figure 3, different markers were used to show the "ON" state of each device.Our results show an overlap between the linear-model data and the manipulated data, proving that a linear model represents the logic function equally well and can be used to model a smart space.Using linear model control can be done easily by manipulating matrix elements.

Conclusion
We have proposed a smart-space linear model through the conversion of a logic function to a linear model.A smart space is typically represented by a logic function whereby smart devices operate in the smart space; in a state-space approach, the smart space is expressed as a linear model by the presented algorithm.This linear model describes the relations between the device states and inputs that represent the environment and between the device states and the situation of smart space.The example in this paper presents a linear model of smart space using four devices, each of which has two states and five control inputs based on the proposed model.In addition, the states of the devices and the corresponding situations are shown with different control inputs.Experimental result shows that outcomes using this linear model are the same as logic rules.Although the linear-model results are the same as logic functions, control can be done easily using linear model by manipulating the matrix elements.Moreover, if the infrastructure of smart space is changed, then it can be easily adopted because environmental factors are represented by matrix elements and the relation between every variable is expressed by the coefficient matrix.This model can be applied in an Internet of Things platform whereby correspondence between devices is necessary for a number of purposes.In

Figure 1 :
Figure 1: Block diagram of the proposed smart-space model.

x 4 x 3 x 2 x 1 u 5 u 4 u 3 u 2 u 1 Figure 2 :
Figure 2: The format variables that can be used in the minterm calculations.

Table 1 :
Logic rules for state change.