Power Allocation and Energy Cost Minimization in Cloud Data Centers Microgrids: A Two-Stage Optimization Approach

Data centers are becoming an important asset in today’s connected and intelligent world. Indeed, with the emergence of $5G$ networks, the growth of Internet of Things (IoT) and cloud computing, the data centers are increasingly becoming an essential component in delivering our daily services. On the other hand, cloud data centers, are outfitted with power-hungry servers and electrical installations that require enormous quantities of energy. In addition, operating cloud data centers in microgrids can be more reliable and sustainable than having them managed directly by the smart grid operator. However, microgrids have to deal with the high energy cost that their data centers may incur. In this context, managing the power allocated to the data centers and minimizing microgrids energy cost is a challenging problem. In this paper, we model a two-stage optimization approach in a microgrid-cloud architecture. In the first stage, we consider that the cloud data centers are run by multiple providers and try to get as much power as possible from the microgrid, to store this energy and to be able to execute the maximum of users applications. Such a power behavior requires an optimal power assignment from the microgrid to mitigate the risk of blackouts and power outages. Thus, the data center’s huge power demand was modeled as a non-cooperative game. The microgrid controller calculates the optimal power that will be assigned to each data center according to its Power Usage Effectiveness (PUE), number of real-time applications and its network bandwidth usage. In the second stage, the microgrids try to minimize their energy cost by optimally purchasing power from the main grid and the other migrogrids, and by selling back their stored energy. We compare our approach with three existing power minimization approaches: (i) our previously presented scheme called “Basic Game Scheme” (BGS), (ii) traditional and (iii) price-based approaches. Simulations results show that our two stage optimization approach is up to 25% more effective in terms of energy cost. In addition, our scheme promotes MGs green energy usage which significantly reduces power load rate and CO2 emission with a percentage up to 52% comparing to “BGS” and price-based scheme.


I. INTRODUCTION
Over the past few years, the use of digital technology has become inevitable and has changed from a modest efficiency driver to a critical force for progress in all business industries. In fact, most companies are aware of this development and start aligning their existing business processes and customer experiences to the demands of today's markets. The digital The associate editor coordinating the review of this manuscript and approving it for publication was Chun-Wei Tsai . transformation process must, on one hand, be adapted to new business models, and on the other hand, deal with the colossal volume of data and transactions generated by the companies departments [1]. Therefore, a flexible and automated infrastructure is needed to better control this data deluge. Cloud computing is a solution that can meet these needs. More and more companies are migrating their infrastructure to cloud computing data centers (DCs). According to Gartner Inc [2], the global market for public cloud services is expected to grow with 55.5% in 2022 to reach 331.2 billion VOLUME 10, 2022 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ dollars, compared to 214.3 billion dollars in 2019. Moreover, digital transformation is not the only factor responsible for the development of cloud computing. The emergence of Internet of Things (IoT) is significantly increasing the use of this technology. In fact, their computation, storage and energy constraints have led IoT devices to migrate their intensive tasks to cloud DCs. Furthermore, with the advent of 5G networks, bandwidth and transmission requirements will continue to increase over time, up to 100 times more than 4G networks require [3]. Therefore, the importance of cloud data center functions in terms of storage, compute and data management is increasing at an exponential rate. An increasing number of DCs have been built around the world to store the massive amount of data generated by various services such as Industrial IoT, smart homes, autonomous vehicles, etc. Despite the tremendous progress made in building energy-efficient servers and network equipment, the energy costs incurred by the DCs have increased dramatically with the growth in demand for these services. For example, the total energy cost of DCs in the United States is estimated to be 7.4 billion dollars per year [4]. Furthermore, it is estimated that the data center industry accounts 1.4% of the global energy consumption [5] and this percentage tends to rise to 8% in the next five years [6], [7] [8].
Several efforts have been done to minimize the energy consumption of DCs [9] [10] [11], [12] [13]. These solutions consider only the DCs' servers and cooling system energy efficiency. We must note that cloud DCs have the main characteristics of being distributed, flexible and can use on-site generators and energy storage units to better manage their energy consumption. Energy providers can exploit these features by proposing customized services to reduce the DCs energy consumption [14]. Nevertheless, this cannot be afforded by the traditional electricity networks, which cannot offer a real-time visibility of the DCs energy behavior to energy suppliers.
To deal with this problem, the smart grid (SG) has emerged to provide an intelligent power infrastructure. The fusion of power infrastructure, information and communication technologies has offered additional services in terms of responsiveness, flexibility and security to all the energy system components. Indeed, SGs can integrate Distributed Energy Resources (DERs) [15], using several technologies like: fuel cells, photovoltaic panels and wind turbines, to create smart MGs. A Microgrid (MG) is a distribution network that incorporates a variety of DERs that can be optimized and aggregated into a single system. Thus, a MG is capable of balancing loads and running in an islanded mode, whether connected or not connected to a traditional utility power grid. Integrating MG into the SG architecture can improve reliability. This can be achieved by supplying back-up power in case of a grid failure or a rise in energy prices [16]. The MGs also help to minimize CO2 emissions by providing clean energy for customers [17]. Therefore, MGs seem to be an important asset for managing cloud DCs energy.
In this paper, we consider the role of MGs in managing the allocation of energy to DCs and model a two-stage optimization approach in a microgrid-cloud architecture. In the first stage, we consider that the cloud DCs are run by multiple suppliers and aim to have the maximum of energy from the MG, to store their energy and execute the maximum of users applications. Such a power behavior requires an optimal power assignment from the MG to mitigate the risk of blackouts and power outages. Thus, we model this DCs behavior in requesting power from the MG as a non-cooperative game. The MG controller calculates the optimal power to assign to each DC according to its Power Usage Effectiveness, number of real-time applications and its network bandwidth usage. In the second stage, the MG aims to minimize its energy cost by buying the optimal quantity of power based on its DCs power assignment game, and by selling the surplus of its stored energy to the other MGs present in the system. This paper is an extension of our previous work [18] and the major contributions of this paper are as follows: • We designed a microgrid-cloud architecture with a two ways energy exchange where each MG can buy and sell energy from/to the SG and the other MGs.
• We enhanced our previous work [18] by formulating a two-stage optimization approach using game theory and linear and non-linear programming.
• We designed our game payoff function as a nonlinear optimization problem and determined the optimal solution.
• Considering the assigned power to data center, we formulated the MG energy cost minimization problem as a linear optimization problem and solved it using Matlab optimization tool [19].
• We compare our two-stage optimization scheme with three other schemes, and show that our proposal is more efficient in terms of energy cost.
The remainder of this paper is arranged as follows. The following section provides a literature review of related work. Section III presents our system architecture. Section IV details our game formulation for power allocation. Section V presents the formulation of MGs energy cost minimization problem. Section VI presents the simulation results of our two-stage optimization scheme. We conclude the paper in Section VII.

