Model Predictive Control for Microgrid Functionalities: Review and Future Challenges

Renewable generation and energy storage systems are technologies which evoke the future energy paradigm. While these technologies have reached their technological maturity, the way they are integrated and operated in the future smart grids still presents several challenges. Microgrids appear as a key technology to pave the path towards the integration and optimized operation in smart grids. However, the optimization of microgrids considered as a set of subsystems introduces a high degree of complexity in the associated control problem. Model Predictive Control (MPC) is a control methodology which has been satisfactorily applied to solve complex control problems in the industry and also currently it is widely researched and adopted in the research community. This paper reviews the application of MPC to microgrids from the point of view of their main functionalities, describing the design methodology and the main current advances. Finally, challenges and future perspectives of MPC and its applications in microgrids are described and summarized.


Introduction
In most developed countries, the policy framework for climate and energy follows the ambitious commitment of reducing greenhouse gas emissions and reaching a neutralcarbon-based energy system in the next few decades. From the power grid's perspective, the delivery of such ambition requires the development of cost-efficient approaches that respond to the challenges of affordability, competitiveness, security of supply, and sustainability of electric power systems fully-based on renewable energy systems.
The current distribution and transmission grids will have to evolve to be able to deliver a low-carbon and competitive energy supply while the power quality and reliability levels will be even more restrictive than nowadays. This will also require changes in the current operation of electrical markets, as to handle the uncertainties of renewable energy system (RES), they should become more flexible. The planning and operation of power systems will have to be adapted to the non-synchronous nature environment of future power systems where Renewable Energy Systems (RES) will be dominant, thus making it more prone to frequency instability in a context where most of the ancillary services to provide grid stability will mainly need to be provided by the RES of consumer-based resources, rather than based on the inertia of conventional generators.
Under this challenging scenario, microgrid technology emerges as a key solution to pave the way for these future neutral-carbon smart grids. As defined by CIGRE [1], microgrids are electricity distribution systems containing loads and distributed energy resources, (such as distributed generators, storage devices, or controllable loads) that can be operated in a controlled, coordinated way either while connected to the main power grid or when they work as islanded systems. The transformation of the smart grid towards a more structured system based on microgrids with storage systems working in a cooperative and self-organized way appears as a key to transform our current energy system into a more intelligent, robust, and greener one. A microgrid-based structure of the smart grid would not only allow better integration of the emerging distributed components in the wholesale market but could also be utilized as a part of distribution and transmission system management through evolving flexibility (ancillary service) market and novel grid management concepts. The flexibility provided by energy storage systems in microgrids, as well as the ability of microgrids to operate on grid-connected/islanded mode, appear as key solutions to the challenges posed by the future transmission and distribution grids. The introduction of microgrids could improve reliability, reduce emissions, and expand energy options in the future power system. They may also add redundancy and increase grid security. Several microgrid facilities can also recover and utilize heat from their Distributed Generation (DG) systems, a practice known as combined heat and power generation. Cooling generation can be also included as a flexibility tool or power-to-X. The interconnection of these microgrids into networks of microgrids provides another degree of flexibility. Microgrids can also increase the resilience, security, and smartness of the energy system in an endeavor to progress towards an energy system which is capable of hosting a large share of variable renewables. An overview of the different functionalities of microgrids in a structured smart grid and their interaction with the different players of the electric market is shown in Figure 1. While most of the technology related to microgrid components such as RES and ESS have reached their technological maturity, there still exist challenges regarding their combined optimization in a microgrid as set of subsystem subjected to uncertainties such as renewable generation, load consumption, and energy prices. Besides the aforementioned problems with RES and loads, ESS also have to be optimally controlled by the microgrid according to their operation costs or physical constraints. The complexity of the algorithms is even increased when several microgrids have to be optimized at the same time. Because of the technical and economic benefits that microgrids can bring to the future energy systems, several methodologies have been developed to solve their associated problems and numerous review studies have been developed related to microgrid management from a global perspective such as [2][3][4] to particular issues such as power quality in microgrids [5,6], stability, and control aspects of microgrids [7], energy management system (EMS) [8], resilience [9] or buildings microgrid [10].
As can be seen in the aforementioned studies, Model Predictive Controller (MPC) appears as a powerful tool to deal with all the control aspects related to microgrids in all their control layers. The potentiality of MPC-based controllers for microgrids is an object of study in several recent studies [11][12][13][14]. The term MPC [12,15] does not refer to a specific control strategy but rather encompasses an ample range of control methods that makes explicit use of a model of the process to predict the behavior of the system and obtain the optimal control signals by minimizing an objective function. The proposed methodology allows the selection of the best amongst all feasible input sequences over a future horizon according to established criteria which can be weighted. At each sample instant, the first input of this sequence is applied to the control system and the procedure is repeated in a receding horizon fashion at every sampling time. MPC methodology can easily handle the different constraints of the devices which integrate the microgrid, enabling the controller to optimize each of the microgrid components closely to their ultimate profitable margins but integrating aspects as degradation, operation cost, power, and energy capacity limits. The MPC methodology also allows the design of hierarchical multi-layer systems and control systems made by a number of control algorithms working on different time scales. Its formulation as hybrid MPC allows the formulation of complex cost functions for the microgrid optimization problem integrating logic, dynamic, and mixed-products-based variables within the Mixed Logic Dynamic (MLD) framework. Its stochastic formulation allows for facing the uncertainties in the forecasting of renewable generation or load consumption to consider several possible scenarios with an assigned probability which can be different to the one that is finally executed. Its distributed formulation allows the optimization of several microgrids working in the same network respecting the individual behavior and optimization for each microgrid controller. As a recent example, MPC has been satisfactorily applied to power electronic devices with its Finite Control State (FCS) and continuous control state formulation (CCS) [12].
Despite the many reviews of microgrid control issues and MPC applications, no summary of MPC controllers considering final-use applications of microgrids has yet been published. The main aim of this review is to introduce MPC from the perspective of microgrid functionalities. In this review, the development of MPC and various improved MPC schemes for the main microgrid functionalities are introduced and analyzed, highlighting their main contributions. The study concludes with a discussion of future challenges regarding the development of microgrid functionalities using Model Predictive Control. The inserted references have been selected using as keywords the titles of the sections, as well as the keywords given in the review article. The database used corresponds to google scholar and scopus. For the selection of the references reviewed in this work, two criteria have been used: (i) Relevance: According to the number of citations of each reference, (ii) Novelty considering those works related to this review published in the last two years.

