## Abstract

In this work, a social welfare maximization problem is solved to determine the optimal scheduling of end-user controllable loads, smart appliances, and energy storage. The framework considers multiple retail energy suppliers as well as the AC power flow constraints of the distribution system. The demand side management program is focus on residential and commercial end-users. We have formulated a day-ahead residential bidding/buyback scheme modeled as an optimal power flow problem. This demand side program schedules end-user’s controllable loads or smart appliances and takes advantage of the flexibility of an energy storage system. The demand side management scheme minimizes retail company’s operating costs in the wholesale market, and it also considers distribution network constraints, assuring the appropriate quality of service. We have used a dual decomposition method to decouple some constraints while maximizing social welfare. We have also introduced a demand response call event with the main objective to take into consideration the system operational constraints. Through the coordination via local marginal prices, we have obtained a decentralized and distributed bidding/buyback scheme proposing a demand side management program that preserves the integrity of the private information of the different participants.

## 1 Introduction

The evolution of the energy sector under the paradigm of *smart grid* is enabling the interaction between end-users and energy service providers operating in the retail market, maximizing capital profit and performance of the power grid [1–3]. Thanks to smart meters, home or buildings Energy Management (EM) system, controllable loads, electric vehicles, and the sustained cost reduction of residential energy storage system or batteries technologies, demand side flexibility will become an important lever also for grid operators [4–8]. The main objective is the transformation of the traditional grid into a cost-effective, energy efficient, and resilient power grid [9–11].

Under this new paradigm, controllable and manageable load appliances have become an active area of new research where demand side management (DSM) is emerging as an essential component in energy management programs of the *smart grid* [6,7,9]. Generally, DSM refers to managing the consumer’s energy usage in such a way to yield desired changes in their load profile, deferring loads from on peak to off peak hours. In Refs. [12–16], it is presented an overview of the researches related to the use of building thermal mass for shifting and reducing peak cooling loads in commercial buildings. These works summarize control models used to minimize energy costs by an intelligent operation of their thermal appliances and the thermal mass of the building in response to dynamic prices. Most of the works in the literature explore how this models can schedule an optimal power profile reducing cost, but they do not say nothing about how this consumption changes affect the whole system.

DSM can be broadly classified into incentive-based programs, where the customers are motivated to change their power profile by receiving incentives for reducing/rising their consumption, and price-based programs, focused mainly on price of electricity varying over time [17,18]. It is in this sense that home or buildings energy management system, together with the new capability of real-time consumption reading through smart meters, could provide an opportunity for end-users in the residential sector to schedule and control smart and flexible loads, maximizing the energy efficiency regarding hourly price tariff and end-user’s comfort [12,17,19]. The grid is shifting from traditional supply control to demand control, where the role of end-users is changing from passive to active in the power system.

The retail side of the electricity market involves the final sale of power from an energy supplier to an end-use consumer. This sales range from the service for a large manufacturing facility to small business or residential buildings and individual households. In electricity markets where full retail competition is provided, customers may choose between their preferred energy supplier and an array of competitive suppliers, as opposed to being a captive customer of a single provider. The energy supplier purchase electricity from the wholesale market and sells it on the retail market to its customers. These retail energy companies provides two important values: it aggregates loads so that the wholesale market can operate efficiently, and they hide the complexity and uncertainty, in terms of power reliability and prices, from their customers [7,8,18,20].

From the network management point of view, the new figure of distribution system operator (DSO) owns and operate the wires that supply electricity to homes, businesses, and factories. The traditional Network Operator model was focused on the one-way delivery of electricity, with a clear definition of upstream and downstream flows and a reliable control of the supply side. Nevertheless, in the near future, a DSO will have to deal with new distributed energy resources, such as wind/photo-voltaic farms, electric vehicles, or storage devices in utility and smaller scale, connected to a grid not designed to cater for all these technologies. One option is simply to make the grid stronger, which means reinforcing the network assets, but this can be very expensive and not necessarily the most clever solution. Another option is to manage these distributed energy resources and the flexibility gained by end-users using an optimal power flow (OPF). An OPF is a way to deal with optimization problem by taking into consideration the physical network constraints and also accommodates distributed energy resources plug along the distribution network. It is with this in mind that the DSO must deal with bidirectional flows, uncertainty in supply, flexible demand, and must also be capable to operate networks that can accommodate dispatchable resources through DSM programs. These new agents should be capable of intelligently add different and geographically dispersed inputs/outputs and at the same time deal with a variety of agents participating in the electricity market.

