Commit 2bd9d9a8 authored by Niklas Rieken's avatar Niklas Rieken
Browse files

tap on my shoulder for this nice figures

parent 5a878a39
No preview for this file type
......@@ -11,6 +11,7 @@
\usepackage{graphicx}
\usepackage{float}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc}
\usepackage{listings}
\usepackage{enumitem}
......@@ -49,7 +50,7 @@ A \emph{linear program} (\emph{LP}) consists of \emph{variables} $x = (x_1, \ldo
\text{maximize } & c_1 x_1 + c_2 x_2 + \ldots + c_n x_n\\
\text{subject to } & a_{11} x_1 + a_{12} x_2 + \ldots + a_{1n} x_n &&\leq b_1\\
& a_{21} x_1 + a_{22} x_2 + \ldots + a_{2n} x_n &&\leq b_2\\
& \ldots & \\
& \quad\quad\quad\quad\quad\vdots & \\
& a_{m1} x_1 + a_{m2} x_2 + \ldots + a_{mn} x_n &&\leq b_m\\
& x_1, x_2, \ldots, x_n &&\geq 0
\end{align*}
......@@ -67,7 +68,7 @@ or even shorter
\end{align*}
We call the $x_j$ ($j \in \{1, \ldots, n\}$) \emph{decision variables}, $c^T$ the \emph{objective function coefficients}, $A$ the \emph{coefficient matrix}, and $b$ the \emph{right hand side} of the LP. Moreover, we write $a_i^T$ for the coefficients of the $i$-th constraint. Note that every LP has an ''equivalent`` LP in canonical form:
\begin{itemize}
\item $\text{minimze } c^T x = \text{maximize } -c^T x$,
\item $\min_x c^T x = \max_x -c^T x$,
\item $a_i^T x \geq b_i$ iff $-a_i^T x \leq -b_i$,
\item $a_i^T x = b_i$ iff $a_i^T x \leq b_i$ and $a_i^T x \geq b_i$,
\item $x_j \leq 0$ iff $-x_j \geq 0$,
......@@ -172,10 +173,69 @@ A \emph{face} with respect to $H \subseteq \{1, \ldots, m\}$ is
$$
F \coloneqq \{x \in P \mid a_i^T x \leq b_i \text{ active in } x, i \in H\}.
$$
\begin{figure}
\begin{figure}[H]
\centering
\begin{tikzpicture}
%TODO scopes
\begin{scope}
\path[fill=gray!20] (0, 0) coordinate(p1) -- ++(35:2.5) coordinate(p2) -- ++(-45:2.5) coordinate(p3) -- ++(-120:3.5) coordinate(p4) -- ++(150:3) coordinate(p5);
\node at (barycentric cs:p1=1,p2=1,p3=1,p4=1,p5=1) {$P$};
\foreach \X [count=\Y] in {2,...,6} {
\ifnum\X=6
\path (p\Y) -- (p1) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a1) coordinate[pos=0.5](m1);
\draw[red] (a\Y) -- (a1);
\else
\ifnum\X=5
\path (p\Y) -- (p\X) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a\X) coordinate[pos=0.5](m\X);
\draw[red] (a\Y) -- (a\X);
\node[red] at (p5) {$\bullet$};
\else
\path (p\Y) -- (p\X) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a\X) coordinate[pos=0.5](m\X);
\draw (a\Y) -- (a\X);
\fi
\fi
}
\node (vertex) at (1.5, -4.5) {\scriptsize{''vertex ($0$-dim)``}};
\end{scope}
\begin{scope}[shift={(5.5, 0)}]
\path[fill=gray!20] (0, -1) coordinate(p1) -- (2, -3) coordinate(p2) -- (3, -1) coordinate(p3) -- (2, 1) coordinate(p4) -- (0, 1) coordinate(p5);
\node at (barycentric cs:p1=1,p2=1,p3=1,p4=1,p5=1) {$P$};
\foreach \X [count=\Y] in {2,...,6} {
\ifnum\X=6
\path (p\Y) -- (p1) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a1) coordinate[pos=0.5](m1);
\draw (a\Y) -- (a1);
\else
\ifnum\X=3
\path (p\Y) -- (p\X) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a\X) coordinate[pos=0.5](m\X);
\draw[red,very thick] (a\Y) -- (a\X);
\else
\path (p\Y) -- (p\X) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a\X) coordinate[pos=0.5](m\X);
\draw (a\Y) -- (a\X);
\fi
\fi
}
\node (edge) at (1.5, -4.5) {\scriptsize{''edge ($1$-dim)``}};
\end{scope}
\begin{scope}[shift={(10, -1)},scale=4.3]
\coordinate (A1) at (0,0);
\coordinate (A2) at (0.6,0.2);
\coordinate (A3) at (1,0);
\coordinate (A4) at (0.4,-0.2);
\coordinate (B1) at (0.5,0.5);
\coordinate (B2) at (0.5,-0.5);
\draw[fill=gray!20] (A1) -- (A4) -- (B1);
\draw[fill=gray!20] (A1) -- (A4) -- (B2);
\draw[fill=gray!20] (A4) -- (A3) -- (B2);
\draw[fill=red!60] (A4) -- (A3) -- (B1);
\draw[dashed] (A1) -- (A2) -- (A3);
\draw[dashed] (B1) -- (A2) -- (B2);
\draw (A4) -- (A1) -- (B1);
\draw (A4) -- (B2);
\draw (A3) -- (A4) -- (B1);
\draw (B1) -- (A1) -- (B2) -- (A3) ;
\draw[red,thick](A4) -- (A3) -- (B1) -- cycle;
\node at (.3, -.05) {$P$};
\end{scope}
\node (facet) at (12, -4.5) {\scriptsize{''facet ($(n-1)$-dim)``}};
\end{tikzpicture}
\end{figure}
......@@ -190,23 +250,80 @@ Every face itself is again a polyhedron. A point $x \in P$ is called \emph{feasi
\end{enumerate}
If the last case is true, then the optimal sollution is assumed at a vertex of $P$.
\end{theorem}
\begin{figure}
\begin{figure}[H]
\centering
\begin{tikzpicture}
%TODO scopes
\begin{scope}[scale=.7]
\path (0, 0) coordinate(p1) -- (-3, -2) coordinate(p2) -- (1, -3) coordinate(p3);
\path (p1) -- (p2) coordinate[pos=-.2](a1) coordinate[pos=1.2](a2) coordinate[pos=.3](m2);
\draw (a1) -- (a2);
\path (p2) -- (p3) coordinate[pos=-.2](a2) coordinate[pos=1.2](a3) coordinate[pos=.5](m3);
\draw (a2) -- (a3);
\path (p3) -- (p1) coordinate[pos=-.2](a3) coordinate[pos=1.2](a1) coordinate[pos=.4](m1);
\draw (a3) -- (a1);
\path[draw,red] (-3, 0) coordinate(c1) -- (-2, -.5) coordinate(c2) coordinate[pos=.5](cm);
\draw[red] (c1) -- (c2) node[pos=1.2] {$c$};
\draw[red,thick,->] (cm) -- ($(cm)!.8cm!-90:(c2)$);
\end{scope}
\begin{scope}[shift={(2, 1)},scale=.7]
\path[fill=gray!20] (1, -1) coordinate(q1) -- (3, -4) coordinate(q2) -- (5, -4) coordinate(q3) -- (6, -1) coordinate(q4);
\node at (barycentric cs:q1=1,q2=1,q3=1,q4=1) {$P$};
\foreach \X [count=\Y] in {2, 3, 4} {
\path (q\Y) -- (q\X) coordinate[pos=-.2](b\Y) coordinate[pos=1.2](b\X) coordinate[pos=.5](n\X);
\draw (b\Y) -- (b\X);
}
\path[draw,red] (2, 0) coordinate(c1) -- (3.5, -.3) coordinate(c2) coordinate[pos=.5](cm);
\draw[red] (c1) -- (c2) node[pos=1.2] {$c$};
\draw[red,thick,->] (cm) -- ($(cm)!.8cm!90:(c2)$);
\end{scope}
\begin{scope}[shift={(9, 0)},scale=.7]
\path[fill=gray!20] (0, 0) coordinate(p1) -- ++(35:2.5) coordinate(p2) -- ++(-45:2.5) coordinate(p3) -- ++(-120:3.5) coordinate(p4) -- ++(150:3) coordinate(p5);
\node at (barycentric cs:p1=1,p2=1,p3=1,p4=1,p5=1) {$P$};
\foreach \X [count=\Y] in {2,...,6} {
\ifnum\X=6
\path (p\Y) -- (p1) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a1) coordinate[pos=0.5](m1);
\draw (a\Y) -- (a1);
\else
\path (p\Y) -- (p\X) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a\X) coordinate[pos=0.5](m\X);
\draw (a\Y) -- (a\X);
\fi
}
\node at (p1) {\color{red}$\bullet$};
\path[draw,red] (-1, .5) coordinate(c1) -- (0, 1.5) coordinate(c2) coordinate[pos=.5](cm);
\draw[red] (c1) -- (c2) node[pos=1.2] {$c$};
\draw[red,thick,->] (cm) -- ($(cm)!.8cm!90:(c2)$);
\end{scope}
\end{tikzpicture}
\end{figure}
\begin{lemma}
An $n$-dimensional polyhedron given by $m$ constraints has at most $\binom{m}{n}$ vertices, i.e. finitely many.
\end{lemma}
Thus, of all (usually infinitely many) feasible points, only finitely many are relevant.
Thus, of all (usually infinitely many) feasible points, only finitely many are relevant. However, enumerating all those points and choosing the best solution (\emph{brute force}) is still very inefficient.
Idea for the Simplex algorithm: Move from vertex to vertex such that the objective value only increases (decreases, respectively, if objective is to minimize).
\begin{figure}
\begin{figure}[H]
\centering
\begin{tikzpicture}
%TODO
\path[fill=gray!20] (0, 0) coordinate(p1) -- ++(35:2.5) coordinate(p2) -- ++(-45:2.5) coordinate(p3) -- ++(-120:3.5) coordinate(p4) -- ++(150:3) coordinate(p5);
\node at (barycentric cs:p1=1,p2=1,p3=1,p4=1,p5=1) {$P$};
\foreach \X [count=\Y] in {2,...,6} {
\ifnum\X=6
\path (p\Y) -- (p1) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a1) coordinate[pos=0.5](m1);
\draw (a\Y) -- (a1);
\else
\path (p\Y) -- (p\X) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a\X) coordinate[pos=0.5](m\X);
\draw (a\Y) -- (a\X);
\fi
}
\node[draw,red,circle] (S1) at (p4) {};
\node[draw,red,circle] (S2) at (p5) {};
\node[draw,red,circle] (S3) at (p1) {};
\draw[-latex',red,thick] (S1) edge[bend right] (S2);
\draw[-latex',red,thick] (S2) edge[bend right] (S3);
\path[draw,red] (-1, .5) coordinate(c1) -- (0, 1.5) coordinate(c2) coordinate[pos=.5](cm);
\draw[red] (c1) -- (c2) node[pos=1.2] {$c$};
\draw[red,thick,->] (cm) -- ($(cm)!.8cm!90:(c2)$);
\end{tikzpicture}
\end{figure}
......@@ -223,15 +340,36 @@ This yields to \emph{standard form} for LPs:
where the LP on the right is obtained by setting $x_{n+i} = y_i$ for $i \in \{1, \ldots, m\}$ and we extend $c$ and $A$ in the obvious way.
The transformation from canonical form to standard form preserves dimension and vertices of the polyhedron.
\begin{figure}
\begin{figure}[H]
\tdplotsetmaincoords{70}{45}
\centering
\begin{tikzpicture}
%TODO scopes
\begin{tikzpicture}[scale=3, >=latex', ]
\begin{scope}[tdplot_main_coords]
\path[fill=gray!20] (0, 0, 0) -- (1, 0, 0) -- (0, 1.2, 0);
\draw[->] (0, 0, 0) -- (1.2, 0, 0) node[pos=1.1] {$x_1$};
\draw[->] (0, 0, 0) -- (0, 1.5, 0) node[pos=1.07] {$x_2$};
\node at (0, 0, 0) {$\bullet$};
\node at (1, 0, 0) {$\bullet$};
\node at (0, 1.2, 0) {$\bullet$};
\draw[-] (1, 0, 0) -- (0, 1.2, 0);
\end{scope}
\node at (.45, -.7) {$P = \{x \in \mathbb{R}^2_+ \mid x_1 + x_2 \leq 1\}$};
\begin{scope}[tdplot_main_coords, shift={(2, 1.6)}]
\path[fill=gray!20] (1, 0, 0) -- (0, 1.2, 0) -- (0, 0, .8);
\draw[->] (0, 0, 0) -- (1.2, 0, 0) node[pos=1.1] {$x_1$};
\draw[->] (0, 0, 0) -- (0, 1.5, 0) node[pos=1.07] {$x_2$};
\draw[->] (0, 0, 0) -- (0, 0, 1) node[pos=1.1] {$y_1$};
\node at (0, 0, .8) {$\bullet$};
\node at (1, 0, 0) {$\bullet$};
\node at (0, 1.2, 0) {$\bullet$};
\draw[-] (1, 0, 0) -- (0, 1.2, 0) -- (0, 0, .8) -- (1, 0, 0);
\end{scope}
\node at (3, -.7) {$P' = \{(x, y) \in \mathbb{R}^3_+ \mid x_1 + x_2 + y_1 = 1\}$};
\end{tikzpicture}
\end{figure}
Note that the slack variable $y_i = 0$ iff the $i$-th constraint is active. % complementary slackness?
We can also interpret $x$ as slack varaiable, just note that $x_j = 0$ iff $x_j \geq 0$ active.
We can also interpret $x$ as slack variable, just note that $x_j = 0$ iff $x_j \geq 0$ active.
Let $A_1, A_2, \ldots, A_n, A_{n+1}, \ldots, A_{n+m}$ be the columns of $A$ (the latter $m$ columns are unit vectors for slack varaiables). For $J \subseteq (1, \ldots, n+m)$, let $A_J$ denote the matrix consisting of columns $A_j$ with $j \in J$, e.g. for
$$
......@@ -252,7 +390,7 @@ $$
\right).
$$
A \emph{basis} $B = (B_1, \ldots, B_m) \subseteq (1, \ldots, n-m)$ is a subset of $m$ column indices such that the corresponding columns are linearly independent. $N = (1, \ldots, n+m) \setminus B$ is called \emph{non basis}. Variables $x_j$ with $j \in B$ are called \emph{basic variables}, and \emph{non-basic variables} if $i \in N$.
A \emph{basis} $B = (B_1, \ldots, B_m) \subseteq (1, \ldots, n+m)$ is a subset of $m$ column indices such that the corresponding columns are linearly independent. $N = (1, \ldots, n+m) \setminus B$ is called \emph{non basis}. Variables $x_j$ with $j \in B$ are called \emph{basic variables}, and \emph{non-basic variables} if $i \in N$.
A vector $x \in \mathbb{Q}^{n+m}$ is a \emph{basic solution} to $Ax = b$, $x \geq 0$ if there is a basis $B$ such that
\begin{itemize}
......@@ -267,18 +405,32 @@ If additionally $x_B \geq 0$ holds $x$ is called \emph{feasible basic solution}.
Basic solution are also called \emph{extreme point solutions}.
We need $\dim P$ constraints to describe a vertex. The non-basic variables correspond to the active constraints.
\begin{figure}[h]
\begin{figure}[H]
\centering
\begin{tikzpicture}
%TODO
\path[fill=gray!20] (0, 0) coordinate(p1) -- (2, 1) coordinate(p2) -- (4, 1) coordinate(p3) -- (6, 0) coordinate(p4) -- (5, -1) coordinate(p5);
\foreach \X [count=\Y] in {2,...,5} {
\path (p\Y) -- (p\X) coordinate[pos=-0.2](a\Y) coordinate[pos=1.2](a\X);
\ifnum\Y=4
\draw (a\Y) -- node[below right]{\scriptsize$\Y$} (a\X);
\else
\draw (a\Y) -- node[above] {\scriptsize$\Y$} (a\X);
\fi
}
\node[draw,circle,red,label={[align=left,red,shift={(1.5, 0)}]\scriptsize{At this vertex, the slack}\\[-.5em]\scriptsize{variables of constraint 2}\\[-.5em]\scriptsize{and 3 are $0$.}}] at (p3) {};
\end{tikzpicture}
\end{figure}
Note that the basis in one vertex is not necessarily unique. We call those vertices \emph{degnerate}.
\begin{figure}[h]
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{tikzpicture}[scale=2]
\path[fill=gray!20] (-.8, 0) -- (0, 0) -- (-.64, .64);
\draw[-] (-1, 0) -- (1, 0) node[pos=1.05]{\scriptsize$1$};
\draw[-] (-.8, .8) -- (.8, -.8) node[pos=1.05]{\scriptsize$2$};
\draw[-] (0, 1) -- (0, -1) node[pos=1.05]{\scriptsize$3$};
\draw[-] (.5, .75) -- (-.5, -.75) node[pos=1.05]{\scriptsize$4$};
\node[align=left] at (3.5, 0) {Possible bases:\\$B = (1, 2), (1, 3), (1, 4), (2, 3), \ldots$};
\end{tikzpicture}
\end{figure}
......@@ -316,7 +468,6 @@ The first basis: If $b \geq 0$, all slack variables are a feasible basis, i.e. $
$x_B$ & $\bar{A}_N$ & $\mathbbm{1}_m$ & $\bar{b}$\\
\cline{2-4}
\ & $x_N$ & $x_B$ & \
\end{tabular}
\end{table}
\end{document}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment