A Distributed Optimization Method for Optimal Energy Management in Smart Grid

This chapter presents a distributed optimization method named sequential distributed consensus-based ADMM for solving nonlinear constrained convex optimization problems arising in smart grids in order to derive optimal energy management strategies. To develop such distributed optimization method, multiagent system and consensus theory are employed. Next, two smart grid problems are investigated and solved by the proposed distributed algorithm. The first problem is called the dynamic social welfare maximization problem where the objective is to simultaneously minimize the generation costs of conventional power plants and maximize the satisfaction of consumers. In this case, there are renewable energy sources connected to the grid, but energy storage systems are not considered. On the other hand, in the second problem, plug-in electric vehicles are served as energy storage systems, and their charging or discharging profiles are optimized to minimize the overall system operation cost. It is then shown that the proposed distributed optimization algorithm gives an efficient way of energy management for both problems above. Simulation results are provided to illustrate the proposed theoretical approach.


Introduction
In any energy system, optimal energy management (OEM) is an essential problem because it directly affects to both the technical (e.g., operation and control) and economic (i.e., profit) aspects of such energy system. Recently, smart grid has been proposed as a solution to improve the greenhouse gas emissions and the efficiency and energy management in electric power grids [1]. Important components in smart grid are renewable energy sources (RESs) and distributed energy resources (DERs), e.g., rooftop photovoltaic (PV), electric vehicles (EVs), distributed energy storage systems (ESSs), etc. Those RESs and DERs are expected to replace the polluted fossil-based energy sources for generating electric power and to increase the mobility and flexibility of power grids.
However, the fluctuating and intermittent nature of RESs and the close or on-site location of DERs to end users make the OEM problem in smart grids more complex than that in traditional power grids. This urges the development of new concepts and approaches to deal with challenges that arose in smart grids. Some examples include demand side management (DSM) and real-time (dynamic) pricing (RTP) [2,3]. As one of the main DSM activities [3][4][5], demand response (DR) motivates changes in electric use by end-use customers, in response to changes in the price of electricity over time, or gives incentive payments designed to induce lower electricity use at times of high market prices or when grid reliability is jeopardized [6]. DR not only shifts the load in peak times but also increases the grid's energy efficiency and customers' benefits.
Traditionally, the OEM problem in transmission power networks is treated as the economic dispatch (ED) problem (see, e.g., [7]). Nonetheless, DSM including DR is often not included in the ED problem. To overcome this drawback, the social welfare maximization (SWM) problem is set up and solved, where the benefits from both the suppliers and the consumers are taken into account [8][9][10][11][12][13][14]. The effectiveness of the SWM problem has been verified in [15]. On the other hand, in distribution power networks, the OEM problem is usually investigated with the existence of an intermediate player called the aggregator who manages the power exchange between a small distribution grid and a larger or main grid. Therefore, the OEM problem in such situations means to maximize the benefits of the DER owners, consumers, and the aggregator.
To suppress the redundancy or to supplement the lack of energy from the fluctuating outputs of RESs, and to make the energy scheduling more flexible, ESSs are being introduced into smart grids as a solution. For instance, in power distribution systems or microgrids, EV's batteries are sources of mobile and distributed ESSs that might contribute to the energy efficiency, security, and flexibility of such distribution systems or microgrids. The stability and robustness of vehicle-to-grid (V2G) energy networks have been investigated in [16]. The problem of power scheduling with electric vehicle (PSwEV) in a microgrid has been introduced under a multi-agent setting in [17]. Due to the increase of market share of EVs and plug-in hybrid electric vehicles (PHEVs) predicted until 2050 [18], it is reasonable to believe that the PSwEV problem will be popular and important in the near future.
To solve optimization problems arising in OEM problems, the existing methods can be classified depending on the centralized or distributed nature of such methods and the heuristic or analytical characteristic of the obtained solution. The security and resiliency of centralized approaches are weak due to a single point of failure and the huge communication and data processing, at the central unit. Those limitations can be improved by distributed approaches using multi-agent system (MAS), where each agent corresponds to a bus or a portion of the grid and each agent only communicates with a few other neighboring agents. On the other hand, the heuristic methods (e.g., [19,20]) usually require a long running time and local solutions, which are less effective than analytical methods for convex optimization problems. Thus, distributed and analytical approaches will be developed in the current chapter to solve convex optimization problems representing OEM problems in smart grids.
A MAS-based distributed method for solving the ED problem in smart grid was proposed in [7] where the power losses are approximated by quadratic functions and the nonlinear coupling of oscillating agents is employed for decentralized solution derivation from the Karush-Kuhn-Tucker (KKT) conditions. The projected gradient methods were utilized in [10] to solve the SWM problem, where a MAS was utilized to derive the supply-demand mismatch in a distributed fashion. Another method named dual decomposition was used in [8] to get a distributed solution when the power balance is not strictly required. If the power balance is required, a distributed observer design was employed in [11] to estimate the power mismatch. The Vickrey-Clarke-Groves (VCG) mechanism was used in [9], but it is centralized. A distributed method was presented in [12], but the communication structure was all-to-all. Next, two consensus protocols were introduced in [13] to derive a distributed method for solving the SWM problem. Lastly, the SWM problem with transmission losses modeled by a quadratic function was investigated in [14].
This chapter presents an approach named sequential distributed consensusbased ADMM (SDC-ADMM) for solving nonlinear convex optimization problems having both equality and inequality constraints, which include those from OEM problems in smart grids. The attractive features of this approach are as follows: (i) viable for a general and broad class of constrained convex programming, (ii) distributed implementation, (iii) analytical updates of variables, and (iv) unnecessary checking of the active constraints in the KKT conditions, e.g., as in [7], which slows down the convergence speed and increases the computational complexity. Then the effectiveness of the proposed approach will be demonstrated through two specific OEM problems in smart grids, namely, dynamic SWM (DSWM) and PSwEV.
The rest of this chapter is organized as follows. Section 2 introduces a class of constrained optimization problems in power grids followed by two specific problems. Then an approach to solve those optimization problems is given in Section 3. Simulation results to illustrate the proposed approach are provided in Section 4. Finally, Section 5 summarizes the chapter.