### 1.1 Related Work.

A considerable number of algorithms have been proposed in specialized literature to determine energy forward prices for different retail electricity markets [7,21]. Many of them [18,22,23] consider supply and demand matching not taking into consideration the distribution network performance and their physical constraints. In Ref. [23], authors consider two abstract models. They consider that each supplier submits a supply function to an auctioneer, who will set a uniform market price. They also provide the conditions for the existence and uniqueness of the Nash equilibrium in supply functions under uncertain demand and show that the solution is characterized by an optimization problem whose main objective is the maximization of the social welfare. However, residential demand management requires the coordination of a large number of households in order to improve the overall power system efficiency and reliability. Such coordination is usually implemented via price signals, assuming that customers are price responsive. From this point of view, many heuristic models that consider power load schedules for the customer have been proposed. Authors in Refs. [24–26] comparatively evaluate the performance of home EM controllers that have been designed to schedule energy consumption on the basis of heuristic algorithms. Nevertheless, this heuristic approaches are popular due to their broad applicability (e.g., for black-box models), but in turn may neglect intrinsic problem structures.

As far as we know, no previous research has investigated the problem of finding a global optima to the social welfare involving not only several energy suppliers operating in the retail market, but also taking into consideration the AC constraints on the power grid. In this article, we complement the work exposed in Refs. [27–31] considering: AC physical constraints of the power grid; geographic localization of the residential end-users; several energy providers participating in the retail market; keep the integrity of the participant’s private information developing a decentralize algorithm to find the optimal operating point. We also enrich the work exposed in Ref. [31] introducing a demand response call event with the objective of keeping wholesale market prices and bus voltages in the distribution network under certain limits. Specifically, we propose a decentralized bidding/buyback scheme for the residential DSM program modeled as an OPF problem in order to maximize social welfare.

The objective of the DSM scheme is to manage the appliances for each customer individually but maximizing social welfare (i.e., the customer utilities minus grid operation cost plus energy supply cost). We consider end-users as price-takers in the retail market. Each end-user can decide which model fits better to its smart appliances and should propose the best power profile response to the dynamic prices received from its energy supplier, maximizing their utility perceive by using the appliance and reducing the energy cost. The DC OPF results are potentially inaccurate since the traditional DC model only focuses on active power balance and generally neglect the effect of power losses looking for solutions around an operative point. In that sense, we use a AC optimal power flow model in order to improve the model accuracy of the system, taking into consideration the physical operation constraints (losses over the lines) in a distribution power network trying to minimize not only the voltage deviation but also power losses over the lines.

We use a branch flow model to describe the AC OPF problem which is a non-convex problem due to certain constraints. However, we apply some useful relaxations [32] to solve a new convex problem where under certain conditions we can be sure that both solutions coincide, which enables us to solve the convex problem. We include a dual decomposition of manageable complexity for the coordination of different agents participating in the retail market, preserving not only end-users preferences, constraints, and privacy, but also the distribution network operation and retail companies private information. We propose a decentralized communication over a *smart grid* platform where the different agents exchange public information. This scheme is illustrated in Fig. 1. The utility or energy suppliers send dynamic prices for the next day to their customers. Each customer’s EM receive the prices for the next day and scheduled its smart appliances in order to minimize cost but accomplishing customer’s comfort constraints. Each EM sends back to its energy supplier the power profile for the next day. The energy supplier send to the DSO the power profile of each end-user and reserve in the wholesale energy enough energy to supply their customers. The DSO send back marginal prices promoting changes in end-users behavior.

The main contributions of this study can be summarized as follows: several energy providers supplying end-users in the retail market; a decentralized day-ahead bidding/buyback scheme proposing a DSM program design to maximize social welfare, linking wholesale and retail market prices, taking into consideration AC-constraints of the distribution power network and keeping the integrity of the private information of all active agents. We also introduce a demand response call event with the aiming of keeping wholesale prices and the performance of the distribution networks under a certain reliability limit, maintaining the system demand below a certain limit during peak hours.

## 2 Problem Formulation

