intelligent-environments-lab / CityLearn

Official reinforcement learning environment for demand response and load shaping
MIT License
453 stars 165 forks source link

[BUG] CityLearnEnv.evaluate() raises AttributeError #85

Closed boomerr1 closed 10 months ago

boomerr1 commented 10 months ago

Issue Description

Downloading the quickstart jupyter notebook resulted in an attribute error after running the second code cell. The error originates from the evaluate function, where, apparently, a building in the schema doesn't have the 'net_electricity_consumption_without_storage_and_partial_load' attribute.

Expected Behavior

Expected an output of the cost functions.

Actual Behavior

Got the following error: CityLearnEnv.evaluate() raises AttributeError: 'Building' object has no attribute 'net_electricity_consumption_without_storage_and_partial_load'.

Steps to Reproduce

  1. pip install CityLearn==2.0.0

  2. 
    from citylearn.citylearn import CityLearnEnv
    from citylearn.agents.rbc import BasicRBC as RBCAgent

dataset_name = 'citylearn_challenge_2022_phase_1' env = CityLearnEnv(dataset_name, central_agent=True, simulation_end_time_step=1000) model = RBCAgent(env) model.learn(episodes=1)

print cost functions at the end of episode

kpis = model.env.evaluate().pivot(index='cost_function', columns='name', values='value') kpis = kpis.dropna(how='all') display(kpis)



## Environment

- CityLearn version:  2.0.0
- Operating System: Windows 11
- Python version: 3.8.5

## Possible Solution

x

## Additional Notes

Tested it outside of jupyter notebook as well, and got the same error. I played around by testing some different agents, but didn't make a difference. 

Changing the dataset to 'baeda_3dem' got rid of the error. This gave me the impression the error likely has to do with the schema.json.

However, given that the error happened through basic use of the citylearn package I wouldn't be surprised if the mistake was on my part.
kingsleynweye commented 10 months ago

@boomerr1 thanks for catching this error. I fixed it in the recent pull request. You were right that it is a schema error and the latest version of quickstart.ipynb has a fix.