Constrained optimization problems in smart grid
A lot of OEM problems in power grids can be represented by the following general form of constrained convex programming: where f i : R ! R are scalar, continuous, and convex functions, x i ∈ R are variables, t is the time index, ξ t ð Þ is a known time-varying parameter, μ i . 0 are known parameters, Ω i t ð Þ ⊂ R are local convex constraint sets which might be dependent on the previous time slot t À 1, x t ð Þ ≜ x 1 t ð Þ; …; x M t ð Þ ½ T , and N and M are the number of time slots and variables.
Due to the global constraint (2), (1) is a centralized optimization problem. However, (1) is decomposable into subproblems corresponding to individual time slots; hence we can derive a sub-optimal solution to (1) by resolving it sequentially, i.e., from t ¼ 1 to t ¼ N. Doing so saves much time and computational costs in comparison with solving (1) for all time slots at once. Therefore, a sequential approach to solve (1) will be proposed in this chapter and will be applied to two problems, namely, DSWM and PSwEV. The former aims to maximize the benefits of both generators and consumers in transmission grids without explicitly considering ESSs, while the latter investigates the power scheduling in microgrids with EVs serving as mobile and distributed ESSs.

Dynamic social welfare maximization problem
Consider a smart grid consisting of n conventional generation (CG) units, q renewable generation (RG) units, and m demand units. Denote P 1, G t ð Þ, …, P n, G t ð Þ the powers generated by CG units; P 1, R t ð Þ, …, P q, R t ð Þ the powers generated by RG units; and P 1, D t ð Þ, …, P m, D t ð Þ the powers consumed by demand units; and The generation cost for CG unit i is The utility function for demand unit j [8][9][10], which shows the consumer's satisfaction with respect to its consumed power, is where α j and β j are predetermined parameters. Then the DSWM problem in smart transmission grids is as follows: where P L t ð Þ is the total power loss in the grid at time slot t, (5) is the power balance constraint, (6)-(7) represent the realistic limits on the output powers of CG units and their ramp rates, and (8) is a constraint for consumed powers of demand units. Next, denote the power loss coefficients of CG unit i, demand unit j, and RG unit l by [10]. Then the power balance constraint (5) can be rewritten as On the other hand, for i ¼ 1, …, n, (6) and (7) can be conveniently rewritten as

Power scheduling with electric vehicle
In this problem, we include battery operation into the microgrid to suppress the high demand at the high-cost time of utility electricity. Furthermore, we consider EV battery instead of the stationary battery storage to reduce the installation cost of the battery system.
Our microgrid model consists of n diesel generations (DGs), m demand units, q PV generations, v EVs, and one microgrid operator. This microgrid is connected to the main grid (MG) whose electricity trading price is predescribed as q t ð Þ. The electricity trading price inside the microgrid, one of decision variables, is denoted by p t ð Þ.