This section describes the problem formulation of the proposed residential DSM program. We give an overview of the end-user preference model and its smart appliance model, the energy supplier, and the DSO models. These models will be used in the distributed DSM scheme. We use a discrete-time model with a finite horizon that describes an operational day. Each operational day is divided in *T* periods of equal duration, indexed by $t\u2208T={1,..,T}$. We considered retail companies only participating in day-ahead market; it does not cover real-time balancing market or auxiliary services such as regulation or reserves.

### 2.1 System Overview.

The DSM program is focus on end-users participating in an open retail market with several energy suppliers over a distribution power network operated by a DSO. Let’s assume a total of *H* customers $H:={h1,h2,\u2026,hH}$ participating in the DSM program, each of the homes are connected to a bus in the distribution network, and it has a energy supply contract with a unique energy retail company. Furthermore, each end-user $h\u2208H$ has a home or building EM system connected to the energy supplier’s communication networks via an advance metering infrastructure.

### 2.2 End-User’s Model.

*PF*

_{h}(

*t*):

#### 2.2.1 Smart Appliance.

For each smart appliance $a\u2208Ah$ of end-user *h*, *y*_{h,a}(*t*) denotes the energy consumption for appliances *a* of end-user *h* in the period $t\u2208T$, being **y**_{h,a} the consumption profile vector over the whole operating day. An appliance *a* is characterized by [19,27]:

We model customer preference in the DSM using the concept of utility function from microeconomic. An utility function

*U*_{h,a}(**y**_{h,a}) that quantifies the utility perceived by end-user*h*from using appliance*a*. We assume*U*_{h,a}(·) is convex over**y**_{h,a}.

These linear inequalities summarizes the power capacity and comfort constraints of end-user *h* and can be used to describe a large class of deferrable and controllable loads [19].

Households appliances can be classified mainly into three types: critical, interruptible, and deferrable loads. Critical loads such as refrigerators, cooking,etc. should not be shifted or interrupted at any time. Interruptible loads, such as air conditioners or lights can be disconnected if needed during a demand response call. Deferrable loads such as washers, dryers and EV’s can be shifted during the day but they are required to consume a certain minimum energy before deadlines to finish their task. As we have mention, deferrable load can be characterize by a set of operational or comfort constraints.

We give a general expression of the utility function, since we are not interested in a specific model or to describe a new control model for different appliances such as air-conditioner. In this context, each end-user can decide which model fits better to its needs and should propose the best power profile response to the dynamic prices received from its energy supplier. For the optimization problem of the end-user, the utility function is assumed to be continuously differentiable and concave for each *t* and also the feasible set must be convex. A detailed description of the model for different electric appliances can be found in Refs. [19,27] and Sec. 4.

#### 2.2.2 Energy Storage System Model.

**r**

_{h}such that $\u2200t$:

*D*

_{h}(

**r**

_{h}). This function cost corresponds to the maintenance cost of the battery over its lifetime and depends on how fast/much/often it is charged and discharged. The cost function

*D*

_{h}(

**r**

_{h}) is assumed to be a convex function over

**r**

_{h}[19].

**EU-DSM**

### 2.3 Energy Supplier Model.

Each energy supplier has to decide how much power procure in the wholesale market for each period *t* of the operating day to supply his aggregated demand. Schedule **P**_{z} incurs a cost to the energy supplier *z* of *C*_{z}(**P**_{z}; *t*). The design of retail prices imposed by the energy supplier is a direct consequence of *C*_{z}(· ; *t*). This function summarizes the cost to at least recover the running costs of supplying its aggregate demand and the payment of the wholesale market. The modeling of this cost function is an active research issue which is not treated here [33,34]. Nevertheless, we assume all retailers know perfectly their own function cost *C*_{z}(· ; *t*), which represents a set of forward contracts between the energy supplier and several generators. We consider this cost function as a convex increasing function for each *t* over **P**_{z}. Each energy supplier must derive the optimal decision for power reserved on the day-ahead market and set the prices in the retail market for each of its customer participating in the DSM program. This problem can be mathematically expressed as follows:

**ES-DSM**

*z*

_{i}and

*z*

_{j}, respectively.

### 2.4 DSO Modeled As An OPF Problem.

