Optimized Energy and Air Quality Management of Shared Smart Buildings in the COVID-19 Scenario

: Worldwide increasing awareness of energy sustainability issues has been the main driver in developing the concepts of (Nearly) Zero Energy Buildings, where the reduced energy consumptions are (nearly) fully covered by power locally generated by renewable sources. At the same time, recent advances in Internet of Things technologies are among the main enablers of Smart Homes and Buildings. The transition of conventional buildings into active environments that process, elaborate and react to online measured environmental quantities is being accelerated by the aspects related to COVID-19, most notably in terms of air exchange and the monitoring of the density of occupants. In this paper, we address the problem of maximizing the energy efﬁciency and comfort perceived by occupants, deﬁned in terms of thermal comfort, visual comfort and air quality. The case study of the University of Pisa is considered as a practical example to show preliminary results of the aggregation of environmental data. implementation of building management and control systems. This paper presents a methodology for the optimal control of safety, comfort and energy consumption parameters in smart buildings based on a more direct interaction with the occupants too. Knowledge of the occupancy profile, obtained directly by means of cameras or indirectly by means of measurements of air quality parameters, represents a step forward compared to current design and operation procedures suggested by tech- nical standards. Interaction with the occupants through active participation is considered to be a relevant element of the methodology.


Introduction
Energy efficiency, indoor air quality and user comfort in buildings have received increasing attention in recent years, as they permit a reduction in the consumption of conventional fuels and greenhouse gas emissions, which are fundamental targets in sustainability programs. In addition, they contribute to reducing energy costs and improving the health conditions of building owners [1]. People can be considered as part of any building energy system as, according to the available literature, they spend about 80% of the time indoors-up to 90% in some European countries [2]. Buildings in general, and public buildings as well, are among the major energy consumers in cities, and again this is especially true in European countries. Considering the correlation among energy consumption, its environmental footprint and the implications for global warming [3], energy sustainability emerges as one of the key challenges for decision-makers and society in general. The recent COVID-19 pandemic situation has even further exacerbated the importance of the topic of energy use in public buildings.
A significant amount of energy is necessary in order to maintain the comfort level for the occupants through the operation of various appliances. Occupants can be considered responsible for energy use in buildings; for this motivation "psychology of energy saving" and strategies for energy efficiency have started receiving attention since the 1970s [4,5]. The building energy management and possible trade-offs between comfort and energy consumption have been the subject of several recent studies, such as [6,7]. At the same time, recent advances in Internet of Things (IoT) technologies are among the main enablers of Smart Homes (SHs) and Buildings (SBs). Roughly speaking, a SH or a SB may be defined as a highly automatized environment, where data collected by sensors are gathered and processed in an unsupervised fashion to affect all existing appliances and functionalities and improve the comfort of the people who spend their time in that environment [8][9][10].
While general awareness of the control of environmental variables has increased in the last few years, this interest has been recently increased by the spreading of the COVID-19 pandemic, particularly relevant for commercial and public buildings, such as those for educational purposes [11,12]. All countries have started planning post-lockdown activities and there is a growing concern regarding how social distancing measures and strict indoor air quality control can be enforced in shared buildings to prevent possible airborne virus transmission in indoor spaces.
In our vision, people should be able to enter SBs and learn about some basic environmental variables of the building, such as indoor temperature, air quality (e.g., in terms of CO 2 levels), and visual comfort, and they should be able to interact with the energy systems (e.g., the HVAC-Heating, Ventilation and Air Conditioning-system and lighting systems) up to a certain allowed extent (e.g., for security reasons), combined with natural resources (day lighting, outside temperature, etc.).
From this perspective, people may be willing to know the values of indoor environmental variables and be allowed to control HVAC actuators to improve some of such quantities according to their perceived comfort level. In this regard, people may be seen as mobile sensors that provide further indications to the Building Management System (BMS), and the BMS should be permitted to directly interact with occupants, receiving their feedback in different ways. In general, an elevated performance of the HVAC system can be achieved by radically improving the control performance, which is an important issue in HVAC systems [13]. Ventilation devices, as an important subsystem of the HVAC system, are operated to maintain an appropriate Indoor Air Quality (IAQ). Ventilation systems contribute to about 25-30% of HVAC energy use [14].
A trade-off problem exists in utilizing the several components that can ensure a desired IAQ with minimal energy consumption and reduced energy costs. Currently, such a problem is often solved by adopting a centralized optimization approach. In the recent literature, various methods have been proposed to address the optimization problem of the energy management of buildings and, in general, the main goal of each proposal is to find a balance between user comfort and energy consumption [15][16][17][18].
However, efficient building energy consumption and the maintenance of a high level of comfort are still challenging tasks: various heterogeneous variables and parameters affect the problem. In general, the proposed framework of balancing energy consumption and occupants' preferences by adapting building controls to users' activities and requirements does not consider the direct interaction of the users.
Accordingly, in this work we plan to revisit current energy/environment management strategies of smart buildings by including active occupants who interact with the SB through their smartphones. They will act as both sensors and actuators to complement control systems already installed in buildings (e.g., surveillance cameras to be used in the COVID-19 era to detect and count people occupying a room, as well as to measure if social distancing is maintained). The optimized real-time HVAC control strategy should be found through a multi-faceted optimization problem that considers the different and possibly contrasting desires of people, together with energy consumption reduction in public buildings. The present work tries to include the aforementioned "new applications" within classic BMS optimization problems, and tries to address the challenges of combining classic HVAC or lighting control problems with the new problems arising in a COVID-19 context. As usual, a new challenge (here, the COVID-19 pandemic) may also give rise to new ideas, and in our opinion the COVID-19 pandemic may be a "killer application" to eventually realize truly smart buildings, where users interact with the environmental variables. In this work, some experimental activities carried out in the classrooms of the University of Pisa will be used to support the proposed methodologies. We shall leverage on available pre-pandemic historical data to show the feasibility of our proposal.
Hereafter, the paper is organized as follows: after the introduction, Section 2 presents the proposed methodology. Section 3 shows an overview of sensors used for monitoring action and Section 4 presents the logic of the control system. Section 5 shows some experimental results obtained in pre-pandemic conditions in a building of the University of Pisa and Section 6 describes the implementation of the proposed approach to define feedback on the control system. Conclusions are drawn in Section 7.

ICT-Based Methodology for Balancing Energy Efficiency and Comfort
As mentioned in the introductory section, the problem of balancing the trade-off between minimum energy cost and maximum comfort has been widely explored in the literature. Different optimization methods have been proposed to tackle such a problem, but all of them heavily rely on real-time measured data, and in general on Information and Communication Technologies (ICTs) as the enabling technology to collect and analyze such data.
Data can be acquired through traditional sensors: Internet of Things (IoT) technologies are successfully utilized in real environments to make IoT-based smart buildings successful. In this work, however, we propose a different approach: further exploiting a direct interaction with the occupants by using the potential of their portable devices and communication systems.
Considering the abovementioned possibilities, this study proposes the use of special sensors and advanced ICTs for monitoring environmental conditions indoors, both with the purpose of controlling climatic conditions, somewhat achieving a desired comfort with reduced costs, but also with the further objective of preventing the diffusion of SARS-CoV-2 (and other future viruses with pandemic potential) to support the reopening of public and private buildings with a higher level of safety. To reduce the risk of infection by SARS-CoV-2 and other respiratory viruses, the main strategy is to control the probability of contacts. In fact, SARS-CoV-2 is transmitted among people through inhalation and exhalation. As the occupation density increases, the probability of virus transmission increases, so that the occupancy/density of the building becomes another reason to trigger air exchanges in addition to air quality control. On the other hand, the increased rate of air changes can be highly energy consuming, and the reduced possibility of using some typical measurements such as air recirculation introduces a further criticality because the power of the installed heat exchangers and thermal generators could be not high enough to match the demand of the building and guarantee an acceptable level of indoor thermal comfort.
Considering the above exposed objectives, we propose two main elements. The first is to integrate environmental sensors and tele/thermal cameras to evaluate environmental variables (e.g., temperature, humidity, CO 2 concentration), and, thanks to specific Artificial Intelligence (AI) algorithms, to check in real time the maintenance of safety measures, such as social distancing and the correct use of masks, and the possible presence of feverish people in closed spaces (e.g., schools and university classrooms, entrance queues to sanitary buildings, waiting rooms, public/private buildings in general).
The second relevant element proposed in the paper is the possibility of obtaining direct interaction with the occupants to check the main environmental variables and comfort conditions. The occupants' interaction can be achieved by using personal devices (e.g., smartphones and tablets) by means of specific human-computer interfaces designed for improved user experience.
The control system must acquire the inputs from the occupants, as well as acquire the data by the various physical sensors deployed in the building, to find the best trade-off between normative requirements, perceived comfort, energy use and safety.
The "sensorization" of critical environments and the use of AI algorithms for data analysis offer numerous advantages. Firstly, this does not require the presence of a person in charge of monitoring the accesses and measuring the facial temperature of all users, which is critical in buildings with multiple access points (in addition, facial temperature can evolve over the course of a day). Consequently, no personnel are required to check the correct use of safety devices or keep physical distancing among people. Secondly, room air exchanges can be adjusted according to actual needs (e.g., based on CO 2 concentration, temperature and humidity conditions). The monitoring of these variables will result in unsupervised automatic actions (e.g., automatic adaptation of air changes in the environment) and/or supervised ones (e.g., the reporting of non-virtuous behaviors or the presence of feverish individuals), and integration into existing organizational structures of new methodologies for passive and active COVID-19 monitoring.

