## 3 Solution Algorithms
### ILS-Simulation with Dispatch Strategy  
In the ILS-simulation algorithm, the same methodology as in previous strategies is employed. However, in this case, a dispatch rule is established. The previous mathematical formulation is no longer used as constraints. Instead, the logic remains consistent, and the mathematical constraints are transformed into programming logic for the dispatch strategy simulation algorithm. The dispatch rules are based on the **load following** strategy, a generalization of the model from ([PERSON] et al., 2017). Here, all renewable energies are grouped into a single category. The order of battery charging and discharging is randomly determined, while for diesel generators, the order depends on which is more economical to produce, on average, the maximum demand. At the end of each iteration, the average of the energy not supplied (ENS) is calculated. If this average exceeds the established limit, the iteration is deemed infeasible. Simultaneously, the algorithm counts the number of hours with ENS. Only four possible configurations are defined for the dispatch strategy, as some are neither feasible nor of interest. The first configuration involves only diesel generators (Figure 4), where all the demand is met by these generators. If the demand is less than the rated power of the generators, they are used until the demand is satisfied, following the previously mentioned order, starting with the least expensive generator that covers the greatest demand. If the demand exceeds the capacity, all generators operate at maximum capacity and the amount of energy not supplied is recorded. Additionally, production below the minimum capacity is to be avoided to ensure the integrity of the equipment. The second configuration involves the combination of renewable energy and diesel (Figure 5). The renewable energy sources can be wind, solar, or both. Initially, the microgrid (MG) meets the demand using renewable generators at maximum capacity. If the generation exceeds the demand, the surplus energy is recorded. However, if the generation falls short of the demand, diesel generators are utilized to meet the energy shortfall, following a process similar to that of the first strategy. The third configuration involves renewable generators (solar, wind, or both) and batteries (Figure 6). The total generation from all renewable sources is aggregated to satisfy the demand. If the generation exceeds the demand, the batteries begin to charge in a  
Figure 4: Diesel dispatch strategy. random order, maximizing their capacity. If all batteries are fully charged and there is still surplus energy, this surplus is recorded. However, if the demand is not fully met by the generation, the energy shortfall is covered by discharging the batteries. The discharge priority is determined randomly, with batteries being discharged until the shortfall is met. If the demand exceeds the capacity of the batteries, they are discharged to their maximum capacity, and the percentage of unmet energy is recorded. Finally, the state of charge of the batteries is updated. Figure 5: Diesel–renewable dispatch strategy. Lastly, the fourth configuration (illustrated in Figures 7 and 8) combines all available technologies. It serves as a generalization of the previous cases, always beginning with renewable generators. If the renewable generators can fully satisfy the demand, they are used, and any surplus energy charges the batteries, following the approach of the third strategy. If there is still surplus energy remaining, this surplus is recorded. However, in cases where there is no renewable generation--such as during nights with low wind--the batteries are used first, similar to the third strategy. If the batteries are discharged to their maximum capacity and there is still unmet energy demand, the diesel generator is engaged. Should the diesel generator not suffice to meet the demand, the unmet energy is recorded. During periods when there is renewable generation but it is insufficient to cover the demand, the approach varies.