Optimal Day-Ahead Self-Scheduling and Operation of Prosumer Microgrids Using Hybrid Machine Learning-Based Weather and Load Forecasting

Prosumer microgrids (PMGs) are considered as active users in smart grids. These units are able to generate and sell electricity to aggregators or neighbor consumers in the prosumer market. Although the optimal scheduling and operation of PMGs have received a great deal of attention in recent studies, the challenges of PMG’s uncertainties such as stochastic behavior of load data and weather conditions (solar irradiance, ambient temperature, and wind speed) and corresponding solutions have not been thoroughly investigated. In this paper, a new energy management systems (EMS) based on weather and load forecasting is proposed for PMG’s optimal scheduling and operation. Developing a novel hybrid machine learning-based method using adaptive neuro-fuzzy inference system (ANFIS), multilayer perceptron (MLP) artificial neural network (ANN), and radial basis function (RBF) ANN to precisely predict the load and weather data is one of the most important contributions of this article. The performance of the forecasting process is improved by using a hybrid machine learning-based forecasting method instead of conventional ones. The demand response (DR) program based on the forecasted data and considering the degradation cost of the battery storage system (BSS) are other contributions. The comparison of obtained test results with those of other existing approaches illustrates that more appropriate PMG’s operation cost is achievable by applying the proposed DR-based EMS using a new hybrid machine learning forecasting method.