Sensors for Monitoring and Available Data
Strategies for the sustainable design and management of shared buildings should also promote healthy and comfortable indoor environments. Energy saving potential and control of comfort conditions are surely aided by the measurement of specific variables by means of specific sensors. Occupancy sensors, for example, have a potential to significantly reduce energy use by switching off electric loads when an area is vacated or when its occupation is highly reduced.
Regarding the comfort parameters, it is important to control the values of temperature and relative humidity (RH) and limit the concentration of pollutants, such as CO 2 . Nowadays, after the COVID-19 pandemic experience, with the accurate control of the indoor environment it will be easier to prevent virus transmission. It is recognized that most of the COVID-19 infections happen in public spaces, so that an accurate check of the occupant distribution pattern can reduce the infection rate.
It is well known that a series of parameters have to be for the risk transmission in indoor spaces, and those for a given value of area, height and volume are surely connected with ventilation (mechanical or natural), air recirculation and air flows, humidity and layout and use of the spaces (classroom, corridors, bar, multi-functional spaces). Therefore, accurate control requires first of all the knowledge of indoor air quality parameters, such as temperature, relative humidity and carbon dioxide concentration, as well as an accurate estimation of indoor occupation.

Sensors for CO 2 Concentration, Temperature, and Humidity Detection
To accurately check air quality parameters, sensors for the simultaneous measurement of the different indoor variables can be used. A lot of sensors are available on the market that can be placed indoors. An interesting example could be Chauvin Arnoux, in particular, model C.A 1510. The C.A 1510 is an instrument for measuring physical quantities that provides measurement of: -Carbon dioxide (CO 2 ) concentration in air; -Internal temperature (T); -Relative humidity (RH).
The characteristics of the sensors are the following ones: -CO 2 concentration is measured with infrared technology. The measurement range is from 0 to 5000 ppm; the intrinsic uncertainty is of the order of ±3% (±50 ppm) at 25 • C and 1 bar of pressure. The instrument has a resolution of 1 ppm and it can operate at temperatures in the range between −10 and 45 • C; - The measurement of temperature (T) is obtained by means of a CMOS sensor that can provide a relatively accurate value, with an uncertainty of ±0.5 • C in the range between −10 and 60 • C; - The measurement of relative humidity (RH) is obtained by means of a capacitive sensor that permits the acquirement of values from 5% to 95% RH. The uncertainty is ±2% in the range from 10% to 90% RH and ± 3% RH outside this range. Moreover, the instrument has a resolution of 0.1% RH and a hysteresis of 1% RH. Figure 1 provides a snapshot of the instrument, in which the instantaneous values of CO 2 concentration (in ppm), temperature (in • C) and relative humidity (in %) are reported on the screen, and the typical results of an experimental analysis concerning CO 2 concentration and temperature evolution during an indoor measurement are also reported.

-
The measurement of temperature (T) is obtained by means of a CMOS sensor that can provide a relatively accurate value, with an uncertainty of ± 0.5 °C in the range between −10 and 60 °C; - The measurement of relative humidity (RH) is obtained by means of a capacitive sensor that permits the acquirement of values from 5% to 95% RH. The uncertainty is ± 2% in the range from 10% to 90% RH and ± 3% RH outside this range. Moreover, the instrument has a resolution of 0.1% RH and a hysteresis of 1% RH. Figure 1 provides a snapshot of the instrument, in which the instantaneous values of CO2 concentration (in ppm), temperature (in °C) and relative humidity (in %) are reported on the screen, and the typical results of an experimental analysis concerning CO2 concentration and temperature evolution during an indoor measurement are also reported.

Sensors for Object Detection and Control of the Presence
In recent times, the detection of objects in an image can be simply solved thanks to the improvements in computer vision and deep learning. Object detection systems are based on the concept of placing a bounding box around the objects and associating the correct object's category with each bounding box. Deep Learning (DL) is an effective method to perform object detection, and in fact it is increasingly applied to problems of social distancing [19]. DL, for instance, can be applied to detection through bounding box information with approximate models as in [20], or exploited with hybrid models of Computer Vision and Deep Neural Networks (DNNs) for an automated detection as in [21], or Convolutional Neural Network (CNN) as in [22]. In particular, the model proposed by a research group of the University of Pisa for smart city applications [22,23] consists of four stages. The first level is represented by the introduction of the images into the input layer, then the regional proposals are extracted, after that the features are computed by CNN, and finally these features are classified, as exposed in Figure 2. In particular, Region Based Convolutional Neural Network (R-CNN) uses selective search algorithms in order to define region proposals.

