A Coordinated Optimal Operation of a Grid-Connected Wind-Solar Microgrid Incorporating Hybrid Energy Storage Management Systems

The hybrid-energy storage systems (ESSs) are promising eco-friendly power converter devices used in a wide range of applications. However, their insufficient lifespan is one of the key issues by hindering their large-scale commercial application. In order to extend the lifespan of the hybrid-ESSs, the cost functions proposed in this paper include the degradation of the hydrogen devices and the battery. Indeed, this paper aims to develop a sophisticated model predictive control strategy for a grid-connected wind and solar microgrid, which includes a hydrogen-ESS, a battery-ESS, and the interaction with external consumers, e.g., battery/fuel cell electric vehicles. The integrated system requires the management of its energy production in different forms, i.e., the electric and the hydrogen ones. The proposed strategy consists of the economical and operating costs of the hybrid-ESSs, the degradation issues, and the physical and dynamic constraints of the system. The mixed-logic dynamic framework is required to model the operating modes of the hybrid-ESSs and the switches between them. The effectiveness of the controller is analyzed by numerical simulations which are conducted using solar and wind generation profiles of solar panels and wind farms located in Abu Dhabi, United Arab Emirates. Such simulations, indeed, show that the proposed strategy appropriately manages the plant by fulfilling constraints and energy requests while reducing device costs and increasing battery life.

