Central Heating Cost Optimization for Smart-Homes with Fuzzy Logic and a Multi-Agent Architecture

: Recent years have deﬁned the need to reduce gas emissions to ﬁght climate change, and society’s move to green energies is important to make responsible use of non-renewable energies. Therefore, it is now important to use technologies to optimize the use of actual energy sources. In this aspect, the Internet of Things (IoT) technology has had a great impact on society. Hence, this research work aims to use IoT technology and multi-agent systems to optimize the use of central heating installation in buildings. It is intended to improve the user’s comfort, reduce the consumption of energy and reduce the ﬁnancial costs. Therefore, a multi-agent system is proposed to collect data from sensors located in a smart-home and obtain the best action to perform in a central heating system. The decisions will be taken by an intelligent agent based on fuzzy logic. This technology will allow for generating the control action with a fuzzy controller. The results obtained show that the proposal improves the actual system in terms of users’ comfort and ﬁnancial and energy savings.


Introduction
In 2019, the debate was climate change, and during that year, several conferences took place in different parts of the world, like COP25 (Conference Of Parties 25), Climate Action Summit 2019, and Youth Climate Summit 2019 [1]. These conferences were able to grab the attention of the greatest media communication platforms and, therefore, the attention of the population. The last statement may make a difference in this debate that has been postponed for decades. People are aware of the risk that future generations will have. Therefore, not only political conferences but also social conferences took place last year [1,2] in which environmental organizations and activists explained the risk and consequences of continuing this type of lifestyle. These people had a great impact on the communications media, which was supported the selection of the Swedish environmental activist Greta Thunberg as "Time Person of the Year" [3], only the second woman to receive this recognition on her own after Angela Merkel in 2015 [4]. The concession of this award to an environmental activist supposes the recognition of the importance of climate change or climate emergency, principally because this award is usually related to important international politicians.
Unfortunately, governments do not have a common agreement to preserve the global environment. Some governments are aware of the critical situation and try to do whatever they can to fight global change. However, these actions are not enough if the most important and polluting countries are against green policies. Therefore, future years and future agreements will determine the future of the Earth. Meanwhile, as mentioned before, some countries have determined that the climate emergency research a system that can optimize the use of these old installations while they are replaced with modern ones. This is important given the new policies established in society that aim to reduce energy consumption and gradually introduce green energy; while this transition is developing, proposals like the one presented in this article are important. Therefore, a control system based on MAS architecture and fuzzy logic is presented to optimize the use and reduce the energy consumption of old central heating systems. Data will be collected from sensors that will be integrated into the multi-agent architecture, promoting the correct behavior of the different agents in the system to promote energy savings in the heating system. With the solution presented in this article, it is expected to reduce consumption and, therefore, the emissions of these kinds of systems during the winter months.
The rest of the article will be divided as follows: Section 2 will introduce the most relevant works developed during the last years in this research area, Section 3 will define the proposed system presented in this article, Section 4 will explain the case of study defined in order to prove the effectiveness of the proposed system, Section 5 will show the result obtained from the study and their discussions and finally, Section 6 is where the conclusion of the work and future lines of research will be explained.

Background
In this section, the different works developed in the different areas involved in this scientific research during the last years will be analyzed. This section will be divided into different subsections to analyze the different areas of research properly.

IoT and Smart Environments
The Internet of Things has been defined in different ways since it first appeared. However, almost all the definitions share the same idea. IoT can be defined as an interaction between the physical and digital world, where both of them work together to achieve a common goal. The communication between these two worlds is provided by sensors and actuators. These physical elements have computing and networking capabilities that allow knowing and even changing the state of the element [13][14][15]. These elements that established the link between the real and digital world are connected between themselves and also with a central system. These communications are enabled thanks to several communication protocols like Wi-Fi, Low Power Wide-Area-Networks (LPWAN), Bluetooth Low Energy (BLE), Near Field Communication (NFC), ZigBee and Z-Wave, among others [14][15][16]. Therefore, IoT technology can be implanted in every physical environment, creating a smart environment.
Hence, the application of IoT in industry results in the creation of Industry 4.0. This supposes a new revolution in the industry field. The Internet allows for creating smart products, smart production and smart services [17] thanks to the collection and analysis of real-time data to optimize the decision-making process. Industry 4.0 was related to the use of cloud computing [18]; however, in the last years, fog [19] and edge [8] computing has had its impact in the field. This evolution is possible thanks to the increase in computing capacities of small technological devices, like the sensors and actuators themselves.
Several works implement Industry 4.0 principles to obtain sensorized industries that facilitate the employees' tasks or obtain the best products or results. For example, the study developed by Scheuermann et al. [20] shows how a software agile methodology is transferred to an assembly line. This new application of the agile methodology allows for applying a change of the customers during assembly time. On the other hand, Schlechtendahl et al. [21] show how a non-Industry 4.0 factory can be transformed into an Industry 4.0 factory. They describe how to include the sensors and actuators in the existing environment and establish communications with the gateways and the central software system. Ang et al. [22] demonstrate how a computer design of a smart ship allows integrating Industry 4.0 in the ship design process and the ship's through-life. Another important concept in Industry 4.0 is the digital twin that represents a digital image of a real industry [23]. This concept helps, for example, to detect possible failures in industries.
Appl. Sci. 2020, 10, 4057 4 of 26 Another important application of IoT is in cities. Smart cities used IoT technology in order to communicate the infrastructures of a city with software. Smart-cities appeared to respond to more economically, environmentally and socially sustainable cities [24]. There are several infrastructures of this time developed in different cities. Latré et al. [25] have developed the "City of Things," a testbed for IoT and smart-cities with distributed nodes in the city of Antwerp. In the Spanish city of Santander, Sánchez et al. [26] have developed another testbed for smart-city experimentation.
Smart-buildings and smart-homes make use of IoT to control or monitor the inside situations of the buildings. The idea is that the building's users can easily monitor and control home devices/appliances or situations. Therefore, several devices, sensors or actuators are going to be connected to the network using the mentioned protocols [27]. Several smart-home implementations have been performed in the last years. In 2015, Ghayvat et al. [28] deployed several sensors over a home to obtain a smart-home environment that could forecast the wellness of an individual and monitor her/his physical activity around their home environment. Mano et al. [29] have developed a Health Smart Home (HSH) that can identify the emotions of patients that are being treated in their homes with the purpose of monitoring patients. This research can support the development of IoT technologies. Datta et al. [30] developed another HSH where researchers can monitor the physical parameters of the patients to provide more personalized healthcare. Apart from HSM, another relevant aspect that is increasing in smart-home design is sustainability. Several works have been published during the last years. Chang et al. [31] have developed a unified energy management framework that can use renewable energy to reduce the impact of non-renewable impacts on the environment and also reduce electricity bills. Other researchers [32] have developed another smart-home that can also reduce the amount of energy used in the home thanks to the AI module that allows appliances to be used more sustainably. Furthermore, Karmakar et al. [33] developed dynamically controlling exterior and interior window coverings to determine their state and apply a control action to heaters, air conditioners, etc.
However, this research usually has a common problem. The lack of interoperability is considered as one of the most important barriers to achieving the integrations of IoT environments in real infrastructures. The different disciplines, vendors and standards make it even an even more complicated task [34]. Therefore, the proposal addressed in this article may help to resolve this problem.

Control and Automation Systems
Control and Automation Systems (CAS) have been present for more than a century [35]. They are present in our more common automated tasks. CASs can provide a response based on the inputs of the system. Therefore, they are commonly used in big industry systems and automated systems in several kinds of installations, like a heater or freezing system in buildings and homes. There are several types of CASs: proportional controllers, Proportional-Integral controllers (PI), Proportional-Integral-Derivative (PID) controllers and fuzzy controllers. PIDs are very common in industries solutions; however, fuzzy controllers also offer good performance and allow them to control several variables at the time that they produce a unified response.
Fuzzy systems are based on fuzzy logic. This was first proposed by Zadeh [36] in 1965. In this research, Zadeh proposed the basic principles of fuzzy logic, representation and inference, basic rules of inference and the linguistic variables and its applications to fuzzy control. Several works have used fuzzy control systems. Next, some of them are described briefly.
Mier et al. [37] designed a fuzzy adapted method to improve the response of a scalar fuzzy control system for the speed of an induction motor. They demonstrated that the use of an adaptive fuzzy controller shows improvement against the non-adaptive fuzzy controller. However, the fuzzy control systems are not only applied to classic control problems. They are also applied to the smart-environments that surged after IoT technology appeared. Garg and Kaushal [38] designed a traffic light control system using a Wireless Sensor Network (WSN) and fuzzy control. For this specific case, the authors designed four fuzzy controls that work in parallel to obtain a better performance, fault-tolerance and support. Their results support the system that allows the vehicle's waiting times to be reduced. Another example of fuzzy logic applied to a smart-environment, in this case to Industry 4.0, is the study developed by the Chinese and Norwegians researchers Huo et al. [39]. The study shows a fuzzy control system analyzing the real-time data information of an assembly line. The fuzzy system has two different fuzzy systems: the first one controls the re-balancing of the assembly line, and the second one adjusts the production rate of each workstation. Azaza et al. [40] also developed a smart-home fuzzy control system, in this case, for a greenhouse. They tried to promote a comfortable micro-climate for plants while saving energy and water. For this reason, they developed a smart fuzzy logic control system that uses wireless data monitoring to obtain the output of the system. Several works have used fuzzy logic to control heating systems [41][42][43]. The studies [41,42] show a fuzzy controller implemented in an 8-bit microcontroller. The fuzzy logic control is based on the definition of an engineering heuristic to determine the boiler temperature. So, the output of the system is based on a heuristic, not real data. The study [43] defines a fuzzy controller in which only the difference between the current temperature and desired temperature is taken into account. This study collects the data from the current temperature inside a building or house; however, this value is usually integrated into the heating systems. However, these works do not make use of all the potential and options offered by the sensor networks, which could obtain data in real-time and apply it to the fuzzy control system. One of the major advantages of sensor networks is to obtain data intelligently from heterogeneous data sources that can extend the capabilities of the system and improve its performance. In this sense, the work presented must obtain information of the context where the system is located using different types of sensors and make it available to the fuzzy control system. Moreover, with these technologies, it is possible to establish a balance between user comfort and energy saving.

Multi-Agent Systems
The sensorization of cities, homes and factories, among other infrastructures, allows the deployment of distributed systems. A computer system is needed to manage these complex systems. Due to the nature of these systems, the natural choice is to develop a distributed computer system capable of administering the system. Therefore, MAS offers a valid solution for this new trend.
A distributed system is the main characteristic of a MAS. Every agent is independent of the others, making their own decisions and performing their goals. However, this is not the only characteristic of a MAS; other features are listed below [44]: • Flexibility allows the system to change against agents' and the environment's modifications.

•
Adaptability enables it to change the behavior or actions of the agents easily.

•
Scalability is the ability of MASs to add new devices to their structure.

•
Leanness is the feature that establishes a difference between agents but without incrementing the categories of agents.

•
Resilience allows obtaining the community goal, even if an agent fails or is corrupted.
Thanks to these characteristics, the MAS has become an excellent solution to control and manage IoT infrastructures.
Other researchers have taken this into account; hence, they have developed multi-agent architectures in the IoT field. Recently, Spanish researchers Francisco et al. [45] have created a distributed model predictive control based on a multi-agent system. They see MAS properties as the perfect solution for the distributed model predictive control that uses fuzzy logic to resolve their case of study. However, this multi-agent architecture is not useful in other IoT infrastructures since its implementation is mainly focused on the case study addressed in the paper. Therefore, this MAS cannot be applied without changes in their structure to another case study or IoT environment. The same problem occurs in a framework designed by Maleš et al. [46]. This solution proposes a multi-agent system with deep learning techniques to allow face tracking. The solution is focused on resolving the IoT problem, but the proposed MAS does not record the video sequence by itself, another subsystem is responsible for that task.
Hedjazi et al. [47] propose a solution for maintenance scheduling in industry 4.0 using a MAS. The MAS enables decision-making and promotes competition between the different agents to obtain the global good. The MAS implements a different kind of agent; however, none of them are connected to a smart device or sensor in the industry. On the other hand, Wang et al. [48] have also developed a MAS for Industry 4.0. This solution provides a full solution for this kind of IoT area. The proposed framework is divided into four layers, every one of them with different kinds of agents. Nonetheless, the framework does not include a layer or module to obtain data from the Internet. Researchers from the United Kingdom and the United States of America, Salvador Palau et al. [44], have developed another MAS for Industry 4.0. Same as above, the MAS is well-designed for the Industry infrastructure, but it does not provide a global alternative.
Similarly, Modoni et al. [49] have carried out a study in the context of a MAS carried out in JADE (Java Agent Development framework) to obtain information from a network of sensors inside a smart home and to monitor the home and its users.
Another area in which the agent's theory has a lot of influence is in smart-grids and micro-grids. Proof of this is the study elaborated by Karavas et al. [50], who developed a MAS for the design and control of autonomous poly-generation microgrids. According to the authors, a decentralized system is a right solution for this kind of system. Hence, the agents help to perform a perfect distributed system, although the presented MAS has a simple architecture with only five agents and it does not have modules to distinguish between different kinds of agents. Modules help to make a difference between agents of the same type, so it is easier to scale the system.
Recent work from the University of Málaga's (Spain) researchers, Ayala et al. [51], has established a global solution for a multi-agent architecture in the field of IoT. To test their proposal, they created the "GreenManager system," a MAS oriented for smart-homes and power consumption management. They have created several agents that oversee the electronic devices of the house and a "Green Manager Agent" that acts as a supervisor agent. This agent is the one that controls the whole system. It knows when to send a request to a device agent according to the information that it receives. Therefore, the authors apply the MAS to reduce the electric consumption of houses during the peak hours where the electricity is more expensive.
Therefore, in this article, a fuzzy control system based on a multi-agent platform is proposed to control the effectiveness of home and building central heating systems. The main contributions of the paper are listed below: (I) the proposal of a self-designed MAS for IoT and smart-environments, (II) the communication behavior between the MAS's agents, (III) the collection of sensor data recollected by intelligent agents and (IV) the design of an intelligent control system based on fuzzy logic principles. In the next section, the proposal will be explained in more depth. Table 1 shows a comparison between the proposal and other similar studies. Some of these research studies have been explained before. The study [52] defines a non-linear mathematical model that takes into account information from several sensors inside and outside the home that can produce control of the heating system in small buildings and homes.

Proposed System
As discussed in the previous section, the main contribution of this research article is the multi-agent system for central heating cost optimization in smart-homes. Multi-agent technology provides a distributed architecture. The distributed architecture is composed of different agents. Every agent performs their task. However, the agents work together to accomplish the final goal of the system. Therefore, one of the most important features of MAS is that every agent works in a coordinated way. MASs have other advantages that, together with the features mentioned in the background section, make MASs an ideal solution. These advantages are mobility, the dynamic behavior, and the high level of communications through the transparent management of the message queues. The system is developed in the Python programming language. To construct the MAS, SPADE Python's library [53] was used. Smart Python Agent Development Environment (SPADE) is a Python library developed by Gregori et al. [54,55] that allows for creating a multi-agent platform based on instant messaging (XMPP). Other alternatives were evaluated, such as JADE [56], PANGEA (Platform for Automatic coNstruction of orGanizations of intElligent Agents) [57,58], AIOMAS [59] and osBrain [60]. However, SPADE was selected because its focus on the Python programming language allowed it to be easily integrated with the simulation model that will be explained later. On the other hand, Python is one of the most relevant languages today and is especially focused on data processing. This means that the system can be improved in the future by other researchers. Hence, when a SPADE's MAS is deployed, its agents run their tasks in an XMPP server to establish the communications between them. This characteristic is outstanding for the SPADE platform. So, with the use of this software, it can develop a MAS that is going to be deployed in a central system. Consequently, some of the agents of the designed platform may be connected with physical objects through the specific communication protocol.
The architecture designed for this article is shown in Figure 1. Proposed multi-agent system. One of the main characteristics of the proposed architecture is that the agents are divided into different modules which establish a difference between the agents. It is assumed that the agents that belong to the same group could be similar or work together in order to obtain a sub-goal of the system. With these modules, it is easier to include, delete or modify agents. Furthermore, the different modules, agents and communication between agents will be explained in the following subsections.

Proposed System
As discussed in the previous section, the main contribution of this research article is the multiagent system for central heating cost optimization in smart-homes. Multi-agent technology provides a distributed architecture. The distributed architecture is composed of different agents. Every agent performs their task. However, the agents work together to accomplish the final goal of the system. Therefore, one of the most important features of MAS is that every agent works in a coordinated way. MASs have other advantages that, together with the features mentioned in the background section, make MASs an ideal solution. These advantages are mobility, the dynamic behavior, and the high level of communications through the transparent management of the message queues. The system is developed in the Python programming language. To construct the MAS, SPADE Python's library [53] was used. Smart Python Agent Development Environment (SPADE) is a Python library developed by Gregori et al. [54,55] that allows for creating a multi-agent platform based on instant messaging (XMPP). Other alternatives were evaluated, such as JADE [56], PANGEA (Platform for Automatic coNstruction of orGanizations of intElligent Agents) [57,58], AIOMAS [59] and osBrain [60]. However, SPADE was selected because its focus on the Python programming language allowed it to be easily integrated with the simulation model that will be explained later. On the other hand, Python is one of the most relevant languages today and is especially focused on data processing. This means that the system can be improved in the future by other researchers. Hence, when a SPADE's MAS is deployed, its agents run their tasks in an XMPP server to establish the communications between them. This characteristic is outstanding for the SPADE platform. So, with the use of this software, it can develop a MAS that is going to be deployed in a central system. Consequently, some of the agents of the designed platform may be connected with physical objects through the specific communication protocol.
The architecture designed for this article is shown in Figure 1. Proposed multi-agent system. One of the main characteristics of the proposed architecture is that the agents are divided into different modules which establish a difference between the agents. It is assumed that the agents that belong to the same group could be similar or work together in order to obtain a sub-goal of the system. With these modules, it is easier to include, delete or modify agents. Furthermore, the different modules, agents and communication between agents will be explained in the following subsections.

Supervisor Agent
The supervisor agent is the agent that controls and supervises the rest of the agents. It is in charge of initiating the rest of the agents. It controls and verifies that all the agents do their tasks. Agents have an associated behavior that defines how they are going to perform their tasks. Different kinds of behaviors exist, like one-shot behavior, cyclic behaviors and periodic behaviors between other more complex behaviors [61]. The supervisor agent has different types of behavior: (I) a one-shot behavior to initialize the agents at the beginning of the MAS initialization, (II) a periodic behavior to check that the rest of the agents are still active, and (III) a cyclical behavior to receive messages from the AI module agents. After performing the simulation, which is its main task, the agent ends its behavior and, therefore, its activity, ending the execution of the program and the MAS.

Devices Module
The devices module is one of the two modules in which this proposed architecture is formed. This module contains the sensors' agents. Every module inside this architecture will be connected to a specific sensor through the specific protocol. The number of devices agents will depend on the number of circumstances that the central system wants to control or measure. In the current proposal, the system will have four different device sensors. These four sensors are listed below.

•
Outside temperature agent: the proposed system will include a temperature sensor located outside the home or building to obtain the temperature in the closest possible environment to the building. The use of a crawler agent and a crawler module were considered in obtaining the outside temperature. This module would connect itself to the Internet to obtain the temperature. However, usually the sensors that different webpages use are located outside the cities. Hence, temperature values could not be as reliable as expected. • Inside temperature agent: the system will also include a temperature sensor inside the house to know if the control system achieves the comfort temperature. There could be as many temperature sensors as the user wanted (for example, one per room). However, in this case, the mean temperature of all rooms will be considered. It is important to obtain the inside temperature since the control system will determine its action taking into account this value as we will see.

•
Outside humidity agent: another aspect that is important to consider when a control system wants to maximize the user's comfort is the humidity. Since the user is going to be inside the building, the proposed system will only consider the outside humidity; inside humidity will depend on the aimed temperature. • People counter agent: the control system will also be informed if there are people or not inside the building, so no energy is wasted at all. The control system will consider this information and will only turn on the system when there are people inside the building. Different kinds of sensors can be used for this purpose, from simple ones like PIR (Passive InfraRed sensor) sensors or presence sensors to more sophisticated sensors like thermal sensors or optical sensors. Furthermore, we can collect the total number of people inside the house or just if there is someone inside the building. The definition of this sensor could change, depending on the circumstances evaluated in the study case. However, the result will be the same, to know if there are people or not inside a building.
All these agents work in very similar ways. As it is logical, each one of them will be connected to a different sensor, but its operation is practically identical. All of them have a cyclic behavior in which they obtain the current data that the sensor is measuring. Depending on this value, the agent will act in an intelligent way and will determine the most convenient action, even changing its behavior. All the agents share a common characteristic; they have a small temporary memory that stores the last n values measured by the sensor and collected by the agent. The value of the variable n is totally configurable; for this proposal, we have selected a value of n = 50. This temporary memory will be used with two purposes: (I) to check that the current measured value is not an extreme value (Equation (1) is used for this purpose) and (II) to check that the current measured value is not equal to the last n/25 values available in the temporary memory. If the purpose (I) is fulfilled, the value is automatically discarded, and it is not saved in the system database, the agent temporary memory, nor sent to the fuzzy agent. Once checked (I), if it is also fulfilled (II) the agent intelligently increases the waiting time to take the next value, understanding that the values are stable, and it is not necessarily a constant consultation to the sensor. In this way its activity and energy reduces consumption. The more times this situation occurs in a row, the longer the waiting time will be. In addition, the value will be stored in the temporary memory but will not be stored in the system memory or sent to the fuzzy agent. When the agent detects again a change in the measured values, it will return to its normal activity, send data to the fuzzy agent and store them in the global system database.
where x is the current measured value, X is the set of values stored in the sensor agent's temporary memory, mean(X) is the average of the values of the set X, std(X) is the standard deviation of the values of X and threshold is a defined value; in this case, the value 3 has been used.

Artificial Intelilligence Module
This module will be the brain of the system. It is going to use the information collected by the previous module and transmitted by the supervisor agent to evaluate all the variables and obtain the appropriate output for the present situation. So, the agents present in this module will be described as follows: • Fuzzy agent: this agent will be the key to the control system. It includes a fuzzy control system that can use the information collected by the sensor agents and generate a control action that will be sent to the system. Inside it, the rules and membership functions of the different variables will be defined, so the appropriate control action can be resolved. It receives the data from the agents in the sensor module to carry out the control action. This implies that it is listening to this group of agents. However, if any of them are not sending measurements because the values do not change or because the agent has fallen, the agent will pick up the last record stored by that agent from the database. When this circumstance takes place, a message will be sent to the agent supervisor to check that the agent is still active. This agent has a periodical behavior since it will not be constantly generating an output to be applied in the heating system. • Control agent: the last agent is the control agent, which is responsible for setting the control action defined by the fuzzy agent and informing the supervisor agent that an action has been set in the physical system. The behavior of this agent is very simple, but its importance is crucial since it is in charge of changing the state of the system. As the agent has to be listening to the message sent from the fuzzy agent, its behavior will be cyclic and will perform its task every time it is required.

Communications between Agents
In these subsections, the behavior of the system will be explained. How agents communicate with each other will be explained in detail.
The proposed architecture is based on different modules, and every one of them is specialized to a different task or goal. However, the proposal is also based on the communication between the different modules, so they can share the results of their objectives to solve the common problem together. The communication between agents and modules is also a basic behavior of MAS.
Once the system is deployed, the first agent that starts working is the supervisor agent. Once the supervisor agent is started, its first task is to start the rest of the agents of the system. These agents include sensor agents and AI agents. Once the rest of the agents are initiated, they will begin to work as defined by their behavior. Meanwhile, the agent supervisor will periodically check that the rest of the agents are alive. If some of them have failed and have stopped being active, the agent supervisor will be in charge of activating that agent/s again. On the other hand, the sensor agents will work in the way defined in the previous section, recovering the measured values and evaluating this value to determine their action or if they should change their behavior. When the action is to send the measured values, these will be sent to the fuzzy agent.
Here, the fuzzy agent will be listening to the messages that can come from the sensor agents to obtain the values that will determine the control action to be done. If not all the values are obtained after a considerable time, the last values stored in the database will be used and the supervisor agent will be warned that something may have happened with some sensor agent. When all the values are received, the blurred control system will be initialized. The rules and membership functions will depend on the study case. Therefore, in Section 4, rules and membership functions will be explained and analyzed. Consequently, once the output is defined, the fuzzy agent will send another message to the control agent. This agent will apply the output to the physical system and once it is done, it will inform the supervisor agent through a message.
This process will be repeated as many times as desired. The most interesting approach is to run this process every, for example, five minutes to check if the environmental circumstances have changed since the last control action was performed and therefore, the control action has also changed. With this approach, the computational cost, as well as the impact on a real distributed sensor network, will be minimized since sensors will not be constantly sending data. This strategy will also reduce energy consumption since agents can sleep while this window of time is closed, decreasing the consumption of said agents as well as sensors. A lower interval is possible; however, the energy consumption of the system and sensors will increase. A higher interval is also possible, although the measured values may change during that time as it might affect the users' comfort. Consequently, it is considered that the appropriate interval should be set to five minutes. The whole process is illustrated in Figure 2 for a better understanding.
Appl. Sci. 2020, 10, x FOR PEER REVIEW 10 of 26 the way defined in the previous section, recovering the measured values and evaluating this value to determine their action or if they should change their behavior. When the action is to send the measured values, these will be sent to the fuzzy agent.
Here, the fuzzy agent will be listening to the messages that can come from the sensor agents to obtain the values that will determine the control action to be done. If not all the values are obtained after a considerable time, the last values stored in the database will be used and the supervisor agent will be warned that something may have happened with some sensor agent. When all the values are received, the blurred control system will be initialized. The rules and membership functions will depend on the study case. Therefore, in Section 4, rules and membership functions will be explained and analyzed. Consequently, once the output is defined, the fuzzy agent will send another message to the control agent. This agent will apply the output to the physical system and once it is done, it will inform the supervisor agent through a message.
This process will be repeated as many times as desired. The most interesting approach is to run this process every, for example, five minutes to check if the environmental circumstances have changed since the last control action was performed and therefore, the control action has also changed. With this approach, the computational cost, as well as the impact on a real distributed sensor network, will be minimized since sensors will not be constantly sending data. This strategy will also reduce energy consumption since agents can sleep while this window of time is closed, decreasing the consumption of said agents as well as sensors. A lower interval is possible; however, the energy consumption of the system and sensors will increase. A higher interval is also possible, although the measured values may change during that time as it might affect the users' comfort. Consequently, it is considered that the appropriate interval should be set to five minutes. The whole process is illustrated in Figure 2 for a better understanding.