The Distribution System Operator is responsible for the technical operation of a given distribution network area, ensuring an appropriate level of quality in the delivery of energy services over it. With the proliferation of distributed energy resources and controllable loads, the planning in advance of the generation and the appropriate schedule of the flexible and controllable demand through an OPF would improve the performance of the power system. An OPF seeks to minimize certain objective function, such as generation cost or unit commitment, physical losses in the lines, or voltage drop in each bus. Nevertheless, the optimization is subjected to Kirchoff’s laws, power balance and capacity constraints, contingency constraints, etc. The major disadvantage when solving an OPF is that the problem formulation is generally non-convex and NP-hard.

#### 2.4.1 OPF Formulation.

*i*→

*j*. We assumed the graph $G$ is a tree for a radial distribution network. The bus 0 or root denotes the feeder of the distribution network that has fixed voltage and flexible power injection, representing the limit of the authority of the DSO. In the oriented graph, we adopted the link direction where all the links in $G$ point away from the root. For each node $i\u2208N$, let

*V*

_{i}(

*t*) be the complex voltage, and

*s*

_{i}(

*t*) =

*p*

_{i}(

*t*) +

**i**

*q*

_{i}(

*t*) the complex bus load. Specifically,

*V*

_{0}is the fixed voltage in the root node and

*s*

_{0}(

*t*) is the power injected in the system. We consider that each bus $i\u2208N\u2216{0}$ supplies the set of end-users $Hi\u2208H$. The aggregate load in each bus satisfies

*V*

_{0}and the impedance {

*z*

_{ij}=

*r*

_{ij}+

*ix*

_{ij}} for each link $(i,j)\u2208E$, then the other variables including the power flows, node’s voltages, currents, and the bus loads satisfy the following physical laws for all branches $(i,j)\u2208E$ and all $t\u2208T$ [30,35]:

*l*

_{ij}(

*t*) = |

*I*

_{ij}(

*t*)|

^{2}and

*v*

_{i}(

*t*) = |

*V*

_{i}(

*t*)|

^{2}. The phase angles of the voltages and the currents are not included. Nevertheless, they can be uniquely determined for radial distribution networks [32]. The main objective of the DSO is to operate the distribution network efficiently, providing the delivery of the energy service with good quality and avoiding congestion and blackouts. In this sense, we use a convex function that penalizes losses in the system and deviation from a reference voltage.

### 2.5 Demand Response Call.

*z*can be defined by the schedule of a power demand limit $(TDRz,PDRzmax)$, where $TDRz\u2208T$ specifies the set of times of the DR event and $PDRzmax$ is the aggregated demand limit imposed by the supply company

*z*according to the available supply. The DR call can be included in the energy supplier’s cost function as an extra charge as follows:

*V*

^{min}and

*V*

^{max}are the minimum/maximum allowed voltage in each node of the distribution power network.

### 2.6 Social Welfare Maximization.

We use the social welfare definition as the standard maximization of customers utilities minus grid operation costs plus energy supply cost. We assume that energy suppliers are regulated or under perfect competition (there are enough buyers and sellers such that the prices reflect supply and demand). In this scenario, retail companies earn just enough profit to stay in business and no more. In this case, their objective is not to maximize their profit through selling electricity, but rather induce customer’s consumption in a way that maximizes the social welfare. End-users will make use of their EM system and the flexibility gained by their smart appliances and their batteries to be able to consume as much energy as they need but as costless as they can. The main goal of the DSM program is to maximize social welfare by minimizing operational costs, schedule day-ahead end-users aggregated demand, linking wholesale and retail markets, and also keep service’s quality in the distribution power network. The social welfare maximization problem can be expressed as an OPF problem as follows:

**OPF**

**y**,

**r**,

**p**,

**q**: = (

**y**(

*h*) =

**y**

_{h},

**r**(

*h*) =

**r**

_{h},

**p**(

*h*) =

**p**

_{h},

**q**(

*h*) =

**q**

_{h},

*h*∈

*H*= {1, ..,

*H*}) represent the control variables of each participant in the DSM program. In Eq. (14), the first term is the operative cost of the grid operators due to voltage deviation, the second term is energy suppliers cost of buying energy in the wholesale market, and the third term is the aggregated utility of all the customers in the DSM scheme. Constraints (15) represent supply companies reserving enough energy in the wholesale market to at least supply their customers. The last equalities are the coupling constraints for the social welfare problem, where Eqs.(16) and (17) stand for the power active and reactive balance in node