of energy management systems (EMSs) based on renewable energy sources (RESs).Indeed, RESs, particularly wind and solar power, utilization has substantially grown in the past decades and a further increase is expected in the future to reduce greenhouse gas emissions [1], [2].However, their sporadic nature impacts both the power quality and the economic competitiveness of energy supply systems equipped with both renewable and conventional sources.The support of short-term and long-term energy storage systems (ESSs) technologies is required for the integration of RESs in the main grid [3], [4].However, due to low energy density and self-discharge, battery-ESSs (BESSs) can be used only for short-term storage [5].Among the different long-term ESS technologies, the use of hydrogen-ESSs (HESSs) emerges as one of the most exciting options since it is environmentally friendly, and with high energy density [3].Hydrogen is produced through electrolysis, stored in storage tanks, and re-electrified by fuel cells for meeting electric and contractual demands.
The so-called microgrids, given by the combination of RESs with ESSs, require the deployment of control strategies that take into account equipment limitations, degradation, and costs.This research study focuses on providing control solutions based on the model predictive control (MPC) framework [6], in which the devices are modeled by using the mixed logical dynamical (MLD) formulation [7], [8].Several strategies have been proposed in the literature for the management of HESSs and BESSs integrated with RESs.
With respect to the equipment operation and maintenance costs, for instance, an MPC strategy in which both the short-and long-term optimal planning of a microgrid comprising RESs, a HESS, and a BESS has been considered in [9].The work shows that the strategy satisfies the electrical load demand while minimizing the microgrid running costs.Moreover, the maximization of the hydrogen devices' lifespan has been included in [10], where an MPC policy to control a RES hydrogen-based microgrid has been designed and experimentally tested by computing the equipment degradation at each time interval.In [11], an MPC strategy that takes into account cost optimization and equipment damage has been proposed.The approach limits the intensive use of electrolyzers and fuel cells by constraining the devices to operate within the minimum and the maximum power values.In [12], a coordinated control method for a hybrid large-scale RES based on HESS has been implemented to guarantee the optimal operation of the system.The authors in [13] have designed a stochastic multi-microgrid EMS, based on a chance-constrained programming strategy, which takes into account the uncertainties of the forecasted loads.In particular, the cost functions address the frequent charging/discharging cycles, which represent a major factor in battery life cycle reductions.However, in these papers, neither the degradations are considered, nor the hydrogen devices' short-term features, i.e., the cold and warm starts, and their standby consumptions, are taken into account.This is, instead, one of the key aspects included in the strategy proposed in this research study.
Regarding revenue maximization via the energy market participation, in [14], an MPC strategy has been developed to optimally control the network of interconnected hydrogen-driven microgrids with different ESSs under failure conditions.A control strategy has been implemented in [15] to meet userrequested electric reference by taking into account the devices' life degradation, and the costs related to the HESS acquisition, the electricity export/import to/from the grid, and the operation and the maintenance of the overall system.Other MPC strategies have been presented in the literature for the optimal economic schedule and management of microgrids by considering economic and environmental aspects, see for instance [16].In the aforementioned papers, the authors have presented their studies with regard to the energy market participation, however neglecting the devices' cold and warm starts and/or minimum ON/OFF times constraints which affect their lifespans and short time scale dynamics.
In general, microgrids can exchange energy in the local market with external agents, such as other microgrids, aggregators, or battery/fuel cell electric vehicles (BEVs/FCEVs) [17], to improve their economic benefits [18].In [19], the problem of microgrid economic dispatch and interaction with external agents has been analyzed.By taking into account the energy price predictions and the forecasts of the production, the internal resources of the microgrid are optimally distributed in the day-ahead energy market.A novel supervisory-based model for the optimal scheduling of distributed HESS fueling stations for tracking the external consumers of hydrogen and electricity has been provided in [20].A multi-objective mixed integer linear programming (MILP) framework based on the uncertainty related to the demand, prices, and wind speed for the design of an energy hub including parking areas of hydrogen vehicles has been developed in [21].An optimal scheduling strategy for the energy management of a microgrid including solar panels paired with a HESS and integrated BESS units has been proposed in [22] to satisfy electric and hydrogen demands requested by the industrial hydrogen facility.The authors in [23] have developed a hybrid RES paired with combined ESSs (BESS and HESS) in order to track the requested load of a typical residential house in Dhahran city, KSA, and to produce hydrogen as a fuel for hydrogen vehicles.In [7], a strategy controls a grid-connected wind farm including a HESS, which both meets electric and contractual loads and produces hydrogen as a fuel for FCEVs.Similar to this research study, the latter uses MPC with MLD for devices' models and minimizes the devices' operating costs; however, in [7], a wind-microgrid integrated only with a HESS has been considered, and virtual states have been taken into account in the devices' models by increasing the number of Boolean variables and, consequently, their complexity.Apart from the latter, to the best of the authors' knowledge, the literature seems to not address exactly the combination of different features, as in this article.
The literature on optimization under uncertainties shows that stochastic programming is considered a suitable method for dealing with uncertainties.In particular, stochastic techniques have been proposed in the literature to reduce operating costs and/or emissions of smart grids and microgrids.As a relevant example among others, a contingency-constrained optimal operation model for a multi-microgrids system has been addressed in [24], where the authors have designed a scenario-based approach to integrate multiple uncertainties, e.g., electrical storage, and demand response resources, to reduce the operating costs.The authors in [25] have developed a real-time economic dispatch with static snapshot forecast data to evaluate the best-fit by considering the minute-to-minute variability of solar, wind, and load demand.The paper offers a robust optimization approach that accounts for the techno-economic uncertainties of hydrogen-based power plants.In order to control the load sharing of a solar microgrid paired with hybrid-ESSs and battery packs, an MPC algorithm that includes the degradation issues of the batteries has been developed in [26].In [27], a genetic algorithm and two-point estimate methods have been used for the best-fit day-ahead schedule and coupled with a controller for a hybrid power system including the impact of uncertainties in RESs (wind and solar) and load forecasts.In order to minimize the operational costs of a multi-energy microgrid, a multiple time-scale EMS based on the MPC framework for a HESS multi-energy microgrid which considers forecasted uncertainties regarding the fulfillment of different demands, e.g., electricity, hydrogen, and heating, has been developed in [28].Moreover, in [29], [30], an optimal scheduling power flow problem considering RESs paired with an ESS that takes into account the uncertainties of RESs and load forecasts has been designed.Contrary to the aforementioned mentioned papers, in this study wind power and solar power represent uncontrollable exogenous signals for the controller.In particular, it is assumed that the owners of the wind farms and solar panels provide the best-fit day-ahead schedule to the controller, after taking into account the uncertainties in wind, solar photovoltaic (PV), and load forecasts.Therefore, estimations predicted with statistical, stochastic or machine learning approaches are out this paper's scope.
Heuristics and meta-heuristics techniques are also proposed in the literature.In particular, the genetic algorithm, the particle swarm optimization (PSO), the duelist algorithm, the simulated annealing, and the ant colony optimization are the most adopted heuristic algorithms.An advanced battery-based EMS has been proposed in [31] to reduce running costs by integrating a backup source that provides power supplies on the basis of energy market profiles.Moreover, an improved feedback controller and optimal EMS for BESS based on online optimization have been developed in [32] in order to reduce battery degradation and enhance its lifespan.An energy system with PV and biomass using both invasive weed optimization and PSO has been proposed in [33] to supply the electric demand from a farm located in Alexandria, Egypt.The authors in [34] have studied a strategy for both transportation and building sectors based on a meta-heuristic PSO to guarantee the independence of a university located in Ouargla, Algeria, through the production of hydrogen and power.Moreover, a data-driven approach based on hierarchical multi-objective optimization has been provided in [35] to determine the optimal sizing of an energy system with PV and wind energy.Contrary to the aforementioned mentioned papers, this study uses numerical commercial solvers for the mixed integer programming (MIP) optimal problems, where heuristic approaches are not adopted.
The production and utilization of renewable energy have many economic advantages, which are investigated in the literature.In this regard, in [36], a comparison of six renewable power generation systems in different areas of Saudi Arabia has shown that the lowest cost of energy can be achieved using hybrid-RESs (PVs and wind) with battery storage systems.As further examples of techno-economic analysis, in [37], MPC implemented solutions for the optimal economic dispatch of renewable generation units and demand response have been proposed in a grid-tied hybrid system.Moreover, a comprehensive techno-economic analysis of the solar hydrogen production supply chain by concentrated solar power plants with thermal energy storage with different energy supply schemes has been proposed in [38].A techno-economic analysis of on-site hydrogen refueling stations based on grid-connected PVs coupled with HESSs has been provided in [39], where the levelized cost of hydrogen has been determined for all configurations through the estimation of operational and maintenance costs, investment costs and replacement costs.Another analysis has been carried out in [40] to study the fulfillment of the demand from 25 vehicles by a hydrogen station located in Turkey and powered by a hybrid (PVs and wind) power system.The literature revised above either ignores the high equipment costs or, if it does, the ESSs degradation models are oversimplified.This is one of the main points of the study, which proposes an ESSs model by taking into account both their equipment working modes/switches and their operational constraints.
In all the aforementioned studies, according to the authors' knowledge, the short-and long-term optimal energy management of both the HESS and the BESS that simultaneously takes into account devices degradation, start up/shut down and standby cycles, limitations of the ESSs, and operational and maintenance costs have not yet been addressed.Moreover, in this paper, the production/consumption of hydrogen, and the battery charge/discharge are modeled such that the warm-start and the cold-start processes required by the devices before some state switches are captured.As a result, the model does not explicitly include the two virtual states introduced in [7], [41], and then the number of variables involved reduces.The contributions of this study are: 1) the development of a novel MLD model for ESSs' operations which includes logical variables corresponding to the possible states and their switches, and further Boolean variables, called waiting actions, for safe state switches.The less number of Boolean variables in the proposed model with respect to the models proposed in the literature results in a reduction of complexity and computational costs; 2) the application of the MPC approach to reduce operation and maintenance costs, and simultaneity to minimize the energy exchanged with the grid for high levels of autonomy; 3) the management of the exchange of energy between the microgrid and external agents, such as the BEVs and FCEVs.

