Bellman Equation
v π ( s ) = E π [ R t + 1 ⏟ Immediate Reward + γ v π ( S t + 1 ) ⏟ Discounted Future Value | S t = s ⏟ Starting at state s ] v_\pi(s) = \mathbb{E}_\pi \left[ \underbrace{R_{t+1}}_{\text{Immediate Reward}} + \gamma \underbrace{v_\pi(S_{t+1})}_{\text{Discounted Future Value}} \;\middle|\; \underbrace{S_t = s}_{\text{Starting at state s}} \right] v π ( s ) = E π Immediate Reward R t + 1 + γ Discounted Future Value v π ( S t + 1 ) Starting at state s S t = s
Fundamental concept in RL using a recursive equation to express a way to compute the value of a state based on the values of its successor states.
v ( s ) = E [ R t + 1 + γ R t + 2 + γ 2 R t + 3 + … | S t = s ] = E [ R t + 1 + γ ( R t + 2 + γ R t + 3 + … ) ⏟ G t + 1 | S t = s ] = E [ R t + 1 + γ G t + 1 | S t = s ] = E [ R t + 1 + γ v ( S t + 1 ) | S t = s ] = E [ R t + 1 ∣ S t = s ] ⏟ Immediate Reward R ( s ) + γ E [ v ( S t + 1 ) ∣ S t = s ] ⏟ Expected Next State Value ( ∵ E [ X + γ Y ] = E [ X ] + γ E [ Y ] ) = R ( s ) + γ ∑ s ′ P ( s ′ ∣ s ) v ( s ′ ) ⏟ Transition Dynamics ( ∵ E [ g ( X ) ] = ∑ x P ( x ) g ( x ) ) \begin{aligned}
v(s) &= \mathbb{E} \left[ R_{t+1} + \gamma R_{t+2} + \gamma^2 R_{t+3} + \dots \;\middle|\; S_t = s \right] \\[8pt]
&= \mathbb{E} \left[ R_{t+1} + \gamma \underbrace{\left( R_{t+2} + \gamma R_{t+3} + \dots \right)}_{G_{t+1}} \;\middle|\; S_t = s \right] \\[8pt]
&= \mathbb{E} \left[ R_{t+1} + \gamma G_{t+1} \;\middle|\; S_t = s \right] \\[8pt]
&= \mathbb{E} \left[ R_{t+1} + \gamma v(S_{t+1}) \;\middle|\; S_t = s \right] \\[8pt]
&= \underbrace{\mathbb{E}[R_{t+1} \mid S_t = s]}_{\text{Immediate Reward } \mathcal{R}(s)} + \gamma \, \underbrace{\mathbb{E}[v(S_{t+1}) \mid S_t = s]}_{\text{Expected Next State Value}} && (\because \mathbb{E}[X + \gamma Y] = \mathbb{E}[X] + \gamma\mathbb{E}[Y]) \\[10pt]
&= \mathcal{R}(s) + \gamma \underbrace{\sum_{s'} \mathcal{P}(s' \mid s) v(s')}_{\text{Transition Dynamics}} && \left(\because \mathbb{E}[g(X)] = \sum_x P(x)g(x)\right)
\end{aligned} v ( s ) = E [ R t + 1 + γ R t + 2 + γ 2 R t + 3 + … S t = s ] = E R t + 1 + γ G t + 1 ( R t + 2 + γ R t + 3 + … ) S t = s = E [ R t + 1 + γ G t + 1 ∣ S t = s ] = E [ R t + 1 + γ v ( S t + 1 ) ∣ S t = s ] = Immediate Reward R ( s ) E [ R t + 1 ∣ S t = s ] + γ Expected Next State Value E [ v ( S t + 1 ) ∣ S t = s ] = R ( s ) + γ Transition Dynamics s ′ ∑ P ( s ′ ∣ s ) v ( s ′ ) ( ∵ E [ X + γY ] = E [ X ] + γ E [ Y ]) ( ∵ E [ g ( X )] = x ∑ P ( x ) g ( x ) )
Bellman Equation Example
v ( s BL ) = 7 + γ ( 0.1 ⋅ v ( s BL ) + 0.5 ⋅ ( s T L ) + 0.4 ⋅ ( s B R ) ) v(s_{\text{BL}}) = 7 + \gamma(0.1 \cdot v(s_{\text{BL}}) + 0.5 \cdot(s_{TL}) + 0.4 \cdot(s_{BR})) v ( s BL ) = 7 + γ ( 0.1 ⋅ v ( s BL ) + 0.5 ⋅ ( s T L ) + 0.4 ⋅ ( s BR ))
v = R + γ P v v = \mathcal{R} + \gamma \mathcal{P} v v = R + γ P v
[ v ( s 1 ) ⋮ v ( s n ) ] ⏟ V of a particular state = [ R ( s 1 ) ⋮ R ( s n ) ] ⏟ Immediate Reward + γ [ P 11 ⋯ P 1 n ⋮ ⋱ ⋮ P n 1 ⋯ P n n ] ⏟ Transition Matrix [ v ( s 1 ) ⋮ v ( s n ) ] ⏟ V of future state \begin{aligned}
\underbrace{
\begin{bmatrix}
v(s_1) \\
\vdots \\
v(s_n)
\end{bmatrix}}_{\text{V of a particular state}}
=
\underbrace{\begin{bmatrix}
\mathcal{R}(s_1) \\
\vdots \\
\mathcal{R}(s_n)
\end{bmatrix}}_{\text{Immediate Reward}}
+ \gamma \underbrace{\begin{bmatrix}
\mathcal{P}_{11} & \cdots & \mathcal{P}_{1n} \\
\vdots & \ddots & \vdots \\
\mathcal{P}_{n1} & \cdots & \mathcal{P}_{nn}
\end{bmatrix}}_{\text{Transition Matrix}}
\underbrace{\begin{bmatrix}
v(s_1) \\
\vdots \\
v(s_n)
\end{bmatrix}}_{\text{V of future state}}
\end{aligned} V of a particular state v ( s 1 ) ⋮ v ( s n ) = Immediate Reward R ( s 1 ) ⋮ R ( s n ) + γ Transition Matrix P 11 ⋮ P n 1 ⋯ ⋱ ⋯ P 1 n ⋮ P nn V of future state v ( s 1 ) ⋮ v ( s n )
Solving the Bellman Equation
Linear System of Equations
v = R + γ P v v − γ P v = R ( I − γ P ) v = R v = ( I − γ P ) − 1 R \begin{aligned}
\mathcal{v} &= \mathcal{R} + \gamma \mathcal{P}\mathcal{v} \\
\mathcal{v} - \gamma \mathcal{P}\mathcal{v} &= \mathcal{R} \\
(I - \gamma \mathcal{P})\mathcal{v} &= \mathcal{R} \\
\mathcal{v} &= (I - \gamma \mathcal{P})^{-1} \mathcal{R}
\end{aligned} v v − γ P v ( I − γ P ) v v = R + γ P v = R = R = ( I − γ P ) − 1 R
Computational Complexity: O ( n 3 ) O(n^3) O ( n 3 )
For small MDPs : direct solution is possible (up to 100 states)
For large MDPs :
Iterative methods
Dynamic Programming
Monte Carlo Tree
TD learning