*i*(injected equal to consumed minus generated), and Eq. (18) is the total power to be injected in the root node to supply the aggregated demand plus physical losses.

## 3 Distributed Demand Side Management Program

We focus on developing a scalable and distributed DSM scheme rather than centralized due to the large number of appliances that need to be managed and the quality of the information involved in the optimization problem. Moreover, to maximize social welfare in a centralized way, a third party should count on with the distribution network topology, the cost function of each energy supplier and the set of constraints of each end-user’s appliances. In order to protect the integrity of the private information of the participants, we proposed a dual decomposition method where each agent should solve an optimization problem and exchange public information such that power profiles and locational marginal prices. A convex relaxation of the OPF problem would guarantees the convergence of the distributed algorithm [36,37]. Furthermore, solving each agent its own optimization problem selfishly but coordinated will converge to the optimum of the social welfare problem.

### 3.1 Optimal Power Flow Convexification.

OPF-r provides an upper bound to OPF. For an optimal solution of OPF-r, if the equalities in Eq. (19) were attained at the solution, then it is also an optimal solution of OPF. A sufficient condition under Eq. (19) is active has been derived in Refs. [35,39] for radial distribution network. When OPF-r is an exact relaxation of OPF, we can focus on solving the convex optimization problem. We assume in this work that the sufficient condition for exact relaxation of the OPF-r specified in Refs. [35,39] holds, and therefore, OPF-r is an exact relaxation of OPF.

### 3.2 Dual Decomposition.

The idea of a decomposition method is to solve a problem by solving smaller, but coordinated sub-problems. The coupling constraints that connect the decision variables of the different participant are Eqs. (15)–(18). If these constraints were eliminated, we would have *H* + *Z* + 1 different optimization problem, one per participant in the DSM program. We used a *Lagrange* relaxation of OPF-r, relaxing the coupling constraints. Let define:

$\u03f5z=(\u03f5z(t),t\u2208T={1,..,T})$ be the

*Lagrange*multiplier associated with the power balance constraint (15) of utility company*z*.$\mu i,\lambda i=(\mu i(t),\lambda i(t),t\u2208T={1,..,T})$ be the

*Lagrange*multipliers associated with constraints (16,17). Those controls signal would be the locational marginal prices imposed by the DSO to end users on each node*i*in $G$ to an additional kiloWatts.$\sigma =(\sigma (t),t\u2208T={1,..,T})$ be the

*Lagrange*multipliers associated with network injected power constraints in the distribution network. These constraints (18) concerned with power balance in the 0 or root bus and are the marginal prices of one additional kiloWatts in the system.

*i*and supplied by energy supplier

*z*:

It is clear that Eq. (20) is separable if we minimize over the decision variables of each participant (primal variables) given a set of Lagrange multipliers (dual variables). However, founding analytically the Lagrange multipliers is unreasonable. Nevertheless, the Lagrange relaxation of OPF-r is not only a convex problem but also it has feasible solutions. As a result, we can assure that strong duality holds (*Slater’s condition*) [37,40]. With zero duality gap or strong duality we can solve the dual problem of the Lagrange relaxation being sure that both solutions coincide. Dual decomposition methods deal with complicating constraints that couple the sub-problems, where the dual master problem controls the prices of the resources. We decouple the dual of the Lagrange relaxation into several sub problems to be solved by each DSM’s participant. We used a sub-gradient method for updating the dual variables in the master problem.

We can see in Fig. 2 the decouple sub-problems, each to be solve by a different end-user, energy supplier, and the DSO. In this framework, each home or building EM interactively communicate with its energy supplier receiving dynamic prices () and sending back its optimal power profile. Each energy supplier interactively communicate with the DSO, exchanging aggregated demand in each bus and receiving local marginal prices for each bus in the distribution network. With this framework, each participant keep the integrity of its private information and also their customers information.

### 3.3 Distributed Algorithm.