II. GENERAL OPERATIONS OF ENERGY PLANT
In the energy plant under investigation, wind and solar are the main energy sources.As shown by the conceptual representation in Fig. 1, the components of the system are the wind farm, the PV panels, two different ESSs (HESS and BESS), hydrogen loads, external consumers (FCEVs and BEVs), local and contractual loads.In turn, the HESS includes a tank, an electrolyzer, and a fuel cell.In the figure, P w , P pv and P ev denote the power generated by the wind farm, PV panels and BEVs, respectively, P pr is the input power given to the electrolyzer, P co is the output power from the fuel cell, P b is the battery power, P req is the requested load, P s and P g are the available system and the grid powers in the system, respectively.The available electricity is used to satisfy load requests.Any excess of energy is used by the electrolyzer, which produces hydrogen that will be stored in the tank, or by the BESS, which charges its battery storage.Then, in low or nearly zero wind/solar hours, the stored hydrogen is re-electrified by the fuel cell and/or the energy in the battery is delivered to loads.These operations require the development of control strategies that operate the devices to provide smooth power injection into the main grid, manage uncertainties, participate in the electricity and hydrogen local consumption and integrate external agents in the microgrid.
The main purposes of the integrated system are to supply the local load both in islanded (i.e., without grid support) and in connected (i.e., with grid support) modes, and to interact with external consumers, e.g., BEVs and FCEVs.As a result, four possible modes are considered: the islanded mode, the grid-connected mode, interaction with BEVs, and interaction with FCEVs.However, the four different architectures feature the common target of minimizing the ESSs' operating costs.The developed hierarchical controller (primary level, secondary level and tertiary control) will be deployed onto the management platform of the hybrid-ESS which is paired to the wind farm and solar panel established in Abu Dhabi, UAE within the funded project CIRA.According to the project, three control scenarios have to be developed and, in our manuscript, we have implemented only the first one to be integrated with the other two scenarios in future developments.In particular, the first control scenario is related to the design of the tertiary control to optimize the power flow between the components of the microgrid (RESs + hybrid-ESSs) and the main grid on large time scales (planning and scheduling) by an online solution of an optimal control problem that provides the current optimal control action by minimizing an objective function.However, our research study targets how the active power is dispatched within the microgrid, according to the proposed criteria, and the reactive power dispatch among the distributed generations is out this paper's scope.

III. SYSTEM MODELING
The modeling of the system under investigation is the first step in the implementation of the model-based control strategy for the operations modes.The proposed strategy consists of the economical and operating costs of the hybrid-ESSs, the degradation issues, and the physical and dynamic constraints of the system [42].Since the formulation deals with both logic and continuous variables, the MLD framework is required to model the operating modes and the switches between them characterizing the hybrid-ESSs.

A. Preliminaries and Notation
In this section, we introduce notations and standard assumptions that will be used throughout the paper.Some models used by the MPC strategy are built upon automata.The tags OFF, STB, and ON are used to label their states, and it is useful to define the state set S = {OFF, STB, ON}, the operation set D = {pr, co, ch, dc}, and the transaction set T = {(OFF, STB), (OFF, ON), (STB, OFF), (STB, ON), (ON, OFF), (ON, STB)}.Furthermore, the subscript d identifies a particular operation of ESSs, i.e., d = pr, d = co, d = ch, and d = dc refer to the operation of the hydrogen devices (electrolyzer and fuel cell) and BESS operations (charging and discharging), respectively.Moreover, α and β are two generic indices that take value in S; when α and β are used in conjunction, it is assumed that α = β.The logic variables used in the model are and mixed variables are νs with some superscript, e.g., ν α , given by P d Γ α d , with P d ∈ R + .General bold is used to denote vectors.Note that the proposed models are in discrete time k, and the mapping to the continuous time t can be derived through t = kT s , with T s = 1h is the sampling time.

