# Does "Iterative Policy Evaluation" Guarantee the "Optimal Policy"?

I am reading about "Iterative Policy Evaluation" algorithm in the context of Reinforcement Learning (http://incompleteideas.net/book/ebook/node41.html). If I have understood this correctly - in a problem that contains multiple "states", this algorithm is used to estimate the "value" of being in any of these states. Once we are able to estimate these "values", we should then be able to study the optimality of selecting different actions to navigate these different states contingent on the state we are currently situated in (i.e. "policies").

For example, consider a problem in which there is there is a grid made of 16 squares. The goal is to reach the "shaded grey squares" by moving "up, down, left and right" (i.e. "actions"):

If we were to use the "Iterative Policy Evaluation" algorithm in this problem, we would be able to estimate the "value" (in this problem, lower values are considered better than higher values) of being in any "square" (i.e. "state"):

This part is understandable so far - the next part is what confuses me. In this particular problem, (after we have used the "Iterative Policy Evaluation" algorithm) we are able to "peak" and see the "value" of all neighboring states relative to the state we are currently in. This means that in the very immediate sense ("greedy"), depending on where we are currently located - we are able to infer which square (i.e. "state") to visit next and which "action" to take next : this is simply done by examining which "neighboring square" has the smallest "value":

This means, we can use the "Iterative Policy Evaluation" algorithm to get a "value map". For instance:

• If I am in Square 9, the "optimal policy" could be to go "UP, UP, LEFT" or "RIGHT, RIGHT, DOWN" or "UP, LEFT, UP" or "RIGHT, DOWN, RIGHT".

But as the diagram indicates, this is a "greedy policy" - and I am not sure if this "greedy policy" is ALWAYS optimal (i.e. leads to the shaded grey squares in the fewest number of movements). This leads me to my question - how can I be certain that "following the arrows" will ALWAYS lead me to the "shaded squares" in the least number of turns - should I sometimes ignore the arrows?:

• In problems where there are far more "states" (e.g. 1000 squares), after we have estimated the values of all these states using the "Iterative Policy Evaluation" algorithm: is it possible that sometimes taking "non-greedy actions" (i.e. moving to a neighboring square having a "less-desirable value" than some other neighboring square) might result in you reaching the "shaded grey squares" in fewer movements (i.e. "more optimal") than a "greedy policy"?

• In other words, is the "Iterative Policy Evaluation" algorithm able to estimate the values of states in such a way, such that : no matter which square you are currently, the greedy policy will always be the "optimal policy" (i.e. take you to the grey shaded squares in the fewest turns)? Or does the "Iterative Policy Evaluation" algorithm only estimate the values of states and the "optimal policy" remains to be determined using some other algorithm?

Thank you!

PS: I am aware of a theorem called the "Policy Improvement Theorem" that has the ability to update and improve the values of the states estimated by the "Iterative Policy Evaluation" - but my question still remains: Even when all states have had their optimal values estimated, will selecting the "greedy policy" at each state necessarily become the "overall optimal policy"? Is it possible that even when all states have had their optimal values estimated, perhaps selecting the policy that leads to the highest reward after "n-steps" instead of "1 step" could be better - or is there some math proof that suggests otherwise?