Chapter 3. The Reinforcement Learning Problem


what is the reinforcement learning problem ?
The reinforcement learning problem is meant to be a straightforward framing of the problem of learning from interaction to achieve a goal.

what is a reinforcement learning method?
Any method that is suited to solving reinforcement learning problem we consider to be a reinforcement learning method.


3.1 The Agent-Environment Interface

问题描述
智能体-环境的交互,建立强化学习中智能体与环境交互的框架。

The agent-environment interaction reinforcement learning
“The agent-environment interaction reinforcement learning”

名词解析:
Agent: the learner and decision-maker.
Environment: the thing it interacts with, comprising everything outside the agent.

符号解释:
S S S: 环境状态的集合,the set of environment’s states, s t ∈ S s_t \in S stS - the environment state at time step t t t.
A ( s t ) A(s_t) A(st): 处于 s t s_t st状态时可以采取的动作, the set of actions available in state s t s_t st, a t ∈ A ( s t ) a_t \in A(s_t) atA(st) - an action selected at time step t t t.
R R R:reward, r t + 1 ∈ R r_{t+1} \in R rt+1R - a numerical reward.(用 r t + 1 r_{t+1} rt+1而不用 r t r_t rt表示瞬时奖励的原因:下一个奖励和下一个状态是被联合决定的。we use r t + 1 r_{t+1} rt+1 instead of r t r_t rt to deote the immediate reward due to the action taken at time t t t because it emphasizes that the next reward and the next state, s t + 1 s_{t+1} st+1, are jointly determined)
π \pi π: the agent’s policy.
π t \pi_t πt: the agent implements a mapping from states to probabilities of selecting each possible action at each time step t t t.
π ( s , a ) \pi(s,a) π(s,a): the probability that a t = a a_t = a at=a and s t = s s_t = s st=s.

智能体与环境的区分(the boundary between agent and environment):
actions 是我们想要学习如何做出的任何决策。
states 是我们在做出决策的时候可能用到的有用信息。
任何不能被agent随意改变的事情被认为不属于agent部分的,而是environment一部分。但是environment 对于agent并不是黑盒的,reward 的计算不属于agent部分的。

目标导向学习的行为被约简为3个agent与environment之间的回传信号:
①一个信号用来表示智能体选择的动作 - one signal to represent the choices made by the agent(actions);
②一个信号用来表示被选择的动作的基础 - one signal to represent the basis on which the choices are made(states);
③一个信号用来定义智能体的目标 - one signal to define the agent’s goal(the rewards).

框架的评价:
上图描述的框架适用于大多数的 decision-learning 问题,但并不是所有的强化学习问题都可以用此框架来抽象出来表示。


3.2 Goals and Rewards

问题描述
用一系列从环境中反馈给智能体的奖励信号来表征强化学习所要实现的目标。这种形式化的表述也是强化学习中的重要的特性之一。

目标与奖励之间的关联:
用奖励来形式化目标。
不是最大化瞬时奖励,而是最大化累计奖励。
奖励信号是想告诉agent想要实现的目标,而不是实现此目标所采取的方式。
把关于奖励设置的信息归于Agent之外。
奖励的设置会表征我们想要实现的目标,如何设置奖励也是至关重要的。


3.3 Returns

问题描述
形式化累积奖励。
统一化 episodic tasks 和 continuing tasks 的累积奖励。

两种强化学习类型
①episodic task: 智能体和环境的交互可以被自然地分割成一系列的episode。
episode:(trial) 整个交互过程可以被分为多个子部分。每一个episode都以一个特殊状态结束,这个特殊的状态称为 终止状态(terminal state),用 S + S^+ S+ 表示,非终止状态(nonterminal state)用 S S S 表示。
②continuing task:不能够被分为多个子部分,可以无限制的一直进行下去的任务。

R t R_t Rt : return , defined as some specific function of the reward sequence after time step t t t.

