5
$\begingroup$

I have difficulty understanding the meaning of stationary policy in the RL (MDP) setting.

Specifically, let's assume stationary dynamics $$P(s_{t+1}=j|s_t=i,a) = P (s_{k+1}=j|s_k=i,a) \ \forall t,k,i,j,a$$ In other words, given a fixed policy, the probability of transitioning from state $i$ to state $j$ under some action $a$ does not change over time.

We know that a stationary policy will always choose the same action in the same state, independent of time, while a non-stationary policy can choose different action in the same state, depending on time.

I do not understand why in the case of finite-horizon problems the optimal policy is non-stationary while in the case of infinite horizon problems the optimal policy is stationary.

If this is truly the case, why most RL algorithms use stationary policies in episodic settings (i.e. finite-horizon)?

Furthermore, in reality, a lot of environments are non-stationary and it makes more sense to use a non-stationary policy instead of a stationary one. Again, why most RL algorithms use stationary policies in these cases, too?

$\endgroup$
4
  • 1
    $\begingroup$ Do you have sources for all these definitions/claims in your question? e.g. the equation, definitions of stationary policy and fixed policy, claims that one is optimal in finite horizon problems and the other in infinite horizon problems. I don't think I agree that all of those definitions are correct, which is why I'm wondering where they're coming from $\endgroup$ Commented Feb 17, 2018 at 9:56
  • $\begingroup$ Stationary means time-invariant. The equation follows directly. You can have a look at Wikipedia en.wikipedia.org/wiki/Stationary_process. The definition can also be found in any decent book. The fact that the optimal policy for the finite horizon setting is not guaranteed to be stationary is mentioned here: goo.gl/52HGjg (around 15:25). I actually never found a formal statement that the policy in the infinite horizon setting is stationary. I only inferred this because all major RL literature uses this assumption (for example I have never seen $Q(s,a)$ which depends on time). $\endgroup$
    – niko
    Commented Feb 17, 2018 at 13:12
  • 1
    $\begingroup$ Example for non-stationary optimal policy: MDP with 0 stage rewards and 2 terminal states, $s_1$ and $s_{10}$ with $r(s_1)=1, r(s_{10})=10$. Consider starting at $s_0$ which is right next to $s_1$ and 5 steps away from $s_{10}$. Let $T=5$. Initially, you will try to go to $s_{10}$. Since the environment is stochastic, you might end up again at $s_0$ at step 4. As you know you cannot reach $s_{10}$ in the remaining steps, you will try to go to $s_1$ - hence the choice depends on t. Similarly, with some good value of the discount factor, the same case can be made in the infinite horizon setting. $\endgroup$
    – niko
    Commented Feb 17, 2018 at 13:15
  • $\begingroup$ @nbro, we don't seem to have an MDP tag. I guess it's not clear to me we really need it. People have been using MP for a long time now. $\endgroup$ Commented Feb 23, 2019 at 17:34

3 Answers 3

2
$\begingroup$

Yes, you are correct that infinite horizon MDPs admit a stationary policy (which means time-invariant policy).

There are two questions:

  1. Why do finite horizon MDPs have a nonstationary policy while infinite horizon MDP has a stationary policy.
  2. Why do we use episodic tasks than finite horizon MDPs in practice.

Your first question is easy to answer. Consider a 1 length horizon and a 10 length horizon. If you have only 1 step left, it makes sense to immediately take the action that gives you the highest expected reward. However, if you have more steps, it might be possible to take any action that gives you a lesser reward at the moment but would take you to a better state from where you could get better rewards. For example, if you have an exam tomorrow, you will be busy studying for your exam, and you will keep all other stuff away. If you follow cricket, consider the twenty-twenty matches. The batsman would hit the ball differently for the same kind of ball in the first and the last over. However, in the case of an infinite horizon MDP, how many ever steps you have already taken, you have an infinite number of steps remaining. That means you are exactly in the same situation as the previous time you visited the same state. If you are aware of infinite series sums, consider x = 1+ 1/2 + 1/4 + 1/8 + ...=1 + 1/2(1 + 1/2 + 1/4 + 1/8 +...) = 1 + x/2. The same stuff has happened here, because of which you replace the infinite series in the bracket with s. If you considered a test match to be a decent approximation for an infinite horizon case within the first 20 overs, you would notice that the style of play is consistent over these 20 overs (unlike the case in a 20-20 match).