A complete description of the proposed DSM scheme can be found inAlgorithm ^{1}. After several iterations, the algorithm will converge to the optimal solution of OPF-r which is also the optimal solution of OPF if relaxations (19) are exact, and $(\u2211h\u2208Hiphk\u2212pik)$, $(\u2211h\u2208Hiqhk\u2212qik)$, and $(\u2211h\u2208Hphk+\u2211irijlijk\u2212\u2211zPzk)$ will converge to zero. In the proposed DSM scheme, the private information of each end-user, including the utility function and comfort constraints, appears only in EU-DSM problem. Each energy supplier receives the power profile from their customers and informs to the DSO the aggregated demand in each node for the next day. With this information, the DSO solves an OPF in the distribution network using the system information, including power flow constrains (8)–(10) and (19), system demand, voltage tolerance, and power losses. The DSO is in charge of actualizing locational marginal prices and system prices in node 0, sending this information to the energy suppliers. Each energy supplier re-formulates retail prices and sends them back to its clients.

#### Distributed DSM Algorithm

**initialization**$k\u21900$. The DSO sets the dynamic prices over the distribution network and send them to each energy provider. The energy provider sets the dynamic retail price $wiz$ for each bus in $G$ and send them to its clients $h\u2208Hz$.

**repeat**

With $wik$ received, the end-user's EM calculates a new demand schedule $yhak+1$ and $rhk+1$ for each appliance $a\u2208Ah$ solving the

**EU-DSM**problem, and communicates the power profile $phk+1$ scheduled to be consumed from the grid.Each energy provider communicates to the DSO the aggregated demand to be consumed by its clients in each bus $i$.

The DSO receives the aggregated demand per bus and runs

**OPF-DSM**. Actualizes $\sigma k+1$,$\mu ik+1$ and $\lambda ik+1$ with a sub-gradient method and sends them back to each energy provider.Each energy provider computes $Pzk+1$ by solving

**EP-DSM**problem, actualizes $\u03f5zk+1$ and communicates the new retail price $wik+1$ to its clients.$k\u2190k+1$

**until** convergence

## 4 Numerical and Analysis Results

We consider a scheduling horizon of twenty-four periods of one-hour, starting at 1 AM until 12 PM. We consider 150 houses and small commercial clients attended by two retail companies. We use the IEEE 13-node^{1} test feeder [41] as the power distribution system shown in Fig. 3. We assume at least 15 households are connected to each load bus and supply by an energy supplier, even though different end-users plug in the same bus could be supplied by different companies. The feeder has a nominal voltage of 4.16 kV. Since our focus is on residential end-users, we assume there is a secondary distribution transformer at each load bus which scales the voltage down to the household’s level. In this figure, we can see how energy companies exchange public information with their customers, connected through the distribution grid, and with the DSO over a communication platform.

Each household is assumed to have one thermal appliance, a battery, and inelastic appliances with mean consumption capture by **x**_{med} shown in Fig. 4. We use SEDUMI [42] to solve the OPF problem and matlab.

It follows a brief description of the components used in the simulation.

*Heater*: we model thermal appliances such as heating, ventilation, air conditioning, etc., which control the temperature inside a room or working area. Let’s $Thin(t)$ and*T*^{out}(*t*) be the inside and outside temperatures of the place where appliances of end-user*h*works, and let’s $Aht$ be the set of time that end-user is in the working area. In the HVAC system, the relationship between the cooling/heater load and energy consumption can be described aswhere$Thin(t)=Thin(t\u22121)+\alpha (Tout(t)\u2212Thin(t\u22121))+\beta yh(t)$*α*represent thermal characteristics of the working area and*β*represents the thermal efficiency of the system: for*β*> 0 the appliance is a heater, while for*β*< 0 is a cooler [19,43]. We define $Thin(0)$ as the temperature at the end of the previous day. The outside temperature of end-user environments is shown in green color in Fig. 5, which represent a typical day. End-users are not at home during office hours chosen randomly from 7:00–9:00 AM to 5:00–9:00 PM. Commercial clients are open between 7:00 and 9:00 AM and close 6:00 and 9:00 PM. For simulation purpose, we assume a comfortable temperature in the room is 23 ° C and a deviation*ε*= ± 1 ° C is acceptable by end-user’s EM system controller. Nevertheless, this settings can vary for different end-users, with no impact in the simulation results.$|Thin(t)\u2212Thconf(t)|\u2264\u03f5$*End-user’s Utility Function*: For each household or end-user, the utility or level of satisfaction perceived is related to the inside temperature and penalized its deviation from the comfort temperature set by the end-user:where$Uh(yha(t);t)=\u2212bh\Vert Thcomf(t)\u2212Thin(yha;t)\Vert 2$*b*_{h}is a positive constant. We assume three cases for the appliance.There is always a resident at home with the heater working all time, maintaining the temperature of the environment at 23 ° C.