对于 epoisodic tasks ,一个最简单的表示 R t R_t Rt 的式子为:
R t = r t + 1 + r t + 2 + . . . + r T R_t = r_{t+1} + r_{t+2} + ... + r_T Rt=rt+1+rt+2+...+rT,
T T T: a final time step
对于 continuing tasks , T = ∞ T = \infty T=,所以不能像离散化任务那样子定义。此时引入了一个新的变量,discount rate 。
γ \gamma γ: discount rate, 0 ≤ γ ≤ 1 0 \le \gamma \le 1 0γ1, 对后续奖励打个折扣,这样处理的话最后的累计奖励的值不会发散。决定了后续奖励的比重, γ = 0 \gamma = 0 γ=0 时,只考虑瞬时奖励, γ = 1 \gamma = 1 γ=1时,后续的每一个奖励都与现在的瞬时奖励等重,此时的agent 更加具有远见,但是难以计算。
此时的期望奖励表示为:
R t = r t + 1 + γ r t + 2 + γ 2 r t + 3 + . . . = ∑ k = 0 ∞ γ k r t + k + 1 R_t = r_{t+1} + \gamma r_{t+2} + \gamma^2 r_{t+3} + ... = \sum_{k=0}^{\infty} \gamma^k r_{t+k+1} Rt=rt+1+γrt+2+γ2rt+3+...=k=0γkrt+k+1

统一化处理:
为了更加精确地描述episodic tasks ,需要引入格外的标记符号。例如: s t , i s_{t,i} st,i - the state at ktime t t t of episode i i i( a t , i a_{t,i} at,i, r t , i r_{t,i} rt,i, π t , i \pi_{t,i} πt,i, T i T_i Ti, etc),但是实际中我们不会刻意地去区分两个不同的episode,所以还是用简单的表示形式来表示, 如 s t s_t st 表示 s t , i s_{t,i} st,i
对于 episodic tasks 和 continuing tasks ,需要用统一的符号来表示,我们引入 吸收态(absoring state)来实现。
absorbing state

“吸收态特性”
统一形式为:
R t = ∑ k = 0 T γ K r t + k + 1 R_t = \sum_{k=0}^T \gamma^K r_{t+k+1} Rt=k=0TγKrt+k+1
T = ∞ T = \infty T= γ = 1 \gamma = 1 γ=1不能同时成立。


3.4 The Markov Property

问题描述
状态信号需要的信息。定义了环境的马尔科夫特性。
ouer mian concern is not with designing the state singal, but with deciding waht actions to take.

状态表示:
可以是原始信号,也可以是对原始信号加工之后的信息,也可以是序列信息等。但是智能体不能从状态表示中推断出环境的所有信息(例如,机器在玩十三点扑克游戏,它不能从状态表示中知道下一张牌是啥)。
agent can’t konw hidden state information in the environment.

