\input{template}
\input{macros}

\begin{document}
\lecture{25} {ILP formulations for SAT and shortest path problem
(contd.)}{Mohit Kansal}

In this lecture we will formulate Integer Linear Programs(ILPs) for some of the problems discussed in the tutorial.
\section{SAT}
A SAT problem can be defined as follows:
\begin{itemize}
\item \textbf{Input:} An expression of the form $(x_i \vee
\overline{x_j} \vee ... ) \wedge (... \vee ... \vee ...) \wedge
...$, where a variable $x_k$ can take value T or F. \item
\textbf{Output:} Assignment of TRUE/FALSE values to literals
$x_{i}s)$ for the expression to be true or NOT SOLVABLE if such an
assignment is not possible.
\end{itemize}
Our task is to formulate this problem as an ILP:
\begin{itemize}
\item \textbf{Variables:} There will be one variable $y_i$ per
boolean variable $x_i$
\begin{equation}
y_{i} = \begin{cases}
    0 & \text{if $x_i$ is \false} \\
    1 & \text{if $x_i$ is \true} \\
    \end{cases}
\end{equation}
\begin{center}
$0\leq y_i\leq 1$, $y_i$ is integral \\This ensures that $y_i$ is
either 0 or 1.
\end{center}
\textit{Note: } If we choose $y_i$s to be -1 and 1 in place of 0
and 1, formulation in the above form is difficult.
 \item
\textbf{Inequalities:} Consider a clause $x_i \vee x_j$ This will
be true if either $x_i = 1$ or $x_j = 1$ or both. Clearly, the
inequality will be $y_i + y_j \geq 1$. Similarly, for the clause
$x_i \vee \overline{x_j}$, the inequality will be $y_i + 1 - y_j
\geq 1$ or $y_i - y_j \geq 0$. \item \textbf{Inequality Matrix:}
The inequality obtained from each clause will correspond to one
row of the matrix. \item \textbf{Cost function:} Immaterial in
this case as long as we can find feasible $y_i$s satisfying
$Ay\leq b$, $0 \leq y_i \leq 1$, $y_i$ is integral.
\end{itemize}

\section{Shortest Path}
A Shortest Path problem can be defined as follows:
\begin{itemize}
\item \textbf{Input:} A Directed Graph with edge weights as
positive integers and two special vertices s and t. \item
\textbf{Output:} Set of edges which form a shortest path between
$s, t$.
\end{itemize}
Our task is to formulate this problem as an ILP:
\subsection{Formulation 1}
\begin{itemize}
\item \textbf{Variables:} Clearly the output is a subset of the
original edge set. So there will be one variable per edge$(e)$
between two vertices u and v, $x_{uv}$
\begin{equation}
x_{uv} = \begin{cases}
   0 & \text{if the edge from vertex u to vertex v is not chosen for the shortest path} \\
    1 & \text{if the edge from vertex u to vertex v is chosen for the shortest path} \\
    \end{cases}
\end{equation}
\begin{center}
$0\leq x_{uv}\leq 1$, \\$x_{uv}$ is integral
\end{center}
Define
\begin{align}
c_{uv} \text{- cost of the edge from vertex u to vertex v} \notag
\end{align}

\item \textbf{Cost function:} Clearly the cost function in this
case is
\begin{align}
min&\sum x_{uv}c_{uv} \notag
\end{align}
\end{itemize}

Before we formulate the inequality let us state a lemma.
\newtheorem{lem1}{Lemma}
\begin{lem1}
Let V be a set of vertices and let s, t be the two vertices for
which the shortest path has to be found. For every $U\subset V$
s.t. $s$ $\epsilon$ $U$, $t$ $\not\epsilon$ $U$ at least one of
the arcs coming out of U must be selected.
\end{lem1}
\begin{itemize}
\item \textbf{Constraints:} From the above lemma we can see that
the following inequalities force a path from s to t
\begin{align}
& \text{$\forall$ subsets U of V, s.t s } \epsilon \text{ U, t }
\not\epsilon \text{ U} \notag \\
& \sum_{u \epsilon U, v \not\epsilon U} x_{uv} \geq 1 \notag
\end{align}
\end{itemize}

\subsection{Formulation 2}
In this formulation we use a polynomial number of constraints
\begin{itemize}
\item \textbf{Constraints:} Clearly there will be only one edge
coming out of the starting vertex $s$ in the shortest path and
there will be only one vertex coming into the terminating vertex
$e$. This is represented as follows
\begin{align}
\sum_v x_{sv} - \sum_p x_{ps} = 1 \notag \\
\sum_u x_{ut} - \sum_q x_{tq} = 1 \notag
\end{align}
For all the other vertices (including the ones which are not in
the shortest path) the number of edges (of the shortest path)
coming in should be equal to the number of edges going out.
\begin{align}
\forall u \neq s, e \text{    }\sum_p x_{pu} - \sum_q x_{uq} = 0
\notag
\end{align}
\begin{equation}
x_{uv} = \begin{cases}
    0 & \text{if the edge from u to v is not chosen for the shortest path} \\
    1 & \text{if the edge from u to v is chosen for the shortest path} \\
    \end{cases}
\end{equation}
\begin{center}
$0\leq x_{uv}\leq 1$, $x_{uv}$ is integral
\end{center}


Clearly each of the vertices in the Vertex Set will contribute to
one row of the matrix.
\end{itemize}
\end{document}