SOC 0 initial battery storage system's state of charge (kWh) SOC 24 final battery storage system's state of charge (kWh) The associate editor coordinating the review of this manuscript and approving it for publication was Zhaojie Ju .
SOC max upper bound of battery storage system's state of charge (kWh) SOC min lower band of battery storage system's state of charge (kWh) P min charge lower bound of battery storage system's charging rate (kW) P max charge upper bound of battery storage system's charging rate (kW) P min discharge lower bound of battery storage system's discharging rate (kW) P min discharge upper bound of battery storage system's discharging rate (kW) η charge efficiency of battery storage system's charging (%) η discharge efficiency of battery storage system's discharging (%) N PV number of photovoltaic modules A PV area of the solar panels (m 2 ) C rep replacement cost of battery storage system (US$) P bl battery storage system's lifetime (yr) η rt square root of both ways of battery storage system's efficiency (%) C bd battery storage system's degradation cost coefficient (1/kWh) γ processing cost consists of CO 2 , NO X , and SO 2 costs (US$/kWh)  Sustainable development and environmental issues are crucial objectives of the energy sector. Re-structure of the electrical power market, diffusion of the renewable energy technologies, promotion of distributed generation (DG), and transmission integration are some leading tools for the energy sector to sustainable development as its ultimate goal. The deployment of DG units has received a great deal of attention. For instance, renewable energy sources (RESs) accounted for 26.5% of the global electrical power demand in 2017, and it is predicted to increase in next years [1]. As a result of fast population growth and excessive electrical power consumption, energy security, as well as electric power supply, have become crucial issues that need to be appropriately addressed. The expanding centralized power plants and renewable energy supply could be considered as a solution. However, there are several barriers for generation expansion planning based on conventional centralized fossil fuel power plants due to various environmental and economic problems. The resistance and opposition from the citizenry as well as environmental activists/organizations have led to significant delays or cancellations in construction of new large-scale fossil fuel power plants by government authorities. Moreover, a prerequisite for such power plants would be the new transmission systems, which their investment and operation costs are quite costly and expensive [1], [2]. Therefore, for addressing the problems associated with conventional centralized power generation systems, the increasing deployment of renewable DG units could be emerging as a realistic option to supply clean energy. The DG units could provide the electricity near or at the place of energy consumers. Hence, the transmission distance in DG-based energy systems would be less than centralized power generation systems. Accordingly, transmission losses could be minimized, while a reliable energy supply is guaranteed. [3]. In addition, toward the establishment of a sustainable energy sector, RESs such as photovoltaic (PV) and wind turbine (WT) units are often utilized as distributed energy resources (DERs). To facilitate the development of DG units, a novel concept called prosumer microgrid (PMG) (a consumer who produces and consumes the energy simultaneously) has been introduced [4]. The emergence of PMG concept has created an energy management change in the energy sector. More specifically, it has intensified consumers' flexibility and energy provider's diversity requirements [5]. In cases that the electricity produced by PMGs is higher than electricity consumption, a substantial amount of additional electrical energy could be produced. The energy system's designers would be assured of consistent electricity generation and consumption levels at all times through using the energy storage system (ESS).
Toward improving operational efficiency, PMGs need a local energy management system (EMS) to manage ESSs, e.g. battery storage system (BSS), and maximize profits [3]. The EMS operational procedures have the objective of minimizing electricity imports at peak hours, also providing electricity to consumers under contract. Also, the optimal scheduling of BSS charging and discharging power is needed, particularly for residential PMG under contract to supply the designated level of power during contracted periods. Moreover, the renewable-based energy, as well as cheap energy from the grid at off-peak periods, should be reserved [6].
Many recent studies have focused on the optimal scheduling and operation of PMGs. The optimal operation of PMGs might be adversely affected due to the uncertainties of load consumptions and renewable DG units' output power due to weather conditions. Hence, predicting weather parameters and load demand to improve the PMGs' optimal operation has been interested in recent research works [7], [8]. It is possible to utilize historical values to forecast future load values by executing an autoregressive or machine learning model. For instance, El-Hendawi et al. [9] developed a Wavelet Neural Network (WNN) for day-ahead load demand prediction to minimize the PMGs' operation cost. In [10], the Artificial Neural Networks (ANNs) were used to forecast the PV unit generation for the PMGs' day-ahead operation. Sujil et al. [11] presented an adaptive neuro-fuzzy inference system (ANFIS)-based PV and WT generation forecasting model for the PMGs' EMS.
Liu et al. [12] reported optimal day-ahead scheduling for the RES-based PMG, which considered intermittence and fluctuations of RESs as system uncertainties, while no analysis was performed on load demand's uncertainties. Although reference [13] utilized multilayer perceptron (MLP) ANN to predict day-ahead weather conditions for optimal scheduling of PMGs, the load uncertainties have been neglected. On the other hand, several studies like [14] exist, which developed load forecasting methods to concern load demand uncertainties and did not consider the uncertainties of RES-based DG units due to weather conditions. There are a few studies in the literature such as [15], which considered both weather and load uncertainties for optimal operation of PMGs. Hence, there is a research gap about developing the optimal operation of PMGs based on comprehensive forecasting of load and weather data, which concerns the uncertainties of both supply and demand sides.
Moreover, some energy management schemes such as demand response (DR) programs could be useful for PMGs to consume the electricity more efficiently, while peak shaving and peak load shifting would be achievable [16]. For large electricity consumers, a stochastic energy procurement problem was presented in [17] by taking into account the effects of DR programs on the system's operation cost. Nojavan and Aalami [17] showed that the expected system's operation cost could be decreased by DR programs because of the energy consumptions shifts from high price periods to low price ones. In [18], a detailed DR framework was established, and a new concept called electricity shifting potential was unveiled with the objective of identifying and quantifying DG potential toward participation in real-time DR programs. Ma et al. [19] analyzed the DR-based optimal energy dispatch strategies for multiple energy systems, while the uncertainties of renewable-based DG units' output power have not been concerned in [19]. In [20], a DR program has been introduced for the day-ahead operation of RES-based system considering environmental perspectives. Cao et al. [20] neglected the load demand uncertainties, and solutions such as load forecasting to minimize the impacts of load uncertainties have not been reported. Mazidi et al. [21] developed incentive DR-based PMG's optimal scheduling, which studied the uncertainties of load and weather data. However, no solution, e.g. forecasting method, was not provided in [21] to overcome the system uncertainties and their negative impacts on the PMG's operation. This literature review shows that a great deal of attention has been received on DR-based EMS of energy systems and PMGs. However, substantial work is still required on the simultaneous concerning system uncertainties and DR programs, which have not been acknowledged.
In this research work, a new method for PMG's DR-based optimal operation is proposed, which is developed based on a novel hybrid machine learning-based method using adaptive neuro-fuzzy inference system (ANFIS), multilayer perceptron (MLP) artificial neural network (ANN), and radial basis function (RBF) ANN. The proposed optimization method considers the precise forecasted load and weather data.
Test results illustrate the accuracy of the proposed hybrid forecasting method in comparison to other existing algorithms. Also, simulation results infer that the proposed DR-based optimal scheduling of PMGs based on load and weather data's forecasting is useful to overcome the uncertainties problems. Moreover, considering the BSS degradation and grid emission costs are other advantages of the proposed method.
The novelties and contributions to state of the art have been developed based on the literature review and existing research gaps in the field of optimal operation of PMGs. The essential contributions of this article could be listed as follows: • Proposing a novel optimal operation of PMGs using simultaneous forecasting of demand and supply side's parameters; Although several papers in the literature, such as [9]- [11], [22]- [25], have reported different forecasting methods to predict load and weather parameters separately to optimize the operation of PMGs, a few studies could be found that simultaneously considered all stochastic behaviors of essential uncertain parameters such as load demand, solar irradiance, ambient temperature, and wind speed. This paper tries to fill such a research gap by simultaneous forecasting all mentioned parameters for having an accurate operation and scheduling of PMGs, which consider uncertainties of both demand and supply sides. Hence, different machine learning algorithms are used to forecast the essential parameters of PMGs, and the precise forecasted data is used to optimize the PMGs' operation. As discussed, the simultaneous forecasting of weather and load data is one of the main contributions of this paper, which fills the existing knowledge gap in the literature.
• Introducing a new hybrid machine learning-based method using adaptive neuro-fuzzy inference system (ANFIS), multilayer perceptron (MLP) artificial neural network (ANN), and radial basis function (RBF) ANN for forecasting the essential stochastic parameters of PMGs; Most of the existing research works like [24] have introduced different methods to forecast only one parameter, e.g. load demand and solar irradiance, using different forecasting algorithms. In some references like [13], different stochastic parameters have been forecasted using a single forecasting algorithm. The forecasting of different PMGs' parameters using a new hybrid method based on various features of different machine learning algorithms has not received a great deal of attention. In this paper, a new hybrid machine learning-based method is developed to precisely forecast the PMGs' parameters. Also, a selection criterion is introduced, which evaluates the accuracy and performance of different algorithms and selects the best pattern of PMGs' forecasted data. Therefore, the accuracy of the forecasted data and the optimality of the suggested scheduling and operation could be guaranteed using the proposed hybrid machine learing-based method.
• Developing a DR program based on the best-selected load pattern using the proposed new hybrid machine learning-based method; The third and important novelty of this paper is developing a DR program based on the best-selected load pattern. The proposed model for DR program requires the precise load demand data. Similar studies are available in the literature, which implemented DR program to smooth the load consumption by the user [19], [20]. However, they considered a ''pre-defined'' load pattern without any particular load forecasting methodology. This would deviate optimization results in realistic applications. Therefore, the implemented DR program using the forecasted load demand data, which has been obtained by the proposed selection criterion is the third contribution of the paper.
• Consideration of the BSS degradation in optimal operation of PMG.
The fourth novelty of this paper is developed based on future works introduced in [13]. The third term of the proposed objective function of this paper includes a model for the degradation of the BSS. This model is defined based on minimizing the gap between the highest and lowest SOC of BSS in each operational day.
The remainder of this paper is organized in the following manner: Section 2 represents an overview of the understudy system. Section 3 presents the mathematical formulation of the proposed forecasting approach and optimization problem. The forecasting and optimization results are shown in Section 4, and the final section draws the conclusions. Fig. 1a shows the conceptual structure of the understudy energy system, including the prosumer interactions and EMS. Fig. 1b also illustrates the single line diagram of the test system. In Fig. 1b, the data lines have been shown in addition to power lines.