B. Model of Energy Storage Systems
The on, off, and standby modes are the three physical states in which the HESS and BESS can operate.As Fig. 2 shows, each operation of the ESSs (production and consumption of hydrogen for the HESS; charge and discharge for the BESS) can be represented by a three-state automaton with the state set S = {OFF, STB, ON} and the transaction set T = {(α, β) ∈ S × S | α = β}, where (α, β) denotes the transition from the state α to the state β.As a result, four automata are required, one for each of the considered operations.The nodes refer to the states of the devices, while the edges indicate the state transitions.The state is ON when the electrolyzer (fuel cell) is producing (consuming) hydrogen and the BESS is charging/discharging; the state OFF corresponds to the opposite situation, i.e., the hydrogen device is not producing/consuming hydrogen and the BESS is not charging/discharging; the state STB denotes the case in which the device is consuming electric power even if its corresponding operation is not active.In order to consider the slow response of the devices, the transitions (OFF, STB) and (STB, ON) require a waiting action, called cold-start and warm-start processes, respectively.Due to the waiting actions, the transition (OFF, ON), denoted by the dashed edge, is not allowed.
The automata can be described through logical and continuous variables, according to the MLD framework [43].Then, for the state α ∈ S of the automation related to the operation d ∈ D, the logic variable Γ α d is defined such that Γ α d (k) = 1 if the automaton for the operation d is in the state α at the time-step k, and Γ α d (k) = 0 otherwise.Similarly, for the transition (α, β) ∈ T of the automation related to the operation d ∈ D, the logical variable Δ β α,d is defined such that Δ β α,d (k) = 1 if the automaton for the operation d switches from the state α to the state β at the time-step k, and Δ β α,d (k) = 0 otherwise.1) MLD Constraints for the State Actions: As already discussed, some state transitions are subject to their corresponding waiting actions due to the slow response of the devices.In order to take into account these actions, it is useful to define for each state a further logical variable These constraints are now equivalently rewritten in linear inequalities [43] to be included in numerical solvers.To this aim, each left-side expression in ( 1) is defined by introducing the two logical variables ν ≥ξ m and ν ≤ξ M , as follows where According to the MLD equivalences in [43], the definitions in (2) are equivalent to where M is an upper bound of P d , and −M is its lower bound.Then, each constraint in (1) is rewritten as Moreover, the intentions to stay in a state are mutually exclusive, i.e., α∈S 2) MLD Constraints for the State Transition: The logical variables Γ α d and Δ β α,d are derived by the variables Υ α d .Indeed, the transitions (OFF, STB) and (STB, ON) are enabled only after a fixed time interval which is necessary to execute the cold-start and the warm-start processes.This constraint can be described by introducing the following definitions ) where τ c and τ w are the time intervals for the cold-start and warm-start processes, respectively.The definition in (6a) is equivalently converted into the following inequalities and the definition in (6b) can be rewritten as a set of inequalities in a similar fashion.The remaining allowed transitions, instead, do not require a waiting action and are defined as for all (α, β) ∈ T \ {(OFF, STB), (STB, ON), (OFF, ON)}.
The expression above is equivalent to Moreover, in order to model the inadmissibility of the transition (OFF, ON), it is Δ ON OFF,d (k) = 0 for all d ∈ D and all time-steps k.In addition, for all d ∈ D the condition has to be considered due to the fact that at most one transition can occur at each time-step.
3) MLD Constraints for the States: Finally, the state variables Γ α d are obtained from the transition variables Δ α β,d as According to this definition, the automation is set to α if at k − 1 the state was not α and at the current time one of the two transitions pointing to α is enabled, or if at k − 1 the state was α, there are no enabled transitions and the state remains unchanged.
The definition above can be rewritten as Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
In (11), the product of two logical variables makes the problem nonlinear, and it must be introduced a further logical variable which is recast as the following set of inequalities Finally, the operations of the electrolyzer and the fuel cell are not interconnected, i.e., the production and the consumption of hydrogen can occur at the same time.On the other hand, the charging and discarding are mutually exclusive, and then the further constraint must be considered.

