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

1. 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 state-space approach . 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 first-order 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 . 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-6]. In , 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 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.

2. 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 . This approach is different from "conventional" matrix algebra, as it requires the "unit" matrix [A]UNIT for multiplication operations. Authors in  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 (ith 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:

y = D x x, (1)

where D is called the coefficient matrix that defines the logic function(s) and x and y are the input and output vectors, respectively.

2.1. Single Logic Function. In this section, a single logic function has been converted into a linear algebraic equation. Consider the following Boolean-logic function:

y = f([x.sub.1], [x.sub.2], ..., [x.sub.n]). (2)

Any Boolean function can be expressed as a Sum of Products (SOP) in a canonical form, as follows:

[mathematical expression not reproducible]. (3)

Equation (3) can be represented in a matrix form, as follows:

[mathematical expression not reproducible], (4)

where [mathematical expression not reproducible] is the coefficient matrix that holds the values of all of the minterms of the logic function, while the [mathematical expression not reproducible] vector holds all of the minterms. The order of the matrix and vector terms must be adhered to.

The ith column of an identity matrix ([I.sub.n]) is used to represent the logic value in the logic equations . Considering the identity matrix, [mathematical expression not reproducible] in terms of Boolean values. True (1) and False (0) are represented as [mathematical expression not reproducible], respectively. If there are n variables, then the Boolean function is a logical mapping from a set of {[v.sup.1.sub.2], [[v.sup.2.sub.2]}.sup.n] to {[v.sup.1.sub.2], [v.sup.1.sub.2]}.

Assuming that [x.sub.1] and [x.sub.2] are two logic variables that are represented as [mathematical expression not reproducible], with a and b [member of] {0,1}, then the Kronecker product (([cross product])) of the two logic variables is calculated in the following way:

[mathematical expression not reproducible]. (5)

Equation (5) shows that the Kronecker product between two logic variables represents all of the minterms; similarly, the following can also be shown:

[mathematical expression not reproducible]. (6)

The coefficient matrix elements [mathematical expression not reproducible] consist of two values [mathematical expression not reproducible], where [d.sub.i] [member of] {0, 1} and i = 1, 2, ..., [2.sup.n] are the substituting values, and the dimension of the coefficient matrix D is equal to 2-by-2", where n is the number of logic variables:

[mathematical expression not reproducible]. (7)

From (4), and using (6), it can be written as the following:

y = D x x, (8)

where [mathematical expression not reproducible] with y [member of] {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.

2.2. Multiple Logic Functions. Consider the following Boolean-logic functions:

[mathematical expression not reproducible]. (9)

Equation (8) can be expressed as the SOP in a canonical form:

[mathematical expression not reproducible]. (10)

Equation (10) can be represented by m linear equations akin to (4):

[mathematical expression not reproducible]. (11)

All of the elements of the coefficient matrix and [y.sub.i] in (10) are represented by [mathematical expression not reproducible], with e, and y [member of] {0,1}, and are expressed as follows:

[mathematical expression not reproducible]. (12)

By applying the Khatri-Rao product * between all of the coefficient matrices, we can obtain the coefficient matrix E for (12) . The dimensions of coefficient matrix E are equal to [2.sup.m]-by-[2.sup.n], where m is the number of logic functions and n is the number of logic variables, as follows:

[mathematical expression not reproducible]. (13)

Applying the Kronecker product ((r)) on the left side of (12),

[mathematical expression not reproducible]. (14)

From (12), the usage of (6), (13), and (14) can be written as the following:

y = E x x. (15)

3. 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:

[mathematical expression not reproducible], (16)

where [f.sub.i] : [V.sup.n+m] [right arrow] V, i = 1, 2, ..., n, and [x.sub.j] [member of] V, j = 1, 2, ..., n, are the states of the devices and [u.sub.l] [member of] V, l = 1, 2, ..., m, are the inputs that represent the environment.

The situation of the smart space can be expressed as the following:

[mathematical expression not reproducible], (17)

where [h.sub.j] : [V.sup.n] [right arrow] V, j = 1, 2, ..., p, are the logical functions; [x.sub.j] [member of] V, j = 1, 2, ..., n, are the states of the devices; and [y.sub.l] [member of] V, l = 1, 2, ..., p, are the situations.

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:

x(t+1) = C x (x(t) [cross product] u(t)), y(t) = H x x(t), (18)

where the matrices C and H are called the coefficients of the logical functions of (16) and (17), respectively. One has [mathematical expression not reproducible].

The input-state coefficient matrix (C) and the state-situation coefficient matrix (H) are matrix representations of the SOP of a logic variable that is used in logic expressions. Input (u), state (x), and output (y) 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.

4. 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 [u.sub.1], [u.sub.2], [u.sub.3], [u.sub.4] and [u.sub.5] are formed on the basis of the sensor data and the four devices' states are considered as [x.sub.1], [x.sub.2], [x.sub.3], and [x.sub.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 . 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:

[mathematical expression not reproducible]. (19)

There are four current states and five input variables on the right-hand side of (19). We consider that [2.sup.9] = 512, SOP for the expression of the logical function (19) into a canonical form. When we calculated the minterms, we used variable [x.sub.4] as MSB and [u.sub.1] as LSB. Figure 2 shows the variable minterm format.

Equation (19) can be expressed as the SOP in canonical form, as follows:

[mathematical expression not reproducible]. (20)

Equation (20) can be represented in a matrix form as the following:

[mathematical expression not reproducible]. (21)

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 [mathematical expression not reproducible] 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 [mathematical expression not reproducible] and False [mathematical expression not reproducible]. By applying the Khatri-Rao product * between all four of the coefficient matrices in (21), the following coefficient of matrix C can be obtained:

[mathematical expression not reproducible]. (22)

The dimension of the coefficient of matrix C is equal to 16by-512. The minterm vector can be calculated by x(i) ([cross product]) w(i), where [mathematical expression not reproducible], as follows:

[mathematical expression not reproducible]. (23)

By substituting [mathematical expression not reproducible] with [x.sub.i] [member of] {0,1}, followed by the application of the Kronecker product (([cross product])) on the left-hand side of (21), the following can be derived:

[mathematical expression not reproducible]. (24)

From the use of (22) by (21), (23) and (24) can be written in the following way:

x(f + 1) = C x (x(t) ([cross product]) u(f)). (25)

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:

[mathematical expression not reproducible]. (26)

Similarly, a logical function that describes the situation can be represented by a linear algebraic equation in the following way:

y(t) = H x x (t), (27)

where H is the coefficient matrix and y and x are the output and input vectors, respectively. The dimensions of y, H, and x 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.sup.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 smart-space 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.

5. 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 this modeling, all of the logical variables are represented by the values of 1 or 0. In the future, k-value logic will be used to express the logic variable more effectively.
```ALGORITHM 1: Linear model (C, H, u, x).

Data: input-state coefficient matrix C, state-output coefficient
matrix H, at a given time, List of input I, List of state S, input
vector u, state vector % Result: Situation y

(1) x, u initialization;
/ * Next state calculation */
(2) for i = 1 to q do
/* q is the total no. of inputs in list of input I */
(3)   u = u ([cross product]) [I.sub.j];
(4) end
(5) x = C x x ([cross product]) u;
(6) for j=1 to I do
/* I is the total no. of inputs in list of input I */
(7)    x = x ([cross product]) [S.sub.j];
(8) end
(9) y = H x x;
```

http://dx.doi.org/10.1155/2016/8325054

Competing Interests

The authors declare that they have no competing interests.

Acknowledgments

This work was supported by the Industrial Strategic Technology Development Program (10041788, Development of Smart Home Service Based on Advanced Context-Awareness) funded by the Ministry of Trade, Industry & Energy (MI, Korea). The work reported in this paper was conducted during the sabbatical year of Kwangwoon University in 2013.

References

 B. Friedland, Control System Design: An Introduction to State-Space Methods, Dover, New York, NY, USA, 2005.

 D. J. Cook and S. K. Das, Smart Environments Technology, Protocols, and Applications, Wiley-Interscience, Hoboken, NJ, USA, 2005.

 M. C. Mozer, "The neural network house: an environment that adapts to its inhabitants," in Proceedings of the AAAI Spring Symposium on Intelligent Environments, pp. 110-114, 1998.

 J.-Y. Hong, E.-H. Suh, and S.-J. Kim, "Context-aware systems: a literature review and classification," Expert Systems with Applications, vol. 36, no. 4, pp. 8509-8522, 2009.

 H.-S. Park and S.-B. Cho, "A modular design of Bayesian networks using expert knowledge: context-aware home service robot," Expert Systems with Applications, vol. 39, no. 3, pp. 2629-2642, 2012.

 M. H. Kabir, M. R. Hoque, K. Thapa, and S.-H. Yang, "Two-layer hidden Markov model for human activity recognition in home environments," International Journal of Distributed Sensor Networks, vol. 2016, Article ID 4560365, 12 pages, 2016.

 K. Truemper, Design of Logic-Based Intelligent Systems, John Wiley & Sons, Hoboken, NJ, USA, 2004.

 C. R. Edwards, "The logic of Boolean matrices," The Computer Journal, vol. 15, no. 3, pp. 247-253, 1972.

 D. Cheng, H. Qi, and Z. Li, Analysis and Control of Boolean Networks: A Semi-Tensor Product Approach, Springer, London, UK, 2011.

 L. Ljung and T. Soderstrom, Theory and Practice of Recursive Identification, The MIT Press, Cambridge, Mass, USA, 1982.

 J. L. Schiff, Cellular Automata: A Discrete View of the World, Wiley-Interscience, New York, NY, USA, 2008.

Sung-Hyun Yang, M. Humayun Kabir, and M. Robiul Hoque

Department of Electronic Engineering, Kwangwoon University, Seoul 139-701, Republic of Korea

Correspondence should be addressed to M. Humayun Kabir; humayun@kw.ac.kr

Received 28 August 2015; Revised 16 February 2016; Accepted 14 March 2016

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

Caption: Figure 3: Representation of a situation with corresponding devices at "ON" states.
```Table 1: Logic rules for state change.

Rules for state change

(i)      [mathematical expression not reproducible]

(ii)     [mathematical expression not reproducible]

(iii)    [mathematical expression not reproducible]

(iv)     [mathematical expression not reproducible]

Table 2: Logic rules for situation.

Rules for situation

(i)      [mathematical expression not reproducible]

(ii)     [mathematical expression not reproducible]

(iii)    [mathematical expression not reproducible]

(iv)     [mathematical expression not reproducible]

Figure 2: The format variables that can be used in the minterm
calculations.

[x.sub.4]  [x.sub.3]   [x.sub.2]   [x.sub.1]

[u.sub.5]  [u.sub.4]   [u.sub.3]   [u.sub.2]   [u.sub.1]
```