Chapter 3: Finite Markov Decision Processes

第三章:有限马尔可夫决策过程

Reinforcement Learning: An Introduction (2nd Edition) — Sutton & Barto

目录 / Table of Contents

  1. 3.1 智能体-环境接口 / The Agent–Environment Interface
  2. 3.2 目标与奖励 / Goals and Rewards
  3. 3.3 回报与回合 / Returns and Episodes
  4. 3.4 统一符号 / Unified Notation
  5. 3.5 策略与价值函数 / Policies and Value Functions
  6. 3.6 最优策略与最优价值函数 / Optimal Policies and Value Functions
  7. 3.7 最优性与近似 / Optimality and Approximation
  8. 3.8 本章小结 / Summary

3.1 智能体-环境接口 / The Agent–Environment Interface

English MDPs are meant to be a straightforward framing of the problem of learning from interaction to achieve a goal. The learner and decision maker is called the agent. The thing it interacts with, comprising everything outside the agent, is called the environment. These interact continually, the agent selecting actions and the environment responding to these actions and presenting new situations to the agent. The environment also gives rise to rewards, special numerical values that the agent seeks to maximize over time.
中文 MDP是对"从交互中学习以实现目标"这一问题的直接表述。学习者和决策者称为智能体(agent)。与之交互的、包含智能体之外一切事物的部分称为环境(environment)。两者持续交互——智能体选择动作,环境响应这些动作并向智能体呈现新情境。环境还产生奖励(rewards),即智能体力求随时间最大化的特殊数值。
English At each of a sequence of discrete time steps t=0,1,2,..., the agent receives a representation of the environment's state St∈S, selects an action At∈A(s). One step later, it receives a reward Rt+1∈R and finds itself in a new state St+1. This gives rise to a trajectory: S0,A0,R1,S1,A1,R2,...
中文 在离散时间步序列 t=0,1,2,... 的每一步,智能体接收环境状态的表示 St∈S,选择一个动作 At∈A(s)。一步之后,它收到一个奖励 Rt+1∈R 并发现自己处于新状态 St+1。这产生了一条轨迹:S0,A0,R1,S1,A1,R2,...

动态函数 / Dynamics Function