Sensors for Object Detection and Control of the Presence
In recent times, the detection of objects in an image can be simply solved thanks to the improvements in computer vision and deep learning. Object detection systems are based on the concept of placing a bounding box around the objects and associating the correct object's category with each bounding box. Deep Learning (DL) is an effective method to perform object detection, and in fact it is increasingly applied to problems of social distancing [19]. DL, for instance, can be applied to detection through bounding box information with approximate models as in [20], or exploited with hybrid models of Computer Vision and Deep Neural Networks (DNNs) for an automated detection as in [21], or Convolutional Neural Network (CNN) as in [22]. In particular, the model proposed by a research group of the University of Pisa for smart city applications [22,23] consists of four stages. The first level is represented by the introduction of the images into the input layer, then the regional proposals are extracted, after that the features are computed by CNN, and finally these features are classified, as exposed in Figure 2. In particular, Region Based Convolutional Neural Network (R-CNN) uses selective search algorithms in order to define region proposals. The proposed detection approach can also be applied to images acquired by thermal cameras to establish a complete AI system for people tracking, social distancing control and facial temperature monitoring without direct interaction with the occupants. By means of the elaboration of the images acquired, measured distance (D) between the center of each bounding box for a detected person can be defined according to Figure 3a. This figure also reports an example of a social distancing check (the green box corresponds to a safe situation, while the red box indicates an unsafe situation). The proposed detection approach can also be applied to images acquired by thermal cameras to establish a complete AI system for people tracking, social distancing control and facial temperature monitoring without direct interaction with the occupants. By means of the elaboration of the images acquired, measured distance (D) between the center of each bounding box for a detected person can be defined according to The proposed detection approach can also be applied to images acquired by ther cameras to establish a complete AI system for people tracking, social distancing con and facial temperature monitoring without direct interaction with the occupants means of the elaboration of the images acquired, measured distance (D) between the ter of each bounding box for a detected person can be defined according to Figure 3a. figure also reports an example of a social distancing check (the green box correspond a safe situation, while the red box indicates an unsafe situation).   An application in indoor and outdoor scenarios for COVID-19 people detection and social distance checking has been proposed in [22]. It is to be noted that the proposed algorithm has been implemented in real-time on a low-cost embedded platform, such as Jetson Nano. Moreover, as shown in Figure 3b, the system can be scaled from a single node to a solution with multiple distributed nodes, thus scaling the application area from a single building to a district and then to a smart city.

A User-Centric Control System
As we have already discussed in the introduction, the main objective of the study referred in the manuscript is to propose systems where users can influence the functioning of climate automatic control systems, with the further objective of solving an optimization problem with contrasting objectives, aiming at obtaining a convenient trade-off between comfort and energy consumption. The main functions of a building management control system are sensing the environmental factors by measurements and optimizing control strategies based on the current and predictive states of the building and occupancy [24]. Similar ideas have already been widely explored and applied in other contexts, see, for instance, building automation applications in hotels or cruise ships, where guests may be permitted to both interact with the climate/lighting systems in their own rooms and also in shared spaces (e.g., receptions or lounge areas) or in public buildings with reference to lighting control systems [25]. Besides, similar opportunities are not usually available in residential/commercial buildings, such as shopping centers, universities or restaurants, which are the scope of this paper.
Following typical trends in similar applications, we assume that interactions between a building management control system and its occupants should be based on suitably developed smartphone/tablet apps. By subscribing to such apps, a guest accepts to share his/her personal information (e.g., locally measured environmental data, occupancy data, data regarding the usage of the building) to gain access to the building management control system. From this perspective, building guests/customers serve as mobile sensors which enrich the already existing sensor network. Customers may share information directly measured by their smartphones (e.g., temperature, humidity, distance from other customers, density of occupancy, mobility patterns inside the facility) and also communicate textual information (e.g., a customer may inform the system that he/she is feeling cold). The data acquired by the sensors (of temperature, concentration of specific pollutants, humidity, and illuminance) are thus integrated with information collected from app subscribers. Such data may be used for safety/security purposes (e.g., occupancy data), but also to solve the complex problems of balancing energy consumption and comfort [26].
Accordingly, the control platform aggregates all the data and tries to solve a multiobjective optimization problem for finding the most convenient trade-off between energy efficiency and comfort. Then, it will send the appropriate control signals to the available actuators (i.e., the HVAC system). Additionally, interaction with acoustic, environmental, and lighting systems, with the purpose of obtaining occupant-centered acoustic and lighting control, should be considered as well. Overall, the system behaves as a cyber-physical system where individuals interact with the building management system.
In specific situations, in addition to behaving as mobile sensors, occupants may also be allowed to perform specific actuating actions. This may be orchestrated by assigning appropriate priorities to single occupants (e.g., teachers, technic staff, and students in a university framework) and by allowing some categories of occupants to take specific control actions (e.g., changing the temperature set-point, changing the frequency of air exchangers, or interacting with the blind or lighting system). Within the platform, all non-main commercial building electric loads, Miscellaneous Electric Loads (MELs), which are not controlled by the energy management system, will also take an important role, as they contribute a significant portion of the energy consumption.
To implement and fully exploit the aforementioned capabilities and obtain the expected results, the ICT platform should have the following features:

•
Most currently existing building control and management systems rely on predictive models and the simulation of occupancies. However, the accuracy of predictions of actual occupancies is obviously questionable and subject to unexpected anomalous deviations. Conversely, the proposed ICT platform will not require buildings and occupancy models, but will rely on data acquired in real-time by appropriately installed static sensors, and integrated with dynamic information. By embedding learning and self-adapting capabilities, the platform will be permitted to define a "just-enough-accurate" model for the building/occupants' behaviors, which can be used for optimal decisions. • In order to prevent the problems connected to the occupants that can override the decisions of the ICT platform and/or not adopt its recommendations, the control system will be able to define optimal strategies for the operating systems, like HVAC. To this aim, an iterative procedure based on the learning and self-adapting mechanisms embedded in the control system is required. Such a procedure will provide the control strategy, will evaluate how much the occupants' actions are consistent with these decisions, and will calibrate the decision-making mechanism to "close the gap" between decisions and occupants' actions. • Energy awareness can be further boosted by the direct interaction between occupants and the platform through a kind of gamification technique in which wise behaviors and the resulting greater energy efficiency will be consequent to the participation in this "social game".

•
The interaction between the ICT platform and occupants will be designed with the objective of maximizing the energy-saving with the constraints of maintaining a comfortable working environment.