Diesel generation and load demand
The generation cost function C i P i, G t ð Þ ð Þfor DG unit i is similar to that in the Section 2.1. The formulas of constraints for DG powers are also the same to that shown in (6) and (7), i.e., For the microgrid internal trading, the revenue function of DGs has the following form: Load demands are assumed as fixed parameters in this problem. The electricity cost of load demands is calculated by

Electric vehicle
For simplicity, we assume that EVs have only one round-trip route per day, and the home of each EV owner is the only charging point for each EV.
Denote P h, EV t ð Þ the charging/discharging power of the h-th EV during time slot t (P h, EV t ð Þ . 0 in charging mode and P h, EV t ð Þ , 0 in discharging mode), P h, EV t ð Þ need to satisfy the following constraint: To reduce computational cost, P h, EV t ð Þ between departure and arrival time slots of a route are assumed by zero, without loss of generality, and P h, EV t ð Þ at these departure and arrival time slots are assumed to be equal to a half of ÀP drive h , where P drive h is the equivalently consumed power of the h-th EV as if the EV route just lasts for one time slot.
The state of charge (SOC) of EV battery at the starting point of a next time slot depends on the SOC at the starting point of current time slot and a charging/ discharging efficiency φ h , as shown in (4).
SOC constraint is as follows: When EVs are at home (from the arrival time to the next departure time), their charging/discharging scheduling can be utilized for DR actions. The variable P h, EV t ð Þ during EV plugged-in time is the decision variable and will be solved by the proposed algorithm. However, it is necessary to ensure that EVs have enough energy (SOC) for their routes before their departure times. To satisfy this requirement, we consider a simple EV charging strategy based on [21]- [22] in which P min h, EV and P max h, EV in (13) are specified during the EV plugged-in time. The EV charging strategy is presented below.
The battery life function of EVs depends on EVs charging/discharging power [23], as follows: where μ h and π h are constant coefficients, h ¼ 1, …, v.
The revenue function of EVs is defined in [21], taking into account the battery life cost:

Microgrid operator
The revenue function of the microgrid operator is calculated by where P g t ð Þ is the power trading between the MG and the microgrid via the microgrid operator. In the case that the microgrid sells power to the MG, P g t ð Þ is negative. Furthermore, P g t ð Þ needs to satisfy upper and low bounds, as follows:

Power balance constraint in the microgrid
With the existence of EVs and the MG, the power balance constraint in the microgrid has more terms than that in the DSWM problem, as follows:

Multi-agent system description for smart grid
The SDC-ADMM approach is based on MAS and consensus theory so that it can be run in parallel in all generation and consumption units. Hence, the MAS description for smart grid needs to be introduced first. More specifically, each agent is assigned to a generation or demand unit, and the communication among agents is represented by an undirected graph ℊ. Each node represents a unit in the grid whose variable is x i or ξ, and each edge represents the communication between two nodes. For each node i, denote ℵ i its neighbor set and ℵ i j j the cardinality of ℵ i .

Reformulation of smart grid optimization problems
To develop the SDC-ADMM approach, (25) is first reformulated into the 2-block form of ADMM. The following closed convex sets are defined corresponding to the global and local constraints:

together with their indicator functions [24]
Hence, (25) can be rewritten as follows: s:t:P À X ¼ 0 Because the indicator function of a closed, non-empty convex set is proper, closed, and convex [25], the cost functions in (28) are also proper, closed, and convex with respect to P and X. Hence, (28) and (29) is exactly in a 2-block ADMM form [24]. Next, an augmented Lagrangian associated with (28) is defined as follows: where ρ . 0 is a scalar penalty parameter and u is called the scaled dual variable or scaled Lagrange multiplier [24]. Subsequently, the optimization problem (28) and (29) can be iteratively solved where at each iteration k ¼ 1, 2, …, the variables P, X, u are updated by [24]: This algorithm is stopped if the criteria r k 2 ≤ ε pri and s k 2 ≤ ε dual are both satisfied, where r k ≜ P k À X k and s k ≜ X k À X kÀ1 are the primal and dual residuals at iteration k; ε pri . 0 and ε dual . 0 are called primal and dual feasibility tolerances that can be chosen by with ε abs . 0 and ε rel . 0 which are some absolute and relative tolerances suggested to be 10 À3 or 10 À4 [24]. In [26], those tolerances and stopping criteria are shown to be computed and verified in distributed manners.
In the following, the variables P, X, u will be updated in a distributed manner using MAS and consensus theory. It can be observed that u is updated in a decentralized fashion when P and X are already updated. Therefore, only the updates of P and X are introduced below.