II. SYSTEM OVERVIEW A. SYSTEM ARCHITECTURE
The forecasting module in the proposed PMG's EMS performs the day-ahead load forecasting based on a hybrid machine learning-based forecasting method using ANFIS model, MLP-ANN, and RBF-ANN. On the other side, the utility grid transfers predicted weather parameters (solar irradiance, ambient temperature, and wind speed) to the EMS through an interface link. Similar to load demand, weather parameters are also forecasted with the same hybrid machine learning-based method. After monitoring the overall predicted data (solar irradiance, ambient temperature, wind speed, and load demand), the best-selected daily pattern for each parameter is used for solving the optimization problem of PMG's operation cost. Afterwards, optimization and forecasting results, as well as input data of PMG, are stored in the data storage for further analysis.

B. LOAD AND WEATHER FORECASTING
Forecasting PMG's load demand profile is an important task of each EMS, especially when the consumption patterns become more complex and dynamic. Moreover, depending on priorities and operational objectives of each PMG, performing accurate weather predictions would be necessary [26]. In this regard, one of the significant origins of uncertainties in the optimization process is weather forecasting inaccuracies, which are also responsible for deviations in optimal scheduling of PMGs. Different time-scales such as day-ahead and hour-ahead are used for load and weather forecasting.
The forecasted values are applied in the PMG operation process through EMS. Several challenges are attributed to load demand and weather parameters prediction due to operational properties of PMGs, namely Spatio-temporal uncertainties in load demand and inherent variability and intermittency in RESs. However, this paper considers load demand and weather parameters forecasting for day-ahead scheduling of PMG using a hybrid machine learning-based method.

C. OPTIMIZATION PROBLEM
The PMG's aim is to minimize its day-ahead operation cost. Therefore, the considered EMS should adopt control decisions to adjust electricity exchange with the utility grid and storage systems. Hence, for particular applications such as DR and energy management programs, various optimization decisions are adopted, which could be formulated as a mixed-integer linear programming (MILP) problem.

D. DATA MONITORING AND DATA STORAGE SYSTEMS
A large amount of data, including electricity price, electrical loads, and RESs generation, are collected by the EMS [6]. To get more insights and a better understanding of the energy system's activities, it is necessary to analyze the collected data properly. An exact assessment of collected data would lead to an improvement in prediction performance and optimization models.

E. DERs
According to the proposed EMS structure, DERs including RESs and BSS are having a significant role in power balancing of the PMG. The resources, e.g. PV and WT units, could generate the electricity and the BSS could store the energy to enhance the system's economy features. The RESs and BSS are connecting to EMS through an interface link for day-ahead optimization of the PMG.

F. PMG AND CONSUMERS CONTRACTED LOAD
In the proposed method, the optimization problem is solved from the viewpoint of PMG. Hence, PMG attempts to maximize its profits in the energy market. The EMS of the PMG tries to store electricity in BSS during low-price periods with surplus electricity from RESs, and utilizes the stored electricity during peak hours. In most cases, peak electricity prices are coinciding with peak load consumptions, especially in residential sectors. Therefore, PMG also performs peak-shaving simultaneously. On the other side, the PMG is usually contracted to supply a specific amount of power to the neighbor consumers in the PMG market during the contracted hours of the operational day. In this way, an energy business model is established based on the contribution of the PMG and consumers, which is the primary motivation of the understudy prosumer market. The PMG benefits from the contract with the consumers. On the other hand, consumers are also enjoying low-rate electricity compared to the main grid.

III. MATHEMATICAL MODELING
In the following subsections, methodologies for weather and load forecasting as well as proposed energy scheduling for the day-ahead operation of the PMG are presented. Generally, the proposed optimization method considers intermittency and uncertainty of RESs and load demand in optimal day-ahead operation.

