\documentclass[11pt]{article}
\usepackage{handout}
\usepackage{amsmath,amssymb,amsthm,epsfig}
\usepackage[ruled,vlined]{algorithm2e}
\begin{document}
\input{courseMacros}

\newtheorem{Theorem}{Theorem}
\newtheorem{Corollary}{Corollary}
\newtheorem{Lemma}{Lemma}
\newtheorem{Claim}{Claim}
\theoremstyle{definition}
\newtheorem{Definition}{Definition}
\newtheorem{problem}{Problem}
\newenvironment{Proof}{\noindent{\bf Proof: }}{\qed}
%\theoremstyle{remark}
\newtheorem{Remark}{Remark}

\thispagestyle{empty}
\thispagestyle{empty}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1.8ex}

\head{CS G399}{Algorithmic Power Tools I}{Fall 2007}{Scribe: Bishal Thapa}{25 September 2007}


\newcommand{\p}{\mathcal{P}}
\newcommand{\U}{\mathcal{U}}
\newcommand{\coll}{\mathcal{S}}
\newcommand{\xpy}{x + \lambda y}
\newcommand{\Alg}{\mathcal{A}}
\newcommand{\opt}{\mbox{OPT}}
\newcommand{\eps}{\varepsilon}

\noindent {\bf Lecture Outline:}
\begin{itemize}
\item
Uncapacitated Facility Location:
\begin{itemize}
\item
Linear Programming Rounding Approach : Constant (6)-Approximation
\item
Combinatorial ``Greedy" Approach : Constant (6)-Approximation
\end{itemize}
\end{itemize}

In this lecture, we take a look at two separate constant approximation
polynomial-time solutions for the Uncapacitated Facility Location problem.
The first algorithm features a deterministic LP rounding approach, and the
second algorithm takes a greedy approach to the problem (which is not explicitly
a primal-dual algorithm, but can be analyzed by looking at the dual LP), both yielding
a solution of cost within a factor of 6 of the optimal.

\section{(metric) Uncapacitated Facility Location}
We described the Uncapacitated Facility Location problem in the previous class.
\begin{table}[h]
\begin{center}
\begin{tabular}{|ll|}
\hline

$V$ & Set of demand points (clients) \\
$F$ & Set of possible facility locations\\
$d_i$ & Demand for the service at demand point $i$\\
$c$ & Metric on $V\cup F$\\
$c_{ij}$ & Cost for assigning $i \in V$ to facility $j \in F$\\
$\sigma $ & Assignment function, $\sigma : V \rightarrow F$\\
$f_j$ & Cost of opening a facility at location $j \in F$\\
$Facility\,Cost$ & $= \sum_{j \in F} f_j$\\
$Service\,Cost$ & $= \sum_{i \in V} d_i \times c_{i \sigma(i)}$\\
$Total\,Cost$ & $=Facility\, Cost + Service\, Cost$\\
\hline
\end{tabular}
\label{table:8-users}
\end{center}
\end{table}

Our goal is to minimize the total cost. Notice that we are considering the
uncapacitated metric facility problem. So, the \emph{metric} service costs
satisfy this property (triangle inequality):
\[ c_{ij} + c_{jk} + c_{kl} \ge c_{il} \,\, \forall \,i,j,k,l \in V \cup F\]

\subsection{LP Rounding}
Assuming unit demands, the UNCAPACITATED FACILITY LOCATION PROBLEM (UFLP) can be formulated as an
integer linear program as follows:

\[min\hspace{0.6in} \sum_{j \in F} f_j \times y _j + \sum_{i \in V} x_{ij} \times c_{ij}\]
\[s.t.\hspace{0.6in} x_{ij} \le y_j  \hspace{0.5in} \forall i \in V,j \in F\]
\[\hspace{0.6in} \sum_{j} x_{ij} \ge 1 \hspace{0.5in} \forall i \in V\]
\[\hspace{0.9in} x_{ij},y_{j} \in \{0,1\} \hspace{0.5in} \forall i \in V, j \in F\]

By relaxing the integrality constraints we get the linear program:

\[min\hspace{0.6in} \sum_{j \in F} f_j \times y _j + \sum_{i \in V} x_{ij} \times c_{ij}\]
\[s.t.\hspace{0.6in} x_{ij} \le y_j  \hspace{0.5in} \forall i \in V,j \in F\]
\[\hspace{0.6in} \sum_{j} x_{ij} \ge 1 \hspace{0.5in} \forall i \in V\]
\[\hspace{0.9in} x_{ij},y_{j} \ge 0 \hspace{0.5in} \forall i \in V, j \in F\]

LP rounding algorithms solve the latter linear program and round the fractional
solution of the primal LP suitably to achieve a feasible integral solution
to the problem. Algorithm~\ref{alg:round} achieves a solution of cost within
a factor of 6 to the optimal solution.

