# An Enhanced System Architecture for Optimized Demand Side Management in Smart Grid
## 3 Proposed CHEMA and its Implementation  
This section elaborates on the details of CHEMA and its implementation. Household appliances could be characterized on the basis of energy or power consumption. A major portion of the household appliances, almost 63%, consists of energy based loads and is very useful for DSM purposes [20]. These loads include water heaters, space heaters, air conditioners and refrigerators. We have added these basic loads in CHEMA with least impact on user comfort. Our proposed model consists of six layers: Appliance Interface (AI), Optimized Energy Cost (OEC), Theft and Faults Detection (TFD), Green Effects (GEs), Demand Prediction (DP), and Dynamic Pricing. Basic layout of the proposed CHEMA is depicted in Figure 1.  
The first layer is used for the appliance interface, _i.e._, basic parameters used for modelling of various appliances and energy cost minimization algorithm are provided using a MATLAB (R2007a, National University of Science and Technology (NUST), Islamabad, Pakistan) file. Appliance rating, required slots, and capacity is loaded through this file. The second layer is used to execute four different  
Figure 1: Proposed Comprehensive Home Energy Management Architecture (CHEMA). cases of the energy cost minimization. The results of the second layer are used to detect the electricity theft and faults at the third layer. Finally, green effects are calculated at the fourth layer, and purpose of this layer is to motivate the users to reduce the energy consumption by displaying carbon emissions at users' premises. The fifth layer is demand prediction, which is not implemented in our work; however, the purpose of including this layer in CHEMA is to enhance its capability of energy cost minimization in the context of short term load forecasting of users' load. The sixth layer is proposed for the dynamic pricing information. It is supposed that, in the smart grid environment, users are equipped with an advanced communication and control link with utility through the smart meter in order to get the real-time pricing information. The utility is also capable of monitoring the users' consumption in real-time by using the same communication link. We have used the ToU pricing scheme in CHEMA; however, the purpose of the dynamic pricing layer is to propose the inclusion of dynamic scheduling ability to CHEMA in the context of real-time information obtained from utility. We have implemented four out of the six layers in this paper. In CHEMA, all the appliances are interfaced with the first layer and basic parameters of all the appliances are loaded into the MATLAB workspace. In the case of missing parameters while loading, the model generates the error message and does not proceed to the next layer. The second layer is dedicated for energy cost optimization. Four energy management and cost minimization cases are implemented at this layer: unscheduled energy cost model, unscheduled with PPC, scheduled with PPC and scheduled with flexibility. The single Knapsack optimization technique is used for scheduling options. The third layer is used for theft and fault detection purposes and is based on a malicious node detection strategy. Whenever faults (e.g., phase to ground fault) occur, the model detects it and a beep is generated for a user's immediate attention. The fourth layer is used for GEs. The remaining two layers are proposed for demand prediction or load forecasting effects and dynamic pricing, respectively. ToU pricing scheme has been used in this model. However, various dynamic pricing models may be implemented at this layer. Complete flow chart of CHEMA is depicted in Figure 2.  
After the basic parameters' initialization at AI, the CHEMA algorithm checks for value of \(S\), which stands for schedulability. If the value of \(S\) is 1, the algorithm goes to scheduling options; otherwise, it goes to unscheduled options. Furthermore, it checks for two parameters: \(P\) and \(F\), which stand for PPC and flexibility, respectively.