2
$\begingroup$

I am wondering about the mere definition of the word 'policy'. Let us sassume that we have a finite space of states $S$ and a finite set of actions $A$. People tend to write that it is a 'stochastic function'

$$\pi : S \to A$$

i.e. what they mean is that we have a function $\pi^{(d)} : S \times A \to [0,1]$ such that for every $s \in S, \sum_{a \in A} \pi^{(d)}(a) = 1$ and the agent samples its next action according to this distribution, i.e. $P[A_t = a|S_t = s] = \pi^{(d)}(s, a)$ in the Markov process.

One of the first examples given in this area is the N-armed bandit. I.e. there are $N$ one-armed bandits $B_1, ..., B_N$ and every single one $B_i$ gives a reward distributed like $\mathcal{N}(\mu_i, \sigma_i)$ when pulled. The underlying probabilistic state machine (or whatever you want to call it) has just one reflexive state and all actions $B_1, ..., B_N$ lead back into that single state.

The first strategy ones comes up with is the greedy one: Pull some random arms $a_0, ..., a_w$, collect rewards $r_0, ..., r_w$ for a while and then at each time $t$ for each bandit $B_j$ compute

$$ p_j = \frac{\sum_{\substack{i \in \{0,...,t-1\} \\ a_i = B_j}} r_i}{\sum_{\substack{i \in \{0,...,t-1\} \\ a_i = B_j}} 1}$$

(i.e. compute the mean reward in the past that you received from $B_j$) and then pull $B_j$ that has the highest $p_j$.

However, now the action $a_t$ taken at time $t$ does not only depend on the single state in the automata but rather on all the past observations. In fact, that is the whole point in reinforcement learning: For a current state, check which states were similar in the past and check which action the agent took at that past time and from that somehow conclude what would be the smartest thing to do now.


So, it appears to me that the policy depends on much more than the current state: it depends on all the past states and all the past rewards ... So how come that one can simplify it like $\pi(s)$ or $\pi(a|s)$ when in fact one should write $\pi(a_t|s_t, ..., s_0, r_{t-1}, ..., r_1)$?


NB: It seems to me that there is a hidden concept of 'rounds'/matches involved in here. For example: when one wants the computer to learn to play pong using a neural network then one starts with a neural network and fixes that neural network for the whole round. In that sense, it is feeded the current state $s$ and samples an action $a$ from it. Only after the current match is finished one updates the weights of the neural network (multiplied by a factor depending on whether or not the game was won). So somehow a policy is a weird thing that is like $\pi(a|s)$ during one 'match' but the agent is allowed to change after one 'match' but then one needs to specify and formalize 'match' (i.e. start states and end states and how they are connected, etc). This seems a little complicated.

$\endgroup$
1
$\begingroup$

In think you are conflating the idea of the policy, with how some types of policy are learned.

The two are usually kept separate, and you can either have the concept of a "current policy" $\pi(a|s)$ or you might use a subscript $\pi_t(a|s)$ if you are explaining how policy changes from step to step in an online environment. Not all RL agents work purely online, or have a simple way to express how they change from step to step though. In fact not all policies have anything to do with RL - the existence of a policy function is independent of how that function is arrived at.

The current policy may well be determined through experience of the agent, but that is not usually considered "part of" the policy function. Instead the policy is viewed as a function that can be changed arbitrarily, by changing its parameters. In RL this is usually done either by directly modelling the function (as in policy gradient methods like REINFORCE) or via a learned value function (as in value methods, like Q learning), and then learning through updates based on experience.

There is no requirement for a policy to depend on experience in any particular way, and RL theory does usually not require tracking the dependency of policy on history to the degree where your suggested notation would be useful. To be complete, your suggested notation may also need the history of all the actions, the starting policy and/or its parameters, any hyper-parameters of learning, the type of RL algorithm being used. In addition, the influence of all this history is already summarised in the Q table or estimated q function or parameters of the policy function - reminding yourself of that in the notation is really optional, because how this dependency works is often already captured by shorter notation.

You may see, for policy gradient methods, the notation $\pi(a|s, \theta)$ or $u(s, \theta)$ or similar to represent the policy. The parameters $\theta$ of the function being learned are made explicit in those cases precisely because this is a useful detail to be reminded of. Of course $\theta$ is very likely dependent on the history of the agent etc as before, but there is little benefit from making this explicit, when $\theta$ completely sums up the influence that this history has had.

