2
$\begingroup$

I've been recently given an assignment based on Reinforcement Learning and I'm supposed to implement the value iteration algorithm in a grid environment.

The assignment:

enter image description here

enter image description here

My doubt is why do I even need an initial arbitrary policy as given in the parameters (in the assignment) to implement the value iteration algorithm? And so, the change in the values of a and b shouldn't affect the algorithm. Am I correct in my thinking about it?

$\endgroup$
0

1 Answer 1

2
$\begingroup$

It seems to me that you're thinking about the parameters a and b as being characteristic of the agent that's moving in the environment (therefore determining the final policy), but they are actually a characteristic of the environment.

Think of a frozen lake. You want to pass the lake but there is a hole five meters in front of you. Let's say you have boots with a rubber sole, so there is no risk to slip while walking (i.e. all transition probabilities =1). What is the optimal policy? Simply moving forward till the hole, goes around it and then forward again. But what if you were wearing wooden clogs instead? Now if you walk forward there is the risk to not be able to stop when you want to (i.e. when you decide to move forward of one step you might fail and keep going forward for several steps, with probability a). How many steps would you wait before moving to the left or to the right to avoid risking to fall into the hole? The optimal policy is obviously different in this second scenario. Think about it, I will not answer in detail about how the parameters affect the final policy because stack exchange is not meant for homework.

Also, an arbitrary policy is necessary simply because in value iteration you first update the values and only when they converge you infer from then the optimal policy. So you need some arbitrary prior belief about the environment to start update the values.

Edit

So here's a quick visualisation of the impact of different transition probabilities (the parameters a and b in your assignment) on the optimal policy. I used a different grid to make it easier and more explicit (i.e. you don't even need to calculate the values to see the optimal policy).

As you can see in the picture below, there are some terminal states in the third column and a goal state which gives a huge reward on top of it. From the starting point on the bottom we want to reach the goal state.

enter image description here

We have two cases:

Non stochastic environment

On the left we have the case in which all transition probabilities are 1. In this case the optimal policy is simply going forward till the second row, where the goal state is located, and then move right or left to reach it. The terminal states are not scary at all, in this case we could consider them as walls that we can't cross, but the optimal policy do not reflect any risk of falling in them. This is precisely because the transition probabilities are all 1.

Stochastic environment

On the right we have a different situation. In this case only 3 action have a transition probability of 1: going south, east or west. The transition probability for nord is 0.2 meaning that 80% of the time we will slip and go east instead (I wrote right in the picture meaning east, my bad). What is the impact of this simple change in the environment?

This time the second column become really dangerous, because if we try to go nord and fail we will end on a terminal state. On the other hand, if we choose another action we will end on a legitimate state, without any risk because the other transition probabilities are 1! Therefore the agent learn that on the left side of the grid the best strategy is to go down and circumnavigate the terminal states from the right, because only in the fourth column we can move north without risk, in fact in those cells even if we try go north and fail we would just hit a wall and we could try again going north the next turn till we will eventually succeed.

Hope this make sense!

$\endgroup$
16
  • $\begingroup$ Thank you for the answer but I still have some doubts like why is my problem similar to the second case of frozen lake you talked about? In my problem, if the agent in state $s$ takes an action $a$ to reach state $s'$, isn't the transition probability simply equal to one/zero? I thought the probabilities given were actually $\pi(a|s)$, which gives the probability of a particular action being chosen when our agent is in a state $s$. And while applying the value iteration update rule, we don't require these probabilities, $$V_{k+1}(s) \leftarrow max_a \sum_{s',r}p(s',r|s,a)[r+\gamma V_k(s')]$$ $\endgroup$
    – Carrick
    Commented Apr 17, 2020 at 0:35
  • $\begingroup$ @Carrick From the text I would say that the transition probabilities are (N,S,W,E) = (0.2,0.3,a,b), or at least I don't see any other possible interpretation. So you have to reason in terms of a stochastic environment, and therefore the frozen lake, which is a classic example used to explain stochastic grid world (plenty of many others if you google it, I suggest particularly this one. $\endgroup$ Commented Apr 17, 2020 at 1:01
  • $\begingroup$ Also the transition probabilities in the formula are: p(s',r | s,a) i.e. probability of getting reward r of state r' given an action a in state s (and you sum over all the possible outcomes of action a in state s, which are not unique in a stochastic environment) $\endgroup$ Commented Apr 17, 2020 at 1:01
  • $\begingroup$ So, you mean the given probabilities in the assignment are actually the transition probabilities, $p(s',r|s,s)$, right? And I can't access the link you shared $\endgroup$
    – Carrick
    Commented Apr 17, 2020 at 1:12
  • $\begingroup$ @Carrick Yes exactly. Here's again the link, hope it works if I paste it without hyperlink cis.upenn.edu/~cis519/fall2015/lectures/… $\endgroup$ Commented Apr 17, 2020 at 1:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .