Agent-based Indoor Air Quality Control System

Taiwan has suffered from widespread haze and poor air quality during recent years, and the control of indoor air quality has become an important topic. Here, we report a system relying on intelligent agent theory, in which collected data on air quality is used in calculations, then agents make decisions in accordance with prewritten rules, using conflict resolution mechanisms to resolve any conflicts encountered by the equipment, to improve indoor air quality. Regarding implementation, the simulated system used the Arduino open source microcontroller system to collect air quality data and trigger building equipment to improve indoor air quality. We also used the graphic control program LabVIEW to write a control program and user interface. The implementation revealed that rules can be prewritten and equipment conflicts resolved after considering a small number of pieces of building equipment and air quality factors. However, when the system’s operating decisions are simultaneously based on many air quality factors and users, the system cannot respond exhaustively to all situations. Consequently, the system requires editable software and a suitable accessible human-computer interface for communication and interaction.


Motivation and Goal
Taiwan's economy has grown rapidly over the past few decades, but although this has greatly increased wealth, it has also caused environmental pollution. In particular, because of the topography and prevailing wind directions in western Taiwan, particulate matter produced by industrial parks and thermal power plants cannot easily disperse, which has caused the air pollution situation to deteriorate steadily. Figure 1 shows National Aeronautics and Space Administration (NASA) satellite aerosol optical depth (AOD) data, where AOD is a key physical measure of the turbidity of the atmosphere. In this image, the deeper the color, the greater the difficulty light has in penetrating. It can be seen that there are large amounts of particulate matter in western and southern Taiwan, and the Yunlin Sixth Naphtha Cracker and Taichung Thermal Power Plant may be major sources of this pollution. (1) Because people cannot continuously observe and actively control indoor air quality over long periods, artificial intelligence is needed to control indoor air quality. Intelligent agents are artificial intelligent control systems that are able to periodically sense the environment and perform improvements. Figure 2 shows a process flowchart for this study's construction of a multiple agent indoor air quality control system based on intelligent agent theory, the development of a simulated system, and the analysis of its feasibility.

Literature Review
This study recommends the establishment of a multiple agent indoor air quality control system based on intelligent agent theory. Intelligent agent theory and indoor air quality indicators and guidelines are described as follows.

Intelligent agent theory
In the field of artificial intelligence, intelligent agents refer to autonomous entities that can sense the surrounding environment and initiate actions to achieve design goals. An agent can receive various types of information from the environment, confirm the order of task priority and target behavior, and make decisions without any need for human intervention. (2) Intelligent agent technology is currently one of the most important research paradigms in the field of artificial intelligence and focuses on the development and use of knowledge representation tools as computing and information communication mechanisms in an environment characterized by distributed intelligence. (3) The basic modules forming the core of an intelligent agent consist of sensors, computing mechanisms, and actuators, and the agents include both software and hardware. Intelligent agents can assume the role of humans in a system and help humans judge the state of an environment. Intelligent agents can be classified as the following five types; (4) after simple reflex agents sense the environment, they can perform actions in accordance with behavioral rules (Fig. 3).
(1) Simple reflex agents (2) Model-based reflex agents (3) Goal-based agents (4) Utility-based agents (5) Learning agents Furthermore, program developers can use graphic symbols to draft the operating processes of an intelligent agent system and thereby clarify the operations at each step during system development. Some of the graphic symbols that may be used are shown in Fig. 4. As shown by the intelligent agent behavior model in Fig. 5, an intelligent agent performs calculations after   sensing the environment and relies on actuators to change the environment on the basis of its calculation results. (5) Multiple agents are object-oriented cooperative distributed problem-solving systems (OOCDPSSs) based on agent communities and comprise all the various relationships between agents. (6) This framework establishes an inward/outward communication order in an agent society, where a leader agent (LA) serves as the society's chief responsible agent. When an OOCDPSS deals with a problem, it divides the problem appropriately into multiple subproblems, assigns the subproblems to appropriate problem solvers for resolution, and finally integrates the results of problem solving to achieve an appropriate resolution (Fig. 6). This framework can be applied in the design of smart building systems, and designers can assign sensing results from different sensors to individual agents for subsequent handling. A communication platform can be used to resolve conflicts between individual agents, and the system can then activate various types of equipment. This type of system thus operates in a cycle of sensing, calculation, communication, and action.

Indoor air quality
In accordance with Taiwan's Environmental Protection Administration (EPA), Executive Yuan, indicators of indoor air quality include ozone (O 3 ), fine particulate matter (PM2.5), particulate matter (PM10), carbon monoxide (CO), sulfur dioxide (SO 2 ), and nitrogen dioxide (NO 2 ). Because of the differences in units used to quantify these substances, to simplify sensor measurements and program control criteria, we employ fine particulate matter (PM2.5) as the chief control variable. Fine PM2.5 causes respiratory tract and cardiovascular diseases, including myocardial infarction, cerebrovascular disease, and lung cancer. (7) The "Air Quality Guidelines" issued by the World Health Organization in 2005 give a 24 h average value standard for PM2.5 of PM2.5 < 25 μg/m 3 and an annual average value standard of PM2.5 < 10 μg/m 3 . (8) Taiwan's EPA provides the air quality indicator grades for fine particulate matter shown in Table 1. Because PM2.5 is harmful to human health when its concentration level reaches grade 6, this study therefore recommends that the lower limit of grade 6-a PM2.5 concentration of 48 μg/m 3be taken as a threshold value dividing good and poor air quality, and the upper limit of grade 6-53 μg/m 3 -be taken as a buffer value ensuring that particulate matter does not immediately reach a high hazard value after exceeding the threshold for good air quality.

Theory and Method
In accordance with the above analysis, the indoor air quality control system constructed in this study required the four dimensions of (1) a system framework, (2) a rule table design, (3) the analysis of the chances of conflict, and (4) conflict resolution methods and handling principles. Persons encountering discomfort, such as painful eyes, coughing, or throat pain, should reduce physical exertion and outdoor activities in particular.
1. Adults and children with heart, respiratory, and cardiovascular disease, and elderly persons should avoid physical exertion and outdoor activities in particular.
2. Persons with asthma may need to increase the frequency of inhalant use.

System framework
The conditional (if-then) reasoning framework shown in Fig. 7 was compiled on the basis of air quality factors and control methods. Individual intelligent agents then initiate the actions of the building shell and equipment intended to improve indoor air quality on the basis of air quality monitoring data and if-then decisions. Each piece of equipment has an operating time and the sensors continue monitoring the environment with frequency after each change in the environment.
Taking PM2.5 fine particulate matter as the chief air quality control variable, we constructed the simulated environment shown in Fig. 8. In this environment, the main computer receives data transmitted from outdoor and indoor sensors, and triggers devices on the basis of prewritten criteria after the computer's intelligent agents perform situation analysis, in a cycle of sensing, calculation, and action.
Our indoor air quality control system based on intelligent agent theory ( Fig. 9) is composed of three parts, namely, the input end (sensing), processing end (calculation), and output end (action), which are described as follows: (1) Input end (sensing): The input end is the source of the air quality control system framework's data, which comprises indoor environmental data and outdoor environmental data. After collecting data, the input end transmits it to the processing end. (2) Processing end (calculation): After the collection of indoor and outdoor data, the processing end performs assessment and comparison. It employs prewritten rules to determine whether the environment currently has any problems and whether any facilities or equipment must be activated to improve the environment.   (3) Output end (action): The output end serves to activate facilities and equipment to improve indoor air quality. The implementation of this indoor air quality control system requires electromechanical equipment and control software; our system employs Arduino (10) and LabVIEW technology. (11) The device linkage of an intelligent agent system possessing sensing/calculation/action capabilities is shown in Fig. 10, where the sensing end chiefly relies on Arduino to operate electromechanical equipment and communicate with the computer. In addition, the system uses a gateway to obtain outdoor particulate matter data provided by the EPA from a cloud database. A LabVIEW program is responsible for performing data calculations. At the actuation end, after the program has processed the data, control signals are sent to actuation equipment and devices via Arduino boards to improve indoor air quality. The system maintains one set of actions for time T an and begins the next cycle after the sensors have performed sensing with frequency (Fig. 11).
Furthermore, an agent society can be developed from these intelligent agents with sensing/ calculation/action capabilities. However, when multiple intelligent agents control the same device, conflicts in the form of inconsistent actions may occur. Consequently, agents must be able to communicate and coordinate with each other.   To investigate the feasibility of an agent society, we designed the multiple agent framework shown in Fig. 12 and added temperature as a control variable. Intelligent agent 1 can activate the window mechanism and air purifier as a control method upon receiving data from outdoor and indoor particulate sensors, while intelligent agent 2 bears responsibility for receiving data from indoor temperature sensors and can also control window opening and air conditioning. Because both agents can control window opening, they therefore need to communicate to coordinate their actions. Each piece of equipment has an operating time T an , and the sensors continue monitoring the environment with frequency f after each change in the environment.
We used an Arduino device system and a multiple agent control system written in LabVIEW to design the experimental framework shown in Fig. 13. Fig. 13. Block diagram of experimental multiple agent indoor air quality control system.

Rule table design
After obtaining an experimental framework, we designed a rule table. We used a rule-based approach to produce a rule table and listed possible situations as a basis for activation criteria. This study divided air quality into two states, good and poor, and used 1 to indicate good air quality and 0 to indicate poor air quality in the rule table. We further took the lower limit of grade 6-a PM2.5 concentration of 48 μg/m 3 -as the threshold value dividing good and poor air quality. Table 2 gives the rule tables for intelligent agent 1. When an indoor temperature rule table was written for intelligent agent 2, 0 was used to represent a temperature higher than 26 ℃, 1 was used to represent a temperature between 20 and 26 ℃, and 2 was used to represent a temperature of less than 20 ℃ (Table 3).

Analysis of chances of conflict
In our experiment, two intelligent agents separately controlled an air purifier, windows, and an air conditioner. In this case, a resolution program was needed because the fact that the two agents controlled the windows based on different criteria might lead to control conflicts, in which case the system would not operate normally. Conflict situation analyses are given as below.   When the indoor particulate concentration is high and the outdoor particulate concentration is low, when the indoor particulate concentration is low and the outdoor particulate concentration is low, and when the temperature is excessively high or low, agent 1 may judge that the windows need to be opened on the basis of the particulate concentration, but agent 2 may judge that the windows need to be closed on the basis of the temperature. By summarizing these conditions, we can compile conflict rules 1-4 in Table 4.
It is also possible that agent 1 judges that the windows need to be closed on the basis of the particulate concentration, but agent 2 judges that the windows need to be opened on the basis of the temperature. By summarizing these conditions, we can compile conflict rules 5 and 6 in Table 4. After determining when conflicts will occur, we can now determine resolution programs.

Conflict resolution methods
When rules are in conflict, the following methods are usually taken to resolve the situation: (12) (1) setting the priority order, (2) following the longest match principle, and (3) adding new rules.
Setting an order of priority is a common method of resolving conflicts in agent systems. Because control conflicts usually occur when multiple agents seek to operate the same equipment, setting an order of priority can give one agent first priority when controlling the equipment. In contrast, when other conflict resolution methods are used, it may be necessary to go back and revise the rules, which may often cause confusion in the system. The first step in setting an order of priority is to prioritize the consideration of conditions under which people may face immediate dangers. For instance, the consideration of conditions such as an excessively high carbon monoxide concentration or the occurrence of a fire must receive the highest priority. However, in the case of conditions that do not have the highest priority, such as those that are harmful to people but not immediately so, planners should consider whether third-party equipment can resolve the conflict and if such third-party equipment is present, it can be activated to resolve the conflict. For instance, a cross-flow heat recovery ventilator can resolve the conflict that occurs when it is necessary to close the windows and turn on air conditioning to reduce the temperature, and simultaneously draw in fresh air for ventilation. In this situation, when it is necessary to close the windows and simultaneously provide fresh air, the cross-flow heat recovery ventilator can be triggered. Furthermore, when third-party equipment is used, the order of priority in which the equipment is activated can also be set. Taking this experiment as an example, the problem of a high particulate concentration can be resolved through either natural ventilation or the use of an air purifier, while an abnormal temperature can be resolved only through the use of air conditioning. Because there is only one method of resolving temperature abnormalities, controlling the temperature should therefore receive the highest priority. In this situation, the appropriate conflict resolution methods are those in the conflict resolution table shown in Table 5.
In addition, when the order of priority is set to resolve conflicts, it may also be necessary to consider the difficulty in environmental control. For example, because there were few methods of controlling the temperature in this experiment, temperature control had a relatively high priority. We therefore recommend that the system first control the temperature before controlling the particulate concentration. After deciding the order of priority, the next step is to consider control conflicts. For instance, when air conditioning must be turned on, closing windows must be prioritized, followed by turning on the air purifier to control the particulate concentration. If it is necessary to admit outdoor air because the windows have been closed, even more equipment will be needed, such as a total heat exchanger. However, employing such a resolution program will require combining the situations in all rule tables and finding all conditions under which conflicts may occur, which will require an even more complicated rule table to resolve conflicts. When there are too many intelligent agents, efficiency will decrease.

Research Process and Results
The following are explanations verifying the above four dimensions of the proposed indoor air quality control system, including four aspects: (1) program description, (2) user interface, (3) program implementation and testing, and (4) establishment of a multiple agent program.

Program description
The sensing, judgment, and actuation program written using LabVIEW is shown in Fig. 14. Data received by the sensors is inspected to determine whether the voltage exceeds the threshold value, and the results are classified in accordance with the rule table to decide whether to turn on building equipment. However, since it was found in the experiment that it was difficult to adjust the ambient particulate concentration to a constant value, which would allow us to observe whether the program and equipment could operate normally, we used a slidingtrack variable resistor instead of indoor and outdoor sensors to provide input voltage values.

User interface
The user interface consists of the following: (1) Sensor status display As shown in the lower right part of Fig. 15, the air quality threshold value was set at 0.871 V, (13) which is converted from the sensed concentration value of 48 μg/m 3 via a function. A voltage exceeding 0.871 V indicated that a high pollutant concentration had been detected and the indoor air quality was poor, while a voltage of less than 0.871 V indicated that the indoor air quality was good. Figure 15 also shows that the current situation is good outdoor air quality and poor indoor air quality.
(2) Actuator status display The upper part of Fig. 15 shows the window-opening device status, i.e., the current servo motor opening angle, and whether the air purifier has been turned on.

(3) Rule status
The lower left part of Fig. 15 displays the current rule implementation status. Take the current lighting Rule 3 as an example. It shows that if the outdoor air quality is poor, and the indoor air quality is good, then LabVIEW sends control command 10 to close the window and send Arduino control code 0 to the fan, which represents the air cleaner being off. These rules are written in LabVIEW's rule-based case structure (Fig. 16).

Program implementation and testing
The Arduino board was connected to the computer and the plug-in program LabVIEW for Arduino's communications file "LIFA_Base.ino" uploaded to the Arduino board, which enabled Arduino and the LabVIEW program to communicate. Arduino was then connected to the sliding-track variable resistor, which was used to simulate data from sensors. The system also included one servo motor, which represented the window-opening device, and one 12 V fan, which represented the air purifier (Fig. 17). A servo motor rotation of 90° indicated open windows, while a rotation of 10° indicated closed windows. Turning on and off the fan represented turning on and off the air purifier, respectively. Because the voltage of the Arduino board (5 V) was different from that of the fan, a relay was used to turn the fan on and off.

Establishment of a multiple agent program
After adding a second agent to our existing single-agent framework, we added a conflict resolution program to complete the multiple agent framework. Because conflicts would involve concurrent action by both agents, it was necessary to provide the agents with a channel of  communication. The two possible communication methods include transmitting the judgment results of one agent to the other agent and letting the second agent make an integrated decision, or having both agents transmit their data to a third agent and letting the third agent make a decision. Although the method adopted will depend on the agents' communication framework in these cases, the agents need to be able to transmit mutually readable data and must have a communications protocol. The rule tables of the two agents in this experiment were included in the same program and the issue of communication was temporarily ignored. If two programs have been written, it will be necessary to consider how these programs will transmit data. Figure 18 shows a full diagram of the LabVIEW program. See Figs. 19-21 for the program content and detailed diagrams. Figure 19 shows the sensing portion of the multiple agent program. The two sensors consist of intelligent agent 1's sensor, which receives indoor and outdoor particulate matter data, and intelligent agent 2's sensor, which receives indoor temperature data.  The upper half of Fig. 20 shows intelligent agent 1's PM2.5 judgment and control portion, while the lower half shows intelligent agent 2's temperature judgment and control portion. The central block consists of the experiment's priority rule conflict resolution program and the right side consists of the building equipment control program. After the PM2.5 sensor received indoor and outdoor data, it judges whether to open the window and turn on the air purifier. After the temperature sensor receives indoor data, it judges whether to open the window and turn on the air conditioning equipment. Finally, the system resolves any possible conflicts involving the window-opening device via the preset order of priority and turns on building equipment in the correct sequence. The intelligent agents in this study employed LabVIEW's case structure mechanism to determine the effect of if-then rules. Different input conditions resulted in different events via the judgment on the basis of rules. Finally, building equipment was turned on in accordance with the prewritten rules (the rule-based case structure is shown in Fig. 21).
This experiment's conflict resolution program is shown in the middle right of Fig. 20. This program decided which agent's judgments had the highest priority on the basis of the order of priority settings. As a result, when a conflict was encountered, the system lets the agent with the higher priority have equipment control rights. Because both agents in this experiment were written in a single program, local variables were used to transmit information and perform calculations, and priority settings prevented conflicts from occurring. However, if two intelligent agents were implemented in the form of two agent programs, the communication protocol used by the programs to exchange information would have to be taken into consideration.
The normal operation of our programs verified the feasibility of a framework based on intelligent agents. The agents were able to resolve conflicts and control the building equipment in accordance with their order of priority. This experiment incorporated the default settings of the multiple agents as much as possible, and the resolution program accounted for all the conflict situations that the agents might face. Nevertheless, because a system may encounter unexpected and difficult-to-resolve situations, such as situations when different users may have different building equipment needs, a control system's program must also allow revisions and be able to communicate interactively with users.

Conclusions
We constructed an indoor environment containing a multiple agent society with a "sensingcalculation-communication-action" ability, which was used to verify the feasibility of applying intelligent agent theory to air quality control systems. In our experiment, multiple agents converted the voltage values from sensors to data values, which were compared with threshold values, and controlled a motor (representing a window) and a fan (representing an air purifier) in accordance with a rule table. This experiment provisionally used sliding-track variable resistors to simulate sensors; actual sensors can provide input data in future research. The experiment revealed that rules can be written in advance to resolve equipment conflicts when it is necessary to consider only a small number of pieces of equipment and air quality factors. However, when there are many pieces of building equipment and air quality factors, and when users are involved in operating decisions, a system similar to that in this study would not be able to account for all situations. Because of this, a control system must also allow revisions and be able to communicate interactively with users.