Closed kbenne closed 1 year ago
Thanks @kbenne for reporting. I've done some memory and simulation time profiling with the following case:
Ubuntu 18.04 VM Test Case: bestest_hydronic Simulation period: 180 days starting from 0. "master" = current master branch using numpy arrays and append "list" = version using python lists and append "parray" = version using python arrays and append "3600s" = 3600 second advance step size "60s" = 60 second advance step size
Below is a plot of computer memory use over time to complete the simulation period (memory recorded every 1s of real time) given the different arrangements described above. Note the reduction in memory consumption and total simulation time provided by use of python arrays instead of numpy arrays or python lists for the data appending and storing.
I therefore propose changing the implementation to use python arrays for data storage instead of the current approach of numpy arrays.
Above plot created using the attached python script and development on this branch: https://github.com/ibpsa/project1-boptest/tree/issue520_arrayAppend. Latest commit on that uses python arrays. Remaining to-do I see there is adjust numerical differences in unit test results and review. memory_test.txt
Here's a benchmark plot for multizone_office_simple_air, a more complex test case with more points being stored. Benchmark settings same as previous comment. Python arrays seem to provide memory efficiency here as well.
See discussion also with regards to single or double float precision here: https://github.com/ibpsa/project1-boptest/pull/521#discussion_r1121090969.
We have noticed that the time required to step the simulation increases (about linearly) during a simulation. This isn't as noticable for two week test scenarios, but if you perform an annual run then it becomes more significant. We are seeing almost a four fold increase in step time by the end of an annual simulation.
After some investigation it appears like the problem is related to the
y_store
andu_store
data structures, which hold the historical simulation data and grow over the simulation time. The problem is that these structures are copied on every step in the process appending (they are numpy arrays).Here is a graph of the simulation step time over the course of an annual simulation.
This issue relates to https://github.com/ibpsa/project1-boptest/issues/240 which resulted in numpy array being introduced, because it is more memory efficient compared to Python List. The problem we are seeing now is that numpy array results in copies which are computationally expensive.
The solution may be to use Python Array https://docs.python.org/3/library/array.html which should offer efficient storage of numerical values and be computationally efficient. (avoid copy on each step)