A. FORECASTING WEATHER AND LOAD DATA USING MACHINE LEARNING ALGORITHMS
The advantages of machine learning algorithms have been utilized for forecasting short-term load or weather data, separately [22], [23]. The time-series forecasting methods for prediction of load demand and weather conditions have received a great deal of attention [13], [14], [24], [25].
However, most of them merely focused on one or two parameters (e.g. wind speed, solar irradiation, etc.) for performing short-term forecasting. In PMG context, very few studies are available that performed short-term forecasting on different uncertain variables such as weather parameters and load demand, which indeed have severe impacts on the operation cost of the PMG [15].
As mentioned above, time-series forecasting is interested in recent studies. Generally, time-series is a set of samples, which have been arranged in uniform time intervals [13]. In time-series forecasting approaches, a model is utilized to forecast future samples based on historical data [27].
In this study, three of the most potent and well-known machine learning algorithms, i.e. ANFIS model, MLP-ANN, and RBF-ANN are used for predicting time-series values of load demand and weather parameters. The main reasons for choosing these particular machine learning algorithms are mature technology and simplicity of implementation compared to hybrid algorithms, which could be sophisticated for other researchers who want to pursue the proposed approach. Forecasting results of the utilized machine learning algorithms are compared to analyze the performance of each method. This approach has been used in many recent studies where specific parameters are forecasted, and results are discussed accordingly [24], [25]. However, in day-ahead scheduling and operation of PMGs, monitoring daily predicted load and weather data should be considered as one of the important tasks of the PMG EMS. The EMS is responsible for the optimal operation of the PMG. This paper proposes a comparative approach for the EMS of the PMG to precisely select the best-predicted pattern by different machine learning algorithms for each parameter (solar irradiance, ambient temperature, wind speed, and load demand). The selected best-pattern is 24-h (daily) values of forecasted load demand and weather parameters. To obtain the best pattern, each of the predicted patterns by machine learning algorithms is compared with the corresponding actual patterns by (1). The patterns with the least mean squared error (MSE) are selected for day-ahead PMG optimization. Fig. 2 show the overall steps of the proposed approach and pattern selection structure.
In the proposed method, the ANFISI model is used for the proposed forecasting method, and the corresponding mathematical modellings are presented in this section. Fig. 3a shows the structure of the ANFIS model, which has two inputs and one output. As expressed in (2-3), there are two base rules as Takagi-Sugeno in the form of if/then rules [24]. A typical ANFIS structure has five layers, which their summary could be given as follows [24]: Layer 1: In this layer, the obtained signal of any node is forwarded to the other layer. This layer is called the fuzzification layer. The cells outputs are shown in (4): In the implemented ANFIS model, µA is selected according to (5): Layer 2: This layer is obtained by the degrees of membership, which the output of any node indicates the firing strength of each rule. This layer is called the rule layer, and the calculation is done based on (6).
Layer 3: Each node in this layer would be a fixed N labeled node. The i-th node calculates the ratio of rule's firing strength concerning the summation of all rules' firing strength as (7). This layer is called the normalization layer.
Layer 4: The outputs of different defined rules are determined according to the previous layer value as (8). This layer is called defuzzification layer.
Layer 5: In this layer, the ANFIS model output would be obtained as (9) based on output values different rules. This layer is called the sum layer.
In the proposed method, the following ANFIS models have been used to forecast time-series data [24]: • The first considered ANFIS model is a fuzzy c-means clustering (ANFIS-FCM), which generates a fuzzy inference system (FIS) structure.
• The second type of ANFIS model is subtractive clustering (ANFIS-SC), creating a Sugeno-type FIS structure.
• The third type of used ANFIS model creates a FIS structure based on grid-partition (ANFIS-GP) data. All the generated rules under different types of ANFIS model are demonstrated in Fig. 3b. The ANFIS-GS is implemented based on the Sugeno-type FIS structure [28]. As can be seen, three rules are generated for ANFIS-GP, which lead to accurate results. Three Gaussian membership functions (MFs) [29] are generated for inputs and outputs based on the designated rules, as shown in Fig. 3c. Gaussian membership functions are suitable for the available dataset in this study. It is possible to select constant or linear type for the output MFs. Hence, the output MF type is selected as a linear MF in this study. Since a single time-series dataset would be considered for forecasting, only one input (input1) could be defined in the rules. Based on the MFs, if the input data belongs to input MF1, MF2, and MF3, it could be concluded that the output data belongs to output MF1, MF2, and MF3, respectively.
For ANFIS-SC, as the second type of ANFIS model in this paper, two rules are considered. Therefore, Mamdani FIS structure [30] is generated for the ANFIS model, which contains one rule for each cluster. As can be seen, if the input data (in1) belongs to the first cluster (in1cluster1) and the second cluster (in1cluster2), then the output data belongs to output cluster 1 (output1cluster1) and output cluster 2 (output1cluster2), respectively.
After generating input and output data in ANFIS-FCM type, Mamdani FIS structure is specified. Three clusters are considered, and three rules are generated based on the clusters, as shown in Fig. 3b. As demonstrated, generated FIS contains one rule for each cluster. Hence, if the input data (in1) belongs to the first cluster (in1cluster1), the second one (in1cluster2), and third cluster (in1cluster3), then the output data belongs to output cluster 1 (output1cluster1), cluster 2 (output1cluster2), and cluster 3 (output1cluster3), respectively.
In this paper, four statistical criteria have been used to examine the forecasting performance of the machine learning algorithms. The utilized statical criteria are linear regression (R), standard deviation (St.D.), mean squared error (MSE), and root mean squared error (RMSE). The formulations of the considered statical criteria are shown in (10)(11)(12)(13). These criteria are most commonly used to report the accuracy of forecasting in the literature [31]- [33]. However, the proposed approach uses MSE to determine the best-forecasted pattern.
In addition, MLP-ANN and RBF-ANN have been used in this paper. However, they are not expressed in details, and corresponding theories and mathematical expressions could be found in other references like [34], [35].