A Review of MPC-Based Control Methods for Microgrid Applications
The microgrid control system must address several aspects with different timescales. The optimization of the system taking into account the day-ahead electrical markets requires sample periods of 1 h; real-time control of power quality and reliability (PQR) issues-fast electrical control of the phase, frequency and voltage of individual resourcesmust be done on time scales lower than one second or less; unit commitment, economic dispatch, demand-side optimization, and energy exchanges with the utility grid are performed on time scales of minutes or hours. Thus, an extended approach is necessary to develop a hierarchical control structure that handles these different time scales. These levels are shown in Figure 2 and are explained in depth in [16]. The primary level operates on a fast time scale and maintains the voltage and frequency stability during changes on the generation or demand, or after switching to the islanded mode. This control is implemented locally in the DERs. The secondary level is responsible for ensuring that the voltage and frequency deviations are adjusted to zero after a load or generation change is produced within the microgrid. This level is responsible for eliminating any steady-state error introduced by the primary control and is also used for synchronization with the grid during the transition from the islanded mode to grid connection. The tertiary control is used to optimize the power flow between the components of the microgrid and the main grid (or other microgrids) on large time scales (planning and schedule). A summary of the main goals of each control level of the microgrid depending on its working mode can be found in Figure 3. In the next subsections, we describe in detail how the MPC was applied to solve specific problems within the microgrid architecture.

Electrical Markets, Flexibility, and Ancillary Services
The intense development of both the Variable Renewable Energy (VRE) and the Information and Communication Technology (ICT) sectors enable new paradigms of operation for individual prosumers, for clusters of prosumers associated within sustainable nZEB buildings and/or structured in the form of microgrids. In fact, the greatest challenges faced by the energy system planners of near 100% renewable power systems conceived within the European National Plans for Energy and Climate [17] are oriented to identify new sources of system inertia (Power system Inertia is the capability of an alternate power system to store kinetic energy in rotating masses-usually from the electric generators/machines directly connected to the grid-that acts to overcome imbalance between power supply and demand, thus being the most important mechanism in the fast frequency regulation of the power system.) [18,19] and novel sources of flexibility [20,21].
Flexibility is a concept that is easy to understand but difficult to explain, as it is a rather intuitive property of power systems. In a broad sense, the flexibility of a power system describes its ability to adapt the electricity generation and consumption patterns to maintain balance between energy supply and demand and thus to ensure robust and stable operation within different time scales, in an economical and sustainable manner. As such, when VRE (Variable Renewable Energy) sources, like wind and PV systems, started to develop and increase their shares in the overall energy mix share, "flexible power systems" were considered to be the ones with a relevant share of fast-responsive power plants, e.g., hydro or thermal open-cycle units, while a large share of nuclear and/or slow-response coal plants would classify them as non-flexible.
The quest for novel sources of flexibility has been one of the most relevant areas of research in the recent years [20][21][22]. Microgrids, prosumers, and the so-called DSM-demand side management/DR-demand response capacity have been consistently considered to be (one of) the most valuable new sources of adjustment between production and consumption, especially as the share of dispatchable (regulated) power plants, capable of offering power/energy reserves diminishes. Due to the small dimension (both of power capacity and energy volumes), a single prosumer or microgrid is of little value in assisting a transmission system operator (TSO) in maintaining the stability of the system. This is the main reason why different structures of operation, aggregation, and negotiation of electricity are requested together with the definition of new energy/electricity players and actors for the energy transition decade just started. Recent research [23] addressed the organization of prosumers in the form of resource aggregators (including their identification, classification and connection with other power system players) and characterized in detail the role of resource aggregators and the organization of new business models for demand response in electricity markets. With a different, but extremely valuable and innovative approach, Pasetti et al. [24] addressed the role of Virtual Power Plants and Demand-Side Management in Urban Energy Systems, with a focus on a VPP (virtual power plant) architecture with the capability of supervising the prosumer participation in DSM programs. Unlike classical VPP architectures that usually build on dispersed VREs, these authors focused on a VPP model constrained by the physical domain of single users, i.e., to single points of common coupling (Pcc) of the distribution network, i.e., under a microgrid structure. The VPP architecture proposed by Pasetti et al. [24] allows the integrated and coordinated implementation of several control and management strategies applicable to microgrids and clusters of consumers aggregates , e.g., energy management, demand response, and ancillary services and is a promising concept for years to come.
Several other authors have addressed this subject under different approaches (and angles of application) in recent years. One valuable operation of aggregators of consumers or microgrids is to offer/trade ancillary services to the TSO. Majzoobi and Khodaei [25] developed a model for optimal scheduling to minimize microgrid cost (and maximize value) by adapting consumption profile to the local resources and providing ancillary services. The model successfully addresses day-ahead schedules with sub-hourly timeintervals. One application considered to have a higher potential in the near future is the new, blockchain-based, organization of consumer energy transaction management for (sharing and) trading within a smart active operation of distribution networks [26].  How local energy markets will be structured and organized in order to maximize the benefits offered by local generation as well as the smoothing effects of aggregation and the valuable effects of DSM is a current area of research (e.g., project TradeRES, [28]), as well as the development of European regulations and governance decisions that will shape our behavior as consumers in the next few decades.

Resilience, Risk Management, and Fault Tolerant Control
Resilience, risk management, and Fault-Tolerant Control (FTC) have become relevant issues of power systems in recent years. One of the reasons is the effects that natural disasters can cause to electrical grids. In this challenging framework, microgrids can play a very important role to improve the resilience of power systems based on renewable generation. Reliability of power supply has to be considered as a fundamental aspect in environments with critical loads (i.e., hospitals, military facilities, etc.,) even more important than the economic optimization of their energy management system (EMS). Microgrids can provide resilience to this kind of facilities through their capacity to form self-sustainable islanded energy systems [9]. In this section, a review study of the main methods to increase the resilience and fault-tolerant control application to microgrids is carried out.