C. Power Exchanged With the Utility Grid
In the system, the electricity can be both purchased from and sold to the grid.Then, the logical variable Θ g is defined such that Θ g (k) = 1 if the system interacts with the grid at the time-step k, and Θ g (k) = 0 otherwise.In particular, based on the definition in [7], it is where P g is the grid power that defines the possibility to either buy from (if P g (k) > 0) or sell energy to (if P g (k) < 0) the utility grid.The definition ( 15) is equivalent to which can be rewritten by introducing two logical variables Θ sell and Θ buy defined as The logical expressions (17a) is equivalent to which can be recast by the following inequalities where M g is an upper bound of P g (k), −M g is a lower bound of P g (k), and is a small positive number which is usually set equal to the machine precision.The definition in (17b) can be rewritten in a similar way.In order to define the interaction with the utility grid, the slack variables ν sell and ν buy are defined as The product variable ν sell can be recast as and ν buy can be recast in the same way of ( 21).
The technique adopted for transforming the (nonlinear) mixed product in (20a) in the equivalent mixed-linear formulation (21) can be used for the other mixed products; for the sake of brevity, the repetition of such transformation will be not reported for other analogous cases later in the paper.

D. Hydrogen Storage System
The dynamics of the stored hydrogen H in the tank is where the logical power auxiliary variables of the electrolyzer and the fuel cell ν e (k) = P pr (k)Γ ON pr (k) and ν f (k) = P co (k)Γ ON co (k) are required to hide the non-linearity introduced by the product of two decision variables.The auxiliary variables can be written as linear constraints as reported in [43].η e and η f are the efficiencies of the HESS devices, T s is the sampling time, and H ls (k) models the use of the stored hydrogen for supplying demand from external agents.

E. Electrical Storage System
The dynamics of the stored energy in the BESS is given as a function of the stored energy at the previous time-step and the power P b (k) exchanged with the storage units during its charging and discharging.The activation of charging and discharging modeled by the Boolean variables Γ ON ch and Γ ON dc , respectively, depends on the sign of P b (k) (positive when discharging and negative when charging), i.e., According to the MLD framework, the definition in ( 23) can be equivalently rewritten in terms of linear inequalities.Moreover, charging and discharging affect the dynamics of the stored energy through different efficiencies, namely η c and η d , respectively [19], by resulting in where soc(k) denotes the stored energy at the time-step k, c max is the maximum storage capacity, Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
ν dc = P b (k)Γ ON dc (k) are such that the power P b (k) exchanged with the storage unit is defined as P b (k) = ν dc (k) − ν ch (k).Note that the charging and discharging efficiencies η c and η d can be possibly updated when a significant deviation with respect to the current adopted values is measured.

F. Power Balance Constraint
The power balance at a given time-step k is (25) where P re = P w + P pv , P b = ν d − ν c and P h = ν e − ν f are the RES power, the BESS power, and the net-hydrogen storage power, respectively, P g is the exchange power with the grid and P s is the available power in the system.In order to model the batteries of EVs, the slack variable ν ev = P ev δ ON ev has to be considered, where δ ON ev is a logical variable such that δ ON ev (k) = 1 if the BEV is connected as external consumer and δ ON ev (k) = 0 otherwise.Note that the batteries of BEVs are modeled similarly to the BESS in (24) but with the addition of the logical variable δ ON ev .

G. Physical Constraints
The hydrogen devices, the stored hydrogen in the tank, and the stored power in the battery have to keep within the minimum and the maximum constraints, i.e., where P min d , P max d , with d ∈ D, H min , H max , soc min , and soc max are the minimum and the maximum bounds of the power of the hydrogen devices (electrolyzer and fuel cell), the power of the battery (charging and discharging), hydrogen tank, and battery storage, respectively.It is worth to highlight that the constraint (26c) introduces a further dependence between soc(k) and the battery power P b (k) since P b (k) must be such that the BESS must operate in a range of soc(k) values to avoid over and undercharging that remarkably reduce the number of admissible cycles.

IV. CONTROL STRATEGY
The adoption of ESSs allows to cope with the uncertainty of the RESs and enables additional services, e.g., the injection of smooth power.Hence, the control architecture distinguishes between the microgrid in the intraday market when no energy/hydrogen is exchanged with external consumers and the microgrid with external consumers, where additional costs are included for the optimal tracking of their requests.

A. Cost Functions
This section presents the cost functions included in an optimization problem for the requirements of the controller.In order to improve the readability, it is useful to define the set M = {1, 2, . . ., 24} containing the samplings considered in the proposed control, which derive from the sample time of 1 h.

1) Grid Cost Function:
The grid cost function is related to the possibility to either buy from (if P g (k) < 0) or sell energy to (if P g (k) < 0) the utility grid.The possibility to participate to the electricity markets can be leveraged to maximize the energy selling revenue or economical energy buying cost from the main grid.Then, the cost function for selling/buying energy to the main grid is given by where T s is the sampling time, k is the current time instant, j = 0, 1, . . ., T − 1 accounts for future time instants, T is the discrete time optimization horizon, and ν sell and ν buy are given in (20) to model the possibility of purchasing/selling energy from/to the utility grid during market operations at time-step k over the control horizon H, respectively, and c sell and c buy are the corresponding energy prices.It is important to highlight that the purpose of the intraday market is to handle electricity transactions for the following day through the presentation of electricity bids by market participants.

