-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_reward.py
63 lines (51 loc) · 2.7 KB
/
get_reward.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from typing import List
import numpy as np
###########################################################################
##### Specify your reward function here #####
###########################################################################
def get_reward(electricity_consumption: List[float], carbon_emission: List[float], electricity_price: List[float]) -> List[float]:
"""CityLearn Challenge user reward calculation.
Parameters
----------
electricity_consumption: List[float]
List of each building's/total district electricity consumption in [kWh].
carbon_emission: List[float], optional
List of each building's/total district carbon emissions in [kg_co2].
electricity_price: List[float], optional
List of each building's/total district electricity price in [$].
Returns
-------
rewards: List[float]
Agent(s) reward(s) where the length of returned list is either = 1 (central agent controlling all buildings)
or = number of buildings (independent agent for each building).
"""
# *********** BEGIN EDIT ***********
# Replace with custom reward calculation
carbon_emission = np.array(carbon_emission).clip(min=0)
electricity_price = np.array(electricity_price).clip(min=0)
reward = (carbon_emission + electricity_price)*-1
# ************** END ***************
return reward
def get_default_reward(electricity_consumption: List[float], carbon_emission: List[float], electricity_price: List[float]) -> List[float]:
"""CityLearn Challenge user reward calculation.
Parameters
----------
electricity_consumption: List[float]
List of each building's/total district electricity consumption in [kWh].
carbon_emission: List[float], optional
List of each building's/total district carbon emissions in [kg_co2].
electricity_price: List[float], optional
List of each building's/total district electricity price in [$].
Returns
-------
rewards: List[float]
Agent(s) reward(s) where the length of returned list is either = 1 (central agent controlling all buildings)
or = number of buildings (independent agent for each building).
"""
# *********** BEGIN EDIT ***********
# Replace with custom reward calculation
carbon_emission = np.array(carbon_emission).clip(min=0)
electricity_price = np.array(electricity_price).clip(min=0)
reward = (carbon_emission + electricity_price)*-1
# ************** END ***************
return reward