Need for Fault-Tolerant Control in Building Systems and Microgrids
Intelligent building design is entering its third generation [29], in which different control systems are exchanging data to assist a variety of building management systems. The first generation of intelligent buildings deals with independent systems; the second generation deals with interconnected systems; and the key phenomenon behind the third generation is the increase in the number and the variety of sensors distributed throughout building functionalities.
In this context, the whole building system is highly vulnerable to different kinds of faults. Unbeknownst to many, discrepancies from different sources could cause a big penalty over cost and comfort. Energy efficiency and user comfort are directly targeted by an abnormality in building operation. Thus, to make a resilient building management system, it is important not only to identify the severity, the cause, and the type of each fault but also fault-tolerant techniques.
The study carried out by [30] proved that many HVAC systems perform poorly because the importance of control has been underestimated by producers. In fact, the majority of installations are controlled by a simple control law, of the All or Nothing or PID type [31]. Hence, there is a need to use an advanced control system to improve the performance of the HVAC system.
Another important solution that will allow buildings to enhance their EMS is the integration of a number of small production units called thermal microgrids that do not stop increasing remarkably [32]. These units are rapidly becoming the mainstay of the future power system. At the same time, storage systems have become more reliable, cheaper, and cleaner, thus making viable the possibility of storing energy to cope with the intermittent nature of renewable electricity production. However, to have an efficient microgrid, an optimal control system is needed for the energy management between production, storage and consumption that adapts to the presence of faults and minimizes the occupant's discomfort and the increase of energy consumption [33,34]. The paper presented in [35] formulates distributed and centralized MPC strategies to balance fluctuations in solar power generation by directly controlling the aggregate demand of clusters of distributed residential air-conditioners. HVAC systems or combined cooling, heating and power microgrids can add flexibility to RES without increasing their economic cost.
The control system, whether for the thermal regulation of the building or the energy management of the microgrid must have a certain degree of intelligence in order to ensure optimal operation. All the more so since today, automated systems are subject to increasingly demanding performance constraints resulting in the application of ever more efficient controls, not only in the case of nominal operation but also in the event of fault appearance. This leads to the general notion of fault tolerant control systems.

Fault Tolerant Control Techniques for Building Systems: State of the Art
The goal of a fault tolerant system is to allow desired objectives to be maintained, not only in nominal operation but even in the presence of faults. It is very important to specify that the objectives to be achieved during these two operating modes are different [30]. Over recent years, FTC became an appealing area of research for building researchers. Various FTC strategies have been developed to compensate the fault effects and to maintain such desired performances in buildings. An important number of research and survey papers are available in the literature. Methods vary from adaptive control [36] to distributed [37] to model-based techniques [38]. The use of an adaptive control technique to control a set of IoT temperature systems subject to different failures has been discussed in [39]. Three mechanisms have been used for this purpose: a module for the data quality improvement, a state prediction module that predicts the future error and a PID controller. The authors in [38] made the design of a bank of local adaptive FTC agents to compensate some sensor faults in HVAC systems.
Fault-tolerant control techniques use an explicit model of the system under diagnosis. They can be passive or active models [40]. In general, all FTC approaches consist of two important stages: fault detection and identification and control system reconfiguration. Passive FTC techniques don't modify the parameters and the structure of the controller [41]. FTC techniques in the literature are interested only by active techniques. The use of passive FTC in building systems has not been given an adequate span of attention in the academia. Unlike, passive FTC methods, active FTC techniques are adaptive ones. The reaction to system failure is in real time by reconstructing the control actions to attenuate or eliminating the impact of such identified faults. They require fault diagnostic tools. In addition, they can cope with a greater range of faults and variations in system behavior compared to passive methods [42].
In the literature, numerous studies have developed various active FTC applications in buildings. For example, Ref. [43] exploits an approach that accommodated stuck damper vanes of the air handler. Ref. [44] investigates a supervisory fuzzy logic based FTC to characterize and correct fouling performance degradation faults for variable air volume (VAV) air-conditioning systems. Experimental results for an FTC algorithm for detecting and correcting sensor and damper faults in air-handling units (AHUs) are presented in [45].
Moreover, active FTC methods are distinguished from passive ones by the use of an FDI module and an online synthesis of a controller. Several methodologies for the design of fault accommodation strategies are proposed in the literature such as the method of pursuing a reference model [46], adaptive control [36], and many more. Most of the fault accommodation strategies have been developed for linear models. Some techniques mentioned above, such as model tracking methods, could be applied to nonlinear systems using the input/output nonlinear linearization control strategy. However, the nonlinear command remains difficult to implement in building systems.

New Challenges for Fault-Tolerant Control in Building Systems
The performance of the overall FDI/FTC system depends on many factors such as the availability of actuators and the fact that the sensors are always in good operation mode and that all the data are available [40]. However, on the one hand, data gaps i.e., missing data are the most important sensor fault types in buildings [47]. This is a challenge. On the other hand, the study in [48] concluded that typical faults in buildings consist of 13 types of faults and discussed the annual impact of each of them in terms of energy consumption. All the types of faults mentioned above are faults of the type "normal faults", i.e., easy to reveal. In addition, there are other insidious types of faults. For example, the fact that there is no noise in the ventilation system does not imply no fault but that no fault has been revealed [49].
Many applications deal with a set of fault situations that are known in advance [50]. The design of the control law so that the side effects of a fault are compensated for is usually done by FTC control schemes seen previously. However, whatever the FTC control strategy (passive or active), its feasibility depends on the performance of the FDI diagnostic part of each fault [51,52]. Numerous studies on FTC control are conducted assuming the availability of the perfect FDI. This requires the availability of complete information about the system model, which is not the case. In a building system, model-based FDI techniques rely on analytical model, derived from a physical relation. In connection with buildings, it is really impossible to develop a complete physical-model matching accurately the reality for a whole building system. The various phenomenon like heat transfer from facade or unplanned occupancy are challenging jobs to model. Model-based diagnosis believes in behavioral constraints only and assumes them to be true in all circumstances. It assumes that the model represents the reality of building operation independently of the current context and any fault can be detected by measuring the physical variables and checking the consistency with a reference model. However, universally valid behavioral models i.e., valid whatever the context, are difficult to set up. Nevertheless, behavioral models always valid i.e., universal are difficult to set up. Erroneous all-context models might lead to invalid diagnoses [53]. According to [54], diagnosis reasoning must differ in different scenarios, e.g., fault detection and diagnosis approaches should be different for normal working days and a vacation period.