2) Hydrogen Operating Cost Functions:
The hydrogen operating cost functions are related to the operation of the hydrogen devices (electrolyzer and fuel cell).In order to tackle their expensive costs, the life cycles are defined based on the number of working hours and state switches.To save devices' lifetime and consequently enhance cost saving, not only the working hours for the hydrogen devices have to be minimized, but the devices' startup/shutdown/standby cycles and the fluctuations in the operation conditions are also included since operational switchings prematurely reduce the life of the devices.Consequently, the hydrogen operating cost functions are the combination of three terms: the hydrogen devices' working costs, the degradation cost of the devices associated to their switching and the energy spent in keeping the units warm during the standby mode.Hence, the cost functions can be defined as follows For the reader's convenience, the term , with o ∈ {pr, co}, accounts for the devices' operating power only at their ON states, according to the replacement and maintenance costs (c rep o and c OM o ) associated to their cycles lifespan (NH o ).The term c α β Δ α β,o (k + j), with α, β ∈ A and β = α, accounts the working switches from α to β for each device, according to the cycle cost of the state transition from α to β, denoted by c α β .The third term P α o π sp (k + j)Γ α o (k + j)T s represents the energy spent to keep the devices warm in their standby mode, according to the power spot price π sp .
3) Load Tracking Cost Function: The load tracking cost function is included in the optimization algorithm to take into account the tracking of the forecasted electric reference demand.Such a function is defined by the cumulative square error between the available system power and the reference signal, as follows where P s and P req are the available power in the system and the requested load, respectively.

4) Hydrogen Tracking Cost Function:
The hydrogen tracking cost function is related to the satisfaction of requests by the external hydrogen consumer, i.e., FCEVs.In particular, the stored hydrogen in the tank is used to meet the external hydrogen consumer requests H req with a free decision variable H ls .Hence, the corresponding cost function is given by

5) Energy Exchanging With BEVs Cost Function:
The cost function of the energy exchange process with BEVs is given by where ν ev is the final exchange of power delivered by the demand of BEVs and P exc is the initial requirement of power from external agents.

6) Battery Cost Function:
The battery cost function is related to the lifetime of the battery, which can be expressed as a function depending on the number of working hours.However, to save devices' lifetime, not only the working hours for the battery storage system is minimized, but the fluctuations in the operation conditions are also included since operational switchings prematurely reduce the life of the device.Therefore, the battery cost function is expressed as where c bat is the battery capital cost, N cyc b is the battery working cycles, c deg ch and c deg dc are the battery degradation costs for charging and discharging, respectively, and c α β are the device cycle costs associated to the corresponding logic states transition.Focusing on the battery cost function, it is possible to recognize that the first two terms are similar to the corresponding ones in the hydrogen operation cost function.The last terms, instead, are introduced to avoid high-stress ratio in the charging and discharging process.It is important to highlight that the slack variable ν ON = P (k + j)Γ ON (k + j), with ∈ {ch, dc}, is required to hide the non-linearity introduced by the product of two decision variables.

B. MPC Algorithm
The control strategy is based on the MPC framework [43], whose architecture is shown by the conceptual block in Fig. 3.In the diagram, the vectors u u u 0 and u u u in and the matrix U U U include the initial conditions, the inputs and the outputs of the proposed controller, respectively.According to the MLD framework, for a given time-step k, the cost functions are minimized and the corresponding optimal control sequence is determined for j = 0, . . ., T − 1 steps ahead, where T is the control horizon, but only the first sample of the control sequence is applied to the system before the horizon is advanced one step.The purpose behind choosing MPC policy is to simultaneously handle constraints, delays and system disturbances that may occur on the plant even though they have not been explicitly modeled.The proposed control compares for the following day the forecasts of the RESs power P re and load demand P req , and computes the optimal scheduling of the devices, the evolution of the hydrogen level H and the state of charge soc for the next few hours.Then, the references determined by the MPC strategy will be used in the secondary control layer to compensate for any deviations of the real-time renewable generations and electricity demand from the forecasted one in short term.
In the controller, the set of the decision variables at the generic step k + j is given by where  State transition constraints ( 7)-( 10), State constraints ( 13)-( 14), Utility grid constraints ( 19)-( 21), HESS dynamics (22), BESS dynamics (24), Power balance constraint (25), Physical constraint (26), (34) where the global cost function J GF (k + j) is given by J GF (k + j) = ω g J g (k + j) + ω pr J pr (k + j) + ω exc J exc (k + j), (35) with J g (k + j), J pr (k + j), J co (k + j), J b (k + j), J t (k + j), J H (k + j) and J exc (k + j) are the grid cost, the hydrogen devices operating costs, the battery cost, the load tracking cost, the hydrogen tracking cost and the energy exchanging with BEVs cost function as defined in ( 27), ( 28), ( 32), ( 29), ( 30) and (31), and ω g , ω pr , ω co , ω b , ω t , ω H and ω exc are suitable weights selected through numerical simulations to define a trade-off between goal satisfaction, power consumption and equipment degradation.The optimal sequence of the problem in ( 34) is given by Ĥ * k = {H * k , H * k+1 , . . ., H * k+T −1 }, where H * k is the optimal value of H k at the time-instant k + j.By receding the horizon, only the first optimal control input from the optimal sequence is set to the energy storage systems.For the sake of clarity, Algorithm 1 explains the working of the proposed MPC approach.

