Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
benjamin-arfa opened this issue Jul 4, 2021 · 1 comment

Comments

@benjamin-arfa
Copy link

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
Copy link
Collaborator

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants