\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{xcolor}

\DeclareMathOperator*{\E}{\mathbb{E}}
\let\Pr\relax
\DeclareMathOperator*{\Pr}{\mathbb{P}}

\newcommand{\eps}{\epsilon}
\newcommand{\inprod}[1]{\left\langle #1 \right\rangle}
\newcommand{\R}{\mathbb{R}}

\newcommand{\handout}[5]{
  \noindent
  \begin{center}
  \framebox{
    \vbox{
      \hbox to 5.78in { {\bf CS 388R: Randomized Algorithms } \hfill #2 }
      \vspace{4mm}
      \hbox to 5.78in { {\Large \hfill #5  \hfill} }
      \vspace{2mm}
      \hbox to 5.78in { {\em #3 \hfill #4} }
      \textcolor{red}{\textbf{NOTE:} THESE NOTES HAVE NOT BEEN EDITED OR CHECKED FOR CORRECTNESS}
    }
  }
  \end{center}
  \vspace*{4mm}
}

\newcommand{\lecture}[4]{\handout{#1}{#2}{#3}{Scribe: #4}{Lecture #1}}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{assumption}[theorem]{Assumption}

% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.
\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

\parindent 0in
\parskip 1.5ex

\begin{document}

\lecture{9 --- Sep. 28, 2017}{Fall 2017}{Prof.\ Eric Price}{Changyong Hu}

\section{Overview}

In the last lecture we discussed Perfect Hashing and Bloom Filters.

In this lecture we moved from hashing to routing, and we are going to use randomization to improve routing.

\section{Introduction}
	
	Suppose we have a network modeled by a directed graph with $N$ nodes and they can communicate with each other by sending messages through edges in the graph. Consider the communication model that each node has a message for some nodes, all communication among nodes proceeds in a sequence of synchronous round. In each round, each edge can only pass one message or packet. So sending $k$ messages over an edge takes $k$ units of time.\\
	What is a proper problem to analyze?
	\begin{itemize}
		\item	If one node wants to communicate with other node, one just broadcasts to everyone.
		\item	What makes it hard is if multiple nodes want to send messages. However, if every node want to communicate with one same node, the bottleneck would happen there so it's not interesting either. 
	\end{itemize}
	So we discuss permutation routing in this class: 
	\section{Permutation Routing}
	Each node $i$ wants to send a message to $\Pi(i)\in [N]$, $\Pi(i)$ is a permutation.\\
	Question: how long does it take to route all messages?\\
	Ideally: oblivious routing:\\
	An oblivious routing algorithm for the permutation routing problem satisfies the following property: the route followed by $v_i$ depends on $d(i)$ alone, and not on $d(j)$ for any $j \neq i$. $v_i$ is the packet from node $i$, $d(i)$ is the destination of packet from node $i$.
	\begin{eqnarray*}
		&\text{Path } P_i \text{ for } i\rightarrow \Pi(i), ~~~~P_i \text{ is independent of } \Pi(-i) &\\
		& P_i=(e_1,\cdots,e_l)&\\
		& e_j \text{ is an edge: } l \text{ is length} &\\
	\end{eqnarray*}
	\subsection{Hypercube Graph}
	$N$ vertices: $N=2^n$, each vertex is indexed by $n$ bit string.\\
	edge $i$ to $j$ exists if $i$ and $j$ have exactly one bit difference.\\
	Diameter $n\Longrightarrow$ ideally $O(n)$ time to route.
	
	\begin{eqnarray*}
		\mathbb{E}[\text{distance between }i\text{ and }\Pi(i)]&=&\frac{n}{2}\\
		\mathbb{E}[\text{total number of messages passed}]&\geq &\frac{Nn}{2}
	\end{eqnarray*}
	%\begin{figure}[!t]
	%	\centering
	%	\includegraphics[width=0.5\linewidth]{hypercubes.eps}
	%	\caption{"hypercubes" for $n=0,1,2,3$}
	%\end{figure}
	{\centering
		can hope for $N$ messages/round\\
		so hope for $O(n)$ rounds.\\
	}
	Can we get $O(n)$ time to resolve any permutation?	

	message that is targeted at node $j$, currently most significant bit $b$ of $i \oplus j$, send $i\rightarrow i\oplus 2^b$\\
	Bit fixing routing:\\
	fix bits left to right\\
	\begin{eqnarray*}
		&\Pi( 0 1 0 1 1 0 1)= & 1 1 0 1 1 1 0\\
		\downarrow & 1 1 0 1 1 0 1~&\\
		\downarrow & 1 1 0 1 1 1 1~&\\
		\downarrow & 1 1 0 1 1 1 0~&
	\end{eqnarray*}
	However, $\exists$ permutations such that bit fixing takes $\Omega(\sqrt{N})$ time steps.
	\begin{eqnarray*}
		\overbrace{X}^{\lfloor n/2\rfloor} & 0& \overbrace{0 0\cdots 0}^{\lfloor n/2\rfloor}\\
		0 0 \cdots 0 & 1& ~~ X
	\end{eqnarray*}
	So after weight($X$) times of bit fixing, where weight$(X)=\sum_{i=1}^nX_i$, all the messages come to the same position 
	\begin{eqnarray*}
		\overbrace{00 \cdots 0}^{\lfloor n/2\rfloor} & 0& \overbrace{0 0\cdots 0}^{\lfloor n/2\rfloor},\text{  next step for every node goes to}\\ 
		00\cdots 0 & 1& 00\cdots 0, \text{and final destination is}\\
		0 0 \cdots 0 & 1& \underbrace{X}_{\lfloor n/2\rfloor}
	\end{eqnarray*}
	So for all $X$, the messengers will cross the same edge $e$ from $00\cdots 0$ to $\overbrace{00\cdots 0}^{\lfloor n/2\rfloor} 1 \overbrace{00\cdots 0}^{\lfloor n/2\rfloor}$. 
	Pick $X$ to have exact $n/4$ $1$s in it, $\binom {n/2}{n/4} \approx \sqrt{N/n}$ \\ 
	Claim: for all deterministic oblivious algorithms, $\exists \Pi$ s.t. it takes $\Omega(\sqrt{\frac{N}{n}})$ times.\\
	
	\subsection{Randomized routing algorithm: $O(n)$ time}
	(I) Bitfixing is good for random assignment\\
	(II) Reduce arbitrary case to random case
	
	Define $L(e)$: $\#$ paths that use edge $e$. The expectation for $L(e)$ is the same for any $e$.
	\begin{eqnarray*}
		&\because &\mathbb{E}[L(e)] \text{ are equal for different } e.\\
		&\text{and }&\mathbb{E}[\text{total length of all paths}]=\frac{Nn}{2}\\
		&\therefore& \mathbb{E}[L(e)]=\frac{\mathbb{E}[\text{total length}]}{\# \text{ edges}}=\frac{Nn/2}{Nn/2}=1.
	\end{eqnarray*}
	Time for a path $p=e_1,e_2,\cdots,e_l\leq \sum_{i=1}^lL(e_i) \leq n\cdot \max\limits_e{L(e)}$.\\
	Let $L(e)=\sum_{i\in [N]}H_{ie}$, where $H_{ie}$ stands for event $e\in P_i$. $H_{ie}$ are independent, bounded in $[0,1]$. Now we can apply chernoff bound and then union bound.
	
	$Pr[L(e)>t]<2^{-t} ~\forall t \geq 6$\\
	Using union bound, we have $\max\limits_e{L(e)} \leq O(N)~ w.h.p$, but we need a constant bound for $\max\limits_e{L(e)}$.
	
	\begin{lemma}
		Let $T_i$ be the time of path i, we have $T_i\leq n+|S_i|$.
		\label{lemma:Ti}
	\end{lemma}
	\begin{proof}
	Let the path be $\rho_i = (e_1, e_2, \cdots, e_k)$. For a fixed $i$, $S$ is set of other paths that intersects $i$'s path. If a packet is ready to follow edge $e_j$ at time $t$, we define its $\sl{lag}$ at time $t$ to be $t-j$. The $\sl{lag}$ of $v_i$ is initially zero, and the delay incurred by $v_i$ is its $\sl{lag}$ when it traverses $e_k$. We will show that each step at which the $\sl{lag}$ of $v_i$ increased by one can be charged to a distinct member of $S$. When the $\sl{lag}$ of $v_i$ increases from $l$ to $l+1$, there must be at least one packet from $S$ that wishes to traverse the same edge as $v_i$ at that time step. Let $t'$ be the last time step at which any packet in $S$ has $\sl{lag} l$. Thus there is a packet $v$ ready to follow edge $e_{j'}$ at $t'$, such that $t'-j'=l$. We know that some packet of $S$ leaves $\rho_i$ at $t'$. Since $v$ is ready to follow $e_{j'}$ at $t'$, some packet $\omega$ in $S$ follows $e_{j'}$ at $t'$. Now $\omega$ leaves $\rho_i$ at $t'$; if not, some packet will follow $e_{j'+1}$ at step $t'+1$ with $\sl{lag}$ still at $l$, violating the maximality of $t'$. We charge to $\omega$ the increase in the $\sl{lag}$ of $v_i$ from $l$ to $l+1$; since $\omega$ leaves $\rho_i$, it will never be charged again because paths can't rejoin. Thus, each member of $S$ whose path intersects $\rho_i$ is charged for at most one delay, establishing the lemma.
	\end{proof}	
	
	This lemma claims for path i,each intersecting path delays it for at most one time step.\\
	Given $\Pi$ random, for fixed $P_i$ we know that 
	$Pr[P_i\cap P_j\neq \emptyset] \text{ is independent of } Pr[P_i\cap P_k\neq \emptyset]$. Also\\
	\begin{eqnarray*}
		\mathbb{E}[|S_i|] &\leq& \mathbb{E}[\# (P_j, e\in P_j \text{ s.t. }e\in P_i)]\\
		&\leq&\mathbb{E}[\sum_{i=1}^l L'(e_i)]\\
		&=&l\leq n\\
	\end{eqnarray*}
	Note that this $L'(e)$ denotes the $\#$ of path that go through $e$ except for $P_i$.\\
	Therefore $\forall e, \mathbb{E}[L'(e)]\leq 1$.\\
	Bounding $|S_i|$:\\
	\begin{eqnarray*}
		Pr[|S_i|\geq t] &\leq& 2^{-t}, \forall t\geq 2en.\\
		\Longrightarrow Pr[|S_i|\geq 6n] &\leq& \frac{1}{N^6}\\
	\end{eqnarray*}
	By Lemma. \ref{lemma:Ti} we have \\
	\begin{eqnarray*}
		Pr[\max\limits_i {S}\leq 6n] &\geq& 1-\frac{1}{N^5}\\
		\Longrightarrow Pr[\max\limits_i T\leq 7n] &\geq& 1-\frac{1}{N^4}\\
	\end{eqnarray*}
	
	The problem here is we don't get random $\Pi$ anymore, we will retrieve the randomness by randomly picking a mid-state. Note that the routing process is reversible.
	\begin{itemize}
		\item	Given $\Pi$ adversarial, for each node i choose $\sigma(i) \in[N]$ i.i.d;\\
		\item   Send $i \to \sigma(i)$, wait until $7n$ rounds are complete;\\
		\item   Send $\sigma(i) \to \Pi(i)$, wait until another $7n$ rounds are complete;\\
	\end{itemize}
	Thus the whole process success with prob $\geq 1-\frac{2}{N^4}$.\\



\bibliographystyle{alpha}

\begin{thebibliography}{42}

\bibitem[MR]{MR}
		Rajeev~Motwani, Prabhakar~Raghavan
		\newblock Randomized Algorithms.
		\newblock {\em Cambridge University Press}, 0-521-47465-5, 1995. %pub - isbn - year

\end{thebibliography}

\end{document}