Figure 2. Communication behavior.
This communication between agents also leads us to evaluate the computational cost that the proposed system has. In general terms, the computational cost can be defined as follows in Equation (2): This communication between agents also leads us to evaluate the computational cost that the proposed system has. In general terms, the computational cost can be defined as follows in Equation (2): where O is the cost, i is the number of the sensor, s i is the time consumed in obtaining the data from the sensor (this value will change according to the specific sensor and communication protocol), m i is the time consumed in the message form one agent to another, f is the time consumed by the fuzzy system in obtaining the appropriate exit to the system, m c is the consumed time in the request to control agent and m s is the time consumed in the message from control agent to supervisor agent. The cost associated to the operation of the test is the minimum possible, because, in order to carry out the system function, only those agents that are essential are used and with the lowest number of messages between agents possible. It is crucial that each agent works independently from the other in order to minimize the cost. In this way, the sensors' agents will be collecting the data and sending it when they consider it necessary so that the fuzzy agent determines the action to be carried out and this is applied to the heater. At the end of the process it is necessary to send a message to the supervisor agent so that it is aware that the function of the system has been carried out correctly and that it is functioning normally.

Case Study
A case study is necessary to test and verify that the architecture presented in Section 3 can achieve the goal of the paper. Therefore, this section will explain in detail the case study followed in this research. All the considerations, assumptions, and system specifications and definitions will be mentioned in the current section.

Baseline
In order to compare the results obtained with the proposed method it is essential to equate it with a common solution of the problem. Consequently, a baseline is required. Additionally, to test and validate the proposal and possible changes in the system, the simulations will be run in a virtual environment rather than in a real one. MATLAB's Simulink toolbox [62] has been used for this purpose.
There is a Simulink model that simulates the behavior of the house heating system [63]. The model mimics the behavior of a simple house heating system. It has a heater, a basic controller typically used in this kind of installations, and a house with four rooms and one radiator in every one of them. Each path inside the heating system is simulated as a combination of thermal convection, thermal conduction, and the thermal mass.
The controller implemented in the baseline is a proportional control that evaluates the actual temperature of the house regarding the aimed temperature, with an error of ± 2 • C, a 4 • C hysteresis. Hence if the actual temperature is higher than the aim one plus 2 • C, the controller does not open the gas valve; otherwise, if the actual temperature is lower than the aimed one minus 2 • C, it opens the valve. Equation (3) describes the controller behavior. As can be seen, the control seems to be very simple, but it is effective. Many heating controllers use this kind of controllers to satisfy the requirements of a house or building: where V g (x) is the state of the valve at moment t, T c is the current temperature, and T a is the aimed temperature.
The heater of the system receives the fuel that the valve, regulated by the aforementioned control, supplies, and the water inside the thermal system and returns the same water but hotter thanks to the boiler effect. The boiler acts under constant circumstances of humidity and air. It can transfer the heat generated by the combustion to the water thanks to a heat exchanger [64]. So, the water that leaves the heater is much hotter than the one that enters it.
As mentioned before, the model of the house has four rooms, with one radiator in each one of them. These rooms receive the influence of the outside temperature that changes over time. In this approach, the external temperature is simulated using Equation (4): where T is the temperature obtained at a specific time t, A is the amplitude of the sin function, F is the frequency (rad/s), P the phase (rad), and b the bias applied to the function.
To obtain the temperature values, the amplitude was defined to 6, the frequency to 2·π 12·3600 , the phase to 0, and the bias to 5.
The radiators of the rooms transfer the heat in the water to the air. The model's rate of heat transfer is proportional to the temperature difference between the air and the fluid, the heat transfer coefficient (100 W/m 2 k), and the surface area in contact with the liquid (5 m 2 ). Every radiator in the system shares these properties. The convective heat transfer is defined in Equation (5). Furthermore, each room exchanges heat with its environment through its exterior walls, roof, and windows. In this model, it is assumed that rooms do not exchange heat between each other. The rooms have six different types of heat transfer: roof-atmosphere convection, roof-atmosphere leakage, air-roof convection, wall-atmosphere convection, wall-atmosphere leakage, wall-roof convection, window-atmosphere convection, window-atmosphere leakage, and window-roof convection. The heat transfer is additionally defined by Equation (5) However, in this case, some considerations must be taken into account. These concerns are described in Table 2: where Q is the heat flow, k is the convection heat transfer coefficient, A the surface area, and T A and T B the temperatures of the two bodies. Rooms, wall and window areas are defined in Table 3. Consequently, these tables conclude the summary and explanation of the baseline used to compare the proposal presented in this article. Additionally, these tables include the Building Information Modeling (BIM) used for this study. This BIM is defined in MATLAB's model and our proposal will use the same one to compare both prototypes under the same circumstances. Given that the proposal presented is practically a software project that collects data from sensors distributed throughout the house and that these have their own power supply system or are connected to the house's electrical network, the system will not influence the house's construction standards. It will be implemented in already-built houses that have a central heating system. The only aspect to be considered is how to send the on/off signal to the boiler, but since each brand can use its own standard and this study focuses on the theoretical study of the proposed method, this will not be done.

