This is the code repository for the article "Predict the element instead of the sequence: ResNet surrogate method for very accurate predictions of hourly building energy" in the Applied Energy journal.
To install and test the code yourself, follow these steps:
- Clone this repository to your local disk.
- Install EnergyPlus V24-1-0.
NOTE: Make sure that the path to the EnergyPlus executable is correctly defined in the
runmethod of theBuildingclass inpred_elem_seq/simulation.py. The path is set toC:/EnergyPlusV24-1-0/energyplus.exeby default. - Install the uv Python package and project manager.
- Run the following two commands in the
predict-element-instead-of-sequenceroot directory:uv venvuv pip install -r pyproject.toml.
Even though it is not common practice, we have organized the various implementations of our method into pytest functions.
The arguments of the pytest functions are organized in the tests/conftest.py module as pytest fixtures. Feel free to modify the values
of the fixtures to test different arguments (such as surrogate model hyperparameters).
Use your favourite IDE (or use the command line) to run the main pytest functions explained below.
-
tests/test_surrogate.py:test_get_surrogate
This function uses the
annandann_datasets_trainpytestfixtures to train, test, and save a surrogate model of a building energy model (BEM) with only one weather file in the design space.The
annfixture is an instance of theAnnConfigdataclass that contains all the metadata necessary to clearly define the type and characteristics of the surrogate model (e.g., number of hidden layers), the details of the BEM (e.g., building parameters in the surrogate design space), and details of the surrogate model training and testing datasets (e.g., number of samples).The
ann_datasets_trainfixture is an instance of theAnnDatasetsclass that is used to generate the surrogate model training and testing by simulating the BEM through a design of experiment.test_get_surrogate_weather
This function uses the
annandann_datasets_weather_trainpytestfixtures to train, test, and save a surrogate model of a building energy model (BEM) with multiple weather files in the design space.The
ann_datasets_weather_trainfixture is also an instance of theAnnDatasetsclass, likeann_datasets_train, but it also usesweather_listas an argument, which is a list of .epw file paths that will be randomly selected during the simulations of the BEM.