Coming to your second question, episodic tasks are goal-oriented. If you reach a particular state, you can end. No limit is directly imposed on the number of steps the agent can take(in fact you may not even know the time that is required beforehand), but just that he needs to finish the job. Such situations are best modelled as episodic tasks. Another reason from a computational perspective is that policy planning on infinite horizon MDPs is easier than that of finite horizon MDPs.

$\endgroup$
1
$\begingroup$

I will try to give you an intuitive answer that abstracts away from your particular model. For starters, let's note that if you have any situation where the value of a particular action/policy depends on what happens later, then obviously the optimal action/policy is going to depend on your assessment of what is likely to happen later. If you are dealing with a model with stationary transitions then the only thing that is different at each time period is the number of time periods remaining.

Now, in the stationary finite-horizon case with times $t=0,1,2,...,T$, at each time period there is a different number of remaining time periods. Consequently, the "what happens later" is different in each time period, so unsurprisingly, the optima changes at each time period. Contrarily, in the stationary infinite-horizon case with times $t=0,1,2,...$, at each time period there is still an infinite number of future time periods. Since "what happens later" is the same at each time period, there is a single optima.

This type of dynamic arises in all sorts of problems, but one case where it arises is in game theory. For example, consider a cooperative game where the players can cooperate for some mutual benefit, but they can also betray each other for some immediate higher unilateral benefit. In the infinite-horizon game there is no incentive to betray because the long-term consequences will be negative. But in the finite-horizon game, once you get near the end of the game (e.g., the last round) there is no "later" consequence to betrayal, so it becomes more desirable. (Indeed, for this reason, many game theorists believe that cooperative and moral norms of behaviour arise out of an expecation of long-term repeated interaction.)

$\endgroup$
0
$\begingroup$

We know that a stationary policy will always choose the same action in the same state, independent of time, while a non-stationary policy can choose different action in the same state, depending on time.

This is not entirely correct. A stationary policy can still be nondeterministic (e.g. have a 50% chance of selecting action 1, and a 50% chance of selecting action 2, regardless of the current time).

I do not understand why in the case of finite-horizon problems the optimal policy is non-stationary while in the case of infinite horizon problems the optimal policy is stationary.

The example you already gave in comments yourself explains why non-stationary policies may be required in a finite-horizon setting. I don't think the same case can be made for the infinite-horizon setting though, since the discount factor $\gamma$ is not state-dependent, and there is no time limit that suddenly changes whether or not a highly-rewarding state is still reachable.

If this is truly the case, why most RL algorithms use stationary policies in episodic settings (i.e. finite-horizon)? Furthermore, in reality, a lot of environments are non-stationary and it makes more sense to use a non-stationary policy instead of a stationary one. Again, why most RL algorithms use stationary policies in these cases, too?

It's difficult to tell why choices were made across the board without any specific cases; there may have been different reasons in different cases. In many cases, I expect it is done because it is already difficult enough in practice to learn a single stationary policy for complex problems; learning many different policies for different remaining time horizons would take even more time.

Note that, in cases where the remaining time-to-go is observable to an agent, and also considered to be really important, you could include that time-to-go in your state representation. Then, a "stationary" policy that doesn't change over time (but implicitly still takes it into account by observing the remaining time in the state) can still be optimal.

$\endgroup$
2
  • 1
    $\begingroup$ Thanks. You are right about the infinite horizon case, it was my confusion. So, theoretically, if we have a stationary, infinite-horizon MDP, is the optimal policy stationary or it might be non-stationary? $\endgroup$
    – niko
    Commented Feb 17, 2018 at 15:23
  • 1
    $\begingroup$ @niko To be completely precise, in that case I'd say there exists a stationary policy that is optimal. There may be multiple different optimal policies though, so there could also be nonstationary optimal policies (for example one that switches every time step between different optimal stationary policies) $\endgroup$ Commented Feb 17, 2018 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.