citylearn模块single_agent奖励函数reward_function设计
参考文献:
A Centralised Soft Actor Critic Deep Reinforcement Learning
Approach to District Demand Side Management through
CityLearn 2020:11–4. doi:10.1145/3427773.3427869.
每天的累计reward在0-300范围内
net_electric_consumption in one day -13.72085932928827
net_electric_consumption in one day -87.24712266261261
net_electric_consumption in one day -101.96857692574041
net_electric_consumption in one day -97.90874044831011
net_electric_consumption in one day -122.00274374121156
net_electric_consumption in one day -123.47533288637986
net_electric_consumption in one day -20.941267323103407
net_electric_consumption in one day -14.24673384461663
net_electric_consumption in one day -81.38051917535762
net_electric_consumption in one day -113.88382543664981
net_electric_consumption in one day -135.83601615225706
net_electric_consumption in one day -147.74054092999444
1
if env.time_step % 24 == 0:
#print('net_electric_consumption in one day ', sum(env.net_electric_consumption[-24:-1]))
# 如果白天放电,reward_day = 0,否则为-300
if np.array(action_day[7:18]).mean() > 2:
reward_day = -300
else:
reward_day = 0
# 如果夜晚充电,reward_day = 300,否则为-300
if np.array(action_day[0:6]).mean() > 2.1:
reward_night = 300
else:
reward_night = -300
reward = reward + reward_day + reward_night
# 耗电量为负,则电价为0,如果耗电量为正,则电价为正, reward为负
def reward_function_sa(electricity_demand):
#print('electricity_demand ', electricity_demand)
total_energy_demand = 0
for e in electricity_demand:
total_energy_demand += -e
price = max(total_energy_demand * 0.01, 0)
#print('price ', price)
for i in range(len(electricity_demand)):
electricity_demand[i] = price * electricity_demand[i]
return sum(electricity_demand)
参数:
MAX_EPISODES = 300
learn_rate = 0.001
2
# 鼓励晚上充电,白天放电
if env.time_step % 24 == 0:
#print('net_electric_consumption in one day ', sum(env.net_electric_consumption[-24:-1]))
# 如果白天放电,reward_day = 0,否则为-300
if np.array(action_day[7:-1]).mean() > 2.0![请添加图片描述](https://img-blog.csdnimg.cn/5eb0bae13a00449ea1223da57250b047.png)
:
reward_day = -10
else:
reward_day = 1
# 如果夜晚充电,reward_day = 300,否则为-300
if np.array(action_day[0:7]).mean() > 2.0:
reward_night = 10
else:
reward_night = -3
reward = reward + reward_day + reward_night
#print('reward: ', reward)
reward_epoch += reward
MAX_EPISODES = 100
learn_rate = 0.00001
3
if env.time_step % 24 == 0:
#print('net_electric_consumption in one day ', sum(env.net_electric_consumption[-24:-1]))
# 如果白天放电,reward_day = 0,否则为-300
if np.array(action_day[7:-1]).mean() > 2.0:
reward_day = -30
else:
reward_day = 10
# 如果夜晚充电,reward_day = 300,否则为-300
if np.array(action_day[0:7]).mean() > 2.1:
reward_night = 40
else:
reward_night = -30
reward = reward + reward_day + reward_night
#print('reward: ', reward)
reward_epoch += reward
MAX_EPISODES = 100
learn_rate = 0.00001