$\endgroup$
  • $\begingroup$ Ok, so the answer basically is: yes, it may depend on the whole past (an in particular, it can be non-markovian) as in the greedy policy of the N-armed bandit but one does abuse notation and one does not make that explicit because in RL we (probably?) want to use the Markovian probability on the states and actions and somewhat not on the policy directly? $\endgroup$ – Fabian Werner Sep 28 '18 at 17:53
  • $\begingroup$ @FabianWerner: It's non-Markovian only if you try to reduce the whole learning process into a MRP (perhaps in order to calculate expected reward whilst learning, in advance). There is no abuse of notation, the dependency on learning history is not directly relevant in any of the equations where e.g. $\pi(a|s)$ is used. Yes we are normally interested in a changing policy - hence a MDP and not a MRP for the model. $\endgroup$ – Neil Slater Sep 28 '18 at 18:52
  • $\begingroup$ Now I am confused. Let's say we leave out this reference to the past like you say. Let's say we follow an $\epsilon$-greedy policy in the multi bandit problem. Let us evaluate its performance: $v_\pi(s) = E_\pi[R_t + R_{t+1} + ... | S_t = s]$. Now $R_{t+1}, R_{t+2}, ...$ is the rewards if the agent follows the 'non adaptive' policy $\pi$. The 'non adaptive' version of $\epsilon$-greedy is just a greedy policy, right? So in fact, we are assigning the performance of a greedy policy (without exploration) to the performance of a policy that indeed does explore... ? $\endgroup$ – Fabian Werner Sep 28 '18 at 19:07
  • $\begingroup$ @FabianWerner: I don't understand your comment, sorry. But your formula for $v_{\pi}(s)$ is not applicable in a contextual bandit problem, as there is no model for the progression of state. You cannot predict expected $R_{t+1}$ unless you know the distribution of $S_{t+1}$, whilst in a contextual bandit problem you typically do not. I guess you could run it as an MDP with $\gamma = 0$ . . . $\endgroup$ – Neil Slater Sep 28 '18 at 19:42
  • $\begingroup$ There is a model for the state: if there are N bandits having some distributions of rewards $B_1,...,B_N$ then the model describing this is just a single state with all the N available actions pointing to that particular state again and action $a_i$ (which corresponds to pulling bandit number $i$ gives a reward distributed as $B_i$ describes... $\endgroup$ – Fabian Werner Sep 28 '18 at 20:24
0
$\begingroup$

After thinking about this for a little longer I found the following answer in Puterman, Markov Decision Processes, chapter 6:

Policies can be divided by two 'features' into four categories:

  • are they Markovian (yes/no)
  • are they stationary (yes/no)

If a policy is non Markovian then it indeed depends on the whole history and we then have two write expressions like $\pi(a_t|r_{t-1},s_{t-1},a_{t-1}, ..., s_0)$.

Stationary refers to whether or not the policy depends on the time $t$, i.e. a olicy could consist of multiple small policies $\pi = (\pi_0, \pi_1, ...)$ and at time $t$, $\pi$ involves $\pi_t$.

Both seem to make policies much more general, i.e. allowing access to the whole past should make the policy better, right? Also, making decisions based on the time should generally improve the quality of the policy, right?

Turns out: No. Under suitable conditions, the optimal policy is a deterministic, Markovian, stationary one, i.e. given a 'general', non Markovian, non stationary policy, you will always find a better one that actually is stationary and Markovian (and even deterministic).

Does that mean we can eliminate history dependent and/or non-stationary policies from our heads and from the theory? No! Why? Because you need these policies as 'intermediate steps' on your way towards the best policy.

Example 1: n-armed Bandits. Given a single state $s$ and actions $A_1, ..., A_N$ (that are the 'arms' of the bandit that you can pull) and attached rewards that only depend on the actions and are normally distributed like $\mathcal{N}(\mu_j, \sigma_j)$ for $j=1,...,N$, the best policiy is obviously to always pull the arm $A_j$ such that $\mu_j$ is maximal. However: given that the agent does not know ad hoc which mean is the best, it needs to figure that out using trial and error and one of the most used strategies actually is to approximate the means for each action $A_j$ empirically, i.e. sum the rewards that you received by pulling $A_j$ and divide by the amount of pulls.

Example 2: RNNs. Another strategy how to solve RL problems is using neural networks. Without going into the details of how RNNs work they have a so-called "hidden state". From a practical perspective, 'hidden' is the wrong word, because you can always see it as the programmer of that neural net, so lets call it 'internal'. This internal state is being updated after an episode and is being dragged along when playing, for example, one session of a game. Hence, RNNs descrivbe non Markovian policies!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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