\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{positioning,chains,fit,shapes,calc}

\usepackage{graphicx}
\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}
\definecolor{myblue}{RGB}{80,80,160}
\definecolor{mygreen}{RGB}{80,160,80}

\lecture{13 --- Oct. 12, 2017}{Fall 2017}{Prof.\ Eric Price}{Eirini Asteri, Yanyao Shen}

\section{Overview}
% For online bipartite matching problem, we use $U$ to denote the set of customers, $V$ to denote the set of merchants. Customers in set $U$ appear in an online fashion, and the algorithm chooses an available merchant accordingly. Suppose that a perfect matching with size $n$ exists. 
% In the last lecture, we have shown that 
% \begin{itemize}
% \item Any deterministic algorithm only matches $\frac{n}{2}$ pairs on some adversarial input.
% \item Randomly choosing items only matches $(\frac{1}{2} + o(1))n$ in some bad cases.
% \item The above two are no better than a simple greedy algorithm, which also gives $\frac{n}{2}$.
% \end{itemize}

% In this class, we will prove that the  RANKING algorithm has competitive ratio at least $1-(1-1/(n+1))^n$, which is asymptotically $1-1/e$ \cite{BM,KVV}. 
% . 
In the last lecture,
\begin{itemize}
\item[--] we explored the problem of finding matchings in bipartite graphs,
\item[--] we introduced the problem of on-line bipartite matching, 
\item[--] we observed that any deterministic algorithm for on-line bipartite matching produces an 1/2-approximation and,
\item[--] we studied a simple randomized algorithm with approximation ratio $(1/2 +O(1/\sqrt{n}))$.
\end{itemize}
In this lecture,
\begin{itemize}
\item[--] we will study an $(1-1/e)$-approx. randomized algorithm for the problem of on-line bipartite matching given by Karp, Vazirani and Vazirani \cite{KVV}.
\end{itemize}


\section{Online Bipartite Matching}

\subsection{Introduction}
Let $G(U,V,E)$ be a bipartite graph on $2n$ vertices such that $G$ contains a perfect matching. 
We can think of the situation where we have $n$ customers ($U$) and $n$ merchants($V$).
We assume that the customer vertices arrive in a preselected order, and that the edges incident to a vertex are revealed to us only when the vertex (customer) arrives. The task is to decide, as each customer arrives, which eligible merchant to assign to him, so that the size of the matching obtained is maximized.

\subsection{The Ranking Algorithm}
In \cite{KVV} the authors introduced the Ranking algorithm for the Online Bipartite Matching. The algorithm achieves an expected competitive ratio of $1 - 1/e$.
\vfill

\paragraph{Ranking Algorithm}
\begin{itemize}
\item[--]{\bf Initialization} Pick a random permutation of the merchant vertices, thereby assigning to each merchant a random priority or ranking. 
\item[--]{\bf Matching Phase} As each customer arrives, match him to the eligible merchant (if any) of highest rank.
\end{itemize}

After initialization, there is an ordering on both the customer and merchant vertices (the preselected arrival ordering on customers and the randomly chosen ordering on merchants).

\paragraph{Notation} 
\begin{itemize}
\item[-]Given an arrival order $\pi$ for $U$ and a rank order $\sigma$ for $V$, the ranking algorithm outputs $\text{Matching}(G, \pi, \sigma)$.
\item[-] $M(x):=$ vertex matched to vertex x in the perfect matching
\item[-]  The description \textit{higher rank} is equivalent to \textit{lower ranking order}.
\end{itemize}



% The description \textit{higher rank} is equivalent to \textit{lower ranking order}.

\begin{figure}[h]\label{fig:1}
\centering
\includegraphics[width=\textwidth]{lec12-1}
\caption{Graph from \cite{BM}. }
\end{figure}

