\input{template}
\input{macros}
\usepackage{color, graphicx}
\usepackage{amssymb, amsmath}
\usepackage{epsfig}
\begin{document}
\lecture{24}{ILP formulations for SAT and shortest path problem}{Vinay Agarwal}
\section{Formulating ILP for SAT}
An instance of a SAT problem is a Boolean expression written using only AND, OR, NOT, variables, and parentheses in its CNF form. The question is: given the expression, is there some assignment of TRUE and FALSE values to the variables that will make the entire expression true?

\paragraph{Input:} A set of boolean variables {$z_1$,$z_2$,$z_3$, ... ,$z_{n-1}$,$z_n$,} and a boolean expression in CNF for which a satisfying assignment is to be found.
\begin{align*}
	(x_{11} \vee x_{12} \vee x_{13} \vee & \ldots x_{1{i_1}} )\wedge\\
        (x_{21} \vee x_{22} \vee x_{23} \vee & \ldots x_{2{i_2}} )\wedge \\
        (x_{31} \vee x_{32} \vee x_{33} \vee & \ldots x_{3{i_3}} )\wedge \\
			 & \ldots  \\
        (x_{k1} \vee x_{k2} \vee x_{k3} \vee & \ldots x_{k{i_k}} ) \\
\end{align*}
Where each $x_{ij}$ is either a variable($z_t$), or its negation ($\bar{z_{t}}$)

\paragraph{Output:} An assignment for each $z_t$, such that the above boolean expression evaluates to true.

\paragraph{Solution:} ILP formulation of any problem has three parts 

\begin{itemize}
\item{\bf{Variables}}

Here we attach each an integer variable $y_{t}$ to each boolean variable $z_t$, which represents the assignment of true or false.
\begin{equation*} y_{t} = \begin{cases} 0 & \text{if false,} \\ 1 &\text{if true} \end{cases} \end{equation*}
\text{$y_t$ = 1 - $y_t$ if $z_t$ is in negated}
0 $\leq$ $y_{t}$ $\leq$ 1

\item{\bf{Constraints}}

Constraints will be given by the conditions necessary for each clause of the expression to be true.
\begin{center}
 $y_{11}$ + $y_{12}$ + $y_{13}$ +...$y_{1{i_1}}$ $\geq$ 1\linebreak
 $y_{21}$ + $y_{22}$ + $y_{23}$ +...$y_{2{i_2}}$ $\geq$ 1\linebreak
 $y_{31}$ + $y_{32}$ + $y_{33}$ +...$y_{3{i_3}}$ $\geq$ 1\linebreak
	... \linebreak
 $y_{k1}$ + $y_{k2}$ + $y_{k3}$ +...$y_{k{i_k}}$ $\geq$ 1\linebreak
\end{center}
Where $y_{ij}$ represents the variable $y_t$ attached to the corresponding $z_t$.
\item{\bf{Cost}}

Here cost is immaterial as any feasible solution gives a satisfying assignment.

\end{itemize}
 
\section{Formulating ILP for shortest path problem}
\paragraph{Input:} A directed graph with positive integer weights ($w_{uv}$) and two vertices $s$ and $t$ from its vertex set.
\paragraph{Output:} Shortest/min weight path from $s$ to $t$ 
\begin{itemize}
\item{\bf{Variables}}

Attach one integer variable to each edge $x_{uv}$ which indicates whether the edge ($u,v$)is chosen or not.
\begin{equation*} x_{uv} = \begin{cases} 1 & \text{if edge ($u,v$) chosen,} \\ 0 &\text{o/w} \end{cases} \end{equation*}\\
0 $\leq$ $x_{uv}$ $\leq$ 1
\item{\bf{constraints}}

If there is a path from s to t in the graph then for any two partitions, such that one of them contains s and other contains t, there must be an edge leaving the partition containg s to the partition containing t ( $\exists$ u $\in$ U and v $\in$ V-U s.t u and v are connected).
\paragraph{} 
\begin{align*}
\forall U \subset V, s \in U, t \notin U, \forall u \in U \text{ and } v \notin U \Sigma x_{uv} \geq 1
\end{align*}
\item{\bf{Cost}}
We want to minimize the weight of the path from s to t, ie the sum of all edges in the path should be minimum, 
\paragraph{} 
\begin{center}
 min($\Sigma x_{uv}$$w_{uv}$)
\end{center}
\end{itemize}

\begin{figure}[htp]
\centering
\includegraphics[scale=0.7]{lecture24vfig1}
\caption{Example of a partition}
\label{figure:Shortest path between two vertices. }
\end{figure}

This has an exponential number of constraints. In next class we will see how to write this using a polynomial number of constraints.
\end{document}

