Robust Optimal Scheduling of Microgrid with Electric Vehicles Based on Stackelberg Game

: With increasing penetration of distributed generators (DG), the uncertainty and intermi�ence of renewable energy has brought new challenges to the economic dispatch and promotion of environment sustainability of microgrids. Active loads, especially in electric vehicles (EVs), are thought to be an eﬃcient way to deal with the uncertainty and intermi�ence of renewable energy. One of the most important features of EVs is that their demand will vary in response to the electricity price. How to determine the real-time charging price to guide the orderly charging of EVs and operate with an uncertain renewable energy output represents an important topic for the microgrid operator (MGO). To this end, this paper formulates the optimal pricing and robust dispatch problem of the MGO as a Stackelberg game, in which the upper level minimizes the MGO’s cost, while the lower level minimizes the charging cost of each EV. In the problem, the approximate linear relationship between the node voltage and equivalent load is modeled, and the approximate linear expression of the node voltage security constraint is derived. Using dual optimization theory, the robust optimal dispatch model is transformed into a linear programming model without uncertain variables. Then, the Stackelberg game model is transformed into a mixed integer linear program by using the duality theorem of linear programming. Finally, the eﬀectiveness of the proposed method is proved by simulation within the modiﬁed IEEE33-bus system.


Introduction
In recent years, the escalating global climate crisis has highlighted the urgency of energy transformation [1].Promoting the transformation of the energy structure, establishing a clean, low-carbon, efficient and safe energy production and consumption system with renewable energy as the main body is of great significance to reduce carbon emissions for sustainable development [2,3].However, with the development of clean energy, the uncertainty and intermi ence of its output have brought new challenges to the economical dispatch and promotion of environment sustainability of microgrids (MGs).
Using a flexible load on the demand side will be an effective means to reduce the risk.With the rapid development of power demand, transportation and construction have become the focuses on the demand side [4].As the main source of flexible load, the collaborative development of electric vehicles (EVs) and distributed renewable energy is one of the important ways to realize the sustainable development of urban energy [5].According to research, as of 2021, the number of EVs worldwide reached 16.5 million and is growing rapidly [6].However, uncoordinated charging behavior of large-scale EVs will make the peak-valley difference much bigger and affect the economy and stability of power systems [7].If the charging behavior of EVs can be effectively guided by some measures, the microgrid will be more promising in improving the energy utilization rate of the power market and optimizing the operation of the power system [8].By the means of vehicle-to-grid (V2G), EVs can improve the economy and sustainability of the whole system [9] and provide it with auxiliary services like frequency regulation and voltage regulation [10,11].
Extensive studies on the EV charging strategy have been proposed.An EV charging dispatching scheme considering the safe operation of the grid is proposed in [12].A novel load frequency control strategy is proposed for EVs based on the different travel benefits and state of charge (SoC) in [13].Reference [14] presents hierarchical control of EVs in multi-microgrids, considering five different control modes of operation.A microgrid deep Q-learning optimization strategy is presented based on the user charging behavior history data in [15], which aims to adopt the periodicity of user behavior.Reference [16] proposes the orderly scheduling model of EV charging with optimal grid loss.However, these studies are carried out under a fixed electricity price and direct control, which is passive regulation of EV users.Without considering the guidance of electricity price and the EV users' subjective initiatives, it may not be possible to fully mobilize the enthusiasm of EV users in the open market environment.Also, the existing scheduling plan of EVs is limited to the regulation of the charge/discharge period but ignores the regulation of charge/discharge power, which results in the peak-valley difference not being effectively improved.
Therefore, the traditional models that aim to maximize the benefits of the microgrid operator (MGO) and EVs will lead to conflicts of interest.In order to guide orderly EV charging, it is necessary to build a cooperative game relationship between various subjects.Considering the sequence of the game between price providers and responders, wherein energy price providers can be modeled as leaders and energy price responders can be modeled as followers, the Stackelberg game model is more suitable for analyzing the complex interaction behavior of multi-agents.At present, there have been many studies on the game models in microgrid optimal scheduling.The two-layer optimization model of EV aggregators participating in the two-stage power market is also established as a Stackelberg game model in [17].The game model between the cooperative center and MGOs considering energy and carbon sharing is established, and the effective reduction in energy consumption cost is verified by simulation in [18].The feasibility of the Stackelberg game model in optimal MG scheduling has been fully proved.
Meanwhile, the risk brought by the uncertainty of a high proportion of renewable energy output is an important factor in the optimal scheduling.To deal with the uncertainty of renewable DG, stochastic programming [19][20][21] and robust optimization [22,23] are the regular methods.The stochastic programming based on the ellipsoid set is used to deal with the uncertainty in [24].A two-stage robust optimal model considering the variable cost of the uncertainty of wind turbines (WTs) is proposed in [25].However, the optimization results under stochastic programming heavily depend on the choice of scenario, and the feasible solution under robust optimization methods is usually too conservative.In addition, the voltage security of each node should be ensured as the uncertain prediction error changes, but the influence of randomness of renewable energy output on voltage security is rarely considered at present.Therefore, this paper studies optimization considering the interests of both the MGO and EV users.Compared to the direct control of the charge/discharge periods, the main highlights of the proposed strategy are as follows: 1.The competitive relationship between the MGO and EV users is described by the Stackelberg game, in which the interests of all participants can be maximized at the game equilibrium point.The optimal charging price considering both the optimal of charge/discharge periods and power can be solved to guide the orderly charging of EVs. 2. Considering the uncertainty of the renewable energy output, the approximately linearized power flow model is presented to derive the voltage security constraints with the uncertain parameters, which can be converted to the deterministic optimization problem using the method of strong dual theory.3. The Bertsimas robust optimization framework with a robust control coefficient is proposed to solve the problem, and the use of dual optimization theory is introduced to transform the robust optimal scheduling model into a linear programming model without uncertain variables by using dual optimization theory, in which the MGO can balance the robustness and economy of optimal scheduling according to its own needs.

