bsl546 / energym

Energym is an open source building simulation library designed to test climate control and energy management strategies on buildings in a systematic and reproducible way.
Other
63 stars 11 forks source link

Documentation : Add examples of energym used in the context of HVAC Problems #1

Open benjamin-arfa opened 3 years ago

benjamin-arfa commented 3 years ago

I thought it might be a good idea to document how to use the energym api in the context of a Wrapped Environement (RL) for research purposes. Thanks for the hardwork guys and here is the minimal example, where in the end there is a small fix to make the loop work :)

Code:

import energym
from energym.examples.Controller import LabController
from energym.wrappers.rl_wrapper import RLWrapper

envName = "Apartments2Thermal-v0"
env = energym.make(envName, weather = "ESP_CT_Barcelona", simulation_days=300)
reward = lambda output : 1/(abs(output['Z01_T']-22)+0.1)
env_RL = RLWrapper(env, reward)
inputs = env_RL.get_inputs_names()
controller = LabController(control_list=inputs, lower_tol=0.3, upper_tol=0.8

                          )
steps = 480*10
out_list = []
outputs = env_RL.get_output()
controls = []
hour = 0
for i in range(steps):
    control = controller.get_control(outputs, 21, hour)
    control['Bd_Ch_EV1Bat_sp'] = [0.0]
    control['Bd_Ch_EV2Bat_sp'] = [0.0]
    controls +=[ {p:control[p][0] for p in control} ]
    outputs = env_RL.step(control)
    outputs[0].update({"reward":outputs[1]})
    out_list.append(outputs)
    outputs,_,_,_ = outputs
    del outputs["reward"]
    _,hour,_,_ = env_RL.get_date()
pscharnho commented 3 years ago

Hi Benjamin, we are planning to make a short video series with explanations on Energym, we can also include some information about the wrappers there. It is currently not planned to have a complete RL example, but if you have some working code for that, we would be happy to include it!