\begin{algorithm}\label{alg:round}
\SetAlFnt{\small}
\dontprintsemicolon
 $1.$ Solve the non-integral LP. Let $(<x_{ij}^*>,<y_j^*>)$ be the optimum fractional solution.\;
 $2.$ \For{each client $i \in V$} {define:\;
       \hspace{0.1in}$r_i = 2\sum_j x_{ij}^* \times c_{ij}$\;
       \hspace{0.1in}$B_i = \{j \in F| c_{ij} \le r_i \}$\;}
 $3.$ Sort $r_i$ in the non-decreasing order. WLOG, assume $r_1 \le r_2 \le \cdots \le r_n$.\;
 $4.$ Let $V' := \{r_1,r_2,\cdots r_n\}$ s.t. the index-set of $V'$ represents the clients. Call the set $I[V']$.\;
 $5.$ Let $i := 1, \, F' := \emptyset$.\;
 $6.$ \For{client $i \in I[V']$} {let $j \in B_i$ with $x_{ij}^* > 0$ and $f_j$ minimum. Set $F' = F' \cup \{j\}$.\;
       let $N_i = \{r_k \in V' | B_i \cap B_k \neq \emptyset$\}.\;
       \For{each client $k$ s.t. $r_k \in N_i$} {Set $\sigma(k) \leftarrow j$.\;}\;
       \textbf{Note}: $i \in N_i$ vacuously.\;
       Set $V' = V' \setminus N_i$ while keeping the sorted order among the remaining elements as before.\;
       Re-label the elements in the new V' starting from index $1$. (new $I[V'] \subset$ old $I[V']$.)\;
       If $V' = \emptyset$, \text{break}.\;}
 $7.$ Output $F'$ and $\sigma$.\;
\caption{Rounding the non-integral LP solution}
\end{algorithm}
\begin{Theorem}
The running time for Algorithm 1 is polynomial in the size of input.
\end{Theorem}
\vspace{-0.2in}
\begin{proof}
It is clear that the algorithm terminates. The algorithm consists of three
processes: LP solving, Sorting and Comparing. We know that the linear programming
can be solved in polynomial time using the ellipsoid or interior point methods.
Sorting can be done very efficiently as well, using a merge sort or heap sort at the
cost of $O(n \log n)$ running time. Finally, the comparing procedure involved in step 6
of Algorithm~\ref{alg:round} is doable in polynomial-time also. The detailed complexity
analysis of comparison procedure is left for the reader.
\end{proof}

\begin{Claim}
\label{claim:half}
$\forall i \in V, \sum_{j \in B_i} y_j^* \ge \frac{1}{2}$
\end{Claim}
\begin{proof}(Proof by Contradiction) Let $LP_i$ denote the service cost of client $i \in V$
in the LP solution. So, $LP_i = \sum_j x_{ij}^* \times c_{ij}$. Assume that the claim is
not true. Then, $\sum_{j \in B_i} y_j^* < \frac{1}{2}$ [hypothesis]. \\ We have,
\[ LP_i \ge \sum_{j \notin B_i} x_{ij}^* \times c_{ij}\] because, the right hand side doesn't include $j$'s inside the ball.
\[ \ge \sum_{j \notin B_i} x_{ij}^* \times r_i \left(= r_i \times \sum_{j \notin B_i} x_{ij}^* \right) \]
because, $c_{ij} > r_i$  $\forall j \notin B_i$.
\[ > \frac{1}{2} \times r_i\] because of the hypothesis and the fact that,
\[\sum_{j \in B_i} x_{ij}^* \le \sum_{j \in B_i} y_j^*\] thus,
$\sum_{j \in B_i} x_{ij}^* < \frac{1}{2}$, which further implies,
\[\sum_{j \notin B_i} x_{ij}^* > \frac{1}{2}\] Hence, we get
\[LP_i > \frac{1}{2} \times r_i = LP_i \,\, (contradiction)\]
because of the definition of $LP_i$.
\end{proof}
\vspace{0.2in}
\begin{Lemma}
\label{lem:facility}
Let $LP_F$ denote the facility cost of the LP solution. Then, $\sum_{j \in F'} f_j \le 2 \times LP_F$.
\end{Lemma}
\vspace{-0.2in}
\begin{proof}
We know $LP_F = \sum_{j \in F} f_j \times y_j^*$. For each $j \in F'$, let $i_j$ denote the client in $I[V']$ that
was considered, when $j$ was added to $F'$. Consider a ball $B_{i_j}$. Then,
\[ \sum_{l \in B_{i_j}} y_l^* \times f_l \ge  \sum_{l \in B_{i_j}} y_l^* \times f_j \left(= f_j \times \sum_{l \in B_{i_j}} y_l^*\right)\]
because, we pick $j \in B_{i_j}$ s.t. $f_j$ is minimum [refer to Step 6, Algorithm~\ref{alg:round}].\\
Hence,\[ \sum_{l \in B_{i_j}} y_l^* \times f_l \ge \frac{1}{2} \times f_j \] by previous equation and Claim~\ref{claim:half}.
Adding over all $j \in F'$,
\[ \frac{1}{2} \times \sum_{j \in F'} f_j \le  \sum_{l \in B_{i_j}} y_l^* \times f_l \le \sum_{j \in F} f_j \times y_j^*\]
because, we pick a facility $j \in F$ from each of the non-overlapping balls. If balls overlap, we pick one $j$ from a ball among all the intersecting balls, and
ignore the rest. Also, we pick the least cost facility inside a ball. Hence,
\[  \sum_{j \in F'} f_j \le 2 \times LP_F \]
\end{proof}
\vspace{0.2in}
\begin{Lemma}Let $LP_i$ be the service cost of client $i \in V$ in the LP solution. Then, $\forall i \in V$,\\
 $c_{i\sigma(i)} \le 6 \times LP_i$.
\label{lem:service}
\end{Lemma}
\vspace{-0.2in}
\begin{proof} Consider two possible cases for a client $i$:
\begin{enumerate}
\item Client $i$ is such that some $j \in B_i$ was selected in step 6 of the algorithm~\ref{alg:round}.
Then,
\[ c_{i\sigma(i)} \le r_i = 2 \times LP_i \] by definition of $B_i$.
\item Client $i$ is removed at some iteration in Step 6, due to the overlap of $B_i$ with $B_k$ for some $k$. Then,
\[ r_i \ge r_k, \] \[ \exists l \in B_i \cap B_k\]  Assuming, we included $j \in B_k$ in $F'$, we have
\[\sigma(i) = \sigma(k) = j\] Therefore,
\[c_{ij} \le c_{il} + c_{lk} + c_{kj} \le r_i + 2 \times r_k \le 3 \times r_i\] due to triangle inequality. Hence,
\[c_{ij} \le 6 \times LP_i\]
\end{enumerate}
In either case, $c_{i\sigma(i)} \le 6 \times LP_i$.
\end{proof}
Let $LP_S$ denote the service cost of the LP solution. Then, Lemma~\ref{lem:service} gives us,
\[ \sum_{i \in V} c_{i\sigma(i)} \le 6 \times LP_S\].

\begin{Theorem}
$ Total\,Cost \le 6 \times (LP_F + LP_S)$
\end{Theorem}
\vspace{-0.2in}
\begin{proof}
This follows directly from Lemmas~\ref{lem:facility} and~\ref{lem:service} and the definition of Total Cost. Since,
\[Service\,Cost \le 6 \times LP_S,\ Facility\,Cost \le 2 \times LP_F \]
 \[\Longrightarrow Total\,Cost \le 6 \times (LP_F + LP_S)\].
\end{proof}

\subsection{Combinatorial ``Greedy" Approach}
This algorithm takes a greedy approach on the UNCAPACITATED FACILITY LOCATION problem. The algorithm doesn't
make an explicit use of primal-dual schema however, it substantially derives its intuition from the dual fitting
approach. Algorithm~\ref{alg:greedy} runs on polynomial-time and achieves a solution of cost within a factor of
6 of the optimal solution.
\begin{algorithm}
\label{alg:greedy}
\SetAlFnt{\small}
\dontprintsemicolon
 $1.$ \For{each facility $j \in F$} {define:\;
       \hspace{0.1in}$r_j = r, r > 0$ at which $\sum_{i:c_{ij} \le r} (r - c_{ij}) = f_{j}$\;
       \hspace{0.1in}$B_j = \{i \in V | c_{ij} \le r_j \}$\;}
 $2.$ Sort $r_j$ in the non-decreasing order. WLOG, assume $r_1 \le r_2 \le \cdots \le r_m$.\;
 $3.$ Let $F' := \{r_1,r_2,\cdots r_m\}$ s.t. the index-set of $F'$ represents the facilities. Call the set $I[F']$.\;
 $4.$ Let $j := 1, X := \emptyset$.\;
 $5.$ \For{facility $j \in I[F']$} {Set $X = X \cup \{j\}$.\;
       let $M_j = \{r_l \in F' | B_j \cap B_l \neq \emptyset$\}.\;
       Set $F' = F' \setminus M_j$ while keeping the sorted order among the remaining elements as before.\;
       \textbf{Note}: $j \in M_j$ vacuously.\;
       Re-label the elements in the new $F'$ starting from index $1$. (new $I[F'] \subset$ old $I[F']$.)\;
       If $F' = \emptyset$, \text{break}.\;}
 $6.$ Assign each client to the nearest facility in X. Let $\sigma:V \rightarrow X$ denote the mapping.\;
 $7.$ Output $X$ and $\sigma$.\;
\caption{Greedy Approach}
\end{algorithm}
%\bibliographystyle{alpha}
%\bibliography{paper}
\end{document} 