ugr-sail / sinergym

Gym environment for building simulation and control using reinforcement learning
https://ugr-sail.github.io/sinergym/
MIT License
134 stars 36 forks source link

Simple simulation #256

Closed MichielKempkens closed 1 year ago

MichielKempkens commented 1 year ago

Dear sinergym,

I installed the container and all the example files work perfectly fine. For now I just want to make simple simulation without the use of reinforcement learning in order to compare the two later on. So just a simple simulation without performing any actions, in order to track the temperatures and the total energy used.

best, Michiel

AlejandroCN7 commented 1 year ago

Dear @MichielKempkens,

I think you have two options:

  1. You can use the simulator EnergyPlus directly without having to use Sinergym from the terminal, for example:
energyplus -w sinergym/data/weather/USA_PA_Pittsburgh-Allegheny.County.AP.725205_TMY3.epw sinergym/data/buildings/5ZoneAutoDXVAV.idf 

However, doing so without our framework has some disadvantages. You will have EnergyPlus default output and will not have some added outputs such as our wrapper logger that monitors all interactions with the environment. The IDFs have a default location and designday, which Sinergym changes automatically depending on the specified weather, so you would have to adjust it before using the simulator manually. Finally, the runperiod of the IDFs are set to one episode for DRL, which means that as the IDFs stand you can only simulate one year. So, you would also have to modify the runperiod manually in the IDF before starting the simulation.

  1. You can set up an empty action interface in an environment with sinergym (recommended). I show an example:
import gym
import numpy as np

import sinergym
from sinergym.utils.wrappers import LoggerWrapper

env = gym.make(
    'Eplus-office-hot-continuous-v1',
    action_variables=[],
    action_space=gym.spaces.Box(
        low=0,
        high=0,
        shape=(0,)),
    action_definition=None)
env = LoggerWrapper(env)

for i in range(1):
    obs = env.reset()
    rewards = []
    done = False
    current_month = 0
    while not done:
        a = env.action_space.sample()
        obs, reward, done, info = env.step(a)
        rewards.append(reward)
        if info['month'] != current_month:  # display results every month
            current_month = info['month']
            print('Reward: ', sum(rewards), info)
    print(
        'Episode ',
        i,
        'Mean reward: ',
        np.mean(rewards),
        'Cumulative reward: ',
        sum(rewards))
env.close()

Here you load a default environment, but we replace the space and definition of the default action with an empty one, Sinergym takes care of making the necessary changes in the background. Then, the random agent implemented send empty actions ([]).

The advantages are that you can combine the climates with the buildings as you want, Sinergym will take care of adapting everything automatically (you don't have the disadvantages of before), you can run in a single experiment as many years as you want, with our loggers. When you set an empty action interface, Sinergym leaves the default actuators that the IDF comes with (these can be more or less sophisticated depending on the definition of the building in the IDF).

I hope you find it helpful :)

MichielKempkens commented 1 year ago

Thank you so much for your well explained en detailed answer! Much appreciated!