intelligent-environments-lab / CityLearn

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

[BUG] citylearn.reward_function.MARL #60

Closed Skywuuuu closed 1 year ago

Skywuuuu commented 1 year ago

Hi, I think there is a bug in citylearn.reward_function.MARL.

Issue Description

Please provide a brief description of the issue. When I use MARL reward function in file citylearn.reward_function as my reward function, bug appears at line 64 of this file.

Expected Behavior

It should give the maximum number between 0 and _district_electricityconsumption.

Actual Behavior

TypeError: 'numpy.float64' object cannot be interpreted as an integer

Steps to Reproduce

Just replace the reward function to MARL, and then the bug appears.

Environment

Possible Solution

Simply add parentheses inside the np.nanmax.

reward = np.sign(building_electricity_consumption)*0.01*building_electricity_consumption**2*np.nanmax((0, district_electricity_consumption))
kingsleynweye commented 1 year ago

Hi @Skywuuuu thanks for finding the bug and proposing the solution. I just pushed a commit that fixes it. You will need to update your CityLearn version to the most recent release to have the fix as well as other updates:

pip install CityLearn==2.0b3