## 4 Simulation and Results
### Incorporation of Uncertainty in the Model  
The demand for a grid and the daily radiation intensity are not deterministic parameters, and they usually have uncertainties. Hence, these parameters must be forecasted, and the scheduling must be conducted based on the forecasts. Therefore, the existence of forecasting error is inevitable, and the error must be included in the optimization model in order to mitigate the risk. A common way to model the uncertainties corresponded with solar radiation and demand of the grid is to employ a normal probability distribution. In  
Figure 10: The bought power from the main power system by the distribution network. Figure 9: The behavior of the microgrid in August. other words, the mean value and the standard deviation of these parameters are calculated, and the design and the scheduling must be carried out based on these forecasts. The most famous and the most accurate approach for dealing with uncertainties and probabilistic problems is the Monte Carlo algorithm. In this approach, a large number of probabilistic samples are defined within a specified range, and the scheduling is performed for all of these samples. Then, the probability density function of targeted parameters is extracted. In this study, an upper and a lower boundary are dedicated for the demand of microgrid and distribution network along with the daily solar radiation. It is supposed that the radiation and demand will be materialized within the defined range. These boundaries are depicted in Figures 12-14. Figure 11: The amount of shed load in the distribution network in the presence and absence of microgrid. Figure 12: The upper bound, the lower bound, and the mean value of demand of microgrid in the probabilistic study. Figure 13: The upper bound, the lower bound, and the mean value of demand of distribution network in the probabilistic study. In order to solve the stochastic problem, the Monte Carlo approach is employed. In this respect, for each uncertain parameter, 1000 stochastic samples are generated randomly. To solve the stochastic problem, the following step-by-step procedure is considered:  
* Step 1--Generation of 1000 samples for each uncertain optimization variable. * Step 2--The stochastic generation of a set of solutions for optimization variables. * Step 3--The selection of a set of optimization variables. * Step 4--Test the grid's performance for 1000 samples using the Monte Carlo approach and checking all constraints for 1000 plausible scenarios. * Step 5--The calculation of the objective function (if the constraints are met). * Step 6--Check convergence and termination conditions. If it is converged, then go to step 9. * Step 7--The change of optimization variables based on the optimization method. * Step 8--Go to step 3. * Step 9--End. Table 4 outlines the results of the design of the microgrid with the incorporation of uncertainties. In the case of the 33-bus test system, the cost of power generation is greatly increased. This increase is due to the conditions in which the load may be maximum and production may be minimum. Therefore, these conditions must also be taken into account in the problem. However, as can be seen, the cost has increased by nearly 49% compared to the case where uncertainty is not considered. Thus, it should be considered that in the presence of sources of intermittency, the cost of power supply from the network may increase remarkably, which conveys the importance of stochastic solution. The increase in the system cost pertaining to the uncertainty will be 27%, which is nearly 20% less than the previous case. Therefore, the uncertainties are applied to the model using the average intermittencies in the system cost in all possible scenarios as an objective function. As can be seen, in the stochastic model, the cost of the system has increased by 26% compared to the deterministic case. As the results of the 69-bus test system figure out, the cost of supply in this condition is significantly increased.