B. PROBLEM DEFINITION
The proposed day-ahead optimization problem considering the DR program is described in this subsection.

1) PV UNIT
The PV unit converts solar energy to electrical energy via the photoelectric effect. The output power of the PV cell is strictly related to weather conditions such as ambient temperature and solar irradiance. The output power of the PV unit could be calculated as (14) based on the forecasted solar irradiance and ambient temperature [36]: (14) where η PV t is calculated using (15): 2) WT UNIT WT blades are able to transform the captured energy from the wind into electricity. The generated energy by WT unit could be used in a direct way. The output power of a WT unit generally depends on two important factors: output characteristics of WT and the local wind speed. The WT output power could be determined based on the forecasted wind speed, as shown in (16) [36]:

3) BSS
In this study, the BSS is used for storing surplus electricity from RESs as well as low-price purchased electrical energy from the utility grid during off-peak times. The stored electricity is injected into the system when the electricity price is at its highest rate (peak-hours). Therefore, the BSS plays a crucial role in power balancing and the PMG's operation stability.
The BSS state of charge (SOC) indicates the ratio of the remaining electricity to the nominal capacity of the BSS. As described in (17), the BSS SOC at t + t is specified by the SOC at the t-th time interval and the BSS charging/ discharging power at the t-th time interval [37].
The upper and lower limits of the BSS SOC could be mathematically expressed in (18)(19). According to (20), the initial and final BSS SOC's values must be the same in the BSS's day-ahead scheduling. Due to the significant investment of BSS, it is essential to prevent charge and discharge of BSSs fully because it would degrade the BSS lifetime. Therefore, (21)(22)(23)(24) are considered for prohibiting the BSS to be fully charged and discharged. Since it is not possible to charge and discharge the BSS at the same operational time interval, it is necessary to apply (25), which shows the binary value for charging and discharging of BSS.

4) BSS DEGRADATION MODELING
The BSS's lifetime is directly influenced by its depth of discharge (DOD). In this regard, PMGs might face major charging/discharging of BSS, since they are obligated to provide specific power to fulfill the energy contracts. This process, in the long term, may lead to BSS degradation. It is possible to consider the BSS degradation based on the cost of BSS DOD at the end of the operational day [38], [39]. According to [13], [39], degradation cost of BSS can be achieved by multiplying the minimum level of SOC at the last time interval of the understudy day by degradation cost coefficients. However, it was recommended to consider a comprehensive model for the depreciation cost of BSS by optimizing the gap between the maximum and minimum BSS' SOC values in the PMG's daily operation. Hence, two distinct decision variables need to be considered, including the highest and lowest values of BSS SOC in the operational day. The gap between the expressed formula (26-27) could be minimized. The DR program is able to enhance the demand side's flexibility through decreasing peak load consumptions or temporary peak shifting as a response to the signals of the market price. The DR program is also applicable using incentive mechanisms as lead to avoidance of capacity investment and costly electricity procurement [40]. One of the most significant components for prosperous DR implementations is real-time pricing mechanism. In this study, according to the forecasted load data of PMG, a real-time pricing model is proposed. This pricing model will be used to implement the DR program. Derivations could be found in [19], [20].
The total load demand of PMG based on the forecasted load demand data would be determined as (28).
The average load demand should be calculated using (29).
Also, real-time pricing (RTP) could be defined according to (30)(31). (31) where, T load P ave , K RTP,min t , and K RTP,max t are float factor, lower bound, and upper bound of RTP, respectively.
In the proposed method, the price-based DR program has been considered to assess the impacts of DR on the PMG's optimal scheduling, as (32).

D. PROPOSED OPTIMIZATION PROBLEM
The main purpose of the proposed method is to optimize the operation and scheduling of the PMG, which results in the minimized operation cost. Hence, it is necessary to explain the proposed optimization problem, including the OF, constraints, and details about how the proposed optimization problem is solved. The proposed OF consists of three cost terms: • Power exchange cost; • Emission cost; and • BSS's loss of life (degradation) cost. The mathematical expression of the proposed OF has been shown in (33).
The proposed optimization problem is solved subject to technical constraints, e.g. power balance condition and lower and upper bounds of sub-systems. In this paper, the introduced MILP problem is solved using CPLEX solver in GAMS. Moreover, because of short-term load and weather forecasting in MATLAB, the forecasted data would be linked to GAMS by GDXMRW interface [41].

E. PROPOSED OF'S TERMS 1) POWER EXCHANGE COST
The cost of purchased electricity should be optimized in this term. The same prices are considered for exported electricity from PMG to the main grid. According to (34), P s t shows real values of imported/injected electricity from/to the main grid. The positive and negative values refer to purchasing and selling electricity, respectively.
2) EMISSION COST Different countries in the Paris Agreement have committed to pursue their plans to reduce carbon emissions. Furthermore, it has been recommended to divert the finance flow in the direction of robust development which could be an encouragement to reduce carbon emissions. In this study, the equivalent emission costs for purchasing electricity from the main grid could be considered as the emission cost term using (35)(36) [19]. In this way, γ is processing cost per kW and is composed of CO2, NOX, and SO2. Also, λ e and P im t denote the equivalent emission coefficient for electricity and the purchased electricity from the main grid.

