=Paper=
{{Paper
|id=Vol-2917/paper23
|storemode=property
|title=Model and Tools of Adaptive Control of a Smart Home System
|pdfUrl=https://ceur-ws.org/Vol-2917/paper23.pdf
|volume=Vol-2917
|authors=Khrystyna Beregovska,Vasyl Teslyuk,Vasyl Beregovskyi,Iryna Kazymyra,Liudvih Fabri
|dblpUrl=https://dblp.org/rec/conf/momlet/BeregovskaTBKF21
}}
==Model and Tools of Adaptive Control of a Smart Home System==
Model and Tools of Adaptive Control of a Smart Home System KhrystynaBeregovska1, VasylTeslyuk2, VasylBeregovskyi3, IrynaKazymyra4and LiudvihFabri5 1,2,4,5 Lviv Polytechnic National University, 12 Bandera street, Lviv, 79013, Ukraine 3 Ivano-Frankivsk National Technical University of Oil and Gas, Karpatska St., 15, 76019, Ivano-Frankivsk, Ukraine Abstract The paper describes a mathematical model and tools of adaptive control of a smart home sys- tem, which are based on Petri-Merkov nets, provide an opportunity to reflect the dynamics of work and explore the probabilistic processes that take place in smart home systems. Also, the structure of information technology of adaptive control of smart home system, which includes a number of technical components, and the implementation of the relationship with users is de- veloped and described. An automated software system for administration and forecasting of system’s work has been implemented for the designed smart home system. Keywords smart home; Petri-Markov nets; adaptive control; microcontrollers; sensors; mathematical model; schematic model; marking. 1. Introduction One of the main characteristics of our time is significant scientific, technological and innovative pro- gress [1–3], which is based on the use of intelligent technologies. We are constantly confronted with improved and new technical inventions, the main purpose of which is to provide an increase of comfort for their users. As a result, modern engineering equipment of apartments and cottages gets significantly complicat- ed, the number of devices involved in the formation of human habitat is growing, and thus complicates the process of managing such system. In this regard, integrated intelligent housing management systems – smart home systems («Smart Home») are becoming more and more popular recently [4–6]. Smart home technologies have been around for decades, but if in the past they were used only for performing daily routine operations (turning on / off lighting, heating, air conditioning and household appliances by remote or voice control), now people require an automated decision-making system to manage all subsystems of the smart home, taking into account all the individual characteristics, settings, habits and wishes of each individual user of such system, which can be taken into account using adap- tive systems [7]. Accordingly, the development of adaptive smart home systems is an urgent task today. 2. Literature review Today, a number of benefits that smart systems can provide have made them quite popular, so many scientists and companies around the world are researching such systems. One of the main areas of research of smart technologies and systems is the energy aspect [8]. In particular, British scientists have proposed a systematic approach that combines the reduction of energy MoMLeT+DS 2021: 3rdInternational Workshop on Modern Machine Learning Technologies and Data Science, June 5, 2021, Lviv-Shatsk, Ukraine EMAIL: khbereg@gmail.com (K. Beregovska); vasyl.m.teslyuk@lpnu.ua (V. Teslyuk); beregovskyivasyl@gmail.com (V. Beregovskyi), iryna.y.kazymyra@lpnu.ua (I. Kazymyra); liudvih.p.fabri@lpnu.ua (L. Fabri) ORCID: 0000-0002-1252-005X (K. Beregovska); 0000-0002-5974-9310 (V. Teslyuk); 0000-0002-0401-1490 (V. Beregovskyi); 0000-0003- 1597-5647 (I. Kazymyra) ©️ 2021 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR Workshop Proceedings (CEUR-WS.org) needs achieved by energy-efficient building design, the use of renewable energy sources and its storage to create an energy-positive home. The combination of the right design with modern thermal and electrical technologies allows to create affordable houses, which can significantly reduce energy costs and, consequently, enjoy greater market demand [9]. Another area is to study the benefits of using smart technologies for the elderly. For example, researchers at the University of Lodz (Poland) conducted a study of the institutional and individual conditions for a new concept of smart development of older communities [10]. Research and development in the field of smart cities are also developing significantly. Thus, for example, a mechanism for measuring the performance and accuracy of Java code to improve the quality of implemented cyber-physical systems is proposed. This approach involves the implementation of Java code visualization in an object-oriented smart vehicle traffic control simulator. It analyzes the complexity of the program code and identifies those parts of it that slow down the system. One of the main software tools here is HProf - a tool for measuring performance, which allows to obtain information about the speed and frequency of use of methods in the code. Further refactoring of appropriate methods allows to increase the speed of the code, and, accordingly, the speed and accuracy of the response of the autonomous traffic control system in a smart city [11]. One of the key purposes of smart technologies is increasing the comfort and quality of life for people. Among the researches conducted in this direction, the work of scientists from Shandong University (China) on the study and development of cognitive services of home service robots is interesting. The proposed method is to collect information about the characteristics of a comfortable environment based on the context model built using smart sensors and IoT technologies. The next step is to use a reinforced learning algorithm that helps teach the robot to provide services needed to ensure user’s comfort. To preserve the historical experience and continuous robot’s learning, scientists have proposed the use of a modification of the algorithm of incremental hierarchical discriminant regression. In case of an incorrect decision due to lack of similar historical experience, the user can edit the script, and the correct information will be stored in the robot's memory and used in the future. This realization of experience accumulation in robot is similar to the process of human mental development [12]. Such problems as global warming, the unrepeatability of some resources of our planet, the need for society to switch to environmentally friendly energy sources lead to the need for research in this area. One such work is the work of scientists from the University of Salamanca (Spain) to optimize the cost of central heating for smart buildings with fuzzy logic and multi-agent architecture. The article presents a multi-agent system for a fuzzy logic controller and demonstrates that such technology applied to a distributed Internet of Things system and a smart environment will significantly reduce the scale of gas emissions into the atmosphere [13]. In smart home systems researching, an important aspect is the ability to identify the user's location in it. Today, there are various wireless technologies that can be used for this purpose. An interesting alter- native is LoRa - a long-range modulation technique, among the main advantages of which are low pow- er consumption, high long-distance data transfer rate, good interference elimination and high network efficiency. All this makes LoRa potentially possible for efficient use of location-based things and ser- vices in many Internet applications, which is one of the necessary components for modeling of such multifunctional systems as a smart home [14]. The conducted analysis allows to state about active development and implementation of intelligent technologies in various fields of science and technology. A special place is occupied by the concept of a smart home. At the present stage, new generation of smart home systems are being developed, namely, adaptive smart home systems. 3. Model and tools of adaptive control of the smart home system 3.1. Model of a smart home based on the Petri-Markov net One of the main characteristics of smart home systems is their dynamics and probabilistic processes that take place during the operation of such systems. Therefore, to model the operation of the smart home system, Petri-Markov network was chosen as the basis, which allows not only to effectively model this type of system, but also to investigate the quantitative characteristics of the probabilities of transitions between states of the system based on the history of it’s work [15-17]. Petri nets in this context, serve to reflect the dynamics, and Markov chains [15-17] provide an opportunity to explore probabilistic processes and states that arise in the process of communication between the user and the smart home system itself. The adaptive control system of the smart home developed in the work is based on Petri-Markov nets [17, 18], includes functional elements and allows to take into account the prehistory of events and user behavior, is implemented by an algorithm that can be described by the following steps: Step 1. Determine the set of conditions for the transitions of the smart home system from one state to another: |𝑃| = 𝑚 ; 𝑃 = 𝑆 ∪ 𝐴, where S – multiplicity of sensors; A - multiplicity of activators. Step 2. Identify the set of events that can occur in a smart home system: |𝑇| = 𝑑 These events rep- resent the transitions of the system from one state to another. Step 3. Identify the functions that determine the relationships between events, the prerequisites for these events and the post-event states of the smart home system: 𝐽 ∶ 𝑇 × 𝑃 → {0,1} - posteriority function. 𝑂 ∶ 𝑃 × 𝑇 → {0,1} - antecedence function. Step 4. Set a set of threshold values of the probabilities of events responsible for the operation of the activators of the smart home system: |𝐻| = ℎ - posteriority function; ℎ ≤ 𝑑 . Step 5. Set the initial marking (1): 𝑀0 = [𝑀0 (𝑝1 )𝑀0 (𝑝2 ) … 𝑀0 (𝑝𝑚 )]; 𝑀(𝑝𝑖 ) ∈ ℕ0 ; 𝑀0 ∶ 𝑃 → ℕ (1) Step 6. Determine the initial probability distribution (2): 𝑃(𝑋0 = 𝑠) = 𝑞0 (𝑠); ∀𝑠 ∈ 𝑇 (2) • for the first iteration of the system: 1 𝑠1 = 𝑠2 =. . . = 𝑠𝑗 = j , where s𝑖 - probability of the event i; j – number of competing events; • for the following iterations of the system: read the values from the database of statistics collected and calculated on the basis of previous runs of the smart home system as: 𝑅𝐸𝐿𝐴𝑇𝐼𝑂𝑁𝑆.𝑆𝑈𝑀 𝑠𝑖 = 𝐺𝑒𝑛𝑒𝑟𝑎𝑙𝑆𝑢𝑚 , where RELATIONS.SUM – the actual number of activations of this event (triggers of this transition) according to the database of statistics; GeneralSum - the total number of activations of competing events (triggers of all outputs from this state of transitions). Step 7. Determine the matrix of transient probabilities based on the probability distribution (3): 𝑃(𝑋𝑛+1 = 𝑠𝑛+1 |𝑋𝑛 = 𝑠𝑛 ) = 𝑝(𝑠𝑛 , 𝑠𝑛+1 ), (3) ∀(𝑠𝑛+1 , 𝑠𝑛 ) ∈ 𝑇 × 𝑇. Step 8. Define matrices: • preincidence: 𝐴− = [𝑎𝑖𝑗 − ] (4); • post-incidentality: 𝐴 = [𝑎𝑖𝑗 + + ] (5); • incidence: 𝐴 = 𝐴+ − 𝐴− : − 1, if condition 𝑗 − input condition for the event 𝑖 𝑎𝑖𝑗 ={ (4) 0, if condition 𝑗 − is not input condition for the event 𝑖 + 1, if state 𝑗 − initial state fot the event 𝑖 𝑎𝑖𝑗 ={ . (5) 0, if state 𝑗 − is not initial state for the event 𝑖 Step 9. Determine the control vector for the current marking 𝑀𝑘 (6): 1, if 𝑡𝑖 − active in marking 𝑀𝑘 , 𝑖 = ̅̅̅̅̅ 1, 𝑛 𝑣𝑘,𝑖 = { (6) 0, if 𝑡𝑖 − not active in marking 𝑀𝑘 , 𝑖 = ̅̅̅̅̅ 1, 𝑛 Condition of event 𝑡𝑖 activity in marking 𝑀𝑘 (7): − ∀𝑀𝑘,𝑖 ≥ 𝑎𝑖𝑗 , 𝑗 = ̅̅̅̅̅̅ 1, 𝑚. (7) Step 10. Identify the markings on the following (k+1) step according to the equation of state (8) [18]: 𝑀𝑘+1 = 𝑀𝑘 + 𝐴𝑇 𝑣𝑘 , k = 0, 1, 2, … (8) 𝑀𝑛 = 𝑀0 + 𝐴𝑇 ∑𝑛−1 𝑣 𝑘=0 𝑘 , where {𝑣0 , 𝑣1 , . . . 𝑣𝑛−1 } - a sequence of control vectors, that transfers the state of the system from the initial 𝑀0 into some 𝑀𝑛 . Step 11. Determine the probability distribution at the moment (n+1) [19] (9): 𝑞𝑛+1 (𝑡𝑛+1 ) ≝ 𝑃(𝑋𝑛+1 = 𝑡𝑛+1 ) == ∑𝑡∈𝑇 𝑃(𝑋𝑛 = 𝑡)𝑃(𝑋𝑛+1 = 𝑡𝑛+1 | 𝑋𝑛 = 𝑡) = ∑𝑡∈𝑇 qn (t)p(t, t n+1 ), (𝑞0 )𝑖 = 𝑞0 (𝑡𝑖 ) = 𝑃(𝑋0 = 𝑡𝑖 ), 𝑝𝑖,𝑗 = 𝑝(𝑡𝑖 , 𝑡𝑗 ) = 𝑃(𝑋𝑛+1 = 𝑡𝑗 |𝑋𝑛 = 𝑡𝑖 ), (𝑞𝑛 )𝑖 = 𝑞𝑛 (𝑡𝑖 ) = 𝑃(𝑋0 = 𝑡𝑖 ), (9) 𝑞𝑛+1 = 𝑞𝑛 𝑝, 𝑞𝑛+2 = 𝑞𝑛+1 𝑝 = (𝑞𝑛 𝑝)𝑝 = 𝑞𝑛 𝑝2, ….. 𝑞𝑛+𝑚 = 𝑞𝑛 𝑝𝑚 , де m – the number of steps (events) that must occur to activate the transition 𝑡𝑖 ∈ 𝑇 ∗ 𝑇 ∗ ∈ 𝑇 - multiplicity of events that trigger activators − 𝑀𝑚,𝑖 ≥ 𝑎𝑖𝑗 , 𝑚 = 𝑚𝑖𝑛(𝑚). Figure 1: A fragment of a schematic model of a smart home based on the Petri-Markov net to study one of the system scenarios Step 12. Check the fulfillment of the condition for the implementation of the proactive action (actua- tion tj) (10) [19]: [𝑞𝑛+1 (𝑡𝑛+1 )]𝑗 ≥ 𝐻𝑗 , 𝑡𝑗 ∈ 𝑇 ∗ (10) To represent graphically the dynamics of the system, the reachability graph, which demonstrates the possible states of change of markings in the system of smart house can be used. It’s directed graph, where vertex represents dedicated state – marking, and arcs show the probabilities of transitions be- tween these markings. An example of such graph for a fragment of the schematic model of the system in Figure 1 is shown in Figure 2. Figure 2: Reachability graph of states for a fragment of the schematic model of a smart house Thus, the model for the system of smart house based on Petri-Markov net is developed. It allows to study the dynamics of the system. 3.2. The structure of information technology of adaptive control system of a smart home The key step in a smart home system’s developing is to determine it’s structure and the relationships between the main components. In particular, Figure 3 shows the developed structure of information technology. Information technology includes four main components: • input data generated by sensors; • software and hardware; • methods and models; • source data that determines the signals to turn on or off a particular activator. The structure of the hardware and software complex of the designed system «Smart home» includes physical elements - sensors and activators, a specialized microcontroller for monitoring and controlling the change of states of the designed system «Smart home», a database of statistics (DBS) and auto- automated software system for administration and forecasting of the designed system «Smart Home». For reaching purposes of current work, the microcontroller of STMicroelectronics company is used. It is 8-bit microcontroller of STM8 family (STM8S003F3P6). It serves as the base and was programmed with appropriate commands. For Serial Peripheral Interface (SPI) work 4 lines are used: CLK, MOSI, MISO, SS. The type of em- bedded system, designed here is small scale embedded system. Figure 3: The structure of adaptive information technology An example of the structure of the hardware and software complex is shown in Figure4. Figure 4: The structure of the hardware-software complex of the designed system «Smart home» in interaction with users Users interact with this complex are the administrator-designer - the person who is responsible for the initial setup and configuration of the system, and, in fact, the end user of the system (or several users, for example, in case of family). The input data for the system is information received from the user through his interaction with physical elements - sensors. Depending on the type of sensor, it can be supplied as analog signals, a binary code, which indicates the value of a parameter or a binary code combined with the identifier of the sensor itself. This information is processed by a specialized microcontroller for monitoring and controlling changes of states of the smart home system. The microcontroller interacts with the automated software system of ad-ministruction and forecasting the operation of the designed system, using the developed teaching method, based on Petri- Markov nets and processes the information collected at each iteration. The resulting data is saved into the statistics database (DBS), and the output information is converted into signals supplied to physical elements - activators, providing feedback to the system’s user. 3.3. Implementation of a software product for a smart home system To implement the administration system and foresee the work of the designed smart home system, the Java programming language was used [20, 21]. Today, Java is considered as one of the most popular programming languages, and its main advantages are key to the implementation of such a complex system as a smart home [20, 21]. Figure 5 shows the main window of the developed software system, which allows to see the structure of the rooms in schematic form, as well as to monitor the activity of certain physical elements in the system. Figure 5: The main window of the developed automated software system of administration and forecasting with the interactive image-model of the designed system of the smart house Below is an image of a window with information about a specific user of the system (Figure 6) and the physical element - the sensor (Figure 7). Figure 6: A window with information about the characteristics of the selected user of the interactive image-model of the designed smart home system Figure 7: Window with information about the characteristics of the selected physical element sensor of the interactive image-model of the designed system of a smart home IntelliJ Idea Community Edition, developed by Jetbrains, was chosen as a software development environment, which, among other programming languages, also supports Java, is freely available and provides a convenient and effective set of software tools for software development. 4. Results of approbation As a result of the research, the coefficient of adaptation level of the system, achieved in the process of the developed learning algorithm application, is determined. The coefficient of adaptation level is determined by the formula (11) [7]: 𝐶 a𝑑𝑎𝑝𝑡 = (1 − 𝐶𝑢 ) ∗ 100%, (11) where 𝐶 – the number of commands given by the microcontroller to the executable devices; 𝐶𝑢 – the number of user commands from the remote control to correct the script. Deviation level from the script (12): α = 100% − 𝑎𝑑𝑎𝑝𝑡 (12) Numerical indicators of the coefficient of adaptation level and deviation level, depending on the time of testing and training of the developed system of smart home are presented on Figure 8 and Figure 9. Figure 8: The resulting coefficient of the adaptation level depending on the training time of the system Figure 9: The resulting coefficient of deviation from the scenario depending on the training time of the system From the diagrams in Figure8 and Figure9 we can conclude that the level of adaptation of the system increases with increasing training time. It can also be noted that the coefficient of deviation also depends on the time of the experimental studies. On weekdays (working days) the dynamics of adaptation is faster due to the routine of the working day and a small number of possible scenarios for working with the system. However, on weekends, when the number of scenarios is much greater, the adaptation of the system is slower. Thus, the limitation that can be highlighted here is that the system adaptation may be significantly complicated with scenarios where the user has very differentiated schedule with big number of unpredicted activities and events. So, as the result, the adaptation process will take more time. 5. Conclusion Mathematical model of the system of smart home, which is based on Petri-Markov nets has been de- veloped. The biggest advantage of such model comparing to other existing solutions, some of which were described at the beginning of this article, is that it allows not only to implement the process of adapting the smart home system to specific users, but also to explore the dynamics of it’s work. This is presented in set of states that can be mathematically described in the form of marking vectors or using the reachability graph. The possibility to foresee the following states of the smart home system, allows to implement the mechanism of action in advance and to carry out adaptive management of such systems. Information technology, the structure of which is developed in the context of this work, makes it possible to combine the hardware (presented by physical elements - sensors and activators and a specialized microcontroller for monitoring and controlling the change of states of the designed system), a software product - developed automated software system for administration and forecasting of the designed smart home system and the user, his interaction with the system, the process of debugging and setup, training the system in the process of it’s work with the user. The use of Java programming language for this product, in the long run will allow to scale such system, use it on different platforms and, if necessary, expand the functionality. Described results show the effectiveness of the developed model of adaptive control system of smart home. In the future the model could be extended with the hardware component analysis for researching economic aspect of using this model for energy-consumption investigation and optimization. 6. References [1] J. Wan, J. Yang, Z. Wang, Q. Hua, Artificial Intelligence for Cloud-Assisted Smart Factory IEEE Access, 2018,6, 55419–55430. [2] E. Molnár, R. Molnár, N. Kryvinska, M. Greguš, Web Intelligence in practice J. Serv. Sci. Res., 2014,6, рр. 149–172. [3] O. Boreiko, V. Teslyuk, A. Zelinskyy, O. Berezsky, Development of models and means of the server part of the system forpassenger traffic registration of public transport in the “smart” city, East. Eur. J. Enterp. Technol. 2017,1, рр. 40–47. [4] B.L.R. Stojkoska, K.V. Trivodaliev, A review of Internet of Things for smart home Challenges and solutions. J. Clean. Prod., 2017,140, рр. 1454–1464. [5] M. Bhatia, S.K. Sood, A. Manocha, Fog-inspired smart home environment for domestic animal healthcare Comput. Commun, 2020,160, рр. 521–533. [6] V. Lytvyn V. Vysotska, V. Mykhailyshyn, I. Peleshchak, R. Peleshchak, I. Kohut, Intelligent sys- tem of a smart house. InProceedings of the 3rd International Conference on Advanced Information and Communications Technologies AICT, Lviv, Ukraine, 21–25 September 2019, pp. 282–287. [7] J. Xie, S. Li, H. Yan, D. Yang, Model reference adaptive control for switched linear systems using switched multiple models control strategy J. Frankl. Inst. 356(5), 2019, 2645–2667. [8] M.O. Medykovskyi, I.G. Tsmots, Y.V. Tsymbal, Information analytical system for energy efficien- cy management at enterprises in the city of Lviv (Ukraine). Actual Problems of Economics, 2016, 175(1), pp. 379–384. [9] P. Jones, X. Li, E.C. Bassas, E. Perisoglou, J. Patterson, Energy-Positive House: Performance As- sessment through Simulation and Measurement [10] A. Podgorniak-Krzykacz, J. Przywojska, J. Wiktorowicz, Smart and Age-Friendly Communities in Poland. An Analysis of Institutional and Individual Conditions for a New Concept of Smart Devel- opment of Ageing Communities [11] B.K. Park, G.Ka ng, H.S. Son, B. Jeon, R.Y.C. Kim, Code Visualization for Performance Im- provement of Java Code for Controlling Smart Traffic System in theSmart City. [12] F. Lu, M. Huang, X. Li, G. Tian, H. Wu, W. Si, Learning and Development of Home Service Ro- bots’ Service Cognition Based on a Learning Mechanism. [13] D.M. Jimenez-Bravo, A.L.Murciego, D.H. Iglesia, J.F. De Paz, G.V. Gonzalez, Central Heating Cost Optimization for Smart-Homes with Fuzzy Logic and a Multi-Agent Architecture. [14] K. Kim, S. Li, M. Heydariaan, N. Smaoui, O. Gnawali, W. Suh, M.J. Suh, J.I. Kim, Feasibility of LoRa for Smart Home Indoor Localization [15] J. Komenda, S. Lahaye, J.L. Boimond, T. van den Boom, Max-plus algebra in the history of dis- crete event systems. Ann. Rev. Control 45, 2018, рр. 240–249. [16] A. Tolver, An introduction to Markov chains. Department of Mathematical Sciences, University of Copenhagen, November 2016. [17] V. Teslyuk, K. Beregovska, P. Denysyuk, M. Mashevska, Method of development Smart-House- Systems Models, based on Petri-Markov Nets, and extended by functional components. Proceedings of the XIIth International Conference of Computer Science and Information Technologies (CSIT’2017), September 05-08, 2017, Lviv: Publishing House Vezha&Co., 2017, pp. 352-355. [18] V. Teslyuk, K. Beregovska, Decomposition of models of Smart-House-systems. Proceeding of the 13th International Conference “Perspective Technologies and Methods in MEMS Design” (MEMSTECH’2017), April 20-23, 2017, рр. 22-24. [19] V. Boeuf, P. Robert, A stochastic analysis of a network with two levels of service. Queueing Syst. 92, 2019, рр. 203–232. [20] N. Karumanchi, Data Structures and Algorithms Made Easy in Java: Data Structure and Algorith- mic Puzzles. CareerMonk Publications, 2021, р. 391. [21] A. Batyuk, V. Voityshyn, V. Verhun, Software Architecture Design of the Real-Time Processes Monitoring Platform. In Proceedings of the Second International Conference on Data Stream Min- ing & Processing (DSMP), Lviv, Ukraine, 21–25 August 2018, pp. 98–101.