V. SIMULATION RESULTS
The proposed controller has been tested through simulations that take into account wind and solar profiles, and electric and hydrogen loads.Because of the connection with the main grid, the energy market price profile is considered too.The numerical results show that the proposed controller is able to correctly satisfy the overall system constraints and achieve the set control objectives of the research under study.The analysis and the experimental validation are conducted through simulations according to the considered control.

A. Simulation Setup
In order to satisfy the validation of the proposed control in this research study, the control horizon, simulation horizon, sampling time, and the main characteristics of the device parameters have to be defined.Firstly, the controller sampling time is chosen as T s , synchronized with the RESs installed at the integrated system, located in the United Arab Emirates.Likewise, for the coupled hybrid-ESSs along with the RESs, a prediction horizon of N hours is used in the MPC to store/charge or consume/discharge hydrogen/power through the hydrogen tank/battery without violating the storage hard physical constraints.A longer prediction horizon can also be selected, but the increased prediction horizon results in high computation time.Therefore, a choice of N hours is selected based on the trade-off between the feasible solution and the computation time.For the day-ahead market, numerical results are conducted over the simulation horizon of 24h with a sampling time of 1h for the utility grid interaction.Table I summarizes the main characteristics of the device parameters.Since the control strategy implemented in this paper will be integrated into the Khalifa University laboratory microgrid, which is currently under construction in Abu Dhabi, United Arab Emirates, data from the literature are adopted for the parameters not yet defined.The simulations have been carried out in MATLAB with YALMIP tool and GUROBI optimizer, and the optimization problem of the microgrid under investigation is solved in 25s on a PC with an Intel Xeon (R) W − 2245HQ 3.9 GHz with 128 GB RAM.Fig. 4 shows the requested load, the RES power, and the price profile considered in the scenario.

B. Case Study
The control goal of the microgrid dispatched without external consumers is to meet the requested load and participate in the electricity market.Fig. 5 provides a summary of the strategy's effectiveness by showing that the proposed controller allows the achievement of the ESS optimal behavior.Particularly, in Fig. 5, it is possible to see that the available system power is adequately filtered when tracking the reference.The correct working of hydrogen devices and batters depends on the power  surpluses or the deficit scenarios explained with the help of power flow towards or from the ESSs.In this configuration with the ESSs, the powers P d , with d ∈ D, are always positive, and all variables cannot be different from 0 at the same time.
Their effect can be simplified by considering only two variables, defined as P h = P pr − P co and P b = P ch − P dc , which are the net hydrogen storage power and battery power, respectively.After meeting the load demand, any excess of renewable power is either shunted towards the electrolyzer for hydrogen production or the battery for the charge, while the consumption of hydrogen and the discharge are ON during low or nearly zero RESs hours.Fig. 7 presents the hydrogen devices' powers, the battery power, the stored hydrogen in the tank, and the stored energy in the battery.It can be observed that the sold power revenues are maximized, depending on the energy price profile and the available power.As shown in Fig. 8, during the 24 hours except for the hours 12-18 and 22, the controller tends to sell as much as possible.Then, the controller tracks successfully the users' requests and supplies the contractual loads.
The control goal of the microgrid dispatched with FCEVs and BEVs is to track the requested hydrogen/electric load as a fuel for external consumers.For FCEVs and BEVs, the hydrogen production and the exchange of power with the BEVs have the unconditional highest priority among all objectives, respectively.In particular, at the first step, the requested forecast demand for external agents is addressed through the minimization of the quadratic deviation from the expected hydrogen and electricity demands.Then, the ESSs' operating costs, load tracking and the market participation are addressed by taking the optimal value of hydrogen level and the exchange of power with the BEVs as further constraints in the second step.Over the control horizon T , the exchange of energy and hydrogen correctly meets the requested demand by the external agents as shown in Fig. 9.

