## 2 Optimisation Methods and Modelling
### Theoretical Minimum Daily Operation Cost  
To evaluate the performance of the proposed EH optimisation, this section will introduce a method to calculate the theoretical minimum daily operation cost for the EH shown in Section 2.1. This calculation assumes the system has perfect load predication, the CHP output can be varied from 0 to its maximum rated output, the efficiency at any output is its rated efficiency and there is no delay between the set point and actual output. Therefore, it gives the most conservative base case against which to evaluate the efficacy of the algorithm proposed in this paper. This calculation consists of five steps. First, by comparing the electrical demand and maximum electrical output of CHP, find the first and last time that the electrical demand is greater than CHP electrical output in each high/intermediate price time. Calculate the amount of electrical energy shortage (EES) during each high price time and intermediate price time based on Equation (13):\[E_{sn}=\sum\limits_{t=ns}^{t=ne}E(t)-P_{CHP}\times\eta_{de}\ \times\ T \tag{13}\]  
In Equation (13), \(E_{sn}\) is EES for the \(n\)th high/intermediate price time. \(\sum\limits_{t=ns}^{t=ne}E(t)\) is the sum of the electrical energy consumption calculated during the \(n\)th high/intermediate price time when electrical energy generated by CHP is less than demand and \(T\) is the total time that electrical energy generated by CHP is less than demand during \(n\)th high/intermediate price period. This assumes the CHP capacity is rated such that at certain peak times of electrical demand it will not be able to meet the demand. Second, calculate redundant electrical energy that can be stored during \(n\)th high/intermediate price period if the CHP is working at rated power. \[E_{\mathit{instor}}=(P_{CHP}\times\eta_{de}\times T^{\prime}-\sum\limits_{t= ns}^{t=ne}E(t^{\prime}))\ \times\ \eta_{b} \tag{14}\]  
where \(E_{\mathit{instor}}\) is total electrical energy that can be stored for \(n\)th high/intermediate price time. \(\sum\limits_{t=ns}^{t=ne}E(t^{\prime})\) is the sum of the electrical energy consumption calculated during the \(n\)th high/intermediate price time when electrical energy generated by CHP is greater than electrical demand and \(T^{\prime}\) is the total time that electrical energy generated by CHP is greater than demand during \(n\)th high/intermediate price period. \(\eta_{b}\) is battery charging efficiency. The third step is to find the differences between EES in step 1, and redundant energy that can be stored during the \(n\)th high/intermediate price period from step 2. Using the same method as proposed in Section 2.4, find the best time that CHP needs to work at the rated power to charge the battery. Using the maximum CHP output here avoids storage standby losses as much as possible because charging occurs at the latest possible period before the energy is required. After finding the time that CHP should work at the rated power, the next step of this calculation is to control the output power of CHP at other times of day. At these times, if the electrical demand is greater than CHP electrical power generation, CHP must work at its rated power. If electrical demand is less than rated CHP electrical output, CHP output power should just meet electrical demand. This step considers the electricity tariff and battery overall efficiencies. Also at this step, redundant heat generated by CHP can be stored by the heat storage system and when the CHP output cannot meet the heat demand, the heat storage system will be prioritised to supply the heat load. Finally, calculate the electricity and the gas bought from the grid. The gas price contains two components: gas used to supply the boiler and gas used to supply the CHP.