II. RELATED WORK AND MOTIVATION
A. LITERATURE REVIEW Improving energy efficiency and minimizing cost of energy of DCs is becoming an interesting topic of study for both academia and industries. Several research works have drawn SG-driven energy efficiency techniques for greening cloud DCs. Different SG's functionalities especially demand response and dynamic pricing have been adopted using different architectures. Wang et al. [20] formulate the dynamic interactions between SG and DCs as a two-step price optimization problem. In the first step, they balance the electrical load by using dynamic pricing. The DCs respond to the energy prices, in the second step, by efficiently allocating workload to reduce their overall energy cost. Lu et al. [21] consider the bulk data transfer between DCs to reduce the operational costs of geo-distributed DCs. They formulate an effective two-stage optimization approach to reduce the energy-cost of DCs in a multi-electricity market environment. The proposed approach finds for each bulk data transfer the optimal demand division along the existing time slots, and then determines the optimal route and schedule for each period. Ghobaei-Arani et al. [34] study virtual machine placement to optimize the energy consumption of cloud DCs. They design a novel mechanism grouping both virtual and physical machines, that consider the power consumption, absolute deviation when placing virtual machines as well as the service level agreement deviation in DCs. Sadegh Aslanpour et al. [35] propose a flexible resource provisioning including power, for cloud computing providers. The proposed scheme is 3D by including service, users, and resource-aware features in enabling resource allocation. In addition, the authors consider the hidden knowledge on the Web users' behavior to deal with under-provisioning and over-provisioning of cloud resources. Another resource provisioning scheme is proposed by Ghobaei-Arani et al. [36]. The authors design a novel meta heuristic-based clustering scheme to satisfy cloud workloads. They combine between the fuzzy C-means technique and genetic algorithm to determine similar clusters, based on user's QoS needs. They also leverage a gray wolf optimizer approach to take a suitable decision about serving cloud workloads. Zhou et al. [31] [32] address the challenge of data center demand response to deal with any operational instability. They propose new pricing models for distributed green DCs, between multiple smart grids and cloud data centers. Thus, energy cost optimization problem is formulated and resolved at the cloud side, while a cooperative game is modeled at the smart grid level [37]. Similarly, Chen et al. [38] leverage distributed cloudlets on the network edge, to design a new online mechanism for power demand response [39].
In addition to considering spatial and temporal price variations in Smart grid -Cloud (SG-C) architectures, various works have considered clean energies like solar or wind energies in order to minimize energy cost and reduce gas emissions for environmental effects. Kawsar et al. [22] try to minimize the energy cost of DCs and propose an approach which schedules DCs workload, by considering available renewable energy, cooling subsystem and electricity rate structure. In the same context, in [23], Gu et al. investigate a set of DCs, supplied with both self-generated renewable energy and grid power in a SG-C system. They also consider the possibility of selling stored energy back to the grid. They develop an algorithm that minimizes the DCs's energy cost. An expansion of this proposal is discussed in [24] it presents a green scheduler that reduces cloud DCs energy cost as well as carbon emissions. Chiheb Ammari et al. [40] address delay-constrained applications in distributed DCs environment. They design a new model for cost and energy-effective scheduling of various applications, while taking into account delay constraint of applications. Thus, the authors formulate a cost reduction problem before resolving it using a modified firefly algorithm. Yuan et al. [25] use the spatial variation of electricity prices and renewable energy power generation for jointly optimizing green DCs provider's revenue and its energy cost. They formulate the problem as multi-objective optimization problem and solve it by an improved multi-objective evolutionary algorithm. Lin et al. [41] address the concern of both carbon emissions and energy consumption of cloud data centers. They explore carbon emission reduction of distributed DCs, when leveraging renewable generations. Thus, a new queue algorithm is designed making efficient job scheduling of the data centers. The authors could achieve a good precision matching of the renewable generation and workload. Zhou et al. [33] study the temporal and spatial variabilities of the electricity carbon in order to make the cloud more green. The author propose a novel optimization framework that considers the service level agreement requirement, electricity cost, and emission reduction. They leverage Lyapunov optimization techniques to resolve the designed framework [42].
In term of energy efficiency, the association of cloud DCs with a SG controller has contributed to important performance. However, some studies suggest that operating cloud DCs in MGs can significantly enhance energy efficiency since MGs are characterized as networks of distributed energy resources that bolster resiliency. Kim [43] considers DCs energy price uncertainties and unpredictable users' demands and formulates a novel two-phase bargaining model. At the first phase, he used Stackelberg game to decide of the dynamic energy price. And at the second phase, he develops a migration bargaining game to balance the workloads among the DCs. Ding et al. [26] propose an innovative energy management approach to reduce the operation expense of a data center running in microgrid. The waste heat collected from data center operation is optimally designed with other resources in the integrated energy management model to minimize the operation cost of data center. Lyu et al. [44] consider data center's dynamic voltage frequency scaling (DVFS) and thermal inertia, and propose a novel optimal sizing method for the energy station in the multi-energy system (MES), which can realize the co-optimization of energy flow and information flow. Yu et al. [27] consider carbon emissions while minimizing the energy cost of DCs in a smart microgrid-cloud architecture. They use stochastic optimization to formulate the problem of minimizing CO2 emission rate and energy cost, they solve it using Lyapunov optimization method. They further analyze in [28] the energy management issue for cloud DCs microgrids and seek to reduce the electricity expense considering battery charging and discharging capacity parameters. Baris et al. [29] consider the influence of increasing data center energy usage on MGs and suggest an innovative solution that takes into account all demand limitations and minimizes the instability-causing effects on grids. Anis et al. [30], [45] study a SG-C architecture in which the DCs are both powered by their self-produced power and the energy acquired from the grid. They propose a solution to efficiently dispatch power to cloud DCs. It consists on determining the optimal amount of power to assign to each DC according to three main indicators: workload charge, renewable energy usage and number of running real-time applications.

