## 2 Distributed Control and IoT Architectures in Smart Environments
### Distributed Management of Energy Resources
Power profilesare determined for all of the supervised entities by taking into account the users' requests, weather forecasts, strategic schedules and constraints (set by the system administrator), historical data (used by machine learning algorithms), and current measurements from distributed sensors (i.e., current weather data, state of charge of storage units, etc.). For each physical entity, one or more profiles can be generated depending on the possible different configurations of the resource. HVAC systems, for instance, may have different feasible demand profiles, depending on the considered comfort levels and on time-shifting or peak-clipping options (implemented by means of thermal storage systems). In this scenario, power profiles are usually determined by the supervisory EMS, which is also responsible for determining the most suitable solution for each physical entity, and by then providing the related job schedules to the supervised resources. Typical job schedules are represented by temperature set-point profiles to HVAC systems, power limitation profiles to renewable generators, or chargedischarge schedules to electrical storage systems. At a higher aggregation level, sensors, generators, and electrical equipment are not directly supervised by the EMS, but by local energy controllers (i.e., according to the power matcher concept [9]). In this case, power profiles are determined for each resource by local intelligent devices, and then aggregated as a class of net power profiles. Data from supervised sensors are used by local intelligence to evaluate the energy generation and demand of physical entities, but not forwarded to the upper supervisory layer (i.e., the EMS). The set of computed net power profiles are provided to the supervisory EMS, which is in charge for the selection of the most suitable net power schedule. Once selected, the net power profile selected by the EMS is forwarded to the local energy controller, which is in charge for ensuring that the given profile is accomplished, by properly controlling all the supervised entities. At the highest aggregation level, which typically corresponds to the smart building scenario, complex sets of sensors, equipment, and energy resources (which may be independent or aggregated by local energy controllers) are supervised by a BEMS. In this case each BEMS (i.e., each smart building) is responsible for computing the forecast or feasible power profiles for each supervised entity, and for collecting the class of net power profiles computed by supervised energy controllers. The set of all of the computed power profiles are then aggregated as a new set of net power profiles, and forwarded to  
Figure 1: Distributed monitoring and control architecture in a smart campus. the supervisory EMS, by following the same monitoring and control process described for the local energy controller scenario. The main advantages of distributed control architectures can be summarized as follows:  
* high scalability and flexibility: the use of decentralized intelligence doesn't require the complete implementation of the monitoring and control functions of all of the supervised nodes in the supervisory layer. This allows the extension and modification of the supervised physical system (e.g., by adding new resources or modifying the existing configuration) without sensibly affecting the structure of the supervisory EMS;
* reduced information throughput between the supervisory level and the system nodes: the implementation of distributed control functions at local nodes or aggregators allows the reduction of the computational complexity of the supervisory EMS.