\begin{lemma}\label{lem:1}
Let $H=G-\{x\}$, $x$ could be either on the left side (customer side) or right side (merchant side). Accordingly, for $H$, we use $\pi_H, \sigma_H$ to denote the arrival order and rank order respectively. We have the following observation:
\begin{equation}
Matching(H,\pi_H,\sigma_H) = Matching(G,\pi,\sigma) + \mbox{ ( a single augmenting path )}
\end{equation}
\end{lemma}
\paragraph{Proof of Lemma \ref{lem:1}.}This property is quite obvious. As is shown in Figure \ref{fig:1}, after removing $x$, the difference of the two matching results is exactly a single augmenting path. 

\begin{lemma}\label{lem:2}
Let $u\in U$, $v = M(u)$. If $v$ is not matched at all in $Matching(G,\pi, \sigma )$, then $u$ is matched to some $v^{'}$ with $\sigma(v^{'}) < \sigma(v)$.
\end{lemma}
\paragraph{Proof of Lemma \ref{lem:2}.} If $v$ is not matched, then, when $u$ arrives, there must be a free merchant $u$ connects to has lower lower ranking order.

\begin{lemma}\label{lem:key}
Let $X_t$ be the probability that the vertex of rank $t$(i.e., $v$ such that $\sigma(v) = t$) is matched. Then,
\begin{equation}\label{eqt:key}
1-X_t \le \frac{1}{n}\sum_{s\le t} X_s
\end{equation}
\end{lemma}
\paragraph{Lemma \ref{lem:key} gives the desired result.} Suppose that the above Lemma \ref{lem:key} is correct. Let $S_t = \sum_{s\le t} X_s$. Therefore, $\mathbb{E}[\mbox{\# matched vertices}] = S_n$. We rewrite (\ref{eqt:key}) in terms of $S_i$:
\begin{align}
& 1-(S_t - S_{t-1}) \le \frac{1}{n} S_t \\
\Leftrightarrow & S_t \cdot \frac{n+1}{n} \ge 1+S_{t-1} \\
\Leftrightarrow & S_t \ge (1-\frac{1}{n+1}) + (1-\frac{1}{n+1})S_{t-1}
\end{align}
Denote $r = 1-\frac{1}{n+1}$, then,
\begin{equation}
S_0 = 0, S_1\ge r, \cdots, S_n\ge r+\cdots + r^n = \frac{r-r^{n+1}}{1-r} \ge n - \frac{n+1}{e}.
\end{equation}
Therefore, $\frac{S_n}{n}\ge 1-\frac{1}{e} - \frac{1}{en} = 1-\frac{1}{e} - o(1)$.

\paragraph{An intuitive but incorrect proof of Lemma \ref{lem:key}.} Let $X_t$ be the probability that the vertex of rank $t$ is matched. Let $v$ be the rank $t$ vertex under $\sigma$. Since $\sigma$ is random, $v$ is uniformly random. Let $u = M(v)$, which is also uniformly random. Let $R_{t-1}\subset U$ that are matched to vertices on the right with rank at most $t-1$. 
\begin{equation}
\mathbb{E}[|R_{t-1}|] = \sum_{s\le t-1} X_s.
\end{equation}
Since
\begin{equation}
v \mbox{ unmatched }\Rightarrow u\in R_{t-1}
\end{equation}
\begin{equation}
Pr[v \mbox{ unmatched }] \le Pr[u\in R_{t-1}]  \underline{\le\frac{1}{n}\sum_{s\le t-1}X_s}
\end{equation}
The underlined part is incorrect since $u$ and $R$ are not independent. To fix, we use the following Lemma:

\begin{figure}[h]
\centering
\includegraphics[width=\textwidth]{lec12-2}
\caption{Graph from \cite{BM}. Illustration of Lemma \ref{lem:help}}
\end{figure}

\begin{lemma}\label{lem:help}
Let $u\in U, v = M(u)$. $\sigma^{'}$ be some permutation, $\sigma^{(i)}$ be permutation obtained by shifting $v$ to rank $i$. If $v$ is not matched in $\sigma^{'}$, then $u$ is matched under $\sigma^{(i)}$ to some $v^{(i)}$, with 
\begin{equation}
\sigma^{(i)}(v^{(i)})  \le \sigma^{'} (v).
\end{equation}
\end{lemma}
\paragraph{Proof of Lemma \ref{lem:help}.} For each $u^{'}$ in left originally matched to $v^{'}$ under $\sigma^{'}$, now $v^{(i)}$ under $\sigma^{(i)}$,
\begin{align}
& \sigma^{(i)} (v^{'}) \le  \sigma^{'}(v^{'}) + 1 , \label{eqt:lem4-1}\\
& \sigma^{(i)} (v^{(i)}) \le \sigma^{(i)} (v^{'}), \label{eqt:lem4-2}\\
\Rightarrow & \sigma^{(i)} (v^{(i)}) \le \sigma^{'}(v^{'}) + 1 \le \sigma^{'} (v).\label{eqt:lem4-3}
\end{align}
(\ref{eqt:lem4-1}) is by definition, (\ref{eqt:lem4-2}) is based on Lemma \ref{lem:1}, the last inequality in (\ref{eqt:lem4-3}) is based on Lemma \ref{lem:2}.

\paragraph{Proof of Lemma \ref{lem:key}.}
Choose random $\sigma$, and choose $v\in V$ uniformly random. Set $\sigma^{'} = \sigma$ with $v$ moved to rank $t$, $u = M(v)$. Choose some $i$ such that $\sigma^{(i)} = \sigma$.

Lemma \ref{lem:help} says that if $v$ is not matched under $\sigma^{'}$ (this event happens with probability $1-X_t$), then $u$ matched under $\sigma$ to $\tilde{v}$ with $\sigma(\tilde{v}) \le \sigma^{'}(v) = t$. 

Let $R_t$ be vertices in $U$ matched to $v^{'}\in V$ with $\sigma(v^{'}) \le t$. The above description gives us the fact that $u\in R_t$. Therefore, we have
\begin{equation}
1-X_t \le Pr[u\in R_t].
\end{equation}
We know that $u$ is independent of $\sigma$. On the other hand, by definition, $R_t$ only depends on $\sigma$ not on $v$, which implies that $R_t$ is independent of $u$. Therefore,
\begin{equation}
Pr_{u,R_t} \left[u\in R_t\right] = \mathbb{E}_{R_t} \left[Pr_{u}\left[u\in R_t\right]\right] = \mathbb{E}_{R_t} \left[\frac{|R_t|}{n}\right] = \frac{\sum_{s=1}^{t} X_t}{n}.
\end{equation}


Since Lemma \ref{lem:key} is proved, according to previous algebra, the $(1-\frac{1}{e})$ competitive ratio performance of RANKING algorithm is proved.

\section{Sampling}

Consider the problem of estimating $\pi$ through sampling. We choose $x,y\in [-1,1]$ uniformly, then, we know that
\begin{equation}
Pr[x^2+y^2 \le 1] = \frac{\pi}{4}.
\end{equation}
Now, instead of estimating $\pi$, we are estimating the probability  $p$ of some event happens. In the above example, the probability $p=\pi/4$.
Then, how many samples do we need in order to get $(1\pm \epsilon)$ approximation of $p$ with probability $1-\delta$? 
Furthermore, what if the probability $p$ that we are estimating is very small?

\bibliographystyle{alpha}

\begin{thebibliography}{42}

\bibitem[1]{BM}
Birnbaum, Benjamin, and Claire Mathieu. 
\newblock {\em On-line bipartite matching made simple.}
\newblock ACM SIGACT News 39.1 (2008): 80-87.

\bibitem[2]{KVV}
Karp, Richard M., Umesh V. Vazirani, and Vijay V. Vazirani. 
\newblock {\em An optimal algorithm for on-line bipartite matching.}
\newblock Proceedings of the twenty-second annual ACM symposium on Theory of computing. ACM, 1990.

\end{thebibliography}

\end{document}