There is a resident at home $\u2200t\u2208Aht$ not participating in the DSM program; we modeled the heater as an on/off appliance scheduled (operated) by the end-user.

There is a resident at home $\u2200t\u2208Aht$ with the EM scheduling and controlling the thermal appliance and the battery. The EM keeps the temperature of the end-user’s environment closed to the comfort temperature.

*Battery*: The storage capacity is chosen randomly from [6,10] kW/h for households and [10,16] kW/h for commercial clients. The maximum charging/discharging rate is 2 kW/h and set*γ*_{h}= 0.5. We model the cost function of the battery as follows [27]:where$Dh(rh)=\eta 1\u2211t=1T(rh(t))2\u2212\eta 2\u2211t=1T\u22121(rh(t)rh(t\u22121))$*η*_{1}and*η*_{2}are positive constants. The first term models the damaging effect of fast charge/discharge. The second term penalizes charging/discharging cycles assuming that if*r*_{h}(*t*) and*r*_{h}(*t*+ 1) have different signs there will be a cost. If*η*_{1}>*η*_{2}, the cost function*D*_{h}is a positive convex function over the vector*r*_{h}.*Energy supplier*: We assume the cost function*C*_{z}(· ;*t*) of the energy supplier*z*is an increasing and convex function that satisfies*C*_{z}(0;*t*) = 0. In this way, we consider for each time period, a cost function*C*_{z}(*P*_{z}(*t*);*t*) = [*a*_{1}*P*_{z}(*t*)^{2}+*a*_{2}*P*_{z}(*t*)]/2 [28].

In Fig. 5, we can see the power scheduled to be consumed from the grid and the estimated temperature of the environment controlled by an end-user’s EM through a thermal appliance for three different end-users. The black triangles and blue squares correspond to end-user with and without a EM system controlling the thermal appliance, respectively, and the red circles corresponds to an end-user whose EM system also controls a battery. The end-user with EM controlling the thermal appliance make use of the thermal inertia of the environment, keeping the temperature close to the comfort set point and smoothing the power profile to be consumed. The EM not only avoid peak consumption but also set the temperature over the comfortable margin in the environment when end-user arrive at home. However, the flexibility provided by the battery lets the EM system consume energy in a more intelligent way, avoiding peak-time and smoothing the estimated power profile according to retail prices received from its energy supplier. In Fig. 6, we can see the capacity of the battery by the EM for the next day, and the signal prices sent by its energy supplier. The EM charge the battery when prices are low and discharge the battery when prices are high, avoiding to consume from the grid when prices are high.

The load profile of the feeder *P*_{z}(*t*) scheduled by the energy supplier 1 without DR-call is shown by the green line in Fig. 7. It can be seen that its customer’s aggregated demand is low for most of the day except in the set of time between 7 and 9 PM. To simulate a DR event for this energy supplier, we need to choose the DR parameters including the demand limit $PDRzmax$ and the set of time $TDRz$. In our simulation, we assume that the provider imposes a demand limit of $PDRzmax=0.26$ MVA during the time period 7 to 9 PM. The effect and the corresponding power scheduled in the wholesale market after the DR-call are shown by the red line in Fig. 7. The energy supplier only controls the demands during the peak hours and its customers may or may not follow the optimal demand schedules. However, the proposed DR-call can effectively manage and encourage changes in the power profile of the end-users, keeping the power to be reserved in the wholesale market under the demand limit during the DR-call.

In Fig. 8, we can see the load profile of the feeder |*P*_{0}(*t*)| and the minimum bus voltage in the distribution system without DR-call described by the blue line. It is easy to see that he minimum bus voltage is below the voltage rating during peak hours. Comparing both figures, we can see that there is a significant correlation between the load level and the voltage drop. Applying a DR-call in the system coordinated by the DSO, we can achieve a reduction in the active power injected to the system and as a result the DSO is able to keep the bus voltage levels within the allowed range during the DR-call. The red lines in Fig. 8 show that the DR-call made by the DSO can effectively reduce the system demand and keep the voltage drop under control. Just like the DR-call made by an energy supplier, the DSO only controls the demands during the peak hours and the end-users in the distribution system may or may not follow the optimal demand schedules. However, the proposed DR-call and the price signal vectors formulated by the DSO and sent to the energy supplier can effectively manage and encourage changes in the power profile of the end-users, keeping the power injected in the system and the voltage drop under the proposed limit during the DR-call.