Building Management Control as an Optimization Problem
The considered building optimization strategy assumes that prior knowledge of the characteristics of the building is given, and occupancy data and external climatic conditions are either measured or estimated. In particular, data acquired from the sensors and from the occupants allow the Building Management System (BMS) to evaluate the energy consumption due to both the lighting system and the HVAC operation (for temperature and ventilation control), the indoor comfort conditions, and to directly interact with the various active systems.
The proposed BMS and its feedback control scheme may be summarized in Figure 4. The environmental data of the building are collected by sensors, enriched with the sensors of occupants who have installed the building application (e.g., sensors available in personal smartphones).  The flow of critical data, represented in red in Figure 4, is directly communicated to the operator, who is in charge of taking actions to respect the safety protocol. This includes the counting of the occupants of a building/room, who should not exceed a safety threshold (e.g., depending on the size of the room), the maintenance of safe distances (e.g., below 1 m) among occupants, and the temperature of single individuals as measured by the thermal cameras (e.g., below 37.5 °C).
If any of the aforementioned rules is infringed, then ad hoc measures should be taken. Conversely, other non-critical environmental quantities are directly elaborated by the control system, possibly changing the set-points of the HVAC system. While the full list of controlled environmental quantities depends on the specific interests, or on the available sensors, they include quantities such as temperature, air quality (e.g., level of CO2), moisture, lighting, and level of noise. Similarly, while only the HVAC system is reported in Figure 4, in general, other available actuators should include the lighting system as well.
The lighting system could allow for simple ON/OFF choices, or could dim the quantity of provided light, or even provide more sophisticated levels of control, e.g., if the light can change the color, change the duration of colors, or associate the light control with music.
The control system may be implemented as an intelligent system that computes the optimal control actions as the outcomes of an optimization problem, which can be formulated as a kind of bounded minimization problem: The flow of critical data, represented in red in Figure 4, is directly communicated to the operator, who is in charge of taking actions to respect the safety protocol. This includes the counting of the occupants of a building/room, who should not exceed a safety threshold (e.g., depending on the size of the room), the maintenance of safe distances (e.g., below 1 m) among occupants, and the temperature of single individuals as measured by the thermal cameras (e.g., below 37.5 • C).
If any of the aforementioned rules is infringed, then ad hoc measures should be taken. Conversely, other non-critical environmental quantities are directly elaborated by the control system, possibly changing the set-points of the HVAC system. While the full list of controlled environmental quantities depends on the specific interests, or on the available sensors, they include quantities such as temperature, air quality (e.g., level of CO 2 ), moisture, lighting, and level of noise. Similarly, while only the HVAC system is reported in Figure 4, in general, other available actuators should include the lighting system as well. The lighting system could allow for simple ON/OFF choices, or could dim the quantity of provided light, or even provide more sophisticated levels of control, e.g., if Energies 2021, 14, 2124 9 of 17 the light can change the color, change the duration of colors, or associate the light control with music.
The control system may be implemented as an intelligent system that computes the optimal control actions as the outcomes of an optimization problem, which can be formulated as a kind of bounded minimization problem: where x is a vector that contains all the monitored environmental quantities (e.g., most notably, temperature, concentration of CO 2 , lighting, moisture). In Equation (1), x and x denote the vectors of lower and upper bounds, respectively, of the environmental quantities (e.g., in the case of temperature control, one may constrain the temperature to lie within 17 • C and 25 • C; or in the case of CO 2 concentration, a classic upper bound of 1500 ppm can be defined, as it is discussed in Section 6 of the paper). The function f (x) represents some cost function of interest that one aims at minimizing to optimize the utility of occupants [27]. In our work, we assume that this cost function consists of two terms, as follows: where f 1 (x) represents the cost associated with discomfort, and f 2 (x) is the energy cost (which we shall compute in terms of energy consumption but could be alternatively translated into the associated cost of energy). In Equation (2), w discom f ort and w energy are two coefficients that can be used to either prioritize comfort or price, or, in general, a convenient trade-off between the two components that are combined in the overall cost function. In addition, such weights should also be used to normalize the different quantities that are combined in the cost function, so that each component has, on average, the same impact on the overall objective function.
After the normalization step, it is possible to think of the two objective functions as expressed in a dimensionless form. We now discuss how it is possible to normalize the two functions. Concerning the component of the objective function related to energy, the total value of used energy, expressed in kWh, can be used as a normalization factor, and the objective function can be defined in a dimensionless way considering the distance from such a reference value.
Energy consumption can be expressed as the sum of the energy consumption determined by the individual components of the building management system in a given period, as: where the four terms appearing in Equation (3) denote the energy required to accomplish the regulation of the indoor temperature, relative humidity, indoor air quality, and lighting. Energy consumption and its components are functions of the vector of variables x, e.g., E(x). However, for ease of notation, they are expressed simply as single variables, e.g., E.
If we let E Re f denote a reference value for energy consumption without any smart control action activated, then the consumed energy can be expressed in a dimensionless form as: Conversely, the definition of a specific objective function for comfort is not trivial. In fact, the concept of comfort cannot be easily translated into a quantitative indicator. Usually, thermal comfort is indicated through a temperature index, so that an optimal value can be defined and the operation of the HVAC system is used for maintaining comfortable indoor temperature and humidity values. Visual comfort is usually evaluated with the brilliance level. Air quality can be indicated by a CO 2 concentration index; both natural and mechanical ventilation systems are employed for maintaining an acceptable CO 2 concentration level in buildings.
In our work, we can adopt some dimensionless parameters similar to the Predicted Mean Vote (PMV) to evaluate the objective function for comfort. We propose some modified dimensionless indicators that can be defined according to Fanger's model, and may be implemented in a feedback loop, as in the spirit of Figure 4, considering thermal comfort level, humidity, IAQ level, and luminance [28,29].
According to the original idea and consistently with the minimization problem expressed in Equation (1), the comfort level is expressed in terms of a discomfort parameter, D, that one wishes to minimize, which can be defined in dimensionless terms as: Considering the definition of the discomfort function D, I is the value of the typical comfort indicator (of temperature, relative humidity, CO 2 concentration and luminance), while I set is the desired set-point of each comfort parameter. In this way, the value of 0 corresponds to the highest comfort level, while the maximum is not upper bounded. Similarly to energy consumption, discomfort and comfort indicators are also functions of the vector of variables x; however, for ease of notation, they are expressed simply as single variables.
The optimization problem defined by Equation (1) can be solved in a convenient way using classic convex optimization tools, if the cost function f (x) is computed by adding single functions that are convex with respect to the single environmental quantities and have their minimum in the preferred set-point (e.g., 21 • C in the case of the indoor temperature). Accordingly, if one prioritizes comfort aspects (by setting w energy equal to zero), then the Control System works to guarantee some specific parameters, such as, for example, a constant temperature level of 21 • C (during the winter season), using simple Proportional Integral (PI) control rules. Conversely, if one prioritizes price aspects, then the temperature will be around the minimum allowed value in winter time, and around the maximum allowed value in summer time, to minimize the cost of the HVAC systems.

