当我学习教程9的时候,我把rl_actions搞糊涂了。因为在程序上,rl_actions是没有初始化和定义的。为什么_apply_rl_actions函数和compute_reward函数会有一个'rl_actions‘参数?我还检查了车辆内核代码,关于apply_acceleration函数。原来的是:
def apply_acceleration(self, veh_ids, acc):
"""See parent class."""
# to hand the case of a single vehicle
if type(veh_ids) == str:
veh_ids = [veh_ids]
acc = [acc]
for i, vid in enumerate(veh_ids):
if acc[i] is not None and vid in self.get_ids():
this_vel = self.get_speed(vid)
next_vel = max([this_vel + acc[i] * self.sim_step, 0])
self.kernel_api.vehicle.slowDown(vid, next_vel, 1e-3)发布于 2019-07-25 19:12:49
查看step方法中的flow/envs/base_env.py,这是调用apply_rl_actions和compute_reward的地方。这3种方法都将应用于代理的操作rl_actions作为参数。这些操作由RL算法提供。rl_actions的形状是您的环境的action_space方法中提供的形状。
RL算法在每个步骤自动调用step方法,为其提供要应用的操作。Flow的环境实际上被封装在Gym环境中,该环境被提供给RL算法。RL算法可以与任何Gym环境一起使用,这使得它非常通用,因为所有Gym环境都有step、reset等方法。如果您想了解更多有关该算法如何工作的信息,请查看如何训练自定义Gym环境。
https://stackoverflow.com/questions/57197779
复制相似问题