## 2 Proposed Model
### Stochasticity  
The sizing of microgrids is a strategic decision of great relevance. Making an adequate decision is crucial to avoid cost overruns or failing to meet expected demand. Therefore, it is essential to minimize errors and arrive at a decision that is both robust and flexible [37]. The deterministic model, however, is limited to a single ideal scenario. Given the high level of uncertainty in radiation, wind speed, and demand forecasts, relying solely on the deterministic model can lead to inadequate sizing [38]. Understanding stochasticity involves grappling with decision-making in the presence of various forms of uncertainty, which can be state-independent or dependent. Stochastic models have traditionally focused on making optimal (or robust) decisions. The first step is to identify the sources of randomness, which can include observational errors, forecasting errors, model uncertainty, control uncertainty, and even goal uncertainty (where different decision-makers may have different expectations). Authors in [39] present a consolidation of various methods for modeling stochasticity, encompassing fifteen different models such as decision trees, optimal stopping, Markov decision processes, reinforcement learning, robust optimization, and one particularly noteworthy model is the optimization-simulation model, which combines these two tools. The approach proposed in this paper, based on an optimization-simulation model, considers variable annual temporal data, which results in multiple potential scenarios. The method evaluates a portfolio of solutions rather than just one, generating solutions with randomness and applying a selection criterion to determine the best alternative, akin to the Monte Carlo method [39]. This approach enables better management of data uncertainty, resulting in a sizing solution that is less sensitive to forecast variations and as cost-effective as possible. Consequently, it becomes possible to conduct sensitivity analyses and achieve improved management of the multi-objective model, thereby identifying variations such as how the percentage use of each technology changes with fluctuations in the forecasts. The process of generating the scenarios that allow dealing with stochasticity is described below (Algorithm 1):  
```
0:\(d_{t}\) and forecast (I) Get forecast hourly data divide the data by each hour (I) Get demand hourly data divide the data by each hour, separate weekdays with weekends (II) Fix distribution for each hourly data set, see which distribution best fits (III) Generate random data for the distribution create scenario for forecast and demand for\(scn\in Scenarios\)do (IV) Solve the model (V) Save best solution lowest LCOE endfor (VI) test robustness test best solutions in each scenario (VII) test costing LCOE best solutions in each scenario (VIII) Get best solution choose the most economical solution that meets the % of robustness (IX) Metrics export the different solutions-portfolio
```  
**Algorithm 1** Stochastic model  
In summary, from the original data, the probability distribution that fits each hourly interval is determined. Specifically, there are 24 distributions for wind speed and solar irradiation, while for demand, the number is doubled. This is because the demand on weekends is distinct from that on weekdays, as it often exhibits different behavior. Using the determined distribution, random numbers are generated to fit each distribution, thereby creating a new simulated dataset [40]. Each dataset--simulated demand, simulated forecast, and simulated fuel cost represents a scenario. A certain number ofscenarios are generated, and the model is run for each, selecting the best sizing based on the LCOE, which is the optimal solution for that scenario. The model must be both robust and economical. Therefore, every optimal solution is tested across all scenarios, or a representative sample to evaluate its cost. This process entails a form of cross-validation.