## 1 Introduction  
Demand response (DR) aggregators have received a lot of attention in recent years due to their effectiveness in maximizing both capacity and energy gains for both end users and distribution service operators (DSOs) [1; 2; 3]. Aggregators serve two important purposes. (1) they provide optimal demand side management (DSM) services to DSOs, resulting in a financial bonus from the DSO, and (2) they ensure a reduction in the electricity bill of end users, which encourages them to participate actively in DR programs [4; 5]. As renewable and alternative energy sources become more affordable, it is becoming more cost-effective to combine them with conventional methods of energy supply [6]. Therefore, we intend to examine the impact of these energy sources on the gains for end users and DSOs for two scenarios: first, when they are utilized by the DSO, and then when they are utilized by the end user. The role of the DR aggregator in connecting DSOs and end users is depicted in Figure 1.  
An ideal DSM scenario is when demand follows generation [7]. In such a case, the load usage profile by end users does not negatively impact energy supply costs incurred by the DSO. However, this is not always the case, since end user loads have varying demands at different time slots within a day, and some of these demands have a negative impact on the DSO from both a capacity and cost perspective. In this work, we consider both load shifting and load curtailment schemes aimed at maximizing cost savings to the DSO, while simultaneously ensuring maximum benefits to end users, without completely sacrificing their comfort. Therefore, inelastic loads are considered for load shifting, while elastic loads are considered for load curtailment. With regard to the end user's appliance demand, energy use per appliance for a typical day is determined according to the active occupancy approach [8]. For this paper, a typical day is assumed to be a winter day in Johannesburg, South Africa. For day-ahead scheduling, the consumers present their projected energy demands for the following day. The DSO or aggregators then take these demands and present them to market operators who then provide an hourly cost profile for the day ahead to the DSO or aggregators. In this paper, it is assumed that both the DSO and aggregators are price-takers. Therefore, they play no role in determining day-ahead market price for hourly electricity demand. Also, it is assumed that the DSO is not a profit-making entity such that additional profit beyond operating costs is used to provide compensation to end users via the DR aggregator.  
Renewable energy sources (RES) have become an important contributor of alternative energy to both end users and DSOs. This additional energy supply has enhanced the conventional power grid by providing additional energy during peak periods [9]. In this paper, we consider the utilization of both the battery energy storage system (BESS) and solar panels by DSOs; end users use rooftop solar panels and plug-in electric vehicles with V2G (vehicle-to-grid) capability. RES have an advantage because they have a very low operating cost compared to conventional energy supply systems. This advantage is considered in this paper by attempting to optimize a multi-parameter objective function with a genetic algorithm. Therefore, the aim of this paper is to examine the impact of optimal utilization of RES on the maximization of compensation accruing to DR aggregators (and consequently to end users) in cases where RES are utilized by the end users, and also by the DSO. The rest of the paper is organized as follows: Section 2 discusses existing research describing the role of DR aggregators in multi-level energy optimization. Section 3 details the proposed methodology for implementing the DR aggregator energy cost optimization model. Section 4 presents and discusses results obtained from the cost optimization objective function using genetic algorithm. Section 5 concludes the paper.