Power Quality and Real-Time Control
Power quality and reliability will be important factors in the transition towards the smart grid, since the power it generates should, according to the various national policies, meet the growing demand cleanly, reliably, sustainably and at a low cost [55].
In electric power systems, any deviation with respect to the theoretical sinusoidal waveform) is considered to perturb the power quality of the electrical grid. The deviation can be in any of the parameters of the wave: frequency, amplitude, waveform and symmetry between phases, and, depending on its degree and the sensitivity of the receptors, this perturbation may have a repercussion on other devices. Depending of the time scale of the perturbation, several classifications can be made, such as variations and events. While variations are continuously measured and evaluated, unpredictable events occur in general and require a trigger action to be measured. Important variations are: slow voltage changes, harmonics, flicker, and unbalance. Important events are rapid voltage changes, dips, swells, and interruptions. The power quality in the microgrid will be a result of the interaction between the main grid, the generator connected to the microgrid and the load fed by the microgrid. High penetration of renewable energy produces energy imbalances in the grid resulting in serious problems in power quality, such as, flickers, sags, variations in frequency, and voltage magnitude of the main grid. This fact is due to fluctuating systems and their inherent intermittency . This makes more precise requirements on the power balance control algorithm, from primary control to the operational planning necessary. This fact requires higher effectiveness in reference tracking for the electronic power associated with the ESS. Moreover, it is necessary to establish new control algorithms different from the classical PIPWM controllers that present a slow response and a long transient period until the references are reached. Frequency is related with the active power balance in the system. This is due to the fact that the employed generating technology is generally formed by a set of synchronous turbines (machine). At the instant when an increase in the demanded electric power is produced, the turbine torque is suddenly applied to the shaft, which will result in a decrease of the rotation speed and consequently, and also the frequency of the wave generated. Meanwhile, the effective voltage value is closely related to the excitation of the synchronous machine. That is, it can be seen that it is important for the active power control implemented through the turbine, while the control voltage is the excitation of the machine. This explains why both problems are studied in a decoupling problem, but in reality they are not at all, the latter being particularly important when producing transient phenomena.
An adequate quality supply provides the compatibility required among all the devices connected to the same grid. In traditional power systems, power quality in a node of the grid is associated with the short circuit power at that point of the grid. Under constant emission, higher short circuit power results in better voltage quality. The controllability of fossil-fuel power plants on which the centralized generation has been based, as well as the traditional lineal loads just cause low level power quality anomalies in comparison with short circuit power in the upstream network [55]. However, this scenario has been modified in recent years marking the transition to the smart grid with the introduction of distributed generators and electronic loads. Regardless of the scenario, power quality would be defined by the interaction between the generation equipment, the consumer devices, and the grid.
Microgrids will also be characterized by a high share of power-electronic devices that will increase harmonic levels and possibly cause instability as the result of interactions between controllers and resonances. MPC has several attractive features regarding its application to the PQR management of microgrids, since the controller can take into account the future behavior of the power inverter, despite its complex dynamics. The cost function can integrate multiple criteria, thus allowing the optimization of important parameters such as active and reactive power control, and the reduction of harmonics or ripple minimization. MPC-based controllers can easily handle the transition between islanded and grid-connected modes, achieving a faster response than that obtained by classical PI-PWM controllers. This aspect may be crucial in the case of energy supply to critical loads. The MPC formulation as a Finite Control Set (FCS) does not imply a high computational cost, which is a relevant issue in the control problem of power inverters.
The PQR control of the microgrid is established in the secondary and primary control levels. The secondary control level is related to the global control of voltage and frequency in the microgrids, including the restoration of voltage/frequency during the transition to islanded mode or the re-synchronization with the main grid. The primary control directly applies to the power converters of the microgrid [12]. This section provides a review of the main contributions related to the application of MPC-controllers to the power quality enhancement in microgrids. The different advantages and disadvantages of each method are summarized in Table 1.

MPC for Power Converters
The field of MPC has been applied to power converters by employing two main control strategies: the FCS and the Continuous Control Set (CCS). The FCS is based on the finite number of switching states that a power inverter can adopt. The optimization problem is simplified by considering these possible switching states in order to predict the behavior of the converter. At each sampling instant, the set of admissible switching sequences is enumerated, the corresponding system response is predicted, the cost function is evaluated and the sequence that yields the minimal cost is consequently selected [56]. The CCS method sends continuous-time signals as control actions, which are sent to a modulator, and the optimization problem is solved analytically by making the derivative of the cost function equal to zero in the unconstrained case. Its main advantage is the use of longer control horizons, since an analytical solution is provided. Nevertheless, the complex topologies of power inverters make it difficult for this methodology to create an appropriate model of the plant, since higher computational resources are also necessary. A basic application of this kind of controllers can be found in [57].
The latest studies related to power quality enhancement with power inverters search the harmonic compensation using four-leg voltage source inverter topologies with active neutral control. In [58], an active power filter implemented with a four-leg voltage-source inverter (VSI) using an MPC scheme is presented for grid-connected applications. The paper presented in [59] applies a similar methodology in the new implementation of the finite control state set model predictive control (FS-MPC) applied to a three-level four-leg flying capacitor converter (FCC) operating as a shunt active power filter. The results obtained by the control algorithm improve the current tracking capability and transient response. However, the use of an FCS-MPC controller attains bad results in the THD content. In [60], a cascade-free fuzzy FCS-MPC is proposed for neutral point-clamped power inverters with a low switching frequency (SF). The main objective of the proposed method is to achieve a low SF operation. The cost function is formulated in order to reduce the SF, and a fuzzy logic control (FLC) technique is employed in order to choose the weighting factors in a dynamic manner. The paper presented in [61] proposes a new flexible reference current generation technique by using a tuning parameter to reduce the active power oscillation flexibly. The reference current generated comprises not only the positive and negative sequence currents but also lower order harmonic components. A flexible multi-frequency reference current computation technique for the unbalanced and distorted grid conditions is developed using MPC control techniques. The experimental and simulation results successfully validate the trade-off between the low frequency power oscillations and current THD, which is established using a tuning parameter. The proposed scheme, therefore, allows active power oscillations to be reduced in microgrid scenarios.
In [62], a composite selective harmonic elimination pulse-width modulation (SHE-PWM) and model predictive control (MPC) for seven-level hybrid-clamped (7L-HC) inverters is presented. The result attained by the proposed methodology is a low switching frequency, which has a good harmonic performance with a reduced computational burden. In [63], a strategy that combines FCS-MPC with a SHE modulation pattern in its formulation is proposed in order to govern multilevel power converters. The proposed methodology is based on considering a desired operating point for the system state (converter current reference), and an associated predefined SHE voltage pattern is obtained as a necessary steady-state control input reference. The cost function is then formulated with the inclusion of both system state and control input references. The experimental results obtained have a fast dynamic response, while a predefined voltage and current spectrum with low switching frequency is achieved in steady-state.
In [64], a model predictive power control (MPPC) scheme and a model predictive voltage control (MPVC) scheme are presented. The proposed methodology consists of controlling the bidirectional buck-boost converters of the battery energy storage systems by using the MPPC algorithm as a basis. The fluctuating output from the renewable energy sources can be smoothed, while stable DC-bus voltages can be maintained as inputs to the inverters. The parallel inverters are controlled by using a combination of the MPVC scheme and the droop method to ensure stable AC voltage output and proper power sharing. The proposed method is simpler than the traditional cascade control and has a better performance, which is validated in simulation in MATLAB/Simulink and on a Real-Time Laboratory (RT-LAB) platform