3) BSS DAILY DOD DEGRADATION COST
The gap optimization is added to the OF in the proposed method, as shown in (37). Whenever the BSS total throughput would be equal to its throughput lifetime, it should be substituted with a new one. According to (38), the BSS degradation cost per kWh could be determined. This cost should be concerned whenever the battery is discharged.

F. POWER BALANCE CONDITION
The power balance condition between supplied and demanded energy could be shown as (39). According to (40)(41), the PMG is restricted to upper and lower bands in importing/exporting of electricity.

A. FORECASTING RESULTS
The solar irradiance, ambient temperature, wind speed, forecasting are implemented based on previous year historical VOLUME 8, 2020 data of Kerman province, which is located in Iran [13]. Also, the historical load data has been gathered from [14]. Fig. 4 indicates hourly historical data from 2007/1/1 to 2007/31/12. More deviations could be seen in wind speed compared to others, which makes it hard for the machine learning algorithms to predict the trend accurately. As early mentioned, three types of ANFIS model, as well as MLP-ANN and RBF-ANN, have been used for forecasting time-series data. The measurement at the time (t-24) was used to forecast the weather parameters and load data at the time (t+24) [14]. For each machine learning algorithm,  i 70 % of all data is used for training, and the other 30 % is used for testing [24]. More details of initialization parameters of MLP-ANN and RBF-ANN are presented in Tables 1 and 2, respectively. Table 3 also shows the considered specifications of each ANFIS model type.
Forecasting results have been indicated in Fig. 5 and Tables 4-9. As can be seen, all the considered machine learning algorithms have satisfying results in forecasting solar irradiance, ambient temperature, and load demand data. However, none of the implemented algorithms could predict wind speed accurately. This is due to high hourly variability of wind speed which does not follow a specific pattern [13]. Table 9 shows the execution time of the forecasting of weather and load parameters using different machine learning algorithms. All the predictions have been performed in MATLAB 2018b environment. As can be seen, ANN-MLP has the fastest performance in comparison to other available algorithms. On the other hand, ANF-RBF has the lowest execution time among the other algorithms.
Moreover, the appropriate level of model complexity is one of the most crucial challenges in the field of forecasting by ANNs [42]. In Table 10, the complexity analyses of different algorithms for load forecasting are presented. The complexity analysis results infer that more complex models could not significantly improve the performance of the forecasting algorithms. The complexity analysis also illustrates that the appropriate models of forecasting algorithms have been selected.
Forecasted and actual weather parameters and load demand data for a typical operational day in December are shown in Fig. 6. The best-forecasted patterns are presented in Table 11, which have been obtained based on the proposed method in (1). As can be seen, the Fuzzy-GP could predict the ambient temperature and wind speed better than other algorithms, while RBF-ANN and MLP-ANN are the most successful algorithms in predicting solar irradiance and load demand data, respectively. Therefore, predicted patterns based on the successful machine learning algorithms are utilized for PMG's optimal day-ahead scheduling.       In this paper, three case studies have been considered for analyzing the proposed day-ahead scheduling of the PMG as below: • Case 1: Day-ahead scheduling using real data and TOU pricing.
• Case 2: Day-ahead scheduling of the PMG using load and weather forecasting and TOU pricing.
• Case 3: Day-ahead scheduling of the PMG using weather forecasting and forecasting-based DR program.

B. CASE STUDIES
The overall structure of the study based on the proposed case studies is depicted in Fig. 7.
In this study, distribution loss is neglected because the PMG has relatively short electrical lines. PV and WT specifications are provided in Table 12 [36]. The BSS technical parameters are shown in Table 13. The considered PMG is optimized under two different pricing regimes, i.e. time of use (TOU) and real-time pricing (RTP).
TOU prices are considered based on actual electricity rates in Iran's electricity market [43]. The utilized rates are illustrated in Fig. 8a. As can be seen, three different price rates are considered for a day. The peak rate belongs to 17:00 to 22:00, while the off-peak rate has been assigned for 7:00 to 16:00. Also, eight hours are reserved for off-peak rates in a day.
The value of e is considered as -0.5 [21]. Also, the upper and lower bands of RTP are set as 0.01 US$ and 0.002 US$, respectively. Moreover, the values of γ and λ e are considered as 0.09704 US$ and 0.1, respectively. According to BSS specifications, the C bd value is assumed to be 0.6 US$ for BSS [13]. Moreover, the operation horizon of the BSS, as introduced in (37-38), is considered as one day.
As discussed in previous sections, the PMG is contracted to supply specific power to the neighbor consumers in pre-defined periods. Fig. 8b shows the details of this contract. As revealed by Fig. 8b, the PMG is contracted to provide electricity in four time intervals during a day. At each interval, which typically lasts two hours, the PMG provides 2 kW electrical power to the neighbor consumers. Based on the time intervals, consumers intended to import power in mid-peak and peak times. Consumers also pay for this electricity to the PMG. However, energy trading is constructed between consumers and the PMG, while both sides benefit from the energy business.
In this study, the introduced MILP problem is solved using CPLEX solver in GAMS 24.8 environment. Additionally, a 64-bit personal computer with 8GB RAM and Intel CPU (Core i5) has been used. The proposed method for short-term load and weather parameters forecasting is implemented in MATLAB 2018b. The forecasted data of weather parameters and load demand are linked to GAMS by GDXMRW interface [41].
In this study, the introduced MILP problem is solved using CPLEX solver in GAMS 24.8 environment. Additionally,   a 64-bit personal computer with 8GB RAM and Intel CPU (Core i5) has been used. The proposed method for short-term load and weather parameters forecasting is implemented in MATLAB 2018b. The forecasted data of weather parameters and load demand are linked to GAMS by GDXMRW interface [41].