The Stackelberg Game Model between the MGO and EV Users
The MGO, as an intermediary between DG and EV users, sets the EV charging price and supplies electricity to its customers while collecting the market price and information like the charging power from EVs.Assuming that EVs are connected to the network through smart terminals, which can automatically calculate and execute the optimal charging strategy according to the price information provided by the MGO, and feedback to the MGO, the MGO revises the EV charging price based on the according to the feedback charging strategy.The optimal results can be obtained until the iteration converges.Particularly, EVs are free from being directly controlled by the MGO.The time-of-use pricing mechanism is adopted to guide EVs to actively optimize charging strategies, rather than a contract agreement.In the Stackelberg game model of this paper, the MGO is the decision-making subject of the upper level (leader), while the EV users are the decisionmaking subjects of the lower level (follower).The structure of the Stackelberg game is shown in Figure 1, which is divided into several stages, which are as follows: 1. EV users report their allowed charging period and the power demand before the day; 2. After receiving the declaration information from EV users, the MGO formulates its electricity procurement schedule and DG generation schedule as well as the timevarying charging price, which is broadcasted to all EV users; 3. EV users calculate their optimal charging strategies under the charging price, and feedback them to the MGO; 4. The MGO adjusts its dispatching schedule and charging price and broadcasts it to all EV users again; 5.The MGO and EV users repeat step 3 and step 4 until reaching the Stackelberg Equilibrium., EV i t P optimization, the utility of the MGO depends on the charging strategy of EVs, while EV charging behavior depends on the charging price set by the MGO rather than being controlled directly.To ensure the interests of EV users and prevent the MGO from overcharging, the average charging price during a day should be fixed.And the smart terminals will automatically charge EVs at the time when the charging price is lower.It is clear that the interrelation between the MGO and EV users is in accordance with the Stackelberg game model.

The Optimal Scheduling Model of MGO
As the leader of the Stackelberg game model, the optimal scheduling is to reduce the power supply cost as well as increase the electricity sales revenue and meet the power demand.The MGO needs to decide its power purchase plan as well as the DG generation schedule and time-varying charging price.The comprehensive cost of the MGO can be calculated using Equation ( 1): where is the cost function of DG and is the electricity the MGO sells to the market, and t E  is the electricity the MGO buys from the market.
The MGO also needs to meet the corresponding constraints during its scheduling process: 1.The output constraint of controllable DG includes its output constraint and ramping constraint: ,min , , where ,max

The output constraint of renewable DG: the deviation between the actual output and
the predicted output of intermi ent renewable DG (wind power, photovoltaic) is uncertain.The cubic set is adopted to define the uncertainty.


is the maximum prediction error.
3. Power flow constraint: the one-line diagram of a radial power network in Figure 2 is adopted to describe the distribution network.Therefore, the power flows can be described through DistFlow branch equations.The linearized Distflow model is adopted in this paper to make the model tractable and ensure the results acceptable.  where , is the line resistance between nodes n and n + 1.
is the line reactance between nodes n and n + 1.Under the robust optimal scheduling of the MGO, the voltage security of each node can be ensured as the uncertain prediction error changes: min ( , , )  is maximum allowed voltage deviation.
Here, we define where .
As a result, the objective in the optimal scheduling model of MGO is to minimize (1), and the constraints are (2)- (7).