MPC for Voltage and Frequency Regulation
Microgrids consist of multiple parallel-connected distributed generators, storage devices, or controllable loads that are able to operate in both grid-connected and islanded modes, in a coordinate mode. In islanded mode, it is necessary to maintain system stability and power quality among the multiple parallel interconnected devices. Deficit balances in the active and reactive power between the different components of the microgrids owing to several aspects, such as the influence of impedance mismatch of the feeders and the different ratings of the distributed units, can lead to poor power quality indexes, which can damage the devices connected to same microgrid AC/DC bus. In connected mode, imbalances in the active/reactive power can affect the schedule carried out with the main grid in the tertiary control.
The increasing presence of nonlinear loads and unbalanced loads could further affect the global power balance in the microgrid. Secondary control levels based on different methodologies, such as enhanced droop-control, network-based control methods, improved hierarchical control approaches based on graph theory, multi-agent system, gain scheduling methods, etc., have, therefore, been proposed. Several references that propose MPC-based controllers applied to voltage and frequency regulation problems in microgrids can be found in existing literature. In [65], an MPC-based controller and a Smith predictor (SP) based controller are applied to the secondary level of the microgrid. The results of this work prove that the proposed methodology enables nominal frequency values to be attained faster, but with fewer oscillations during load variations. The MPC-controller with the SP additionally solves the problems caused by communication delays.
The authors of [66] propose a secondary control level linked to the schedule carried out in the tertiary control level of the microgrid. The microgrid includes a hybrid ESS, and the different operational issues of each of the ESS technologies are also included in order to carry out the real-time power balance of the microgrid. In [67], a fuzzy adaptive model predictive approach for the load frequency control of an isolated microgrid is proposed. The frequency deviation problem is solved by employing a centralized MPC, which is made adaptable by dynamically adjusting its parameters using a fuzzy controller.
In [68], a distributed secondary control scheme is proposed for both voltage and frequency control in autonomous microgrids. The algorithm incorporates predictive mechanisms into distributed generations, while the secondary voltage control is converted into a tracker consensus problem of distributed model predictive control, in which the synchronous convergence procedure for voltage magnitudes to the reference value is drastically accelerated at a low communication cost.
In [69], a virtual inertia control-based MPC for the microgrid frequency stabilization of a system for microgrids is developed. The proposed MPC-based virtual inertia control is tested for several mismatched parameters of the microgrid, wind power, and load disturbances. The proposed MPC-based virtual inertia control is able to reduce and stabilize the frequency deviation of the microgrid and provides robustness to the system subjected to uncertainties and disturbances to the fuzzy logic and conventional virtual inertia systems, thus enhancing the stability and resiliency of the microgrid.
The authors of [70] present a DMPC-based strategy with which to regulate the frequency and average voltage, thereby achieving real and reactive power consensus in the microgrid. The proposed methodology is based on the droop, power transfer, and phase angle equations used to solve the DMPC. The formulation includes explicit operational constraints to ensure the operation of the microgrid within feasible ranges. The controller is also able to modify its adjacency matrix in response to either electrical or communication disturbances. The simulations and experimental tests performed show that the use of the proposed controller makes it possible to attain the regulation and consensus objectives, thus satisfying the operational constraints. The results presented improve the behavior of the microgrid when confronted with electrical disturbances, such as load changes or the disconnection/reconnection of distributed generators, and communication issues, such as latency and data packet losses.

