Complete value iteration algorithm