Evaluated Proposal
Once the baseline has been explained, it is time to clarify how we evaluate the proposal described in Section 3. In the case study, the evaluated proposal does not differ a lot from the baseline. The model is very similar. The only thing that changes is the control. The control will be replaced by a fuzzy controller. Moreover, the MAS proposed will be included to evaluate the proposed method. However, Simulink does not provide a multi-agent platform. Therefore, it is necessary to implement a MAS outside the Simulink software. Fortunately, MATLAB (R2019a, The MathWorks Inc., Natick, MA, USA, 2019) includes a Python API that allows the use of MATLAB's features inside a Python program. Among these features is the ability to interact with a Simulink model prom Python code. So, the evaluated proposal, the MAS, and the fuzzy control will be built in Python and will interact with a modified version of the baseline. The following subsections will explain how the system was built for this case study.

MAS' Design
As mentioned before, the MAS is designed with SPADE. All the agents described before will be included in this case study. However, there are two groups of agents that need a deeper explanation in this research.
The first group is the devices module. In Section 3, it was mentioned that the agents will be connected to a sensor via the specific protocol. Unfortunately, the simulation does not have real sensors. Therefore, the sensor agents will establish a connection with a Simulink component that simulates a real sensor. These components will measure different processes over time and the sensor agents will be able to collect these values whenever they desire. So, for this case study, sensors will be replaced by Simulink components and the sensor agents will be able to obtain the values of this component thanks to the Python MATLAB's API. The MATLAB's API provides access to variables stored in the workspace. Therefore, these Simulink components update the value of the workspace variables so that in this way and using the MATLAB's API, the agents can access the current values of the simulation.
These components will simulate the values. The values will be replicated following the logic behavior of these components in the real world. The gap temperature shows the difference between the actual temperature inside the house and the desired temperature. This desired temperature is defined as a constant value, 23 • C. On the other hand, the outside temperature has to change over time. In this approach, the external temperature is simulated using Equation (4) as well.
To obtain the temperature values, the amplitude was defined to 6, the frequency to 2·π 12·3600 , the phase to 0, and the bias to 5. Another measured value is the humidity, this variable is also simulated with Equation (4). In this case, the amplitude was defined to 6, frequency to 2·π 12·3600 , the phase to 0, and the bias to 75; furthermore, the phase is set to π to simulate the logic behavior between outside temperature and outside humidity. The last measured value is the amount of people, in this case, the simulation is provided by random numbers in the interval [0, 10] that changes every 30 min.
The second group of agents is the ones included in the AI module. However, these agents will be explained better in the next subsection.

Control's Design
It is important to describe how the control has been designed. The fuzzy control and the communication of the output to the Simulink's model will be defined in this subsection.
The fuzzy agent will incorporate a fuzzy controller developed with the Scikit Fuzzy Python API [65]. The fuzzy model developed for this case study has four input variables and one output variable. The four inputs are related to the measured values of the sensors and the output value is the control action determined by the fuzzy logic. The fuzzy logic controller is based on Takagi-Sugeno architecture [66]. The main characteristic of this kind of fuzzy controllers is that the output of the control can be defined by the designer of the system. This kind of fuzzy system is considered to be the appropriate one for the current work since the output of the system should be "on" or "off" (one or zero). Therefore, the output of this fuzzy controller will not experience any fuzzification or defuzzification processes. On the contrary, other systems such as Mamdani assume that the output must be defuzzified, so that the relevant fuzzy sets would have to be defined and the output would be defined by one of these fuzzy sets and its value of belonging to the one that is active. This type of output is not the desired one in the proposed system, but we only want to obtain two values 0 to 1, off or on, respectively. This type of output is provided by the Takagi-Sugeno system that has been designed.
Therefore, in the designed Takagi-Sugeno system, the output does not need to be configured. However, the four inputs of the system have to be adjusted or defined to infer the fuzzy logic principles over them. So, the membership functions for each one of these inputs has to be defined. Table 4 collects all the information needed to delimit the inputs' membership functions. But first, the four inputs have to be described. The first input is "temperature gap," it is the difference of the aimed temperature and the current temperature value collected by the sensor agent. The second is "outside temperature," it is the current temperature value from outside of the building. "Humidity" is the humidity outside the building, and "people" indicates the number of individuals inside the house. Input universe refers to the space where the values of this input are going to be, although, if a value gets out of this universe, the fuzzy system can deal with it without any problems. On the other hand, input intervals refer to the different groups or fuzzy values that the input can have. The types of membership functions are defined as triangular and trapezoidal; trapezoidal functions are used in larger intervals with the aim of achieving greater membership during the whole interval, while triangular functions are selected for shorter intervals. To illustrate this information better, Figure 3 shows the definition of the membership functions: Appl. Sci. 2020, 10, x FOR PEER REVIEW 15 of 26 triangular functions are selected for shorter intervals. To illustrate this information better, Figure 3 shows the definition of the membership functions: As shown in the previous figure, these fuzzy groups represent the membership functions of the system and they define when a value is of one type or another. These fuzzy groups, combined with a series of rules, will define the behavior of the fuzzy system. Rules will evaluate the values of the measured variables and their belonging to any of the membership functions so they can obtain the output of the system. The rules defined for the current case study are defined below. They try to summarize a logic behavior based on the user's experience and knowledge: As shown in the previous figure, these fuzzy groups represent the membership functions of the system and they define when a value is of one type or another. These fuzzy groups, combined with a series of rules, will define the behavior of the fuzzy system. Rules will evaluate the values of the measured variables and their belonging to any of the membership functions so they can obtain the output of the system. The rules defined for the current case study are defined below. They try to summarize a logic behavior based on the user's experience and knowledge: 1.
IF "temperature gap" IS "positive" AND "outside temperature" IS "warm" AND "humidity" IS "medium" THEN 1 10. IF "temperature gap" IS "positive" AND "outside temperature" IS "warm" AND "humidity" IS "low" THEN 1 11. IF "temperature gap" IS "positive" AND "outside temperature" IS "hot" THEN 0 12. IF "temperature gap" IS "positive" AND "outside temperature" IS "very hot" THEN 0 In the previous list, 0 and 1 represent the output of the control system that is going to be applied to the physical system, off and on, respectively. With these rules, the control system infers the normal actions that users could take in their homes and buildings to promote sustainable use of central heating systems. In fuzzy control systems, the rules are usually implemented by experts; in this case study, the experts are the users of the system.
After the fuzzy agent obtains the appropriate control action, the communication will send this action to the Simulink's component to continue the simulation. Once the actions are sent and processed by the virtual system, the sensor's agents will measure the variables and the process continues until the simulation ends.

