## 2 Materials and Methods
### Scenarios S2\({}_{x}\)  
S2\({}_{x}\) scenarios represent an actual CoMG situation. Each dwelling tries to be self-sufficient with its generation and its ESS, but, under certain conditions, each house can provide energy to the other when needed if it has enough energy surplus. To prevent one dwelling from incurring significant reliability losses when helping the other, a simple strategy has been established: dwellings can share energy if the stored energy is above a threshold, but they stop cooperating if it falls below that limit. Thus, this threshold is the key parameter of the proposed strategy. If the ESS is made up of batteries, the strategy entails allowing power sharing if \(SOC>SOC_{C}\), with \(SOC_{C}\) being the \(SOC\) value set as the threshold for power sharing. Each scenario will be indicated as an S2\({}_{x}\), where \(x=SOC_{C}\) (\(\%\)), using x as the key parameter of the study. If \(x=SOC_{C}=SOC_{L}\) (which is the lower limit) is chosen, the scenario is equivalent to two houses with shared resources, without a cooperative strategy. This case will be called a shared scenario. In this work, \(SOC_{L}=20\%\) has been set, so the S2\({}_{20}\) scenario corresponds to the case of the shared scenario but without an intelligent cooperative control, as depicted in Figure 1. In this case, there would be no cooperative strategy and the system would behave as if the resources of both houses were joined together and shared freely by both. For all S2\({}_{x}\) scenarios, the aforementioned indices have been parameterized as a function of \(x=SOC_{C}\) between \(20\%\leq SOC_{C}\leq 40\%\). It is easy to verify that the situation in S2\({}_{20}\) produces unequal results: the home with the worst LOLP and the highest ENS has great benefits, but the one with the best starting indices worsens. This situation would not be admissible for the dwelling with a better initial situation in terms of LOLP and ENS. Therefore, it is necessary to differentiate  
Figure 2: Possible energy flows in S1 when generation is greater than demand (**a**) and when generation is lower than demand (**b**). between this particular case and two dwellings with a cooperative strategy to try to benefit both (S2\({}_{\rm x}\) scenarios). Therefore, the S2\({}_{\rm x}\) scenarios are parameterized as a function of x, studying various cases depending on the cooperation capacity of the two dwellings, as described below. In S2\({}_{\rm x}\), the energy flows are slightly more complex, since under certain conditions an energy flow may appear from one dwelling (either from the generation system or ESS) to the other. In these crossed energy flows, the transmission efficiency \(\eta_{\rm t}\) has to be applied. For the explanation of the method, a superscript \(j\) will be used to indicate the dwelling to which each magnitude refers. For the calculation of the energy flows in these scenarios, if generation in a dwelling (Dj) is greater than demand, the surplus is available to charge its own ESS with the charging efficiency \(\eta_{\rm c}\). If \(SOC^{j}>SOC^{j}_{\rm C}\), the excess between generation and demand would be available to supply energy to the other dwelling with the transmission efficiency \(\eta_{\rm t}\). Additionally, the energy stored in the battery of Dj between \(SOC^{j}\) and \(SOC^{j}_{\rm C}\) could be offered to the other house, with an efficiency \(\eta=\eta_{\rm d}\cdot\eta_{\rm t}\), where \(\eta_{\rm d}\) is the discharging efficiency. The energy stored in the battery of Dj at each moment is \(B^{j}=SOC^{j}\cdot B^{j}_{r}\), where \(B^{j}_{r}\) is the nominal capacity of housing battery \(j\). Therefore, the following values are obtained:  
* \(B^{j}_{\rm M}=SOC^{j}_{M}\cdot B^{j}_{r}\), maximum energy that can be available in battery of Dj. * \(B^{j}_{\rm C}=SOC^{j}_{\rm C}\cdot B^{j}_{r}\), value of energy stored in battery of Dj, below which it is not allowed to export energy to help the other dwelling.