Microgrid Connected Building Comfort Management Systems
Global warming and subsequent climate change have been a strong motivation to reduce overall energy consumption and thus curtail the use of fossil fuels. At the European level, 40% of the energy is consumed by the commercial and noncommercial buildings to serve the functions and comfort of the residing occupants [71]. Consequently, phenomenal research has been contributed to achieve nearly zero energy buildings (nZEB) i.e., buildings or districts joined to smart microgrids incorporating renewable energy sources and storage [72]. These microgrids may or may not be connected to the main utility grid. Over the last few decades, researchers have investigated the goal of optimal operation of the microgrids through a variety of control methodologies to ensure minimum energy consumption while maintaining the comfort of the occupants in the buildings. Among these methodologies, MPC has been most favored technique, thanks to its inherent advantages and flexibility. Equation (1) represents a simplified MPC optimization problem structure commonly seen in the literature. The cost function concerning (i) HVAC energy consumption (J HVAC ), (ii) utility grid pricing and tariffs (J cost ), (iii) maintenance and operational costs of the distributed energy resources (DERs) like photovoltaic (PV) panels, wind turbines (J DER ) coupled with energy storage systems (ESS) (J ESS ) is minimized with subject to the constraints accounting for (i) the thermal dynamics of the building ( f HVAC ), (ii) thermal dynamics of DERs ( f DER ) and ESS ( f ESS ), and essentially (iii) the occupants' comfort bounds. Note that N is the finite horizon that can range from hours, days, or months [73]. Depending on the nature of the cost functions, system dynamics and involved variables, strategies like Stochastic MPC, Deterministic MPC, and even Hierarchical MPC have been implemented and verified on various platforms achieving economical operations of the microgrids [74][75][76][77][78].
(1) Figure 5 depicts the general notion of the microgrid-HVAC building control framework. As the term suggests, the centralized MPC controller gathers the information from the system components and computes an optimal demand management schedule with appropriate DERs setpoints to attain the energy saving and building comfort [79,80], as illustrated in Equation (1). Despite its simplicity, the centralized control architecture imposes several problems as it offers limited scalability, higher computational burden for single platform and being detrimental in the case of fault occurrence. Hence, several studies propose the use of theoretically mature hierarchical control frameworks where a master (upper) controller generates set-points for the slave (lower) controllers ( Figure 5) and thus information among the controllers is exchanged [76,81]; in other words, the optimization problem from Equation (1) is decomposed into sub-problems to reach the optimal solution. Moreover, Ref. [74] have extended the analysis to the goal oriented controller coordination as energy efficient and cost efficient depending on the temporal data exchange among the controllers.
The availability of accurate and detailed models of microgrids and buildings is one of the critical requirements of the MPC technology. On that account, several authors have emphasized the use of tools like TRNSYS, EnergyPlus, and GridMat simulation platforms that offer reliable simulation for long horizons and large-scale complexities [76,82]. However, some articles favor the physics based modeling of the buildings and microgrid components as it provides more access and visibility of the system parameters [75,83]. Inspired by the recent developments in data science, Ref. [84] has employed data driven techniques for the modeling of the occupancy estimation. Determined by the nature of the models and constraints, mixed integers linear programming (MILP) [73,85] or nonlinear programming (NLP) [86,87] optimization methods have been exploited in the literature. The HVAC Building system has significant influence on the disturbances on its dynamics. These disturbances majorly comprise occupancy behavior and the weather forecast. Refs. [73,76] account for the occupancy schedule and activity, based on which the control strategy commands to maintain thermal comfort in Fanger index, pre-cooling, or pre-heating action to avoid peaks of discomfort, in order to modulate HVAC action resulting in energy peak shaving and smooth battery performances. Similarly, to tackle weather forecast errors, authors in [88] have approximated forecast error into piecewise linear form in the MPC formulation. Considering the weather measurements or forecast models is common practice in the literature making the control structure more robust towards its disturbances. Research on control strategies applied on microgrids joined to residential and commercial buildings has a long tradition; however, other nontraditional infrastructure applications have also been studied. Ref. [89] demonstrated MPC strategy on its microgrid system coupled with the marina of Ballen similarly [85] for the application of greenhouse and Ref. [90] has explored the possibility of subways integrated with a smart microgrid and its optimal performance.
A closer look at the literature of control architecture applied to buildings integrated with microgrids, however, reveals a number of gaps. In Table 2, a summary of the main references in this research field is analyzed. Consideration of more versatile microgrid systems, large-scale, and diverse building structures may provoke the practice of other control techniques like distributed, decentralized strategies. However, a great percentage of papers consider a variety of disturbances, but the deployment of robust control strategies for the same is rarely seen. Moreover, most of the results have been carried out on simulation platforms, and their real-time implementation on the the existing building infrastructure can galvanize the market for new products progressing towards a more environmentally friendly ecosystem.

Configuration Main Contributions Limitations Ref
Island system with PV, batteries and residential buildings Considers nonlinearity of the system dynamics, ensures the smooth operation of the storage system Computational complexity may increase exponentially [80] [79] PV, Utility grid and building infrastructure Variety of infrastructure options have been explored, integration with the main utility grid and consideration of prices and tariffs Limited in the configuration as only PV system is considered [65] PV, wind turbines, electric battery and buildings Demand management to smooth the battery operation and utmost energy saving, consideration of occupancy schedule Occupant activity may also affect thermal comfort, weather data are presumed and curtailed to specific season [76] PV, electric battery, and buildings Weather forecast error is considered in the dynamics of PV operation Dedicated robust MPC techniques may aid weather consideration in the building dynamics and controller dynamics as well [88] PV, chiller, electric battery, and buildings Hierarchical control architecture is explored, local optimization at the building level eliminated the need of the data transfer and resulting further data protection Coupling in the local optimization problems is ignored and may not cater for a global optimal solution [81] Combined heat production (CHP), electric storage and buildings Solution for day-ahead real-time scheduling, price forecasting through stochastic optimization Occupancy behavior and weather forecast errors are ignored, the proposed architecture may be complex for a large number of building infrastructures [87] Fuel cell, Diesel generator, electric storage, and buildings Multi-scale MPC: i) day-ahead scheduling for building energy management ii) inter-hour MPC to smoothen DER fluctuations Short term forecasting may affect the scheduling drastically, as two optimization problems are solved simultaneously and data are exchanged, the process delays can affect the performance

