## 3 Methods  
Starting from the current demand of the municipality, the following is studied:  
1. The current cost of electric supply from the grid, without including any renewable installations. This value is obtained according to the average prices published by the Spanish system's operators on their website (Red Electrica de Espana) [67]. This will be the reference value for comparing the other situations. With the previous demand curve and the following price curve, the daily supply cost is obtained, to which a cost of EUR 14.4 for the contracted power term is added, resulting in a cost of 702.27 EUR/day. The prices used for the study are shown in Figure 4.
2. The cost of the supply if the BG-generating plant and the PV power station are added. Since the design of the BG plant is conditioned by the amount of waste available in the municipality, it will have the necessary size for the treatment of all the waste; therefore, the production of BG, in stationary regime, will be considered constant. However, the consumption of BG can be variable, depending on the power of the electric generator that is installed. This power will be one of the objectives of the optimisation problem that is proposed. The rated power of the PV plant will be another objective of the optimisation problem. This power is limited by the available space and the capital required for its installation, so it could be quite large; however, as demonstrated in this paper, the major benefit obtained from this plant is to reduce the demand for energy from the grid, whereas the sale of surplus energy provides much less benefit. The equations of the problem are described below. For every instant t:  
\[P_{D}=P_{G}+P_{P}+P_{B}+P_{E} \tag{10}\]  
where \(P_{D}\) is the demanded power in W, \(P_{G}\) is the power supplied by the grid in W, \(P_{P}\) is the power generated by the PV panels in W, \(P_{B}\) is the power generated by the BG plant in W, and \(P_{E}\leq 0\) is the surplus generation in W. It must be noted that if \(P_{E}\leq 0\), then \(P_{G}=0\), and \(P_{D}<P_{P}+P_{B}\). For this work, the possibility to sell the surplus generation \(P_{E}\) is assumed. The total operation cost will be:  
\[C(t)=C_{G}(P_{G})+C_{P}(P_{P})+C_{B}(P_{B})+C_{E}(P_{E}) \tag{11}\]  
Figure 4: Typical hourly prices of electricity [67]. where \(C_{x}\) is the cost of the energy supplied by \(x\) in EUR/h as detailed below, for which a detailed explanation can be found in Appendix A:  
* \(C_{G}\) is the cost of the energy bought from the grid. * \(C_{P}\) is the cost of the energy produced by the PV installation. An investment value of \(I_{P}=1.5\) EUR/W has been used, considering the cost of panels, electronic inverters, wiring, support structures, and plot renting [68]. * \(C_{B}(P_{B})\) is the cost of the energy produced by the BG reactor. The investment cost of this plant in EUR has been estimated as \(I_{B}=200,000+1500\cdot P_{m}+750\cdot V_{b}\), where \(P_{m}\) is the rated power of the motor-generator to be installed (in kW) and \(V_{b}\) is the volume of the BG reactor (in m\({}^{3}\)). * Finally, in those moments in which \(P_{B}+P_{P}>P_{D}\), the surplus \(P_{E}=P_{D}-P_{P}-P_{B}\) will be sold to the grid at a price \(C_{E}\), which is shown in Figure 4, according to the average prices published by the Spanish system's operators on their website (Red Electrica de Espana) [67]. The main target of the daily management of the system is  
\[\min\int\limits_{0}^{24}C(t)\cdot dt \tag{12}\]  
Using an hourly time interval, Equation (12) can be rewritten as  
\[\min\sum\limits_{0}^{24}C(h) \tag{13}\]  
The variables to be used in the management algorithm are as follows:  
* Investment selection: \(\bigcirc\)  
* Optimise the operation of the BG plant and obtain the value of Equation (13). * Obtain \(\mathrm{C_{G}}(P_{G})+\mathrm{C_{\mathit{E}}}(P_{\mathit{E}})\) in that scenario. * Calculate \(B\) and obtain the IRR. * Modify the values of \(P_{\mathit{pr}}\) and \(P_{\mathit{m}}\) and repeat the process.