C. RESULTS AND DISCUSSION
In this section, the optimization results are presented. The simulation results under various introduced case studies  are evaluated, and the merits of the proposed method are discussed.

1) CASE 1
In case 1, the actual load and weather data (solar irradiance, ambient temperature, and wind speed) are utilized for PMG's day-ahead operation. Figs. 9a and b shows the PV and WT units' output power based on the actual weather data. As can be seen, the PV unit generates electricity between 7:00 and 18:00, where sufficient solar irradiance is available. The electricity generation by WT unit is quite different from the PV unit due to high intermittency of wind speed. TOU electricity prices have been shown in Fig. 8a, which are considered in this case study. The optimization results of this case study have been depicted in Fig. 10. It is concluded based on results shown in Fig. 10a that more electricity is imported from the main grid during the hours that the PMG is contracted to provide electricity to the neighbor consumers. For instance, the purchasing power from the main grid is increased between 5:00 and 8:00, and then, it is dropped to a lower level. All the generated electricity by RESs are used for supplying load demand. Therefore, no electricity id sold to the main grid. According to Fig. 10b, the BSS is charged during off-peak hours of the day because of lower electricity rate in these hours. Also, the BSS is discharged in peak hours because both electricity rate and consumption are significantly increased. The operation cost of the system is also achieved at 1.115 US$. The optimal operation of the BSS clearly had a positive effect on the operation cost of the system because the BSS was able to alleviate imported electricity during peak times by injecting the stored electricity in peak hours.

2) CASE 2
In case 2, the forecasted load and weather data, which have been predicted using the proposed pattern selection approach, are used to achieve precise results. The forecasted output power of PV and WT units are depicted in Figs. 9b and c. Due to the high accuracy of the proposed pattern selection approach for load and weather forecasting, similar patterns are achieved for both forecasted and actual values of RESs output power and PMG load demand. However, more deviations could be seen in the WT output power. Electricity prices are based on the defined TOU rates in Fig. 8a. Optimization results including exchanged power from the main grid, BSS charging and discharging power, and BSS SOC are shown in Fig. 11.
As can be seen in Fig. 13a, the imported power by PMG is increasing during contracted time intervals. Similar to the previous case study, the PMG was not able to sell any electricity to the main grid. Moreover, the BSS was charged in off-peak hours and is discharged in peak hours the same as the previous case study (Fig. 13b). The operation cost of the system is achieved by 1.349 US$, which shows a minor increase in comparison with the previous case study. Since actual load/weather data is ideal, and there are some inherent deviations in forecasting results, it is reasonable to have deviations in operation cost of the system using forecasted load/weather data. However, due to the high accuracy of the proposed approach for selecting the best-forecasted pattern, the difference between operating costs based on actual and forecasted data is not significant (0.234 US$).
To validate the proposed pattern selection approach, a comparison has been made with the conventional method of selecting predicted patterns. In the conventional method, each machine learning algorithm is used for forecasting all the four parameters. Then, prediction values (i.e. solar irradiance, ambient temperature, wind speed, and load demand) by each individual machine learning algorithm are used for calculating the operation cost of the PMG.
Comparison results are indicated in Table 14. As can be seen, the operation cost based on the proposed method has the minimum value in comparison with the conventional method. Although the difference between the operation cost of the proposed approach and the other conventional methods is not significant for a single day, the proposed approach in a longer period such as one month would significantly decrease the PMG's operation cost by accurate forecasting results. Moreover, optimization results, including the system operation cost, are severely dependent on uncertainties of weather and load values.
Hence, the PMG's operation cost might be affected due to inaccurate predicted uncertain data. Therefore, the proposed method always results in optimum results in comparison with other conventional approaches.