In Fig. 9, we can see the dynamics of the proposed distributed DSM scheme, and in Fig. 10, the LMP for each bus in the distribution network for a set of different periods *t*. This prices are the result of the OPF run by the DSO in order to keep the standard qualities in the delivery of the service and minimize losses in the system. For all simulations, we also verify that the solution to the centralized **OPF-r** verify that the equality (19) is attained in the optimal solution. As a result **OPF-r** is an exact relaxation of **OPF**. We can see that nodes far from *slack bus* are expensive than nearer ones, causing a locational effect over the power distribution network. This scheme can be study to promote in an intelligent way the installation of micro generation in the distribution network. It also can be used in meshed networks, balancing power flow through network’s branches and optimizing physical resources.

## 5 Conclusions and Future Work

This work was motivated by the promising benefits of the incorporation of a DSM program focused on a competitive retail market supplying electricity to residential and commercial end-users. We have considered not only the AC distribution network’s constraints but also an array of different energy suppliers participating in the retail market. Furthermore, we have introduced to the DSM program a DR call event with the objective of keeping the wholesale prices and the voltage drop in each bus under certain limits during peak hours. This residential DSM program is modeled as an OPF problem coordinated by the DSO. The DSM scheme schedules end-user’s controllable loads or smart appliances and takes advantage of the flexibility gained by the battery. It also minimizes retail company’s operating costs and considers distribution network constraints, assuring the appropriate quality of service. The dual decomposition method used to decouple some constraints lets us to maximize social welfare while each participant solves its own optimization problem selfishly. Through the coordination via local marginal prices, we obtain a decentralized bidding/buyback scheme for DSM program that preserves the integrity of the private information of the three different actors, mainly its preferences and constraints. Regarding the future work, it is interesting to improve the model for the retail companies, considering them as price-taker in the wholesale market and taking into consideration the risk associated with the natural uncertainty that this kind of markets present. Furthermore, we will revise the DSO model to include operation over unbalanced and mesh distribution network.

## Acknowledgment

This work was financially supported by ANII-Uruguay scholarship (POS_NAC_2018_1_151825).

## Nomenclature

**x**=vector of power flow variables (

**s**_{0},**s**,**l**,**v**,**P**,**Q**)- $H$=
set of households in the power distribution network

*p*_{i}=net real power on bus

*i*is equals to generation minus load $pi=pig\u2212pic$*q*_{i}=net reactive power on bus

*i*is equals to generation minus load $qi=qig\u2212qic$*s*_{i}=net complex load on bus

*i*,*s*_{i}=*p*_{i}+*iq*_{i}*w*_{iz}=retail price vector sent by an energy supplier

*z*to end-user plugged in node*i**z*_{ij}=impedance on line (

*i*,*j*){*z*_{ij}=*r*_{ij}+*ix*_{ij}}**r**_{h}=charge/discharge vector of the battery in end-user

*h***y**_{ah}=power scheduled by end-user

*h*for appliance*a*- $Hi$=
set of households in bus

*i* - $Hz$=
set of households supplied by energy supplier

*z* *S*_{ij}=complex power from buses

*i*to*j*,*S*_{ij}=*P*_{ij}+*iQ*_{ij}**I**_{ij},*l*_{ij}=complex current and module square from bus

*i*→*j***P**_{z}=power scheduled by supplier

*z*in wholesale market**V**_{i},*v*_{i}=complex voltage and module square on bus

*i*- $TDRz$=
set of time DR-call scheduled by supplier

*z* - $PDRzmax$=
limit of power for the DR-call scheduled by supplier

*z*

## Footnote

In order to exemplify the effect of the DR-call, we made several changes to the standard IEEE-13 node test feeder: the in line transformer between node 633 and node 634 is omitted, the switch between node 671 and node 692 is closed, and the line lengths are increased by five times.