Orderly Charging Strategy of EV Users
In the Stackelberg game model, EV users aim to minimize their charging cost as followers in the lower level according to the charging price broadcasted by the MGO.The orderly charging model of the ith EV can be described as , , min Equation ( 8) means that EV users' target is to minimize their charging cost by adjusting the EV charging power.
Serval constraints also need to be satisfied during the EV charging process.
1. Total electricity consumption constraint: EVs have to be fully charged before the end of their allowed charging period.
m i E is the EV ba ery capacity,

P
is the maximum charging power of EV.As a result, the objective of the optimal EV model is (8), while ( 9) and ( 10) are the constraints.

Robust Counterpart for Voltage Security Constraints
If n means the end node of the distribution network, Equation (11) means the linear relationship between the transmi ed power and the node equivalent load.The last equation in (4) can be further described into (12). ) After plugging Formulas ( 6) and (11) into Formula (12), the relationship between the node voltage amplitude and the power of each device can be obtained and expressed by matrix.
[ ] is a n-vector consisting of each node's voltage amplitude. 0V is the nvector in which the elements are equal to 0 V , and n is the number of nodes.R and X are the coefficient matrix of (12).B is the transition matrix between the line transmi ed power and load, and b n is the number of branch lines.Plugging ( 13) into ( 5) and separate the control variables and the uncertain random variables, the voltage security constraints can be transformed into robust counterpart:  max t is the n-order diagonal matrix, which represents the maximum power fluctuation of DG in each node.
 r is the n-order robust control coefficient vector.Using the method of strong dual theory and Karush-Kuhn-Tucker (KKT) conditions, the uncertain variables in the robust counterpart can be eliminated: 1, , and 2,t v represent the dual variable matrix.

The Existence of Stackelberg Equilibrium
When all followers respond optimally according to the leader's strategies, and the leader accepts the response, the results can be considered as the Stackelberg Equilibrium.
is the strategy at the Stackelberg Equilibrium point and satisfies the following conditions: According to [17], the Stackelberg game can reach Stackelberg Equilibrium only if the following conditions are satisfied.In the proposed Stackelberg game, (1) the strategy space of both the leader and the follower is a non-empty compact convex set, and the objective functions are continuous in the field of definition.(2) Given a leader's strategy, there is a unique optimal solution for the followers' objective function.(3) Given followers' strategies, there is a unique optimal solution for the upper leader's objective.
1.The strategy sets of the MGO and EV users are non-empty, closed, and bounded convex in Euclidean space, and the objective functions are continuous with respect to control variables.Therefore, the condition (1) can be satisfied.2. There is a one-to-many relationship in the upper game level; one leader can have many followers associated with it.For EV users, the objective function changes linearly with the EV charging power, which means the EV charging cost is a continuous quasi-convex function of charging power.As a result, for a given charging price broadcasted by the MGO, EV users have unique optimal charging strategies, which satisfies condition (2). 3. The objective function of the MGO consists of three parts: DG generation cost, electricity purchasing cost and electricity sales revenue to EVs.DG generation cost is a convex function of DG's active output, and electricity purchasing cost and electricity sales revenue are linear functions of the MGO's control variables, which means the objective function of the MGO is a convex function in its strategies set.As a result, if the EV charging power is given, the MGO has a unique optimal scheduling plan and charging price.Therefore, there is a unique equilibrium point between the MGO and EV users, which satisfies condition (3).

Solving Process of Stackelberg Game
The optimization problem based on Stackelberg game architecture is a bilevel optimization problem, which is often solved using an iterative method [17].The MGO sets the charging price and broadcasts it to all EV users, and each EV user makes a charging plan according to the broadcasted charging price, and then the MGO collects the charging power feedbacked by EV users to adjust its strategy until Stackelberg Equilibrium is reached.However, with increasingly more EV connected to the power grid, the required optimization times and the amount of calculation will increase with the increasing charging access of EV, resulting in a large amount of calculation burden.
To save iterations, the KKT condition and strong dual theory are applied to transform the lower-level optimization problem of EV users into linear constraints of the MGO.The original two-level optimization problem can be transformed into a single-level optimization problem, and the object function of the MGO can be expressed as ) However, there is nonlinear term , EV t i t c P with minimize function in (18), making the optimal problem unable to be solved directly.The dual problem of EV users can be expressed as , , 0, 0 where 3,i u is the dual variables of equality constraint (9).
are the dual variables of (10), which represent the upper and lower limit of EV charging power, respectively.According to dual theory, the objective function of the MGO is equivalent to (22).
Since there are still constraints relevant to EV charging power , EV i t P , the theorem of mutually complementary elasticity is applied to gain the relationship between original variables and corresponding dual variables. ,i t v  can be thought of as the shadow price of the charging power upper limit constraint. ,0 means that the EV user can gain more benefit if the maximum charging power is increased, and the charging power is maximal at time slot t.Similarly, the charging power is equal to 0 when , 0 . Assuming that EV needs to be charged within 1  N hours, the EV charging power will reach its maximum in the chosen 1 1 N  hour when the charging price is relatively low and be equal to 0 in the hours when the charging price is relatively high, and it will fill the insufficient electricity demand in the remaining one hour.As a result, the relationship between , are binary auxiliary variables, and M is a sufficiently large constant.We can calculate EV charging power at each period by combining ( 9) and (23).

Case Study
To validate the effectiveness of the proposed model, the test systems of the 33-node distribution network shown in Figure 3 is studied, whose reference voltage is 12.66 kV.The capacities of the PV and WT installed on nodes 6 and 32 are both 500 kW, as shown in Figure 4.The forecasted load and output of WT/PV both have a maximal predicting error of 20%.Three different controlled DGs are installed on nodes 17, 20 and 24; the technical parameters of different DGs can be found in Table 1.The cost of DG can be calculated using Equation (24).And the power purchasing price of each period is shown in Table 2.The average value of EV charging is set to be the average value of time-of-use (TOU) price, and the highest charging price is 1.2 times that of the TOU price, while the lowest charging piece is 0.8 times that of the TOU price.
A total of 300 EVs are connected to node 5.The ba ery capacity of the EV is 30 kWh, the maximum charging power is 5 kW, and the initial energy of EVs obeys a uniform distribution of 3~15 kwh.According to the driving characteristics, the EVs can be divided into three types [27]: 1. Day-night hybrid type: allowed to be charged from 15:00 to 03:00 of the next day.2. Dayshift type: allowed to be charged in the time periods 0:00-08:00, 12:00-4:00 and 18:00-24:00.

Robustness Analysis
To analyze the impact of uncertain variables on the results, the 'violation rate' is defined to measure the impact of uncertain variables.In this paper, assuming that the prediction error of renewable DG output obeys the normal distribution, the violation rate can be calculated using Equation (25).

rate = 100%
total N represents the total number of scenes generated by random Monte Carlo sampling, which is set to 1000.vio N represents the number of scenarios in which constraint violation occurs under the influence of uncertain parameters.
When the robust coefficient varies between its maximum and minimum values, we can obtain the results under different robustness levels as shown in Table 3.The larger the coefficient, the greater the volatility of the renewable energy output and the stronger the willingness of the MGO to avoid risks, which results in an increase in the controllable distributed power output to mitigate the influence of power flow caused by the fluctuation of the renewable energy output, as well as an increase in the operating cost.The MGO can achieve a balance between robustness and economy by adjusting the level of robustness.

 
, as the level of robustness increases, the violation rate continues to fall rapidly but the cost keeps rising.This result shows that the MGO can make the distribution system safer by spending more money.However, the violation rate declines much more slowly as the robustness level increases when 0.6 r   .That means that when the current level of robustness is relatively high, the MGO must spend more to achieve a higher level of robustness.Considering that short-term voltage violation is allowed in the actual operation of microgrid, 0.6 is selected to reconcile the robustness and economy in the subsequent analysis.Particularly, in the actual application, the MGO can set to be a reasonable value according to the actual requirements.
Figure 5 compares the total output of the controllable DG and power purchase strategy of the MGO under deterministic optimization and robust optimization.Under the robust optimization, the DG will generate more power; even in the lower price period, DG's output is not equal to 0. The transmission power through distribution network lines can be decreased when DG generates more power, which can avoid the lower voltage caused by the fluctuation of renewable energy output.