3) CASE 3
In case 3, the proposed DR program based on the forecasted load demand is used for PMG's optimal scheduling. In this case, instead of using TOU pricing directly, the RTP mechanism is established based on the TOU pricing equipped with RTP's float factor. The forecasting-based DR program integrates forecasted load data, RTP, and TOU pricing for peak load shaving. It is worth mentioning that both case 2 and 3 use the same forecasted weather data and the main differences are in electricity prices and electrical load profiles. Fig. 12a shows RTP and TOU pricing values during the understudy day. In contrast to TOU pricing, RTP is changing hourly depending on the load consumption pattern.
Moreover, Fig. 12b displays hourly load data before/after implementing forecasting-based DR program. The first result that claims the attention is that the load pattern has been shaved especially in peak times (18:00 to 22:00). The modified load pattern would positively affect the operation of the PMG. Therefore, to investigate the exact impacts of DR program on day-ahead scheduling of PMG, the RTP and modified load values are applied. In fact, during the hours with high consumption of electric power, the rates are climbing up, and in hours with lower power consumption, the electricity price is even less than TOU rates. It shows that the RTP mechanism has a direct relationship with hourly load consumption.
Optimization results based on the proposed methods are shown in Fig. 13. As revealed by Fig. 13a, less electricity is purchased from the main grid during peak hours of the day, which has brought financial profits to the PMG. Basically, this is due to the modification considered by DR program. Moreover, the BSS is charged mainly in off-peak hours where the electricity price is at the minimum level and is discharged when the electricity prices are at the highest rates (19:00 to 21:00). The operation cost of the system is obtained 1.07 US$, which is less than the operation costs of cases 1 and 2. Based on the data given in Table 15, the total imported power by the PMG in this case study is less than case 2, where no DR is considered. In other means, considering DR program in PMG's day-ahead scheduling would reduce emission cost. Moreover, according to Table 15, the PMG has minimum exchanged power with the grid in case 3 because the forecasting-based DR program has been considered. This has resulted in the least operation cost of the system in comparison with other cases. Therefore, utilizing DR program has enhanced the optimal operation of the PMG in different aspects including economically and environmentally. Table 16 shows the summary of operation costs and execution time of optimizations by GAMS software. It is clear that CPLEX solver in GAMS software is adequately fast in solving optimization problems. Therefore, it is a suitable choice for solving MILP problems.
The proposed forecasting method is compared with other similar available studies such as [6], [13], [14] to highlight its advantages. In [6], it has been neglected to consider both load and weather forecasting, and the PMG scheduling has been optimized based on the pre-defined historical data. In [13], a forecasting method based on MLP-ANN has been reported to predict weather data and conducted the scheduling and operation of the PMG based on the predicted weather data. On the other side, Ref [14] neglected to consider weather parameters and focused on load demand forecasting using a typical MLP-ANN. Both [13], [14] did not evaluate the implemented ANN-MLP with another available machine learning algorithm.
In Table 17, the forecasting results of load and weather parameters using the proposed method and other available ones are described. As can be seen, obtained forecasting results of this study and those of others [13], [14] are consistent. Besides, in this study, different machine learning algorithms are compared through two-stage evaluations, which improves the accuracy of the forecasting parameters. Moreover, considering both weather and load forecasting would lead to more realistic optimization results because uncertainties of weather and load are considered accordingly.
The proposed method of [13] for modeling loss of life cost of the BSS merely optimized the minimum level of BSS SOC, while the proposed method of this study optimizes the gap between maximum and the minimum level of BSS SOC (SOC max n and SOC min n ). Based on the results, the proposed method of this paper results in more reduction of PMG operation cost than other methods. In contrast, the proposed method of [13] reduced a small amount of PMG operation cost because they only considered SOC min n in their minimization model. Table 18 compares operation and BSS degradation cost of the PMG based on the proposed method of this study and those of introduced in [13]. As can be seen, the proposed method of this study resulted in lower operation cost of the system. By comparing BSS charging/discharging results based on the introduced method in [13] and the proposed method (as discussed in three cases), it could be concluded that the BSS is discharged when there is a peak-load/peak-price in the day. Another important factor is the amount of RESs productions, which could be effective in discharging of the BSS. According to the results of [13], the BSS is charged when the electricity prices are in off-peak or mid-peak periods. In this study, however, the BSS is charged merely on off-peak hours. Moreover, previous studies [6], [13], [14] have neglected to consider grid emission cost, which is an important term to be applied in the PMG scheduling and operation. In this paper, an emission cost term is added to the objective function based on the processing cost per kW and equivalent emission coefficient.

V. CONCLUSION
In this paper, the DR-based optimal operation of PMG has been proposed using weather parameters and load demand forecasting. A new hybrid machine learning-based forecasting method consists of ANFIS model, MLP-ANN, and RBF-ANN has been developed to forecast the weather and load data. In the proposed hybrid machine learning-based method, the best-predicted pattern among the prediction results of machine learning algorithms is selected, which results in more precise results. Test results inferred that the Fuzzy-GP model, MLP-ANN, and RBF-ANN had a better performance for prediction of both ambient temperature and wind speed, load demand, and solar irradiance, respectively. The day-ahead optimization results based on the bestselected patterns implied that an improvement in PMG's operating cost was achieved in comparison to the conventional machine learning-based forecasting algorithms. Also, the value of operation cost regarding the proposed forecasting approach resulted in the most accurate value. In this regard, the value of operation cost considering best-selected patterns was achieved equal to 1.349 US$. The comparative test results illustrated that a significant inaccuracy (around 20.98%) might occur due to simplified assumptions for uncertain parameters such as load and weather data. Moreover, by applying the DR-based optimal operation of PMG using the developed hybrid machine learning-based forecasting as well as RTP, the PMG's operation cost could be decreased about 4.2%. The value of operation cost considering the implemented DR program was achieved as 1.07 US$. Furthermore, the proposed DR-based optimal operation results in reducing the power purchased from the main grid, which minimizes the emission cost. The total amount of purchasing power is achieved as 257.5649 US$ in the case with the DR program, which shows 8.55 % decrease in purchasing power in comparison to Case 2 without the DR program.