English In a finite MDP, the sets of states, actions, and rewards all have a finite number of elements. The random variables Rt and St have well-defined discrete probability distributions dependent only on the preceding state and action:
中文 在有限MDP中,状态、动作和奖励的集合都只有有限个元素。随机变量 Rt 和 St 具有明确定义的离散概率分布,仅依赖于先前的状态和动作:
p(s',r | s,a) = Pr{St=s', Rt=r | St-1=s, At-1=a}
English The function p defines the dynamics of the MDP. From p we can derive state-transition probabilities p(s'|s,a) = Σr p(s',r|s,a) and expected rewards r(s,a,s') or r(s,a).
中文 函数p定义了MDP的动态特性。从p可以导出状态转移概率 p(s'|s,a) 和期望奖励 r(s,a,s') 或 r(s,a)。
回收机器人示例:一个移动机器人在办公室收集空罐。状态集 S={high, low}(电量高低),动作集 A(high)={search, wait},A(low)={search, wait, recharge}。搜索时找到罐有正奖励,但消耗电量;电量耗尽时需被"救援"(奖励-3)。该系统可用转移概率表和转移图完整描述。

3.2 目标与奖励 / Goals and Rewards

English The agent's goal is formalized in terms of a special signal called the reward. The agent's goal is to maximize the total amount of reward it receives — not immediate reward, but cumulative reward in the long run. We can state this as the reward hypothesis:

"All of what we mean by goals and purposes can be well thought of as the maximization of the expected value of the cumulative sum of a received scalar signal (called reward)."
中文 智能体的目标通过一种称为奖励的特殊信号来形式化。智能体的目标是最大化接收到的总奖励——不是即时奖励,而是长期累积奖励。我们可以将此表述为奖励假设:

"我们所指的目标和意图都可以很好地被视为最大化接收到的标量信号(称为奖励)累积和的期望值。"
关键原则:奖励信号是你向智能体传达你想要什么的方式,而非你希望如何实现它。例如,下棋智能体应仅因获胜而获得奖励,不应因吃掉对手棋子而获奖——否则它可能找到吃子却输棋的方法。

3.3 回报与回合 / Returns and Episodes

English The return Gt is the function of future rewards that the agent seeks to maximize. For episodic tasks (which naturally break into subsequences called episodes, e.g., games, maze runs):
中文 回报(return)Gt 是智能体力图最大化的未来奖励函数。对于回合性任务(自然地分为子序列——称为"回合",如棋局、迷宫穿越):
Gt = Rt+1 + Rt+2 + ... + RT    (回合性任务)
English For continuing tasks (which go on without limit), we use discounting. The agent chooses actions to maximize the expected discounted return:
中文 对于持续性任务(无限期进行),我们使用折扣。智能体选择动作以最大化期望折扣回报:
Gt = Rt+1 + γRt+2 + γ²Rt+3 + ... = Σk=0∞ γkRt+k+1
English where γ (0≤γ≤1) is the discount rate. If γ=0, the agent is "myopic" — only concerned with immediate rewards. As γ→1, the agent becomes more farsighted. A critical recursive relationship holds: Gt = Rt+1 + γGt+1
中文 其中 γ(0≤γ≤1)是折扣率。若γ=0,智能体是"近视的"——只关心即时奖励。当γ→1时,智能体变得更有远见。一个关键的递归关系成立:Gt = Rt+1 + γGt+1

3.4 回合与持续性任务的统一符号 / Unified Notation

English We unify episodic and continuing tasks by considering episode termination as entering a special absorbing state that transitions only to itself and generates only zero rewards. This way the same return formula works for both cases, and we include the possibility that T=∞ or γ=1 (but not both).
中文 我们通过将回合终止视为进入一个特殊的吸收状态来统一回合性和持续性任务——该状态仅转移到自身且仅产生零奖励。这样同一回报公式适用于两种情况,且允许T=∞或γ=1(但不同时)。

3.5 策略与价值函数 / Policies and Value Functions

策略 (Policy)

English A policy is a mapping from states to probabilities of selecting each possible action: π(a|s) = Pr{At=a | St=s}. Reinforcement learning methods specify how the agent's policy is changed as a result of its experience.
中文 策略(policy)是从状态到选择每个可能动作的概率的映射:π(a|s) = Pr{At=a | St=s}。强化学习方法规定智能体的策略如何随经验而改变。

状态价值函数 (State-value Function)

English The value function of a state s under policy π, denoted vπ(s), is the expected return when starting in s and following π thereafter:
中文 策略π下状态s的价值函数记为vπ(s),是从s出发并此后遵循π的期望回报:
vπ(s) = Eπ[Gt | St=s] = Eπ[Σk=0∞ γkRt+k+1 | St=s]

动作价值函数 (Action-value Function)

English The value of taking action a in state s under policy π, denoted qπ(s,a), is the expected return starting from s, taking a, and thereafter following π:
中文 策略π下在状态s采取动作a的价值,记为qπ(s,a),是从s出发、采取a、此后遵循π的期望回报:
qπ(s,a) = Eπ[Gt | St=s, At=a]

Bellman方程 / The Bellman Equation

English A fundamental property: value functions satisfy recursive relationships. The Bellman equation for vπ expresses the value of a state in terms of the values of its successor states:
中文 一个基本性质:价值函数满足递归关系。vπ的Bellman方程用后继状态的价值来表达一个状态的价值:
vπ(s) = Σa π(a|s) Σs',r p(s',r|s,a) [r + γ vπ(s')]
Bellman方程表明:起始状态的价值必须等于期望下一状态的(折扣)价值加上途中期望奖励。vπ是其Bellman方程的唯一解。

3.6 最优策略与最优价值函数 / Optimal Policies and Optimal Value Functions

English Solving a RL task means finding a policy that achieves a lot of reward over the long run. A policy π is better than π' if vπ(s) ≥ vπ'(s) for all s. There is always at least one optimal policy π*. All optimal policies share the same optimal state-value function and optimal action-value function:
中文 解决RL任务就是找到长期获得大量奖励的策略。若对所有s都有vπ(s) ≥ vπ'(s),则π优于π'。总存在至少一个最优策略π*。所有最优策略共享相同的最优状态价值函数和最优动作价值函数:
v*(s) = maxπ vπ(s)     q*(s,a) = maxπ qπ(s,a)

Bellman最优方程 / Bellman Optimality Equation

English The Bellman optimality equation expresses the fact that the value of a state under an optimal policy must equal the expected return for the best action from that state:
中文 Bellman最优方程表达了这样一个事实:最优策略下一个状态的价值必须等于从该状态采取最佳动作的期望回报:
v*(s) = maxa∈A(s) Σs',r p(s',r|s,a) [r + γ v*(s')]
q*(s,a) = Σs',r p(s',r|s,a) [r + γ maxa' q*(s',a')]
English Key insight: Once we have v*, determining an optimal policy is easy — for each state, find the action that achieves the maximum in the Bellman optimality equation (a one-step search). Having q* makes it even easier: simply find any action that maximizes q*(s,a), without needing to know anything about the environment's dynamics.
中文 核心洞见:一旦有了v*,确定最优策略很容易——对每个状态,找到在Bellman最优方程中取得最大值的动作(一步搜索)。有了q*更简单:只需找到最大化q*(s,a)的任何动作,无需知道环境的动态特性。
网格世界示例:一个矩形网格中,四个方向的动作确定性地移动智能体。特殊状态A(奖励+10并转移到A')和B(奖励+5并转移到B')。求解v*的Bellman方程得到最优价值函数(图3.5中),最优策略显示为每个格子中指向最优后继的箭头。

3.7 最优性与近似 / Optimality and Approximation

English Explicitly solving the Bellman optimality equation provides one route to finding an optimal policy, but this solution relies on three assumptions rarely true in practice: (1) we accurately know the environment's dynamics; (2) we have enough computational resources; (3) the Markov property. For example, backgammon has ~10²⁰ states — it would take thousands of years to solve exactly.
中文 显式求解Bellman最优方程是找到最优策略的一条途径,但该方案依赖三个在实践中很少同时成立的假设:(1) 准确知道环境动态;(2) 有足够的计算资源;(3) 马尔可夫性质。例如,西洋双陆棋约有10²⁰个状态——精确求解需要数千年。
English Many different decision-making methods can be viewed as ways of approximately solving the Bellman optimality equation. The online nature of reinforcement learning makes it possible to approximate optimal policies in ways that put more effort into learning for frequently encountered states, at the expense of less effort for infrequently encountered states.
中文 许多不同的决策方法都可以视为近似求解Bellman最优方程的方式。强化学习的在线特性使其能够以如下方式近似最优策略:对频繁遇到的状态投入更多学习精力,而牺牲对不常遇到状态的学习。

3.8 本章小结 / Summary

English Reinforcement learning is about learning from interaction how to behave to achieve a goal. Key elements: actions (choices by agent), states (basis for choices), rewards (basis for evaluation). A policy is a stochastic rule for selecting actions. The return is what the agent maximizes. Value functions assign expected returns to states or state-action pairs. Optimal value functions assign the largest achievable expected return. The Bellman optimality equations are consistency conditions that optimal value functions must satisfy.
中文 强化学习是关于从交互中学习如何行动以实现目标的。关键要素:动作(智能体的选择)、状态(选择的基础)、奖励(评价的基础)。策略是选择动作的随机规则。回报是智能体最大化的目标。价值函数为状态或状态-动作对赋予期望回报。最优价值函数赋予可实现的最大期望回报。Bellman最优方程是最优价值函数必须满足的一致性条件。
English In complete knowledge problems, the agent has a complete model of the environment's dynamics. In incomplete knowledge problems, no such complete model is available. Even with a complete model, the agent typically cannot perform enough computation per time step to fully use it. A well-defined notion of optimality organizes our approach but is an ideal that agents can only approximate.
中文 在完全知识问题中,智能体拥有环境动态的完整模型。在不完全知识问题中,没有这样的完整模型。即使有完整模型,智能体通常也无法在每步进行足够的计算来充分利用它。明确定义的最优性概念组织了我们的方法,但它只是智能体只能不同程度近似的理想目标。

核心概念速查 / Key Concepts at a Glance

English Term 中文术语 简要说明
Agent / Environment智能体 / 环境学习者与决策者 / 智能体之外的一切
State St状态环境在某时刻的表示
Dynamics p(s',r|s,a)动态函数MDP的完整概率描述
Reward Hypothesis奖励假设所有目标都可视为累积奖励的最大化
Return Gt回报未来奖励的(折扣)累积和
Episodic / Continuing回合性 / 持续性有自然终点的任务 / 无限持续的任务
Discount Rate γ折扣率控制未来奖励的现值,0=近视,1=远视
Policy π(a|s)策略状态到动作概率的映射
vπ(s) / qπ(s,a)状态/动作价值函数遵循策略π的期望回报
Bellman EquationBellman方程价值函数的递归一致性关系
v*(s) / q*(s,a)最优价值函数所有策略中可达到的最大期望回报
Bellman Optimality Eq.Bellman最优方程最优价值函数必须满足的特殊一致性条件