The rules that determine the agent’s action for each state in an MDP are known as the policy.

This may be stochastic (the policy defines a distribution over actions for each state) or deterministic (the agent always takes the same action in a given state).

  • A stochastic policy returns a probability distribution over each possible action for state , from which a new action is sampled.
  • A deterministic policy returns one for the action that is chosen for state and zero otherwise.

A stationary policy depends only on the current state. A non-stationary policy also depends on the time step.

The environment and the agent form a loop. The agent receives the state and reward from the last time step. Based on this, it can modify the policy if desired and choose the next action . The environment then advances to the next state according to and issues a reward according to .

Optimal policy

We want a policy that maximizes the return. For MDPs (but not POMDPs), there is is always a deterministic, stationary policy that maximizes the value of every state. If we know this optimal policy, then we get the optimal state-value function :

Similarly, the optimal state-action value function is obtained under the optimal policy:

Turning this on its head, if we knew the optimal action-values , then we could derive the optimal policy by choosing the action with the highest value:

  • The notation here means set to one for action and to zero for other actions.

Some RL algorithms are based on alternately estimating the action values and policy (Tabular Reinforcement Learning).