Preliminary Analysis and Data Acquired in a Pre-Pandemic Scenario: Identification of Meaningful Variables
An educational building has been chosen as the preliminary target setting for this study, for establishing a connection between occupancy and some specific physical parameters such as temperature, relative humidity, and CO 2 concentration. Universities are part of the tertiary sector and are an ideal example of shared buildings, as they include areas that are only shared among few authorized individuals (e.g., departments and teachers' offices) and other parts shared with hundreds/thousands of students (e.g., teaching rooms and laboratories). In addition, universities represent an ideal case study as they are also characterized by relatively high values of energy consumption, which could be easily reduced by applying basic building automation practices. They obviously lend themselves to retrofitting both in terms of structure and behavior [30]. Finally, since universities are educational institutions, they also have the potential to educate students to adopt virtuous behaviors and have an influential impact on society, and should be obliged to act in a sustainable manner [31].
An extensive pilot study aimed at obtaining a preliminary calibration of the method has been carried out in several engineering classrooms of the University of Pisa, where the devices described in Section 3.1 have been used to measure the correlation of the air quality parameters in terms of temperature, relative humidity and CO 2 concentration, and how they vary with different values of occupancy. In principle, the connection between such physical parameters is well known in the literature, but in the case of temperature and RH, it is difficult to establish a quantitative correlation. This appears to be possible considering Energies 2021, 14, 2124 11 of 17 CO 2 concentration, as shown in some original studies available in the literature, such as [32][33][34].
In particular, the building involved in the experimental campaign had been originally designed for commercial activities and it has been refurbished for educational purposes during 2006. The building contains nine classrooms of different sizes, and all of them but one are characterized by high ceilings (more than 5 m high). Additionally, most of the rooms are equipped with blinds to shade the lights during the day, which are particularly convenient when teachers project slides during their lessons.
All classrooms are characterized by a large penetration of light, but thanks to the high ceilings, they are also characterized by a large volume, and by a large volume-to-surface ratio (sensibly larger than 5). In this structure, six different classrooms, characterized by different sizes, volumes, and capacity, have been selected for the monitoring of the indoor air quality, and the main characteristics are reported in Table 1. Considering the typical form of the various classrooms, we considered the average value of the measurements of two or three different sensors, disposed according to the schemes provided in Figure 5a, in the case of two sensors, and Figure 5b, in the case of three sensors placed inside the classroom. Another sensor is placed outside the classroom to collect the reference level. An example is provided in Figure 5b (see the yellow point).  The analysis of the data acquired during the monitoring campaign in the differ classrooms shows that CO2 concentration quickly increases in time, with a rate that pends on the number of occupants, as shown, for instance, in Figure 5 for one of the m itored classrooms.
The data measured during the experimental analysis exhibit a clear correlation w the number of individuals inside the room and with other general indicators of the siz the room, such as the average volume available for each occupant. Measurements h The analysis of the data acquired during the monitoring campaign in the different classrooms shows that CO 2 concentration quickly increases in time, with a rate that depends on the number of occupants, as shown, for instance, in Figure 5 for one of the monitored classrooms. The data measured during the experimental analysis exhibit a clear correlation with the number of individuals inside the room and with other general indicators of the size of the room, such as the average volume available for each occupant. Measurements have been obtained during actual real operating conditions (during lessons or during periods of examination). To establish a direct correlation with the occupancy, ventilation was not disabled until a concentration rate of 1500 ppm had been observed. At this point, ventilation was activated again, as a concentration above 1500 ppm should be avoided [35,36] to maintain healthy indoor conditions, as suggested by the main Technical Standards for the analysis of indoor spaces.
As previously stated, during the first phase of the experimental analysis, when classes start the specific didactic activity (lesson or examination) and the mechanical ventilation is disabled, then it is possible to observe a quite linear correlation between the increase in CO 2 concentration rate and the specific volume per occupant.
A first-order fitting of the data in Table 2 leads to equations such as: where V n occ is the net volume per number of occupants, C {CO 2 } is the concentration of CO 2 , and . r is a proportional factor that can be interpreted as a kind of CO 2 production rate per person, typical of the occupants and of the specific activity carried out inside the room. r, if the volume of the room is known beforehand, then, by measuring variations in CO 2 concentration over a given time, Equation (7) can be used to estimate the number of occupants in the classroom. Combining this piece of information with the one that is acquired through thermal cameras, safety protocols can be activated if the number of occupants exceeds the maximum number that is allowed. Besides, the level of CO 2 concentration can also be used to activate the ventilation system on demand, e.g., when a well-defined threshold value (for example, of 1500 ppm) is achieved, avoiding using ventilation when it is not required, to reduce energy consumption or, in general, activating the air ventilation in correlation with the estimated occupation of the classroom.

Critical Discussion and Future Research
The philosophy of the Control System exposed in Section 5 and summarized in Figure 4 may also be made more sophisticated and better performing if AI algorithms are used to learn the nominal behaviors of occupants. This implies that one could learn the typical occupancy patterns of the building, typical daily (or seasonal) variations of temperature and of other periodic environmental variables, so that the Control System may also predict future values of the environmental quantities and take pro-active actions in advance (e.g., switch on heating ahead of the arrival of students in the morning during winter days).
Although we have not explored this possibility yet, a further innovative step is to directly involve occupants/students, and in general of all the individuals who make use of the shared spaces, such as in shopping centers, public offices of commercial activities in general, to directly interact with the actuators that control the operation of HVAC systems. The risk of this implementation is that individuals with opposite desires give contrasting commands to the HVAC system (e.g., two different students in the same room may either want to switch on or off air conditioning). Accordingly, this possibility may be given only to specific authorized building users (e.g., teachers in our university case study) to prevent clashing situations from occurring.
In addition to the classic air quality control discussed so far, another important innovative aspect of our work is the utilization of AI algorithms and cameras operating in visible and infrared for greater accuracy in measurement (facial temperature), which will always be compensated by algorithms of dynamic calibration that consider environmental conditions (ambient temperature and humidity). The thermal imaging camera will also be combined with a camera in the visible range that can provide information about people's social behaviors (social distancing, correct use of masks, etc.) by applying artificial intelligence algorithms. More in detail, AI algorithms will also be used for "feature extraction" purposes, and a subsequent classification will be performed based on Deep Neural Networks (DNNs) to carry out the people detection and people counting phases (which is expected to be more accurate than the counting based on the ramp of CO 2 concentration). In particular, once individuals have been identified, they will be included in "bounding boxes", as described in Section 3.2, to detect the relative distance (determining if social distancing is respected) and to detect the face in order to determine whether the mouth and nose are appropriately covered with the mask, and also to determine the facial temperature in each bounding box. If safety issues are observed, this information will follow the red path shown in Figure 6, and an operator will be informed. It is important to remark that while the main focus of our proposal is related to buildings, and indoor environments in general, the same philosophy we are applying here may be reused with little modifications in residential areas, and extended to include other sensors that we are not discussing here (e.g., measurement of biometric parameters). More in general, what we are proposing is to consider human behaviors through the multi and interdisciplinary objective of building science, behavioral science, social science, data analysis, user experience based design, automation and control design. As human behavior is complex, it is challenging in general to address all the possible ways in which hu- It is important to remark that while the main focus of our proposal is related to buildings, and indoor environments in general, the same philosophy we are applying here may be reused with little modifications in residential areas, and extended to include other sensors that we are not discussing here (e.g., measurement of biometric parameters).
More in general, what we are proposing is to consider human behaviors through the multi and interdisciplinary objective of building science, behavioral science, social science, data analysis, user experience based design, automation and control design. As human behavior is complex, it is challenging in general to address all the possible ways in which humans can actively interact with "buildings", or with the energy aspects of buildings in particular. Human factors can also be considered as an interesting driving source of innovation for energy efficiency in the built environment that contributes to achieving 2020 net-zero-energy buildings and 2050 post carbon goals set by the Paris Agreement [37].
Finally, the idea of active buildings with automated management of the indoor environment proposed in this paper can also be easily generalized to outdoor environments to contribute to the realization of smart cities. Again, in a smart city context, we envisage the utilization of individuals as mobile sensors that have the ability to interact with the available actuators (for instance, outdoor lamps may dim the provided lighting based on the presence of individuals, or cameras may be used to monitor the correct and safe utilization of public areas). More in general, such active monitoring paradigms should be used to support energy and urban planners in the creation of human-centered energy policies, programs, codes, and standards.

Conclusions
New approaches for designing and controlling the operation of HVAC systems are necessary and urgent to make indoor spaces safe and comfortable without compromising energy efficiency. The installation of instruments for indoor air quality monitoring is paramount, together with the implementation of building management and control systems. This paper presents a methodology for the optimal control of safety, comfort and energy consumption parameters in smart buildings based on a more direct interaction with the occupants too. Knowledge of the occupancy profile, obtained directly by means of cameras or indirectly by means of measurements of air quality parameters, represents a step forward compared to current design and operation procedures suggested by technical standards. Interaction with the occupants through active participation is considered to be a relevant element of the methodology.
The argument specifically developed is that the classic topic of the optimization of a Building Management System (BMS) is becoming even more relevant in a COVID-19 context. Indeed, the functionalities of the same BMS should be further extended to include people counting, the monitoring and display of air quality and the need for air exchange (which plays a role in the spreading of the virus), and also for checking the temperature of individuals entering the buildings and enforcing that due distances are maintained. The optimization can be obtained by means of a cost function that combines different aspects, both in terms of energy consumption and of energy comfort, related to the operation of the HVAC systems, lighting systems, and the miscellaneous energy loads. The optimization method relies upon the definition of a certain number of constraints, such as, for example, the maximum occupancy of the building due to the COVID-19 pandemic and new indicators for comfort, considering the increased needs of air quality for human health. The application of the methodology to a test case represented by an educational building of the University of Pisa is proposed in this paper, evidencing the possible role of conventional sensors (such as temperature, humidity and CO 2 concentration) together with smart sensors.
The case proposed is just an example of a Shared Smart Building, and we tried to extract the main common features so that the same paradigm can also be applied to other examples of interest (this includes shopping centers, shared working facilities, sport and leisure centers, etc.). In most of these cases, the current practice is that people are in charge of measuring the temperature of customers or individuals at the entrance, people counting measures are not always strictly enforced, and proper distancing is not always guaranteed. Our vision is to make this automatic and embedded within the BMS.
Moreover, the method developed could also be extrapolated to external environments to contribute to the realization of smart cities and, in general, to support energy and urban planners in the creation of human-centered energy policies, programs, codes, and standards.