Combined Cooling, Heating, and Power Microgrids
In buildings, the management of heating, cooling and power energy services is characterized by the existence of significant coupling effects. One the one hand, the use of electric appliances in buildings always generates internal heating gains (due to the heat losses generated by the power conversion in the appliances), which helps to reduce heating needs in winter or increases cooling needs in summers. On the other hand, in many buildings, heating and cooling loads are fully generated by electrical systems or require at least some electrical support systems (fans, pumps, etc). Therefore, to optimize the management of heating and cooling systems, it is necessary to include in the control systems information about these complex interactions, and the use of an MPC approach enables the use of complex physical models that accurately describe all coupling effects. In this way, over the last few years, the use of MPC strategies to manage the generation of power, heating and cooling in an integrated way has been gaining attention. The applications are usually at the building level, but applications with multiple buildings in district heating networks have also been addressed. We now present some of the most recent applications found in the literature that not only cope with the interaction between these services, but also include the management of renewable generation plants, storage and the interaction with the market.
Pombeiro et al. [91] proposed an MPC optimization framework to control the heating, ventilation, and air conditioning (HVAC) system in an experimental setting in a Lisbon university building that maximizes user comfort while minimizing costs, constrained to: thermal comfort; variable electricity price; and available electricity in batteries that are charged by a PV system. The algorithm model used a simplified thermal model of the room or an EnergyPlus and the optimization algorithm was genetic algorithm or dynamic programming.
Zhao et al. [92] developed an MPC-based strategy using a nonlinear programming (NLP) algorithm to optimize the scheduling of the energy systems under day-ahead electricity pricing. The distributed power generation in a Hong Kong Zero Carbon Building consisted of a combined cooling and power system and a photovoltaic (PV) system and a stratified chilled water storage tank introduced as the thermal energy storage.
More recently, Zhang et al. [93] proposed a stochastic MPC for a CHP microgrid using mix-integer linear programming. The CHP microgrid consisted of fuel cell based CHP, wind turbines, PV generators, battery/thermal energy storage system (BESS/TESS), gas fired boilers, and various types of electrical and thermal loads scheduled according to the demand response policy. An MILP based energy management model with uncertainty variables represented by typical scenarios was developed to coordinate the operation of the electrical subsystem and thermal subsystem. The simulation results show that the MPC approach was more efficient than an open loop based stochastic day-ahead programming (S-DA) strategy or a pure MPC strategy.
Verrilli et al. [94] focused on the design of an MPC framework that reduces the operating and maintenance cost in a District-Heating Power Plant DHPP at Ylivieska, Finland considering thermal energy storage (TES) and flexible loads. The MPC accomplished this by forecasting the demand and solving a mix-integer linear programming problem that minimized the cost by scheduling boilers, TES units, and flexible loads. The use of a receding horizon approach enhances the robustness to the forecast errors.
The aforementioned applications demonstrate that MPC is the state-of-the-art approach for an integrated management system at the building level. The type of model is usually a nonlinear physical model of the heating, cooling, and power loads (such as ventilation or lighting); the control strategy requires the use of a nonlinear optimization; the cost function can be cost minimization and/or comfort maximization and allow the exploration of the flexibility provided by the storage systems but also by the buildings' thermal inertia. The forecasting of the renewable resources and the loads can be easily complemented with the incorporation of artificial intelligence techniques [95].

MPC for Interconnected Microgrids
As a consequence of the increased penetration of integrated renewable generation such as wind and solar photovoltaic energy as well as energy marketing, EMSs are undergoing changes to adapt to these new challenges. The evolution of isolated self-consumption networks towards the interconnection of networks is being focused on the optimization of energy flows that may be demanded or offered by the microgrids that integrate the network.
With the objective of relaxing computational constraints, current control systems have been shifted from centralized control systems to distributed approaches [96]. In centralized control systems, optimization is carried out globally for all members that make up the network. It requires a costly and critical central control architecture. Control devices and communication channels are also critical points in this approach. In contrast, in a decentralized control system, each member undertakes a local optimization, increasing communication speed and fault tolerance. Unilateral decisions by operators can affect the performance of the electricity grid locally, but do not directly affect global behavior. The distributed architecture aims to be an appropriate EMS for a large-scale microgrid community (MGC).
According to Figure 2, the power flow management and the economic optimization between interacting microgrids are undertaken on the tertiary level. This level will be responsible for achieving optimal interactions between the agents that make up the network. Table 3 describes a set of motivating applications where different techniques have been used to develop networked microgrids. The work of [96] shows a comparison between decentralized, centralized, and hierarchical-distributed MPC approaches for a group of interconnected home-microgrids. The distributed approach improved the power profiles compared to the decentralized strategy. Iterative Computational load [101] Stochastic DMPC Simulation Resilient approach and fault accommodation. [102] Hierarchical DMPC Simulation Hierarchical approach using MILP.
Number of integer variables [103] In the centralized context, the work of [97] applies an MPC on a group of interconnected microgrids with the main grid maximizing the benefits for all the agents and using nonlinear models. From an economical point of view, the work proposed in [98] describes an MPC methodology for energy regulation among microgrids with an internal electric market. It minimizes the deviations due to renewable resources and failures. Another contribution to centralized schemes is the proposal described in [99] where Gaussian Processes are used to predict solar PV generation and load demands. For that, data from nearby microgrids are additionally considered. Forecasts are more accurate compared to locally made predictions.
From the point of view of Distributed MPC (DMPC), there are many contributions to be highlighted. The formulation presented in [100] sets an integrated framework to model, simulate, and optimize large-scale networks based on Lagrange multipliers. The hub networking concept is introduced here. The work of [101] proposes an EMS optimization based on the cooperative logarithmic-barrier method to iterate achieving optimal results similar to centralized MPC on an experimental setup. The work proposed in [102] presents a resilient DMPC approach with respect to the noncompliance of some microgrids using stochastic models. In addition, active mechanisms are incorporated to disconnect microgrids in case of hard discrepancies. Another cooperative framework is presented in [103] where urban districts share certain distributed energy resources. The hierarchical structure uses MPC in both levels with integer programming. An aggregator is added to the control scheme to coordinate and optimize the cost and use of resources. A distributed DMPC framework, suitable for controlling large-scale networked systems such as power systems, is presented in [78]. The overall system is decomposed into subsystems, each with its own MPC controller. These subsystem-based MPCs work iteratively and cooperatively towards satisfying system wide control objectives. The proposed DMPC framework achieves performance equivalent to centralized MPC.

Challenges and Future Perspectives
As discussed throughout this review paper, MPC presents many features that could introduce enhancement in the hierarchical control of microgrids. Nevertheless, several challenges and limitations exist that could degrade its feasibility, performance, and scalability.