Performance of the Proposed Approach
The EV charging price is shown in Figure 6.Since most EV users are more inclined to charge their EVs in the valley period with the lowest price, the MGO sets the charging price in the valley period to CNY 0.4428/kWh, which is the upper boundary of the charging price.As the average value of the charging price is fixed, the MGO has to set the charging price to its minimum value at the peak time while increasing the charging price of the other time to obtain more revenue from charging EVs.  4 compares the results of three cases.
Case 1: All EVs are charged in a disorderly fashion [16].Case 2: All EVs are charged in an orderly fashion in the guidance of charging price decided by the particle swarm optimization (PSO) algorithm in [12].
Case 3: All EVs are charged in an orderly fashion with the guidance of charging price decided by the Stackelberg game proposed in this paper.According to Table 4, in case 1, where EVs are charged in a disorderly fashion, more EVs are charged at the peak time, which results in higher costs for both the MGO and EV users.And the operation of MG will face more pressure due to the higher load peak and bigger peak-valley difference.However, if EVs are guided to be charged in an orderly fashion by the charging price, more EVs will likely be charged at the valley time when the charging price is lower, so their users can spend less money.And the load profile will be fla er due to the EV loads being transferred from peak time to valley time, which makes the operation of the MGO more flexible and economical.
Compared with the PSO algorithm in case 2, the cost of the MGO in this model is reduced by CNY 105.1 and the peak valley rate is reduced by 2.87% while the EV cost is only slightly increased in the proposed model, which fully reflects the game process between the MGO and EVs and can achieve be er results.
At the same time, due to the original model being transformed into a linear programming problem, the solving time is less than the iterative process of PSO. Figure 7 shows the changing trend of the solving time as the number of EVs increases.With an increase in the number of EVs, the PSO algorithm needs a longer time to find the optimal solution, while the solution time in this paper increases slowly, showing be er applicability.To analyze the impact of the different ratios of EVs, Figure 8 shows the costs of the MGO under different EV ratios.When the types of EVs are concentrated ([300, 0, 0] and [0, 0, 300]), the cost of the MGO is lowest.As the distribution of the three types tends to be balanced, the cost of the MGO gradually increases.This is because when a single type dominates, the charging price set by the MGO will be fully in line with the charging period of this type of EVs, so as to obtain the maximum profit.In addition, when the proportion of nightshift type is larger, the cost of the MGO will also be reduced.This is because nightshift EVs are charged during the day, and the price during the day time is higher than that at night, so the price can be set higher during the day to obtain more profit.In addition, the original fixed TOU charging price will lead to higher operating costs overall.

Conclusions
In this paper, the optimal scheduling of the MGO with EVs is modeled.First, the scheduling problem is presented as a mathematical programming problem aiming at the minimum power supply cost of the MGO.Uncertainty parameters such as renewable energy output are studied and modeled as uncertainty sets.Robust optimization is then applied to deal with uncertainty.The proposed robust optimization method makes an MGO tradeoff between economy and robustness by selecting schedules with different levels of robustness.Then, the Stackelberg game between the MGO and EV users is considered, in which EV users are guided to charge in an orderly fashion according to the charging price set by the MGO.And the Stackelberg game problem is transferred into mixed integer linear programming using the method of strong dual theory.The result indicates that by se ing the charging price, the MGO can reduce its cost and smooth its load profile by guiding the orderly charging of EVs, whereby EV users can also save on their charging cost.In the future, more efforts could be made to further optimize the EV charging strategy.Firstly, the regional energy supply and demand ratio can be considered to guide users to participate in renewable energy consumption.Secondly, with the rapid development of EVs, the computational burden is also an urgent problem to be solved in the future.

Figure 1 .
Figure 1.Architecture for the Stackelberg game.
and minimum of DG's active output.and minimum of DG's reactive output.upstream and downstream ramp rate of DG.

Figure 2 .
Figure 2. Diagram of a radial power network.
mean the active power flow and the reactive power flow from node n to n + 1, respectively, and , active and reactive power at node n. , n t V is the voltage magnitude at node n.1    n r according to Figure2.So, the first two equations in (4) can be further transformed into(11).

Figure 4 .
Figure 4. Forecasted load and output of WT/PV.

Figure 5 .
Figure 5.Total output of controllable DG and power purchase strategy of MGO.

Figure 7 .
Figure 7.Comparison between Stackelberg game and PSO under different number of EVs.

Figure 8 .
Figure 8.Comparison of MGO's cost under different ratios of EVs and different charging prices.
its initial energy state, and EV Charging power and charging period constraint: the EV charging power cannot exceed its maximum value.And EV is only allowed to be charged for a certain time period.

Table 2 .
Time-of-use price.

Table 3 .
The results of economy and violation rate with different robustness levels.

Table 4 .
Comparison under different charging strategies.