B. DISCUSSION
TABLE 1 presents a comparative study between the above-mentioned works and our proposal presented in this paper. The comparison is done according to five criteria: minimizing energy cost, minimizing gas emission, minimizing power grid load, integrating renewable energy and the use of MGs. We notice that most of the proposed solutions performed load controlling in DCs with scheduling/migration, peak power shaving and load shifting. In addition, we can observe that considering renewable energy and energy price remain two major factors used for enhancing cloud DCs power efficiency. Yet, limited works have investigated the potential role of MGs in managing power assignment to cloud DCs, and they have not considered how changes in data center power consumption may affect the power grid. Considering these shortcomings, we proposed in our previous work [18], a MG-cloud architecture and investigate the grid power assignment problem to cloud DCs. But, we did not consider the MG energy cost when allocating power to DCs and there were no energy or information exchange between the MGs. In contrary, in this work, we assign power between the DCs while reducing the MGs energy cost. Also we consider a SG-C architecture where the MGs can exchange information and energy with each other.

III. SYSTEM MODEL
In this section, we present our system model and detail the architecture of our system. The main parameters used in our system are summarized in TABLE 2.
As shown in Figure 1, in our architecture, we consider a SG controller which is in charge of managing the supply of energy to its consumers. The SG controller is related to power plants that supply energy to J geographically dispersed MGs. Each MG j denoted by m j , ∀j ∈ J with J = {1, 2, . . . , j, . . . , J } is responsible for supplying n j DCs with power purchased from the main grid and its wind energy. We chose wind turbines as our sole source of renewable energy because of their effectiveness in producing electricity and reducing CO2 emissions compared to photovoltaic panels [46] [47]. In order to manage the intermittent nature of renewable energy, each MG is equipped with batteries to store its energy.
Choosing to use MGs in our system and connecting them to DCs and a SG is mainly related to our problem and our goal. In our work, we try to minimize energy cost and gas emissions, which requires an entity that manages the DCs energy, and the MG is responsible for that in our system. In addition, we consider in our system, a two ways energy exchange where each MG can buy energy from both the SG and the other MGs. Also, it can sell its stored energy to other MGs. In a SG system, a two-way communication can be enabled between the utility providers and the consumers. Thus, in our proposal, the DCs and the SG and MGs' controllers periodically interchange power information through Power Line Communication (PLC). Therefore, we have, on one hand, a vertical communication where the SG and MG controllers have a full view of each data center's energy performance. On the other hand, we have a horizontal communication between MG controllers that periodically exchange the state of their energy charge and the corresponding selling price [48].
The homogeneous DCs running in each MG are managed by different cloud providers. Each data center i supplied by a MG m j , ∀j ∈ J with J = {1, 2, . . . , j, . . . , J } is denoted by dc ij , ∀i ∈ N with N = {1, 2, . . . , i, . . . , n}. We denote by T = {1, . . . , t, . . . , τ } the period of power assignment divided to τ = 24 time slots. We suppose that each dc ij , in each time slot t ∈ T , runs Rt t ij of real-time applications, uses B t ij of bandwidth and consumes ec t ij of energy. We also consider that the grid can supply each MG m j with a maximum amount of power y max j and the DCs can similarly purchase a maximum quantity of power q max ij from the microgrid. We also assume that DCs cannot buy energy from the grid directly. Therefore, in order to optimally allocate power to the DCs, the MGs consider three main data center's metrics: PUE t ij ,CAR t ij and NBU t ij which respectively are the power effectiveness usage, critical applications rate and network bandwidth usage [49] [50]. We define these metrics as follows: 1) The Power Usage Effectiveness PUE t ij : is the most widely used energy efficiency indicator for DCs. In each t ∈ T , reflects the ratio between the overall power consumed by the DC and the energy consumption of its IT equipment [49].
2) The Critical Applications Rate CAR t ij : calculates the ratio of the executing real-time applications in a DC to the sum of real-time applications executing in all DCs powered by the same microgrid.
3) The Network Bandwidth Usage NBU t ij : represents the ratio of the data center used bandwidth to the data center's bandwidth capacity. To perform their requests and enhance the cloud providers' business profit, the DCs compete to get the maximum of energy from the microgrid. Such a power behavior requires an optimal power assignment from the MG to mitigate the risk of blackouts and power outages. Thus, in the first stage, we use game theory to model the uncooperative behavior of DCs in demanding power from the microgrid, where the latter calculates the optimal power to assign to each data center according to its respective metrics: PUE t ij ,CAR t ij and NBU t ij . Then, based on the power assignment game result and its stored energy state, the MG tries, in the second stage, to minimize its energy cost by optimally purchasing power from both the main grid and the other MGs present in the system.