MPC Challenges in General Terms to Provide Solutions for Microgrids
MPC is mainly based on a model; nevertheless, MPC cannot describe unstable systems and originally had difficulty recognizing online models. The complexity of MPC controllers for the large-scale interconnection of microgrids with feasibility criteria for their required execution time is still a non-solved issue. The performance of MPC controllers decreases with the complexity of the number of variables included in the cost functions, it being difficult to guarantee stability and feasibility criteria. Thus, some of those algorithms are likely to remain theoretical. Actual applications are complicated and difficult to achieve. Moreover, due to the complexity of real systems, more hardware, better optimization algorithms, and the expansion of the control law of MIMO systems and nonlinear processes are very important. Large systems of interconnected microgrids must reduce computation times and now incorporate distributed MPC and hierarchical MPC. In the future, the latest schemes, such as explicit MPC and stochastic MPC, could be used as well. For dynamic systems such as power electronic systems, dynamic models can be researched in the future. The optimization of large-scale-interconnected microgrids can be combined with more complex models, as well as control schemes for building comfort should consider more interferences in the future. Overall, the state of MPC use in microgrids can be summarized in three respects. First, the application of MPC in microgrids will have to evolve towards rapid online computation. Control architectures where the techniques of machine learning, deep learning, or reinforcement learning should be combined with MPC controllers in order to achieve better computation time for higher complexity control problems related to microgrids. Second, some of the latest MPC technologies, such as hybrid MPC, stochastic MPC, and distributed MPC are satisfactorily being applied to areas of microgrids. Third, many MPC methods for power quality or real-time control will require the improvement of embedded MPC techniques or an advance in available control platform for these kinds of applications.

MPC and the Introduction of Microgrids in Electric Markets
Microgrids will evolve introducing different power-to-X technologies. The formulation of this kind of system will be an important goal in the future developments of MPC-controllers for microgrids. The development MPC controller with a joint optimization for active and reactive power in the microgrids is also an issue which still requires development. Aspects such as the integration of network constraints or including congestion management in the PCC with the main grid is also a research line to be explored.

MPC and Fault-Tolerant Control in Microgrids
Stability is highly important for microgrids, especially operating in autonomous operation. Thus, far, the stability analysis including recent techniques such as tube-based MPC controllers is an important field to be developed.

MPC and Power Quality for Microgrids
The biggest challenge in the future may be the trade-off between computing time, performance level, and economic cost. It is very difficult to reduce calculation time and cost without affecting performance. This aspect is even critical in the secondary and primary control level of microgrids where real-time controllers have to be implemented. Regarding the primary control level, aspects such as the behaviour of the internal components of such power inverters changing due to operational factors such as temperature, and solving the steady state error, are still questions to be solved in the application of MPC-controllers.

MPC and Networked Microgrids
Currently, networked microgrids are being researched endowing an ability to decide when and how to exchange power in order to optimize energy flows. New methodologies have been developed to provide flexibility measures, such as fast-acting supply, demand response, and energy storage services [104], that even enable aggregators of consumers to participate in electricity markets. In this sense, Blockchain [105] was created with the aim of meeting the optimization needs of decentralized schemes and the digitization of the market. The main objective of blockchain is to eliminate intermediary agents and replace them with a distributed network of digital users. These users verify the transactions executed and ensure the security and integrity of the transactions. Unlike centralized systems, each node owns a copy of the ledger or has access to it in the cloud. Therefore, anyone on the network could access the historical record of transactions and verify their validity, resulting in a high level of transparency. The transaction validation mechanisms are known as consensus algorithms. A blockchain-based platform consists mostly of a distributed ledger, a decentralized consensus mechanism, and cryptographic security measures. In addition, blockchains allow for the automated execution of smart contracts in peer-to-peer (P2P) networks [106].
Taking into account the previous properties that characterize blockchain methodologies, it can be considered that the optimization of interconnected microgrids is a direct application of that. Proof of this is the bibliography dedicated to it [107] and in general to energy networks [105] and Internet of Things (IoT) [108,109]. Note that blockchain does not only provide a feasible distributed implementation but also involves a safe framework for development. See, for example, [110] where a novel permissioned energy blockchain system is introduced to allow secure energy delivery services for EVs and energy nodes through the use of distributed ledgers and cryptocurrency.
To the best knowledge of the authors, there are no blockchain-based microgrid applications that use an MPC in the optimization. However, blockchain methodologies that consider the principles of MPC in consensus algorithms are expected to be developed in the very near future.

Conclusions
This review has been focused on carrying out an analysis of the current development of MPC strategies to develop final-use applications and functionalities in microgrids. Classical MPC mainly solves multivariable constraint control problems. However, this method is not suitable for nonlinear, stochastic, and large-scale interconnected systems. To solve MPC-problems with logic and continuous variables, the hybrid MPC formulation can be used. Piecewise approaches based on a hybrid MPC formulation can be applied to include nonlinearities in the plant predictive model. Recent formulations of MPC controllers include a stochastic formulation which allows the inclusion of uncertainties on the control problem associated with renewable energy and loads, enhancing the resilience of this kind of systems. Distributed approaches have been satisfactorily applied to large-scale interconnected microgrids, reducing the required computation time through the use of decentralized or distributed approaches. In addition, recently, MPC controllers using FCS or CCS approaches are being applied as a powerful tool to improve the power quality in microgrids. MPC methods are continually evolving to solve the most complex problems that the industry and technology need to control. Thus, it is expected that the field of MPC-controllers will continue to provide solutions to face the problem that the promising introduction of microgrids in the future smart grids brings with it.
Author Contributions: Conceptualization, All; methodology, All; software, None; validation, None; formal analysis, All; investigation, All; resources, All; data curation, All; writing-original draft preparation, All; writing-review and editing, All; visualization, All; supervision, All; project administration, All; funding acquisition, All. All authors have read and agreed to the published version of the manuscript.

Acknowledgments:
The authors acknowledge the support given by their affiliation entities: National Center of Hydrogen (CNH2) and University of Seville, in Spain, University of Perpignan Via Domotia, in France and Laboratorio Nacional de Energia e Geologia (LNEG) and Technical University of Lisbon, in Portugal for the support to carry out this study.

Conflicts of Interest:
The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.

Abbreviations
The following abbreviations are used in this manuscript: