马尔可夫决策过程与动态规划
1. 折扣因子实验
折扣因子在马尔可夫决策过程中起着重要作用,它平衡了即时奖励和未来奖励的重要性。我们可以通过实验不同的折扣因子值,来观察其对价值函数的影响。
1.1 折扣因子为 0
当折扣因子为 0 时,意味着我们只关注即时奖励。以下是相应的代码:
gamma = 0
V = cal_value_matrix_inversion(gamma, trans_matrix, R)
print("The value function under the optimal policy is:\n{}".format(V))
输出结果为:
tensor([[ 1.],
[ 0.],
[-1.]])
这与奖励函数一致,因为我们只考虑下一步获得的奖励。
1.2 折扣因子接近 1
当折扣因子接近 1 时,未来奖励会被更多地考虑。以 𝝲 = 0.99 为例:
gamma = 0.99
V = cal_value_matrix_inversion(gamma, trans_matrix, R)
print("The value function under the optimal policy is:\n{}".format(V))
输出结果为:
tensor([[
超级会员免费看
订阅专栏 解锁全文
1260

被折叠的 条评论
为什么被折叠?