P-update step
The update of P in (30) is in fact equivalent to solving the following convex optimization problem: of which the strong duality holds [25]. Let λ kþ1 be the Lagrange multiplier associated with (34) and λ kþ1 its optimal value, at the iteration k þ 1 of the SDC-ADMM algorithm. Then the Karush-Kuhn-Tucker (KKT) conditions can be used to find P kþ1 from the following equations: Since f i P i ð Þ are known, P kþ1 i can be easily determined from (35). To find λ kþ1 , the values of P kþ1 i computed from (35) are substituted into (36). Usually, f i P i ð Þ are chosen to be linear or quadratic functions for simplicity. Hence, the first term on the left-hand side of (35) is in the form of a linear function of P kþ1 i , denoted by e a i P kþ1 i þ e b i . This leads to . The optimal value of λ kþ1 shown in (37) is a global variable because the information of all variables are needed. Therefore, in order to calculate it in a distributed manner, consensus theory is employed where each unit in the grid corresponding to a variable is represented by an agent which exchange its parametersâ i andb i and ξ (if ξ 6 ¼ 0) with a few neighbors in each iteration k of the SDC-ADMM algorithm. This is introduced in the following theorem: Theorem 1. Given a connected undirected communication graph ℊ among agents, the initial conditions of agents are set to be Consequently, the following consensus law is utilized: where w ij are Metropolis weights [27] defined by Then the consensus of all agents is achieved, where the consensus states are Thus, the optimal Lagrange multiplier can be obtained in a distributed manner by Proof: Similar to the proof of Theorem 1 in [26], so it is omitted here for brevity. ■ Remark 1: If ξ t ð Þ ¼ 0, then z Mþ1 is not needed, and hence, there are only M agents in the consensus problem in Theorem 1. Accordingly, The update of X in (31) is obtained by solving a constrained quadratic programming: Further, (42) and (43) is decentralized because both the cost function (42) and the constraint (43) are individually decomposable. Therefore, each agent (unit) just needs to solve a local scalar-constrained quadratic programming: which is easily solved by existing methods. For the DSWM problem, (45) is simply an interval, and X i has an analytical solution [26]. Similar results are obtained for the PSwEV problem.

Algorithm summarization
The convergence of the proposed SDC-ADMM algorithm can be proved in a similar manner to that in [26]; hence it is ignored here for brevity. In the following, a summary for the algorithm is provided.
Each agent determines its local constraint set Ω i t ð Þ; Each agent calculatesâ i andb i , or ξ; All agents run the consensus law (39) with initial values (38), then compute λ kþ1 by (41); Each agent updates its variable P kþ1 i as in (37); %X-update step Each agent updates its variable X kþ1 i by solving (44) and (45); %u-update step Each agent updates its variable u kþ1 i as in (32); %Check the stopping criteria if the stopping criteria are true then break; end end end

Pricing mechanism
For several grid optimization problems represented in the form of (1), e.g., economic dispatch or power scheduling, DSWM, PSwEV, etc., an electricity pricing mechanism is needed to drive the electricity trading in the grid. Interestingly, the optimal Lagrange multiplier associated with the equality constraint (2) is often regarded as the market-clearing price. That will be proved under mild assumptions in the following: Theorem 2. For a sufficiently small but positive ρ, i.e., ρ ! 0, the optimal energy price in the considering smart grid converges to λ * , the optimal Lagrange multiplier corresponding to the constraint (34) or equivalently (26), as k ! ∞.
Proof: For the OEM problems in smart grids, the convex functions f i x i t ð Þ ð Þin (1) and (25) represent the costs for power generations or for the consumers' satisfaction. Therefore, we can denote the following functions as the reward functions for agents: where p t ð Þ is the energy price at time slot t. In the ADMM reformulation (28) and (29), x i t ð Þ is replaced by P kþ1 i t ð Þ. For simplicity, the time index is also dropped hereafter.
The optimal energy price in the system is achieved when the market is cleared, at which the marginal costs of all agents are the same. Hence, In the proposed SDC-ADMM algorithm, this means Substituting (48) into (35), we have If ρ ! 0, we obtain from (49) that Thus, as long as the proposed SDC-ADMM algorithm converges, the optimal energy price p * is equal to the optimal Lagrange multiplier λ * ≜ lim k!∞ λ kþ1 . ■

Simulation results for test systems
In this section, simulation results for two problems, DSWM and PSwEV, are provided to illustrate the effectiveness of the proposed SDC-ADMM algorithm.