IV. STAGE 01: DATA CENTERS' GAME DESCRIPTION FOR POWER ALLOCATION
This section describes the DCs game formulation for power allocation problem in subsection IV-A. Subsection IV-B details our game solution.

A. GAME FORMULATION
To model the DCs' power assignment as a non-cooperative game, we need to define the players, the strategies and the payoff function of the game. Hence we define the game: G = N , St ij , Gn ij i∈N ∀j ∈ J where: • N : represents a set of n players which are in our case the DCs, dc 1j , . . . , dc ij , . . . , dc nj .
• St ij ; ∀i ∈ N : are the strategies of the players in the game. We define the strategy in our game as the power quantity that a dc ij requests from the microgrid. Therefore, the strategy is q ij and varies between zero and q max ij . • Gn ij :St ij → R: the payoff function of player dc ij ∀i ∈ N . The aim of each player is to maximize its payoff function, 0 ≤ Gn ij ≤ q max ij , ∀i ∈ N , to rise its benefits.
To provide a fair power dispatching, the MG controller allocates power to DCs according to their three defined metrics. Thus, the payoff function is designed to involve four functions: a utility function which determines the energy demand of DCs for having a high amount of energy, and three metric based cost functions. We define these functions as follow: 1) Utility function Ut ij (q t ij ): is modeled such that the more the DC rises its power quantity value the higher is its benefit. We opt to design this function with a strictly concave and widely used in literature [51], the logarithm function. Therefore, the utility function of dc ij is formulated as follows [18]: 2) Power usage effectiveness cost function: reflects the cost of a data center in terms of its power quantity demand q t ij and its PUE t ij value. The more the data center is power effective the low its cost is. And the low the data center is power effective the high its cost is. Hence, we define it as follows [18]: where: IT _ec t ij is the power consumption of the IT equipments of the data center and ec t ij its total power consumption.
3) Cost function of the Critical Applications: this cost function aims to reward a data center player when having a high number of real-time applications compared to the other DCs running in the same microgrid, and penalizes it when having a low real-time applications rate. Hence, we define this function as follows [18]: 4) Cost function of the Network Bandwidth: similarly to the above cost functions, this function penalizes the DC based on its power quantity demand q t ij and its bandwidth usage. The higher the bandwidth of a player, the lower is the cost, and vice versa. We give this cost function as follows [18]: where: B t ij and BC t ij respectively are the bandwidth usage value of a data center and its bandwidth capacity. Thus, the payoff function is given as follows [18]: N ) and i = o is the strategies (amount of energy requested) of all the DCs except dc ij .
St is the profile of strategy. The coefficients α, β, γ , δ are set by the MG according to its energy production and needs.

