# Privacy-Preserving Electricity Trading for Connected Microgrids
## 7 Experimental Results  
A simulator was implemented in order to test the correctness and feasibility of the system. It was developed in Sagemath 9.7 on Python 3.10 using its multiprocess features. The simulator was managed by a parent process which read the microgrid system configuration parameters (number of meters, production and consumption patterns, etc.) and then spawned a separate process for each smart meter as well as for the substation. The smart meters and the substation communicated asynchronously via a shared queue which simulated the communication channel. This queue was monitored in order to assess the performance of the communication system. For simplicity, we considered the communication channel allowed the transmission of a message every 30 ms independently of its length. The consumption pattern for smart meters was taken from a data set containing real readings of electric power consumption in a household ([[https://www.kaggle.com/datasets/uciml/electric-power-consumption-data-set](https://www.kaggle.com/datasets/uciml/electric-power-consumption-data-set)]([https://www.kaggle.com/datasets/uciml/electric-power-consumption-data-set](https://www.kaggle.com/datasets/uciml/electric-power-consumption-data-set)) (accessed on 1 February 2024)). All the prosumers in the simulator followed the same consumption pattern. Regarding their production, we differentiated between type A (low producer) and type B (high producer). Diverse simulations were run by varying the number of type A (\(SM_{A}\)) and type B (\(SM_{B}\)) prosumers. Figure 3 depicts the consumption and production patterns considered in our simulations. Production patterns were generated artificially in order to observe the system performance under different conditions. The simulated production patterns do not aim to consider real-world aspects like the absence of solar panel generation after sunset. Throughout the simulation, type A prosumers kept a low production profile with a varying consumption. As for type B prosumers, their behaviour was divided into five episodes:  
* From 00:00 h to 06:00 h: low and stable consumption with a linearly growing production. * From 06:00 to 09:00 h: consumption peak with a high and increasing production. * From 09:00 h to 18:00 h: moderate and stable consumption with a high and stable production. * From 18:00 h to 21:00 h: increasing consumption with a decreasing production. * From 21:00 h to 00:00 h: decreasing production and consumption. Figure 4 depicts the number of offers generated by the substation and the smart meters. It shows the way in which the system reacts to varying conditions. As expected, in periods in which the production of meters could not meet their overall demand, the substation generated offers for the electricity supplied from the global grid. It can also be observed that meters only transmitted offers during the simulation period in which their production was high. Figure 4: Number of offers generated by the smart meters and the substation in a simulated microgrid with parameters \(SM_{A}=6\) and \(SM_{B}=4\). Figure 3: Consumption and production patterns for type A and B prosumers. Power consumption is assumed to be uniform across all smart meters. Our experiments also tracked the usage of the shared-bus communication channel. More specifically, the number of messages waiting to be sent was monitored. The simulator stored the messages to be sent in a queue whose size was monitored throughout the simulation. The size of that queue is depicted in Figure 5. As expected, the number of pending messages increased with the number of transactions, which was highly correlated with the number of offer messages. Figure 6 shows the average time between the transmission of a request message and the conclusion of the pairing process. As expected, this delay time was higher when the number of meters in the microgrid increased. Finally, we compared the difference between the time taken to conclude a transaction when the offer comes from a smart meter and when the offer comes from the substation.