Markov Porperty:
成功保留所有相关信息的状态信号定义为具有马尔科夫特性。(a state signal that succeeds in retaining all relevant information is said to be Markov, or to have Markov Property)
environment responds to the action taken at time t t t:
P r { s t + 1 = s ′ , r t + 1 = r ∣ s t , a t , r t , s t − 1 , a t − 1 , r t − 1 , . . . , r 1 , s 0 , a 0 } Pr\{s_{t+1}=s', r_{t+1}=r|s_t,a_t,r_t,s_{t-1},a_{t-1}, r_{t-1}, ... ,r_1,s_0,a_0\} Pr{st+1=s,rt+1=rst,at,rt,st1,at1,rt1,...,r1,s0,a0}
如果状态信号具有Markov Property,那么
P r { s t + 1 = s ′ , r t + 1 = r ∣ s t , a t } Pr\{s_{t+1} = s', r_{t+1} = r| s_t,a_t\} Pr{st+1=s,rt+1=rst,at}

具有Markov 特性的选择动作的最好策略 等价于 具备完整历史信息的选择动作的最好策略。当状态信号不具备Markov 特性的时候,我们也把它当成近似具备此特性。Markov 特性在强化学习中是很重要的特性,因为具有此特性之后,decisions 和 values 可以被认为是当前状态的函数。


3.5 Markov Decision Processes

问题描述
什么是马尔科夫决策过程?

名词解释:
MDP(Markov Decision Property): 满足马尔科夫性质的强化学习任务被认为是 马尔科夫决策过程, 如果它的状态和动作是有限的,那么就是有限的马尔科夫决策过程(finite MDP)。
转移概率(transition probabilities): 给出任意的状态 s s s 和动作 a a a ,下一个可能的状态 s ′ s' s 的概率为
P s s ′ a = P r { s t + 1 = s ′ ∣ s t = s , a t = a } P_{ss'}^a = Pr\{ s_{t+1} = s'| s_t = s, a_t = a\} Pssa=Pr{st+1=sst=s,at=a}
同理,下一个状态的期望回报:
R s s ′ a = E { r t + 1 ∣ s t = s , a t = a , s t + 1 = s ′ } R_{ss'}^a = E\{ r_{t+1} | s_t = s, a_t = a, s_{t+1} = s'\} Rssa=E{rt+1st=s,at=a,st+1=s}

掌握了 P s s ′ a P_{ss'}^a Pssa R s s ′ a R_{ss'}^a Rssa 之后,只有关于value期望的reward的分布信息是丢失的。

关于 垃圾回收机器MDP 的例子:
recyling robot能够做的决定有:
①actively search for a can;
②remain stationary and wait for someone to bring it a can;
③go back to home base to recharge its battery.
agent 做出相应的决定取决于电池的状态,电池的状态可以被视为是状态的空间 S = { h i g h , l o w } S = \{high, low\} S={high,low},相应的动作的空间有 A ( h i g h ) = { s e a r c h , w a i t } A(high) = \{search, wait\} A(high)={search,wait} A ( l o w ) = { s e a r c h , w a i t , r e c h a r g e } A(low) = \{search, wait, recharge\} A(low)={search,wait,recharge},当电池的状态为 h i g h high high时,我们认为此时机器采取 r e c h a r g e recharge recharge的动作是十分愚蠢的,所以去除了这种情况。

transition probabilities and expected rewards for the finite MDP of the recycling robot example
状态转移概率矩阵
R s e a r c h > R w a i t R^{search} > R^{wait} Rsearch>Rwait

a transition graph
状态转移概率图


3.6 Value Functions

问题描述
几乎所有的强化学习算法都在预测value function,预测智能体在一个给定的状态下有多好(或者说在一个给定的状态下采取某一个动作有多少),也就是在此状态下智能体能够接收到的累积奖励有多少。

value functions:
V π ( s ) V^{\pi}(s) Vπ(s): 在策略 π \pi π的指示下,从状态 s s s开始的期望value。
对于MDPs,定义如下:
V π ( s ) = E π { R t ∣ S t = s } = E π { ∑ k = 0 ∞ γ k r t + k + 1 ∣ s t = s } V^{\pi}(s) = E_\pi\{ R_t|S_t=s\} = E_\pi\{\sum_{k=0}^\infty \gamma^k r_{t+k+1}|s_t=s\} Vπ(s)=Eπ{RtSt=s}=Eπ{k=0γkrt+k+1st=s}
E π { } E_\pi\{\} Eπ{}表示智能体根据策略 π \pi π之后的期望value。我们规定终止状态的vlaue 是 0。我们称呼 V π V^\pi Vπ 为 the state-value function for policy π \pi π

Q π ( s , a ) Q^\pi(s,a) Qπ(s,a):在策略 π \pi π的指示下,从状态 s s s采取动作 a a a之后的期望value。
对于MDPs,定义如下:
Q π ( s , a ) = E π { R t ∣ s t = s , a t = a } = E π { ∑ k = 0 ∞ γ k r t + k + 1 ∣ s t = s , a t = a } Q^\pi(s,a) = E_\pi\{R_t|s_t=s,a_t=a\} = E_\pi\{\sum_{k=0}^\infty\gamma^k r_{t+k+1}|s_t=s,a_t=a\} Qπ(s,a)=Eπ{Rtst=s,at=a}=Eπ{k=0γkrt+k+1st=s,at=a}
我们称呼 Q π Q^\pi Qπ为 the action-value function for policy π \pi π

Monte Carlo Methods: average over random samples of actual returns.

value functions 的一个基本特性:具有递归性质(recursive relationships)。

V π ( s ) = E π { R t ∣ s t = s } = E π { ∑ k = 0 ∞ γ k r t + k + 1 ∣ s t = s } = E π { r t + 1 + γ ∑ k = 0 ∞ γ k r t + k + 2 ∣ s t = s } = ∑ a π ( s , a ) ∑ s ′ P s s ′ a [ R s s ′ a + γ E π { ∑ k = 0 ∞ γ k r t + k + 2 ∣ s t + 1 = s ′ } ] = ∑ a π ( s , a ) ∑ s ′ P s s ′ a [ R s s ′ a + γ V π ( s ′ ) ] \begin{aligned} V^\pi(s) &= E_\pi\{R_t | s_t=s\}\\ &= E_\pi\{\sum_{k=0}^\infty \gamma^k r_{t+k+1} | s_t=s\}\\ &= E_\pi\{r_{t+1} + \gamma\sum_{k=0}^\infty\gamma^k r_{t+k+2} | s_t=s\}\\ &= \sum_a \pi(s,a) \sum_{s'}P_{ss'}^a[R_{ss'}^a + \gamma E_\pi\{\sum_{k=0}^\infty\gamma^k r_{t+k+2}| s_{t+1}=s'\}]\\ &= \sum_a \pi(s,a) \sum_{s'}P_{ss'}^a[R_{ss'}^a + \gamma V^\pi(s')] \end{aligned} Vπ(s)=Eπ{Rtst=s}=Eπ{k=0γkrt+k+1st=s}=Eπ{rt+1+γk=0γkrt+k+2st=s}=aπ(s,a)sPssa[Rssa+γEπ{k=0γkrt+k+2st+1=s}]=aπ(s,a)sPssa[Rssa+γVπ(s)]

这个式子称为 Bellman equations for V π V^\pi Vπ,它将一个状态的value与此状态的后继状态联系在了一起。可以通过下图来解释或联系记忆。
backup diagram for V^\pi

“backup diagram for V π V^\pi Vπ(从后往前看)”

同理,Bellman equation for Q π Q^\pi Qπ的表示如下:
Q π ( s , a ) = ∑ s ′ P s s ′ a [ R s s ′ a + ∑ a ′ π ( s ′ , a ′ ) γ Q π ( s ′ , a ′ ) ] Q^\pi(s,a) = \sum_{s'}P_{ss'}^a [R_{ss'}^a + \sum_{a'}\pi(s',a')\gamma Q^\pi(s',a')] Qπ(s,a)=sPssa[Rssa+aπ(s,a)γQπ(s,a)]
backup diagram for Q^\pi


Gridworld 例子展示:
在一个5x5的格子中,每一个格子表示一个状态,在每一个格子下都有四种可以采取的动作(上、下、左、右),每个动作被选取的概率等价。当智能体采取动作之后它的位置没有发生变化,那么我们将此时的瞬时奖励设置为-1,其余的(除了两个特殊状态)设置为0,特殊状态为 A \boldsymbol{A} A B \boldsymbol{B} B,从状态 A \boldsymbol{A} A开始,无论采取哪种动作,下个状态都会转移到 A ′ \boldsymbol{A'} A,并给予瞬时奖励+10;从状态 B \boldsymbol{B} B开始,无论采取哪种动作,下个状态都会转移到 B ′ \boldsymbol{B'} B,并给与瞬时奖励+5。(设置discount rate γ \gamma γ = 0.9)
如图所示:
grid example

“(a) exceptioal reward dynamics; (b) state-value function for the equiproable random policy.”
从图中我们可以看出:状态 A \boldsymbol{A} A是最好的状态,同时状态 A \boldsymbol{A} A的期望奖励(8.8)小于其对应的瞬时奖励(10),因为从状态 A \boldsymbol{A} A下一步肯定会转移到状态 A ′ \boldsymbol{A'} A,但是在 A ′ \boldsymbol{A'} A之后智能体采取动作之后可能会跑出格子的范围。但是状态 B \boldsymbol{B} B的期望奖励要高于其对应的瞬时奖励,From B ′ \boldsymbol{B'} B the expected penalty(negative reward) for possibly running into an edge is more than compensated for by the expected gain for possibly stumbling onto A \boldsymbol{A} A or B \boldsymbol{B} B


3.7 Optimal Value Functions

问题描述
optimal policy, optimal state-value function, optimal action-value function, and how to solve the Bellman optimal equtions.

名词解释:
π ∗ \pi^* π: optimal policies, π ≥ π ∗ \pi \ge \pi^* ππ, if and only if V π ( s ) ≥ V π ′ ( s ) V^\pi(s) \ge V^{\pi'}(s) Vπ(s)Vπ(s) for all s ∈ S s \in S sS.
V ∗ V^* V: optimal state-value function, V ∗ ( s ) = m a x π V π ( s ) V^*(s) = max_\pi V^\pi(s) V(s)=maxπVπ(s) for all s ∈ S s \in S sS.
Q ∗ Q^* Q: optimal action-value function, Q ∗ ( s , a ) = m a x π Q π ( s , a ) Q^*(s,a) = max_\pi Q^\pi(s,a) Q(s,a)=maxπQπ(s,a), for all s ∈ S s \in S sS and a ∈ A ( s ) a \in A(s) aA(s).
V ∗ V^* V Q ∗ Q^* Q的联系:
Q ∗ ( s , a ) = E { r t + 1 + γ V ∗ ( s t + 1 ) ∣ s t = s , a t = a } Q^*(s,a) = E\{ r_{t+1} + \gamma V^*(s_{t+1})| s_t=s, a_t=a\} Q(s,a)=E{rt+1+γV(st+1)st=s,at=a}


Bellman optimality equation:
it 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.
V ∗ ( s ) = m a x a ∈ A ( s ) Q π ∗ ( s , a ) = m a x a E π ∗ { R t ∣ s t = s , a t = a } = m a x a E π ∗ { ∑ k = 0 ∞ γ k r t + k + 1 ∣ s t = s , a t = a } = m a x a E π ∗ { r t + 1 + γ ∑ k = 0 ∞ γ k r t + k + 2 ∣ s t = s , a t = a } = m a x a E { r t + 1 + γ V ∗ ( s ′ ) ∣ s t = s , a t = a } = m a x a ∑ s ′ P s s ′ a [ R s s ′ a + γ V ∗ ( s ′ ) ] \begin{aligned} V^*(s) &= max_{a\in A(s)} Q^{\pi*}(s,a)\\ &= max_a E_{\pi^*}\{R_t|s_t=s, a_t=a\}\\ &= max_a E_{\pi^*}\{\sum_{k=0}^\infty \gamma^k r_{t+k+1}|s_t=s, a_t=a\}\\ &= max_a E_{\pi^*} \{r_{t+1} + \gamma\sum_{k=0}^\infty \gamma^k r_{t+k+2}|s_t=s,a_t=a\}\\ &= max_a E\{r_{t+1} + \gamma V^*(s') | s_t=s, a_t=a\}\\ &= max_a \sum_{s'}P_{ss'}^a[R_{ss'}^a + \gamma V^*(s')] \end{aligned} V(s)=maxaA(s)Qπ(s,a)=maxaEπ{Rtst=s,at=a}=maxaEπ{k=0γkrt+k+1st=s,at=a}=maxaEπ{rt+1+γk=0γkrt+k+2st=s,at=a}=maxaE{rt+1+γV(s)st=s,at=a}=maxasPssa[Rssa+γV(s)]
backup diagram for
"backup diagram for V ∗ V^* V"
同理:
Q ∗ ( s , a ) = E { r t + 1 + γ m a x a ′ Q ∗ ( s t + 1 , a ′ ) ∣ s t = s , a t = a } = ∑ s ′ P s s ′ a [ R s s ′ a + γ m a x a ′ Q ∗ ( s ′ , a ′ ) ] \begin{aligned} Q^*(s,a) &= E\{r_{t+1} + \gamma max_{a'}Q^*(s_{t+1},a')|s_t=s, a_t=a\}\\ &= \sum_{s'}P_{ss'}^a[R_{ss'}^a + \gamma max_{a'}Q^*(s',a')] \end{aligned} Q(s,a)=E{rt+1+γmaxaQ(st+1,a)st=s,at=a}=sPssa[Rssa+γmaxaQ(s,a)]
backup for
"backup diagram for Q ∗ Q^* Q"


解Bellman optimal equation 的方式:
如果有了 V ∗ V^* V的信息,那么我们只需要进行 one-step search,如果有了 Q ∗ Q^* Q的信息,那么就可以直接对其查找。

例子:
Bellman Optimality Equations for the Recyling Robot
V ∗ ( h ) = m a x { P h h s [ R h h s + γ V ∗ ( h ) ] + P h l s [ R h l s + γ V ∗ ( l ) ] , P h h w [ R h h w + γ V ∗ ( h ) ] + P h l w [ R h l w + γ V ∗ ( l ) ] } = m a x { R s + γ [ α V ∗ ( h ) + ( 1 − α ) V ∗ ( l ) ] , R w + γ V ∗ ( h ) } \begin{aligned} V^*(h) &= max \begin{Bmatrix} P_{hh}^s[R_{hh}^s + \gamma V^*(h)] + P_{hl}^s[R_{hl}^s+ \gamma V^*(l)],\\ P_{hh}^w[R_{hh}^w + \gamma V^*(h)] + P_{hl}^w[R_{hl}^w + \gamma V^*(l)]\end{Bmatrix}\\ &= max \begin{Bmatrix}R^s + \gamma[\alpha V^*(h) + (1-\alpha)V^*(l)],\\ R^w + \gamma V^*(h)\end{Bmatrix} \end{aligned} V(h)=max{Phhs[Rhhs+γV(h)]+Phls[Rhls+γV(l)],Phhw[Rhhw+γV(h)]+Phlw[Rhlw+γV(l)]}=max{Rs+γ[αV(h)+(1α)V(l)],Rw+γV(h)}

同理: V ∗ ( l ) V^*(l) V(l)的表达式也可得。

Solving the Gridworld

V ∗ V^* Vfor the gridworld example”

" π ∗ \pi^* π for the gridworld example"

完整解决Bellman Optimal Equation 需要的条件:
① know the dynamics of the environment,
② enough computational resources to complete the computation of the solution,
③ the Markov property.

近似解:
由于实际情况中存在的计算效率和所需内存的问题,使得我们即使掌握了环境的动态性质也无法完整求解,但是我们建立的关于强化学习的框架可以使我们得以近似求解。


3.8 总结

强化学习是一种如何在交互式中实现一个目标的学习方法。
强化学习框架的组成元素,agent 和 environment 的边界区分。
强化学习任务的两种形式,对于episodic task 和 continuing task 的累积奖励的统一化处理(引入 discount rate 和 吸收态)。
Markov Property 的介绍,如果状态信号满足Markov Property,那么此强化学习是一个MDP(Markov Decision Process),有限的MDP的定义。
value funtions 的表示,其Bellman optimal equations的形式,
如何解决Bellman optimal equation,需要满足的条件,我们现在大多数的做法是采取近似解的方式。


第一版第三章:Richard S. Sutton and Andrew G. Barto.《An Introduction to Reinforcement Learning》
现已有第二版

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值