B. GAME SOLUTION
To identify the optimal solution, we model a constrained nonlinear optimization problem and resolve it using the Lagrange multiplier technique. Each DC seeks to maximize its benefit by maximizing its demands on power. Therefore, we model the following problem [18]: To solve the problem (F'), we use two Lagrange multipliers ij and ij to maximize our function. The Lagrange function is given as follows: Thus, the following KKT conditions are satisfied for each player dc ij : We determine the optimal power demand (q t * ij ) for data center dc ij , ∀i ∈ N , ∀j ∈ J as follows: where cdt 1 and 2, are represented by (09) and (10):

V. STAGE 02: MICROGRIDS ENERGY COST MINIMIZATION
This section presents the formulation of MGs energy cost minimization problem.
In the second stage, the MG tries to minimize its energy cost by selling the surplus of its stored energy to the main grid and/or the MGs and by buying the optimal quantity of power based on its DCs power assignment game result.
We denote by SEC t j the state of energy charge of each MG m j in time slot t, ∀t ∈ T . In order to manage the MG stored energy, we set three main energy charge states: S min j , Sl j , and S max j . S min j defines the minimum quantity of power that has to be stored in each MG for emergency use. Sl j denotes the threshold from which a MG can sell its energy. And S max j is the maximum amount of power that a MG can store.

A. MICROGRID POWER BUYING FORMULATION
In order to power its respective DCs, each MG m j can purchase in each t, ∀t ∈ T a quantity yg t j of power from the SG. Each MG m j can also purchase a quantity ym t jk of renewable energy from a MG k, k = j, ∀j, k ∈ J . Therefore, we formulate the total power puchased by a MG m j as follows: where yg t j ≤ y max j (12) The SG and MGs controllers periodically update and exchange their selling power prices. We denote by Pg t j and Pm t jk respectively the SG and the MG m k selling power price to a MG m j where Pg t j , Pm t jk > 0 in each time slot t, ∀j, k ∈ J and j = k.
In our system, the SG uses Real Time Price (RTP) as a dynamic pricing scheme [20]. We formulate the grid price Pg t j as tired electricity pricing which reflects the MG energy storage value as follows: where π t j > 0 represents the base price and sp j > 0 is a sensitivity parameter. The term sp j Sl j SEC t j reflects the ratio of the energy storage threshold from which a MG can sell its energy Sl j to its state of energy charge SEC t j . The grid price Pg t j goes high when SEC t j < Sl j and goes down when SEC t j > Sl j . VOLUME 10, 2022 We consider in our system that each MG m j purchases power based on the average power quantity assigned to DCs in the previous time slot (t − 1) using our game approach. This average power quantity is denoted by Q_Avg t−1 j and we define the following constraint: where Hence, we define the MG power buying cost as follows: x jk is a binary variable used to check whether a MG m k has a quantity of power to sell to a MG m j or not.

B. MICROGRID POWER SELLING FORMULATION
In order to minimize its energy cost, each MG m j sells a quantity ys t j of its stored energy with a power price denoted by Ps t j . The MG can sell its stored energy to another MG m k . To do so, a MG m j has to satisfy two conditions: (1) that its state of energy charge SEC t j has to be greater than the selling threshold Sl j , (2) there is at least one MG m k with power selling price Pg t k that is greater than the MG m j power selling price Ps t j . We use two binary variables x j and b k to express these two conditions as follows: Therefore, we formulate the selling energy profit of a MG m j as follows: where: ω j is a variable that calculates the max of the set V . This set contains the values of the variable b k of all the MGs in the system as V = {b 1 , . . . , b k , . . . , b J }, ∀k ∈ J and k = j. Hence, if ω j = 1, then it exists at least one MG that satisfies the second condition and the MG m j can sell its energy. However, if ω j = 0, then the MG m j cannot sell its energy to any of the MGs which have a better price proposed from the SG. We note:

C. ENERGY COST PROBLEM FORMULATION
In our system, each MG aims to minimize its total energy cost by purchasing the optimal quantity of power and selling its renewable stored energy. So, the total energy cost of a MG m j is composed of two parts: the power buying cost part and the power selling profit part. We denote by C t j the total energy cost of a MG m j at a time slot t,∀t ∈ T , and we define it as follows: We model the energy cost minimization problem as a constrained linear optimization problem. Convex optimization problems can be solved using a variety of methods, we choose to solve it using Matlab optimization tool. We give the formulation of a mirogrid m j energy cost minimization problem as follows: Minimize C t j yg t j , ym t j , −ys t j subject to (11), (12), (13), (14), (15), (16), (17), (18)

D. SEQUENCE DIAGRAM
To summaries the different steps of our two-stage optimization approach. We present in FIGURE 2 the sequence diagram of our proposal, which details the principal interactions between the key actors in our system. As we can see, in the first stage, the DCs request the maximum quantity of power and are periodically sending their parameters values Rt t ij , real-time applications, bandwidth B t ij and power consumption ec t ij to their corresponding MG. The latter will calculates the corresponding costs C 1 ij ,C 2 ij , C 3 ij . and afterward, calculates the gain of the game and the optimal quantity of power q t ij to be assigned to each DC.
In the second stage, the MG buy energy based on the first stage result. It gets the energy prices from the grid and from the remaining MGs in the system. The MG starts to buy energy from the cheapest to the most expensive one based on the quantity of green energy that the MGs have to sell and also based on the power quantity requested by the MG.

VI. SIMULATION AND EXPERIMENTAL RESULTS
We give, in this section, the simulation results using our approach compared with two existing works and our previous work.

A. PARAMETERS AND SIMULATION SETUP
We consider a set of three geographically dispersed MGs that are responsible for supplying respectively n 1 ,n 2 and n 3 homogeneous DCs with their self generated energy. Every 2 hours We execute our simulations over 24 hours, and measure energy demand of each data center, the MGs energy storage state and the energy selling prices at each cycle in two periods: off-peak hours (from 10 pm to 6 am) and on-peak hours (from 6 am to 10 pm). The gain function coefficients values are fixed by the microgrid's controller based on its needs. We set α =0.8 to induce DCs to buy a lot of energy from the grid. We also set β,γ ,δ with the same coefficient value in order to have an equal importance for all the DCs metrics.
The simulations were performed using Matlab on a Dell OptiPlex 7050 (Intel Core i7 CPU 2.90 GHz with 32G RAM). We detail our simulation parameters setting in TABLE 3.
We compare our proposal with three power assignment approaches: • Traditional approach: it is a method of power allocation in which each MG aims to accommodate all the DCs power demands.
• Price-based approach: we assume that it attempts to allocate power based on the price of grid energy. Thus, we assume that it assigns 90% of the grid power to off-peak hours and 70% to peak hours. The remaining required energy is provided by renewable energy.
• Basic Game Scheme (BGS): in the second stage, we compare our energy cost minimization scheme with the approach presented in our previous work [18]. The latter considers a Microgrid-Cloud architecture where the MG fairly assigns power between the DCs based on their network bandwidth usage, green power consumption and their network equipment energy usage. This proposal does not consider dynamic pricing nor energy exchange between the MGs.
In the simulations, we define the same parameters as those used in [18]. Some parameters values are selected in a random manner but still realistic according to [22]. Hence, cumulative average is taken to get unbiased results.
B. DATA CENTERS' POWER ASSIGNMENT Fig.2 gives the metrics varying costs of the DCs of the MG 01, during one day. We should note that we have randomly chosen the MG 01. The objective is to highlight our power allocation approach. So, we could have chosen any MG in our system. We observe in Fig.2-a that the PUE cost of the three DCs is high at off-peak times when the DCs are less power efficient and have not much active servers due to the lower processing load in this period. However, PUE cost is low at on-peak times when the DCs process a higher number of their clients  requests which incurs a higher amount of active servers. Our simulation placed many more real-time applications at peak times versus the number of applications at off-peak times. Therefore, the ratio of critical applications running in the DCs compared to their total running applications, are higher at off-peak period than they are at on-peak period. Furthermore, we can see that the costs of CAR in Fig.2-b vary correctly according to the number of real-time applications of each DC compared to the total number of real-time applications running in all the DCs. In addition, the DCs bandwidth usage is efficient at on-peak hours compared to their utilization of bandwidth at off-peak period. Therefore, in Fig.2-c the costs of the NBU are high at off-peak hours and low at on-peak hours. Fig.3-a gives the assigning power for each DC of the MG 01 during one day using our non-cooperative game approach. We can see that the assigned power is varying over time and is low at off-peak period and high at on-peak period, following their metrics cost variations depicted in Fig.2. In order to demonstrate the performance of our proposal, we compare in Fig.3-b the overall power allocated to each DC during a day using our scheme with the traditional and price-based schemes. We can notice that the power assignment using our scheme is lower than the power assignment using the traditional and the price-based approaches. This is due to our game approach where the MG fairly distributes power between DCs by inflecting penalties DCs based on their different metrics. Unlike our scheme, the traditional approach satisfies the first arriving requests with the overall power quantity demanded, without considering the overall DCs demands and the MG capacity. This can be demonstrated by observing the quantity allocated to dc 31 which needs more power comparing to the others DCs. This power behavior can serious damages. Moreover, the price-based scheme reduces the power assigned to DCs compared to the traditional approach, but it does not take into account DCs metrics, and may restrict other DCs that require more energy than others. This is why the power that has been assigned to dc 11 is greater than the one assigned to dc 21 using the price-based approach. The performance of our scheme is also shown in Fig.3-c that depicts the total power that has been assigned to each MG during 24h. We can see that our proposal considerably decreases the overall power assigned to DCs compared to other algorithms following the number of DCs of each microgrid. In addition, our game-based scheme fairly allocates power to DCs based on their respective metrics, unlike traditional and price-based approaches that can deprive some DCs for having enough energy.

C. MICROGRIDS ENERGY COST MINIMIZATION
We give in this subsection, the performance of our second stage energy minimization scheme and compare it with BGS our previous proposal. We depict in Fig.4-a-b-c the varying power that has been purchased during one day from the MGs and the main SG by m 1 , m 2 and m 3 , respectively. We can see that for the three MGs the power that has been purchased from the MGs and the main grid is low at off-peak times and high at on-peak times, following their DCs power assignment. In addition, the renewable energy purchased from the MGs by m 1 and m 3 is greater than the one purchased from the main grid at any time of the day. Except for the MG m 2 that has a higher number of DCs to supply than m 1 and m 3 which purchased much more power from the main grid, especially at on-peak times when the energy demand is high. The total power that has been purchased and sold by the three MGs is depicted in Fig.4-d. We notice that in general the stored energy of the MGs has been solicited in a significant way in parallel with the main grid power. This is due to our minimization algorithm that considers a variety of energy sources and adopts a dynamic pricing policy. The power that has been sold back by the three microgirds is obviously minor regarding the fixed selling threshold Sl j . We note that the MG m 2 has a lower quantity of power that has been sold comparing to m 1 and m 3 , because it quickly draws on its stored energy due to its high demand for energy.
We compare in Fig.5 our Two Stage Optimization Approach denoted by (TSOA) with our previous scheme (BGS) in terms of energy cost. We depict the varying costs of the power that has been purchased by each MG during one day using our proposal and BGS scheme. We can remark that the energy cost of each approach, in each MG is low at off-peak times when the energy prices and energy demands are low, and high at on-peak times when the energy prices and energy demands are high. Moreover, the energy cost of each MG using our approach is lower than the one using BGS. The latter allocates its power optimally between its DCs, but it uses only two energy sources, its self-generated energy and, in a significant way, the SG energy. Unlike BGS our approach (TSOA) fairly allocates power between the DCs, in the first stage, and in the second stage, considers multiple energy sources with more varying energy prices. Indeed, we can see in Fig.5-d that the total energy cost of all the MGs using our approach is 25% lower than the one using BGS. This can be explained by the fact that the selling prices proposed by the MGs are, in general, much more interesting than those proposed by the SG. This promotes the use of renewable energy while minimizing the total energy cost.

D. CO2 EMISSIONS & POWER LOAD RATE AWARE PERFORMANCE
We use two metrics to assess our two stage approach: power load rate and CO2 emission. The first metric represents the ratio of the overall assigned power by the main grid to the maximum quantity of power that can be assigned during one day. The second one calculates the amount of CO2 emitted from each MG during 24, and it is calculated using the function below [18]: where Grid ce and Wind ce respectively are: the CO2 emission rate CER [46] of grid and wind energy presented in TABLE 3. We present in Fig.6-a the power load rate of each MG using our two stage optimization scheme TSOA, BGS scheme and price-based scheme. We observe that, for all the MGs, our scheme allows to significantly reduce power load from the VOLUME 10, 2022  main grid with a percentage of 52% than BGS, and 59% than price-based scheme. This is due to our proposal that first purchases the cheapest energy price in the system, thus promoting the use of the MGs stored energy which is usually provided with interesting prices.
Reducing the main grid power load by purchasing more green energy from the MGs has a positive impact on the environment. This is demonstrated in Fig.6-b that shows the performance of our approach in terms of gas emission. We can see that our approach is more efficient than BGS and pricebased approach, and considerably lowers CO2 emissions with a percentage, respectively, of 51% and 66%.

E. EXECUTION TIME EVALUATION
We highlight in this subsection, the execution time of our proposed approach ''TSOA''. We present in the TABLE 4, the execution time of ''TSOA'', ''BGS'', traditional and price-based approaches for 1000, 5000 and 10000 iterations. We can see that our ''TSOA'' is far more time consuming than the traditional and price-based schemes as they are not complex algorithms and are instantly in term of time execution.
We can notice the same thing comparing to ''BGS''. Although, ''BGS'' is part of ''TSOA'', we can see that ''TSOA'' is also taking much more longer time that ''BGS''. This is due to the second-stage cost optimization algorithm, that greatly enhances our previous work in terms of cost optimization and CO2 emissions.

VII. CONCLUSION
In this paper, we proposed a two stage approach that minimizes the energy cost of MGs running cloud DCs. In the first stage, the MGs optimally and fairly dispatch power between their respective DCs. We formulate the microgrid's power assignment to cloud DCs as a non-cooperative game, afterwards we calculate the optimal amount of power to be allocated to each DC according to its defined metrics. Based on their DCs power assignment, the MGs try, in the second stage, to minimize their energy cost by firstly, optimally purchasing power from the MGs and the main grid, and secondly by selling back their stored energy. We model this energy cost minimization problem as a constrained linear optimization problem and solve it using Matlab optimization tool. In order to validate our proposal, we compared it with our previously presented scheme called ''BGS'' as well as traditional and price-based approaches. Obtained results showed that our two stage optimization approach is more effective in terms of energy cost with a percentage up to 25% than the three comparing schemes. In addition, our scheme promotes MGs green energy usage which significantly reduces power load rate and CO2 emission with a percentage up to 52% comparing to ''BGS'' and price-based scheme.
As a perspective, we would like to consider dynamic pricing using MGs. In fact, we will consider that the cloud DCs are cooperative and attempt to shift their client requests to minimize energy cost while considering the client Quality of Service (QoS) requirements.
MOHAMMED ANIS BENBLIDIA received the B.S. degree in computer science from the University of Science and Technology Houari Boumediene, Algiers, Algeria, in 2013, and the master's degree in information systems security from the University of Technology of Troyes, France, in 2017, where he is currently pursuing the Ph.D. degree with the LIST3N Laboratory. His research interests include resource allocation in fog-cloud architecture, smart grid energy management, and energy efficiency in cloud data centers. VOLUME 10, 2022