Simulations
After the baseline and the approach followed in this study are explained, it is time to run the simulations. However, it is also important to define the circumstances of these replications. In these subsections, these circumstances will be explained.
To test the proposed system, a deep simulation has been performed to assess the proposal during a long period. Hence, it will simulate the contaminated running of central heating for 50 h. With this approach, we will simulate the behavior and response of the proposal in almost all the possible conditions. Furthermore, it will be possible to better observe if the proposal allows for a reduction in the consumption of fuel and therefore a reduction of gas emissions to the atmosphere.

Results and Discussion
According to the experiments mentioned in the previous section, this segment will show the results of those experiments and the discussion of the results. The results will be divided into different subsections.

Multi-Agent System
One of the main contributions of this scientific work is the use of a MAS to coordinate different entities to achieve a common goal. The architecture proposed has shown to offer good performance in terms of communication between agents and the performance of every individual agent. The communication behavior between agents allows for the establishment of a good execution of the whole system. Thanks to the messages, the supervisor agent can control the whole system and it knows exactly when to act or send other messages. Furthermore, the MAS has shown that even if an agent fails, it can continue working with the rest of the agents without any problems. This is one of the main characteristics of MASs and the proposed system incorporates it.
Additionally, the communications between agents are done quickly and no delays have been detected during the simulation. Hence, after observing the behavior of the agents, it can be noted that the proposed multi-agent architecture seems to work perfectly in these kinds of systems and that the idea mentioned in the proposal section is confirmed now, MASs are ideal for a distributed system that aims to achieve a common goal.
To test the effectiveness of the proposed MAS, a small sensor network has been deployed, which interacts with the MAS. The sensor network has two Xiaomi NUN4019TY (humidity and temperature sensor, Xiaomi Inc., Beijing, China) and two Garza Power 430041 (presence sensor, Garza, Fuenlabrada, Spain). We established the appropriate connections with them and ran the fuzzy algorithm with the measured values of the sensors. To obtain the number of persons inside the house/building, an algorithm was deployed to interpret the presence's sensors data. The MAS and the strategy defined to obtain the data from the sensors have demonstrated that it works perfectly in a small sensor network's environment; this type of environment is the normal setting in homes and flats.

Fuzzy Control System
The other great contribution of this work is the proposed fuzzy system in charge of controlling the behavior of the system. The aim was to design a new controller that could be able to reduce the use of fuel and therefore to reduce the cost for the citizens. So, the results shown by the fuzzy control system will be explained in this subsection.
Firstly, once the simulation is done, it will be interesting to compare how the fuzzy controller works related to the original controller. Both controllers want to control the temperature inside the building, so it could be interesting to observe that variable. Hence, Figure 4 shows how this variable is controlled by both controllers: Appl. Sci. 2020, 10, x FOR PEER REVIEW 17 of 26 a small sensor network's environment; this type of environment is the normal setting in homes and flats.

Fuzzy Control System
The other great contribution of this work is the proposed fuzzy system in charge of controlling the behavior of the system. The aim was to design a new controller that could be able to reduce the use of fuel and therefore to reduce the cost for the citizens. So, the results shown by the fuzzy control system will be explained in this subsection.
Firstly, once the simulation is done, it will be interesting to compare how the fuzzy controller works related to the original controller. Both controllers want to control the temperature inside the building, so it could be interesting to observe that variable. Hence, Figure 4 shows how this variable is controlled by both controllers: The previous figure shows the temperature variation. The original controller (non-fuzzy) shows a more changeable behavior. This type of behavior may have bad consequences for the system's users' health due to the quick changes in temperature. On the other hand, the proposed system does not vary at all when there are people inside the house. This characteristic facilitates the users' comfort. In Figure 4 we can also observe that the fuzzy controller also has a temperature loss during some specific moments. This behavior can be linked to a bad performance of the controller, however, in Figures 5 and 6 it can be seen that this temperature loss is due to the case in which there are no people inside the building/house. The previous figure shows the temperature variation. The original controller (non-fuzzy) shows a more changeable behavior. This type of behavior may have bad consequences for the system's users' health due to the quick changes in temperature. On the other hand, the proposed system does not vary at all when there are people inside the house. This characteristic facilitates the users' comfort. In Figure 4 we can also observe that the fuzzy controller also has a temperature loss during some specific moments. This behavior can be linked to a bad performance of the controller, however, in Figures 5 and 6 it can be seen that this temperature loss is due to the case in which there are no people inside the building/house. Appl. Sci. 2020, 10, x FOR PEER REVIEW 18 of 26   Figure 5 also shows that the fuzzy controller does not achieve the desired temperature, however, the error is stable, and the difference does not have a significant impact on users' comfort. Therefore,   Figure 5 also shows that the fuzzy controller does not achieve the desired temperature, however, the error is stable, and the difference does not have a significant impact on users' comfort. Therefore,  Figure 5 also shows that the fuzzy controller does not achieve the desired temperature, however, the error is stable, and the difference does not have a significant impact on users' comfort. Therefore, we can conclude that the fuzzy controller works stably and that it does not compromise the comfort of the users.
Another important characteristic when applying a new proposal is to reduce the cost or decrease the emissions of the system. In the evaluated system, these two concepts are linked since the fuel necessary to heat the system's water is the one responsible for gas emissions, while at the same time it is also the one responsible for the cost waste. So, it is important to evaluate the impact on the cost that the system has. This cost is obtained with the amount of fuel consumed and the price established in the baseline. To answer this question, Figure 7 is presented. In it, we can see that in just 50 h of continuous performance of the system, the proposal reduces significantly the cost of this type of system. Hence, the ROI (Return on Investment) is guaranteed. we can conclude that the fuzzy controller works stably and that it does not compromise the comfort of the users. Another important characteristic when applying a new proposal is to reduce the cost or decrease the emissions of the system. In the evaluated system, these two concepts are linked since the fuel necessary to heat the system's water is the one responsible for gas emissions, while at the same time it is also the one responsible for the cost waste. So, it is important to evaluate the impact on the cost that the system has. This cost is obtained with the amount of fuel consumed and the price established in the baseline. To answer this question, Figure 7 is presented. In it, we can see that in just 50 h of continuous performance of the system, the proposal reduces significantly the cost of this type of system. Hence, the ROI (Return on Investment) is guaranteed. In addition, to better illustrate the total cost of both simulations, Table 5 is included. It shows the total cost of each simulation and the average temperature over the simulation. As can be seen, the proposed system decreases the cost by $10.84. The total cost is obtained by multiplying the fuel consumption by a fixed price (0.3002 $/l) defined again by the MATLAB Simulink model. However, the mean temperature is a bit lower because of the behavior explained before where the temperature decreases when there are no people in the building. That temperature is the average temperature during the entire simulation. In the proposal, the average temperature decreases when there are no people in the house, the heating system is turned off. During those moments, the temperature inside declines. Therefore, it is normal that these moments are reflected in the calculation of the average temperature. However, during the rest of the situations in which the heating is on, the temperature remains stable.  In addition, to better illustrate the total cost of both simulations, Table 5 is included. It shows the total cost of each simulation and the average temperature over the simulation. As can be seen, the proposed system decreases the cost by $10.84. The total cost is obtained by multiplying the fuel consumption by a fixed price (0.3002 $/l) defined again by the MATLAB Simulink model. However, the mean temperature is a bit lower because of the behavior explained before where the temperature decreases when there are no people in the building. That temperature is the average temperature during the entire simulation. In the proposal, the average temperature decreases when there are no people in the house, the heating system is turned off. During those moments, the temperature inside declines. Therefore, it is normal that these moments are reflected in the calculation of the average temperature. However, during the rest of the situations in which the heating is on, the temperature remains stable. Since the fuzzy simulation did not achieve the aimed temperature, it was decided that a second simulation of both systems should be run. This time the fuzzy proposal will have an aimed temperature of 24 • C instead of 23 • C. The non-fuzzy proposal will have an aimed temperature of 23 • C. The results of the simulation are shown in Figures 8-11.
Appl. Sci. 2020, 10, x FOR PEER REVIEW 20 of 26 Since the fuzzy simulation did not achieve the aimed temperature, it was decided that a second simulation of both systems should be run. This time the fuzzy proposal will have an aimed temperature of 24 °C instead of 23 °C. The non-fuzzy proposal will have an aimed temperature of 23 °C. The results of the simulation are shown in Figures 8-11.   Since the fuzzy simulation did not achieve the aimed temperature, it was decided that a second simulation of both systems should be run. This time the fuzzy proposal will have an aimed temperature of 24 °C instead of 23 °C. The non-fuzzy proposal will have an aimed temperature of 23 °C. The results of the simulation are shown in Figures 8-11.    The fuzzy proposal retains a slight error in regards to the target temperature. However, now both systems achieve the same temperature (23 °C). The fuzzy proposal still has temperature losses due to the fuzzy rules defined when there are no individuals in the building. Additionally, Figure 11 shows the effectiveness of the proposed system related to cost and energy used reduction. This output  The fuzzy proposal retains a slight error in regards to the target temperature. However, now both systems achieve the same temperature (23 °C). The fuzzy proposal still has temperature losses due to the fuzzy rules defined when there are no individuals in the building. Additionally, Figure 11 shows the effectiveness of the proposed system related to cost and energy used reduction. This output The fuzzy proposal retains a slight error in regards to the target temperature. However, now both systems achieve the same temperature (23 • C). The fuzzy proposal still has temperature losses due to the fuzzy rules defined when there are no individuals in the building. Additionally, Figure 11 shows the effectiveness of the proposed system related to cost and energy used reduction. This output can also be seen in Table 6. Therefore, the proposed system achieves one of its main goals: cost reduction, energy use reduction, and, consequently, the reduction in gas emissions. The results show that the fuzzy proposed system works much better than the baseline reducing cost for the users and therefore the amount of fuel needed to feed the heating system while increasing the comfort of the users. It is true that on average the temperature is lower in the proposed system. However, this fact is due to the behavior of the proposed fuzzy system. As shown in the rules defined, several circumstances (that there are no people inside the house, the temperature outside is too high, there are too many people inside the house, etc.) force the central heating to turn off, reducing the inside temperature on some occasions. These circumstances are controlled thanks to the fact that the fuzzy logic allows us to reduce the cost and obtain one of the goals of the research.

ROI Analysis
Once the simulations are evaluated, it is also important to include a deep analysis of the ROI. Considering the costs of non-fuzzy and fuzzy simulations and the number and prices of sensors needed to implement this new solution in a real environment, we have included the ROI analysis. Table 7 shows this analysis. Both simulations achieve quick benefits. In around ten days, the users of the systems will be saving money.

Conclusions
In this article, a MAS for a fuzzy logic controller has been presented. Regarding the results mentioned, it was demonstrated that the proposed system can achieve the expected results and that this kind of architecture can be applied to a distributed system in the field of IoT and smart-environments. Another important assumption is that this technology can reduce gas emissions in this kind of system. Additionally, if this solution is deployed at a great scale, the gas emissions to the atmosphere in big cities will be reduced significantly. The simulation presented in the study supports this idea.
However, there are several lines of research that this article does not cover. Therefore, these will be defined as future lines of research. The most important one is to perform a MAS that can deploy several fuzzy agents instead of just one. The idea behind this is that the system will be able to control radiators in community buildings to reduce consumption and make sustainable use of the central heating in those buildings. Furthermore, it is expected that families will be able to reduce their taxes. This future line of research is important since it will automatically control the new installations of central heating in Spain. Another action that must be considered as a future line of research is to deploy the proposal of this article in a real environment to prove if the same results can be achieved in a real situation. Furthermore, once we have deployed the system, we can collect data from other types of sensors, like windows sensors or door sensors, and add them to the fuzzy controller. By doing this, the system will be more complex.
Finally, to prove the efficiency of the MAS, it is important to test it in another kind of real environment so we can observe the behavior of the system in a different situation and validate it as a solution for a distributed system in the field of IoT. Probably a smart-city environment would fit well with the system, due to the fact that the number of the sensor will increase significantly and therefore the communications between agents will rise accordingly. This situation will determine the robustness of the proposed MAS.