Test case 1: DSWM problem
For this problem, a modified IEEE 39-bus system (see Figure 1) is used as the test system where it is assumed that there are PV generation units in the system with the total maximum output of 210 MW. The parameters of generators and demand units are taken from [26]. The average PV output curve, which is shown in Figure 2, is suitably scaled from the real PV data collected in New England [28]. Moreover, an average load profile taken from New England Independent System Operator [29] is utilized and properly scaled to obtain the time-varying upper bounds of demand units. This load profile has two demand peaks at 11:00 am and 8:00 pm, and the highest demand is at 8:00 pm, as seen in Figure 3.  Other parameters in the simulation are as follows. The absolute and relative tolerances are set to be ε abs ¼ 10 À4 , ε rel ¼ 10 À3 , while ρ ¼ 0:06. Moreover, the power loss coefficients of generators and consumers are randomly generated within 10%. Then the simulation results are shown in Figures 3-7.   Thanks to PV energy, the peak demand is shifted from 8 pm to 1 pm at which the PV output is maximum, as observed in Figure 3.
Then the electricity price is exhibited in Figure 5 showing that it is highest at 8 pm and lowest at 1-2 pm. This explains why the peak demand can be shifted. Next, the total welfare in the grid is shown in Figure 6 where the maximum welfare is attained at 1 pm when the consumers use most energy and the CG units produce  least energy. Finally, Figure 7 shows the convergence of the proposed SDC-ADMM algorithm.

Test case 2: PSwEV problem
In this test case, a microgrid having 2 DGs, 16 EVs, 4 load demands, 4 PV generations, and a microgrid operator is considered with a 3-day duration. The total number of agents is 27, in which the controllable agents are those for 2 DGs, 16 EVs, and the microgrid operator. The total PV curve and the total demand curve are given in Figure 8. The prescribed electricity transaction price q t ð Þ between the microgrid and the utility company is depicted in Figure 9.
The departure and arrival time and required traveling energies of 16 EVs are randomly generated from mix Gaussian distributions of this parameter of an actual  set of 1400 EVs. The maximum energy capacity of each EV battery is 17.6 kWh, and the SOC limits of each EV battery are set at 20 and 80% of the maximum energy capacity, respectively.
The absolute and relative tolerances are set to be ε abs ¼ 10 À4 and ε rel ¼ 10 À3 . Next, ρ ¼ 0:06. These parameters are the same with those in Section 4.1.
Consequently, the simulations for hundreds of different scenarios corresponding to the above random times are run with the proposed SDC-ADMM algorithm. The results for one specific scenario are then shown in Figures 10-12. Figure 10 shows the benefit of utilizing PV generation and EV charging in the microgrid. First, DG output power is reduced around the time period of high PV output, while the load demand is quite high. Second, when PV output is high, the microgrid operator can sell the redundant electricity to the utility at the highest price. Last, even though EVs do not have much correlation to PV output due to the  EV traveling times, they still benefit the microgrid with their optimal charging and discharging schedules in which the charging is executed at low-price time periods of utility, and vice versa, the discharging is made at high-price time periods of utility. Moreover, the discharging also provides microgrid electricity for selling to the utility at a high price.
Subsequently, the SOC profiles of 16 EVs are depicted in Figure 11. It can be observed that the EV batteries will be charged in the early morning when the electricity price is low, but not to the maximum allowed SOC, i.e., 80% of maximum battery capacity, because of the using of EV charging/discharging strategy in Algorithm 1 and the realistic EV data that only around 6 kWh is enough for each EV round-trip. Further, the charged/discharged SOCs of EVs are different due to their differences on charging/discharging times and required energy for traveling.
Finally, the convergence of the proposed SDC-ADMM algorithm in the PSwEV problem is shown in Figure 11, and the consensus processes in the distributed algorithm for calculating the optimal electric price inside the microgrid are displayed in Figures 12 and 13.

Conclusions
In this chapter, a distributed optimization algorithm called sequential distributed consensus-based alternating direction method of multipliers (SDC-ADMM) is proposed for optimal energy management in smart grids. This algorithm is applicable to a broad class of linear or nonlinear constrained convex programming, of which two specific problems in smart grids have been studied in this chapter. The first problem DSWM tries to maximize the total social welfare in transmission grids in the presence of renewable energy and power losses, while the second problem PSwEV considers the power scheduling in distribution microgrids with renewable energy, electric vehicle as mobile storage, and a microgrid operator. It is then shown that the proposed SDC-ADMM algorithm works well for both problems, in which an optimal real-time electricity pricing scheme is derived as a part of the algorithm which facilitates demand response. Additionally, the existence of renewable energy and electric vehicles with suitable charging and discharging strategies is benefit to the grid for reducing the electricity price and the output power from nonrenewable energy generation.

Conflict of interest
The authors declare no conflict of interest. Consensus for computing λ kþ1 .