Skip to main content
SARSA is generalized policy iteration with action values, like ε-greedy Monte-Carlo Control, with one change: it evaluates the policy with a TD target instead of the Monte Carlo return. The two steps are the same as before:
  1. Learn the action values Q(s,a)Q(s,a) of the current policy, here with TD learning.
  2. Improve the policy by making it ϵ\epsilon-greedy with respect to QQ.

The SARSA update

Temporal Difference (TD) Prediction learns state values. For control the agent needs action values, and the TD(0) update carries over directly: Q(St,At)←Q(St,At)+α[Rt+1+γQ(St+1,At+1)−Q(St,At)],Q(S_t,A_t) \leftarrow Q(S_t,A_t) + \alpha \bigl[ R_{t+1} + \gamma Q(S_{t+1}, A_{t+1}) - Q(S_t,A_t) \bigr], with Q(St+1,⋅)=0Q(S_{t+1}, \cdot) = 0 when St+1S_{t+1} is terminal. sarsa-update-tree Backup tree of SARSA. The update uses the quintuple (St,At,Rt+1,St+1,At+1)(S_t, A_t, R_{t+1}, S_{t+1}, A_{t+1}), which gives the method its name. The target uses At+1A_{t+1}, the action the agent actually takes next with its ϵ\epsilon-greedy policy. SARSA therefore learns the values of the policy it follows, exploration included: it is an on-policy method. Monte Carlo control improves the policy once per episode. SARSA improves it after every step, because the ϵ\epsilon-greedy policy is computed from the current QQ, and QQ changes with every update. Evaluation does not run to completion between improvements; each step moves QQ a little toward qπq_\pi and the policy a little toward greedy. sarsa-policy-iteration Generalized policy iteration in SARSA: every time step performs one partial evaluation and one ϵ\epsilon-greedy improvement. The random actions of the ϵ\epsilon-greedy policy keep every action in every visited state getting updated, so the agent can discover that an action it does not currently favor is better.

Algorithm

The next action A′A' is chosen before the update, because the target needs it, and it is the action taken at the next step.

Convergence

Tabular SARSA converges with probability 1 to an optimal policy and to q∗q_* if every state-action pair is visited infinitely often, the policy becomes greedy in the limit (GLIE, for example ϵ=1/t\epsilon = 1/t), and the step sizes satisfy the usual conditions ∑tαt=∞\sum_t \alpha_t = \infty and ∑tαt2<∞\sum_t \alpha_t^2 < \infty (Sutton & Barto, 2018). With a fixed ϵ\epsilon, it converges to the best ϵ\epsilon-greedy policy instead. SARSA on the Windy Gridworld runs the algorithm on a task where Monte Carlo control struggles. The Q-learning navigation section puts the SARSA target next to the Q-learning target for a TurtleBot3 that learns to avoid obstacles. Key references: (Sutton & Barto, 2018)

References

  • Sutton, R., Barto, A. (2018). Reinforcement Learning: An Introduction. Link

Found an error on this page? Report an issue.