C. Comparison With Literature Results
In order to further demonstrate the paper's findings, this section shows a comparison between the MPC method proposed in this paper and two pertinent literature-based techniques proposed in [19] and [7], respectively, by taking into account a 24-h scenario and a one-week scenario.The authors in [19] have proposed an MPC scheme for the optimal economic schedule Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.  of a hydrogen-based microgrid including hybrid-ESSs and the ultracapacitor and then tested it at the University of Seville in Spain using a lab-scale microgrid.The degradation issues of the fuel cell, the electrolyzer, the ultracapacitor, and the batteries are included in the dynamic models.The degradation issues, however, are less detailed than our model, and, in particular, only the degradation issues caused by the OFF and the ON states are considered.The authors in [7], instead, have proposed an MPC approach for the management of grid-connected wind farms with HESS and local loads.The strategy increases revenue through participation in the electricity market while minimizing the number of switches between operating modes of the HESS.The controller has been tested at the Raggovidda wind park in Norway using a weekly connected-microgrid.However, the microgrid does not integrate PV panels, and then only wind is considered as the RES in the system.Moreover, in order to consider the slow response of the devices, the models proposed in these papers include virtual states, by increasing the number of decision variables, and then open-source solvers cannot be used.
In order to ensure a rigorous comparison, the operation of the BESS, solar panels and external consumers are assumed to be disabled, since the authors in [7] have proposed a control strategy for a microgrid that includes only the HESS and wind farm.Moreover, for the comparison with [19], it is assumed that only the ON-OFF and OFF-ON transitions are permitted since the STB state is not included in their work.Moreover, it is important to highlight that the ON-OFF/OFF-ON transitions are characterized by higher costs than the OFF-STB/ON-STB ones.
Figs. 10-15 show the state switches of the electrolyzer and the fuel cell in the 24-h scenario according to the controllers under investigation.It is possible to observe from Figs. 10 and 11 that the ON-OFF strategy in [19] leads to a greater number of ON-OFF switches compare to those shown in Figs. 14 and 15 which are determined according to the strategy proposed in this study.Similarly, from the comparison between Figs. 12 and 13 with Figs. 14 and 15, respectively, it derives that the strategy presented in [7] generates a larger number of ON-OFF switches compared to our proposed strategy which privileges switches to STB.As a consequence, the devices' degradations are reduced and the     devices' lifespan is increased, when the proposed strategy is adopted.
Table II reports the characteristics of the proposed strategy and those in [19] and [7] and summarizes the results of their comparison obtained with the one-week scenario.From the comparison, it follows that taking degradation aspects into account allows for setting control references that reduce avoidable unit switchings, so as to preserve them from premature degradation and increase their lifespan.This results in maximizing the life span of such expensive devices while decreasing the states switching costs.In particular, when the switching costs and the degradation costs are accounted for in the optimization, the algorithm leads to a reduction in the operating costs by 25% (this estimated value  [19] AND [7] ACCORDING TO SIMULATION HORIZON will be verified on the physical plant, once the construction and commitment of the system are terminated) with respect to the case when they are neglected (this is the case of the revised literature).This reduction results in more than 1500 commutations saving per year.Moreover, it is important to highlight that for the controller proposed in this research study all the commercial and open-source solvers give successful solutions.

VI. CONCLUSION
This work proposed a novel control strategy based on the MPC framework for a wind and solar microgrid, which includes HESS and BESS units, and the interaction with external consumers of hydrogen and electricity (FCEVs/BEVs).One of the main contributions of this paper is the development of a new MLD model for the ESSs' operations, which is integrated into the control.Such a model has a less number of variables compared to the models in the literature, and then its complexity and computational time are reduced.In order to increase device lifespans and efficiency, an optimization problem, which includes the cost that the ESSs' operation introduces at each state transition, is proposed.The validation of the control strategy has been carried out through numerical simulations, including different wind and solar scenarios.The proposed control allows one to increase the battery lifetime, and the maintenance costs reduce.
The control strategy implemented in this paper will be integrated into the Khalifa University laboratory microgrid, which is currently under construction in Abu Dhabi, United Arab Emirates.Future works will also include more sophisticated MPC strategies, e.g., the stochastic MPC, to take into account the regulation service and uncertainties of the forecast loads.Finally, the relaxed signal temporal logic specifications will be used for encoding the MIP constraints in a formal language, which allows one to relax the logic decision variables as real numbers to further reduce the computation time.

1 j=0J
and the other vectors are similarly defined.The optimization problem is minH k T −GF (k + j) s.t.State actions constraints (3)-(5),Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.

Algorithm 1 :
MPC Algorithm for the Wind-Solar Microgrid.

Fig. 15 .
Fig. 15.Fuel cell switches according to this research study.
1 if the device intends to stay in the state α at the time-step k, and Υ α d (k) = 0 otherwise.For the sake of clarity, consider the following examples.Υ ON d (k) = 1 and Γ STB d (k) = 1 represent the case in which the operation d is in the state STB and should shift in the state ON, but due to the warm-start process it still remains in STB.Instead, Υ STB Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply. in order to avoid damages, the powers of the ESSs in their ON state must be bounded, i.e., P d ∈ [P m d , P M d ] for all d ∈ D, where P m d and P M d are lower and upper limits of the operation powers.Specifically, the power associated to the operation d is constrained as d (k) = 1 and Γ STB d (k) = 1 denote the situation in which the operation d is in STB and there is no intention of changing state.The logical variable Υ α d , α ∈ S and d ∈ D, is connected to the relevant power of the corresponding state through constraints that allow the correct functioning of the system.For instance,

TABLE I PARAMETERS
[44]WEIGHTING FACTORS SET IN THE MPC STRATEGY BASED ON THE CIRA PROJECT UNDER THE KUST RESEARCH INSTITUTE AND ON THE LITERATURE[7],[44]

TABLE II COMPARISON
OF THE PROPOSED MODEL WITH