mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 19:36:26 +02:00
Compare commits
128 Commits
opti_blatt
...
prosem
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a318ef2d5 | |||
| 41bdc1bda9 | |||
| a014ffffc7 | |||
| c60b690fec | |||
| f80e11ffe2 | |||
| 3e085ffbe6 | |||
| c455d2197f | |||
| 5eb9ddf2b0 | |||
| 49c5280378 | |||
| 529c7f5118 | |||
| f46c1a2343 | |||
| 1fb66470a3 | |||
| 56ec9ad594 | |||
| c5eac0cfe6 | |||
| 9ac5743b02 | |||
| f15872f6c9 | |||
| 6692df5e06 | |||
| bf01572c41 | |||
| 5dc58682c0 | |||
| c3a7be5d6c | |||
| 0f91b6e7f6 | |||
| 4064c37dbf | |||
| 055079d9d5 | |||
| 91adc86eb1 | |||
| 1f678826c5 | |||
| ca49021373 | |||
| a4ae405911 | |||
| 920ab0bf84 | |||
| 4ee9ab9602 | |||
| d299eb9b75 | |||
| 7ce281fc18 | |||
| 7858f854c0 | |||
| 70f76a6fa6 | |||
| 8ca065840a | |||
| 16427f493d | |||
| 8a6f1fe0f8 | |||
| 87f5d72027 | |||
| d958bd7614 | |||
| 281923ed54 | |||
| 3a824a2af6 | |||
| dd9776f693 | |||
| c9445024a6 | |||
| 1e7da0db62 | |||
| 81ab70be51 | |||
| 0fffc90b0a | |||
| 1d73f91c43 | |||
| 3fa88e27c0 | |||
| 7099956376 | |||
| 7e451ae325 | |||
| 209596e423 | |||
| 6a532d59e0 | |||
| 599b0032cc | |||
| 9460a78c84 | |||
| 19c73063e5 | |||
| dacea16e20 | |||
| 1f3c4a224c | |||
| 07b2f40077 | |||
| f7f0ddff76 | |||
| 3d3fad0958 | |||
| d4bbd0819f | |||
| c2b78301f7 | |||
| 54cfa7594d | |||
| 210e0402d8 | |||
| 57d70e469c | |||
| f4af6e159c | |||
| 1d4cd3392a | |||
| e6025ac530 | |||
| 7dd2da6e74 | |||
| dad77a8dff | |||
| d013e0533e | |||
| 5bdf5a2487 | |||
| f5e1a36683 | |||
| 6507d7a749 | |||
| eb6256a57f | |||
| a324b8291d | |||
| 6afc457d64 | |||
| f768bb15bf | |||
| f589ab47c7 | |||
| 2b0d06f6ea | |||
| 300490a93b | |||
| abf82e25d7 | |||
| d7c4eed8f1 | |||
| 36556eb9b4 | |||
| a051729612 | |||
| 3b2a28a11d | |||
| 9913b6fc95 | |||
| 7818e3b603 | |||
| 88562703a2 | |||
| da05933c8d | |||
| 4cbbe10194 | |||
| 99ca499a0a | |||
| 4d8389eba9 | |||
| a6ed748153 | |||
| 758f40ea1f | |||
| 26fda0ddb4 | |||
| 347f0584a0 | |||
| 240dd113ab | |||
| 7fb91df76f | |||
| 542da545e2 | |||
| 8743f36082 | |||
| 02da1f0144 | |||
| 44ab3e4e0b | |||
| 7913205597 | |||
| 1f552564c9 | |||
| b3df21b7d1 | |||
| 66ba6adf3c | |||
| 034d351d48 | |||
| 7782f3bce6 | |||
| 891d29e8db | |||
| f0ede8a917 | |||
| 6944116e41 | |||
| 4814d034eb | |||
| 18beb0ed80 | |||
| 470120c41a | |||
| 6781c5ac6b | |||
| 32ee17cb3d | |||
| 7f9d6991ad | |||
| 5496fc3dd5 | |||
| d71f895dad | |||
| 11002283c7 | |||
| ba8e658c6b | |||
| 53c2f20454 | |||
| 8c9345ae82 | |||
| c1e7081efc | |||
| 605f14d18f | |||
| d47a755fdf | |||
| 2b4c538135 | |||
| 5d3323e75e |
1
.gitignore
vendored
1
.gitignore
vendored
@ -26,6 +26,7 @@
|
||||
*.pdf
|
||||
*.pdfsync
|
||||
*.ps
|
||||
*.pyg
|
||||
*.snm
|
||||
*.synctex.gz
|
||||
*.toc
|
||||
|
||||
11
README.md
11
README.md
@ -1,4 +1,13 @@
|
||||
uni
|
||||
===
|
||||
|
||||
University stuff
|
||||
Aus gegebenem Anlass:
|
||||
|
||||
Die in diesem Repository zu findenen Latex- und .rkt-Dateien sind Hausaufgaben. Zum Zwecke der Zusammenarbeit innerhalb
|
||||
**meiner** Gruppe werden auch Dateien hochgeladen, deren Abgabedeadline noch nicht erreicht ist.
|
||||
|
||||
Es nutzt anderen Gruppen kein Stück diese noch ausstehenden Abgaben 1:1 zu kopieren, die Namen zu ändern und als ihre
|
||||
eigene Arbeit auszugeben. Denn dann bekommen beide Gruppen keine Punkte. Da dies so in GDB passiert ist, werden die entsprechenden
|
||||
Latexdateien für GDB ab sofort erst nach der Abgabedeadline hochgeladen. Es ist bedauerlich, dass einige Personen in dieser
|
||||
Hinsicht derartig dumm sind. Es spricht nichts dagegen sich die von mir bearbeiteten Abgaben anzusehen und sich Ideen zu holen.
|
||||
Identische Kopien sind aber in keinem Falle angebracht.
|
||||
|
||||
334
ad/AD-Gruppe_8_Koehler_Krabbe_Martens_Blatt4.tex
Normal file
334
ad/AD-Gruppe_8_Koehler_Krabbe_Martens_Blatt4.tex
Normal file
@ -0,0 +1,334 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{bytefield}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{textcomp}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usepackage{algorithm}
|
||||
\usepackage{algorithmic}
|
||||
\usetikzlibrary{automata,matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{(\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
|
||||
\begin{document}
|
||||
\author{Reinhard Köhler (6425686), Tronje Krabbe (6435002), \\
|
||||
Jim Martens (6420323)}
|
||||
\title{Hausaufgaben zum 4. Dezember}
|
||||
\subtitle{Gruppe 8}
|
||||
\maketitle
|
||||
\section{} %1
|
||||
\subsection{} %a
|
||||
Der Algorithmus funktioniert nicht mehr. Dies wird anhand dieses Gegenbeispiels deutlich:
|
||||
|
||||
\begin{verbatim}
|
||||
A = [0,1,4,8,10,13]
|
||||
value = 1
|
||||
low = 0
|
||||
high = 5
|
||||
// erster Schleifendurchlauf 0 < 5, daher Rumpf ausführen
|
||||
mid = (0 + 5) / 2 = 2
|
||||
// A[2] = 4 > value
|
||||
high = 2 - 1 = 1
|
||||
// zweiter Schleifendurchlauf 0 < 1, daher Rumpf ausführen
|
||||
mid = (0 + 1) / 2 = 0
|
||||
// A[0] = 0 < value
|
||||
low = 0 + 1 = 1
|
||||
// dritter Schleifendurchlauf 1 = 1, daher Rumpf nicht ausführen
|
||||
return not_found
|
||||
\end{verbatim}
|
||||
|
||||
Obwohl das Element vorhanden ist, wird zurückgegeben, dass es nicht vorhanden sei. Da es ein Gegenbeispiel gibt, funktioniert der Algorithmus nach der Änderung von \texttt{while (low <= high)} zu \texttt{while (low < high)} nicht mehr.
|
||||
\subsection{} %b
|
||||
\begin{verbatim}
|
||||
BinarySearch(A[0..N-1], value) {
|
||||
low = N - 1
|
||||
high = 0
|
||||
while (high <= low) {
|
||||
// invariants: value > A[i] for all i < low
|
||||
value < A[i] for all i > high
|
||||
mid = (low + high) / 2
|
||||
if (A[mid] > value)
|
||||
high = mid + 1
|
||||
else if (A[mid] < value)
|
||||
low = mid - 1
|
||||
else
|
||||
return mid
|
||||
}
|
||||
return not_found
|
||||
}
|
||||
\end{verbatim}
|
||||
\subsection{} %c
|
||||
\textbf{Formaler Beweis:} Wir müssen beweisen, dass die while-Schleife endet. Angenommen wir befinden uns in Iteration $i$ der while-Schleife.
|
||||
\begin{itemize}
|
||||
\item Zu Beginn der while-Schleife haben wir \texttt{high $\leq$ low} (andernfalls hätten wir die while-Schleife nicht betreten).
|
||||
\item Nach dem Ausdruck \texttt{mid = (low + high) / 2} gilt \texttt{high $\leq$ mid $\leq$ low}.
|
||||
\item Entweder die Schleife wird durch die Rückgabe von \texttt{mid} beendet, womit wir fertig wären.
|
||||
\item Oder sie befindet sich in einer der ersten beiden Fälle des if-Statements. Entweder high wird um mindestens eins erhöht oder low wird um mindestens eins verkleinert, wodurch sich in jedem Schleifendurchlauf die Differenz von \texttt{low - high} um mindestens eins verringert.
|
||||
\item Damit gilt \texttt{low - high < 0} nach maximal $n$ Iterationen der while-Schleife und die Schleife terminiert.
|
||||
\end{itemize}
|
||||
\subsection{} %d
|
||||
\textbf{Beweis der Korrektheit:}
|
||||
|
||||
Offensichtlich gibt der Algorithmus ein korrektes Ergebnis zurück, wenn \texttt{mid} zurückgegeben wird, da dann \texttt{A[mid] $=$ value} gilt.
|
||||
|
||||
Zu zeigen: Wenn der Algorithmus \texttt{not\_found} zurückgibt, dann kommt \texttt{value} tatsächlich nicht in dem Array vor.
|
||||
|
||||
Wir werden dies nun durch die Gegenposition beweisen: Wir müssen zeigen, dass wenn \texttt{value} im Array vorkommt, der Algorithmus \texttt{mid} zurückgibt.
|
||||
|
||||
\textbf{Erster Schritt:} Es ist einfach zu sehen, dass die folgenden Invarianten immer gelten:
|
||||
\begin{itemize}
|
||||
\item \texttt{value > A[i] for all i < low (strict inequality!)}
|
||||
\item \texttt{value < A[i] for all i > high (strict inequality!)}
|
||||
\end{itemize}
|
||||
|
||||
\textbf{Zweiter Schritt:} Annahme, dass \texttt{value} im Array vorkommt.
|
||||
\begin{itemize}
|
||||
\item Bereits bekannt: Invarianten sind wahr. Das bedeutet zu keinem Zeitpunkt im Algorithmus kann sich das Element, das wir suchen, links von \texttt{high} oder rechts von \texttt{low} befinden.
|
||||
\item Der einzige Weg, wie wir theoretisch das gesuchte Element "`verpassen"' könnten, wäre, dass \texttt{high = mid + 1} oder \texttt{low = mid - 1} zu der Situation führen, dass \texttt{high > low} gilt bevor wir das gesuchte Element gefunden haben (weil wir dann die Schleife verlassen).
|
||||
\begin{itemize}
|
||||
\item Durch die Konstruktion des Algorithmus haben wir immer \texttt{high $\leq$ mid $\leq$ low} nachdem \texttt{mid = (low + high) / 2} ausgeführt wurde.
|
||||
\item Solange \texttt{low $\geq$ high + 2} gilt, haben wir immer \texttt{high < mid < low}.
|
||||
In dieser Situation, \texttt{mid - 1 $\geq$ high} und \texttt{mid + 1 $\leq$ low}, haben wir immer noch \texttt{high $\leq$ low} nachdem entweder \texttt{high = mid + 1} oder \texttt{low = mid - 1} ausgeführt wurden, sodass die while-Schleife ein weiteres Mal betreten wird.
|
||||
|
||||
Es gibt zwei kritische Fälle, in denen wir die Schleife verlassen könnten:
|
||||
\begin{itemize}
|
||||
\item \texttt{low = high}. Aber dann gilt auch \texttt{mid = high}. Nach der Annahme, dass \texttt{value} im Array ist, muss \texttt{A[high] = value} gelten. Durch die Rückgabe von \texttt{mid} wird demnach genau der richtige Index zurückgegeben.
|
||||
\item \texttt{low = high + 1}. In diesem Fall gilt \texttt{mid = high}. Nun gilt entweder \texttt{A[high] = A[mid] = value}, wodurch durch Rückgabe von \texttt{mid} das richtige Ergebnis zurückgegeben würde, oder es gilt \texttt{A[high] = A[mid] > value}, wodurch \texttt{high} um eins erhöht würde, was beim nächsten Schleifendurchlauf im Fall \texttt{low = high} enden würde. In dem Fall wird das korrekte Ergebnis zurückgegeben, wie bereits gezeigt wurde.
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\item Dies zeigt, dass wenn \texttt{value} im Array vorhanden ist, der Algorithmus immer damit endet \texttt{mid} zurückzugeben.
|
||||
\end{itemize}
|
||||
\section{} %2
|
||||
\subsection{} %a
|
||||
\subsubsection{} %i
|
||||
In einem Graph ohne Kanten kann jeder Knoten gleich gefärbt sein. Dies gilt, weil die Bedingung $c_{k}(i= \neq c_{k}(j)$ nur gilt, wenn $i$ und $j$ mit einer Kante verbunden sind, was in solch einem Graphen nicht gegeben ist. Daher ist hier nichts zu zeigen.
|
||||
\subsubsection{} %ii
|
||||
Wenn ein Graph k-färbbar ist, dann kann man auch eine weitere Farbe in die Abbildung $c_{k}$ hinzunehmen ohne sie zu benutzen. Dies gilt da $c_{k}$ nicht surjektiv sein muss.
|
||||
\subsubsection{} %iii
|
||||
Man nehme einen k-färbbaren Graphen. Nun kann man solange weitere Farben hinzufügen, bis n Farben in der Abbildung vorkommen. Diese müssen jedoch nicht benutzt werden. Daher ist jeder Graph n-färbbar.
|
||||
\subsection{} %b
|
||||
\subsubsection{} %i
|
||||
Wenn ein Graph 2-färbbar ist, dann gibt es keine Zyklen ungerader Länge. Bei einem Zyklus gerader Länge kann jeder zweiter Knoten die gleiche Farbe haben, ohne mit einem Knoten verbunden zu sein, der die gleiche Farbe hat.
|
||||
|
||||
Alle Knoten mit einer Farbe kann man als eine Untermenge einer Abbildung eines bipartiten Graphen verstehen.
|
||||
\subsubsection{} %ii
|
||||
\begin{verbatim}
|
||||
IST_2FAERBUNG(G) {
|
||||
kanten = E(G)
|
||||
valid = true
|
||||
farben = new Set()
|
||||
foreach kante in kanten {
|
||||
knoten1 = kante.knoten1
|
||||
knoten2 = kante.knoten2
|
||||
farben.add(knoten1.farbe)
|
||||
farben.add(knoten2.farbe)
|
||||
if (knoten1.farbe == knoten2.farbe) {
|
||||
valid = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return (valid && (farben.getAnzahl() == 2))
|
||||
}
|
||||
\end{verbatim}
|
||||
\subsubsection{} %iii
|
||||
Es gibt 2 verschiedene 2-Färbungen, sofern man unterschiedliche Farben nicht als Unterschied ansieht. Pro 2 Farben gibt es genau 2 verschiedene Färbungen.
|
||||
\subsection{} %c
|
||||
Bei einer beliebigen Landkarte werden mindestens vier Farben benötigt, damit direkt benachbarte Länder stets unterschiedliche Farben haben.
|
||||
\subsubsection{} %i
|
||||
\begin{tikzpicture}
|
||||
\node (altona) {A};
|
||||
\node (eimsbuettel) [above right=of altona] {E};
|
||||
\node (nord) [right=of eimsbuettel] {N};
|
||||
\node (wandsbek) [right=of nord] {W};
|
||||
\node (mitte) [below=of eimsbuettel] {M};
|
||||
\node (harburg) [below left=of mitte] {H};
|
||||
\node (bergedorf) [below right=of mitte] {B};
|
||||
|
||||
\path[every node/.style={font=\scriptsize}]
|
||||
(altona) edge (mitte)
|
||||
(altona) edge (eimsbuettel)
|
||||
(mitte) edge (harburg)
|
||||
(mitte) edge (bergedorf)
|
||||
(mitte) edge (eimsbuettel)
|
||||
(mitte) edge (nord)
|
||||
(mitte) edge (wandsbek)
|
||||
(eimsbuettel) edge (nord)
|
||||
(nord) edge (wandsbek);
|
||||
\end{tikzpicture}
|
||||
\subsubsection{} %ii
|
||||
\begin{alignat*}{2}
|
||||
c_{k}(A) &=& gelb \\
|
||||
c_{k}(E) &=& rot \\
|
||||
c_{k}(M) &=& blau \\
|
||||
c_{k}(H) &=& rot \\
|
||||
c_{k}(B) &=& rot \\
|
||||
c_{k}(N) &=& gelb \\
|
||||
c_{k}(W) &=& rot
|
||||
\end{alignat*}
|
||||
\subsubsection{} %iii
|
||||
Die Aussage, dass vier Farben minimal sind, besagt nur, dass man es bei einer beliebigen Landkarte schafft diese mit maximal vier Farben zu färben. Es gibt die Obergrenze der nötigen Farben an. Die Regel besagt hingegen nicht, dass immer mindestens vier Farben benötigt werden. Bei einer Landkarte mit nur zwei aneinandergrenzenden Ländern reichen auch zwei Farben. Bei einer Karte mit nur einer zusammenhängenden Fläche ohne angrenzende Flächen reicht sogar eine Farbe.
|
||||
\subsubsection{} %iv
|
||||
\begin{tikzpicture}
|
||||
\node (sh) {SH};
|
||||
\node (hh) [below right=of sh] {HH};
|
||||
\node (meck) [right=of hh] {MP};
|
||||
\node (bremen) [below left=of hh] {B};
|
||||
\node (nieder) [below=of hh] {N};
|
||||
|
||||
\path[every node/.style={font=\scriptsize}]
|
||||
(sh) edge (hh)
|
||||
(sh) edge (meck)
|
||||
(hh) edge (nieder)
|
||||
(bremen) edge (nieder)
|
||||
(sh) edge (nieder)
|
||||
(bremen) edge (sh)
|
||||
(bremen) edge (hh);
|
||||
\end{tikzpicture}
|
||||
|
||||
In dieser konstruierten Karte (dargestellt als Graph), müssen mindestens vier Farben verwendet werden.
|
||||
\section{} %3
|
||||
\subsection{} %a
|
||||
\[
|
||||
G_{1}: 1, 3, 4, 5, 2, 8, 6, 7
|
||||
\]
|
||||
\[
|
||||
G_{2}: 1, 3, 5, 6, 4, 7, 2
|
||||
\]
|
||||
\subsection{} %b
|
||||
\[
|
||||
G_{1}: 4, 3, 7, 6, 8, 2, 5, 1
|
||||
\]
|
||||
\[
|
||||
G_{2}: 4, 6, 5, 3, 2, 7, 1
|
||||
\]
|
||||
\subsection{} %c
|
||||
\[
|
||||
G_{1}: 1, 3, 5, 4, 2, 7, 8, 6
|
||||
\]
|
||||
\[
|
||||
G_{2}: 1, 3, 4, 7, 5, 2, 6
|
||||
\]
|
||||
\subsection{} %d
|
||||
Für $G_1$ existiert keine topologische Sortierung, da es sich nicht um einen DAG (Directed acyclic graph) handelt. Dies erkennt man daran, dass beispielsweise ein Zyklus von 1 über 5 über 2 zurück zur 1 existiert. $\square$
|
||||
|
||||
Für $G_2$ existieren topologische Sortierungen, z.B.:
|
||||
\[
|
||||
1, 3, 5, 6, 4, 7, 2
|
||||
\]
|
||||
\subsection{} %e
|
||||
Wie bereits etabliert, existieren für $G_1$ keine mit ihm konsistenten topologischen Sortierungen. Für $G_2$ allerdings existieren mehrere:
|
||||
|
||||
Nach Proposition 5 (Uniqueness of topological Sort) im Skript, Folie 163, ist eine topologische Sortierung nur eindeutig, wenn der dazugehörige Graph einen Hamilton-Kreis enthält. $G_2$ enthält keinen Hamilton-Kreis. Dies ist leicht zu erkennen: es gibt keinen Pfad in dem Graphen, der die Knoten $2$ \textit{und} $3$ besucht. Daher gibt es mehrere topologische Sortierungen.
|
||||
|
||||
Eine weitere wäre z.B.:
|
||||
\[
|
||||
1, 7, 2, 5, 6, 4, 3
|
||||
\]
|
||||
\subsection{} %f
|
||||
starke Zusammenhangskomponenten von $G_{1}:$
|
||||
\begin{alignat*}{2}
|
||||
comp1:&&\; 1, 2, 5, 6, 7, 8 \\
|
||||
comp2:&&\; 3 \\
|
||||
comp3:&&\; 4
|
||||
\end{alignat*}
|
||||
|
||||
starke Zusammenhangskomponenten von $G_{2}:$
|
||||
\begin{alignat*}{1}
|
||||
comp1: 1 \\
|
||||
comp2: 2 \\
|
||||
comp3: 3 \\
|
||||
comp4: 4 \\
|
||||
comp5: 5 \\
|
||||
comp6: 6 \\
|
||||
comp7: 7
|
||||
\end{alignat*}
|
||||
\section{} %4
|
||||
\subsection{} %a
|
||||
% Senken finden (alle Senken infiltrieren, dadurch werden alle Module eliminiert)
|
||||
% Algorithmus aus Vorlesung benutzen
|
||||
Es müssen alle Module (oder Knoten) ohne eingehende Kanten eliminiert (bzw. markiert) werden, da diese andernfalls nie erreicht werden können. Zu allen anderen Knoten muss es gerichtete Pfade von einem dieser Knoten geben. Ausnahmen können starke Zusammenhangskomponenten bilden. In jeder starken Zusammenhangskomponente wird daher ebenfalls ein Knoten eliminiert.
|
||||
\newpage
|
||||
\begin{verbatim}
|
||||
function eliminiereMCP() {
|
||||
int zaehler = 0
|
||||
|
||||
list infiltrierteKnoten
|
||||
// füge alle Knoten ohne Vorgänger hinzu:
|
||||
for-all v in Knotenmenge:
|
||||
if v.eingehendeKanten == 0:
|
||||
infiltriere(v)
|
||||
infiltrierteKnoten.add(v)
|
||||
end if
|
||||
end for-all
|
||||
// füge einen Knoten aus jeder
|
||||
// starken Zusammenhangskomponente hinzu:
|
||||
list starkZusammenhaengend = findeStarkeZusammenhangskomponenten()
|
||||
for-all elemente in starkZusammenhaengend:
|
||||
for i = 0; i < elemente.length; i++
|
||||
if infiltrierteKnoten.contains(elemente[i]):
|
||||
zaehler++
|
||||
end if
|
||||
if zaehler == 0:
|
||||
infiltriere(elemente[0])
|
||||
infiltrierteKnoten.add(elemente[0])
|
||||
end if
|
||||
end for
|
||||
end for-all
|
||||
eliminiere(infiltrierteKnoten)
|
||||
}
|
||||
\end{verbatim}
|
||||
\subsection{} %b
|
||||
Wenn alle Senken infiltriert werden, werden dadurch alle Module eliminiert, da alle Module direkt oder indirekt mit mindestens einer Senke verbunden sind.
|
||||
\subsection{} %c
|
||||
Es müssen alle Senken infiltriert werden, da ansonsten einzelne Module nicht eliminiert werden könnten.
|
||||
|
||||
\section*{Zusatzaufgabe} %Zusatz
|
||||
|
||||
Beweis der Terminierung für beliebige natürliche Zahlen größer $0$.\\
|
||||
Trivialer Fall: \\
|
||||
Der Algorithmus terminiert für $n=1$. \\
|
||||
Zweiter Fall: \\
|
||||
Der Algorithmus terminiert für $2^{c} = n$. Dies gilt, da damit nach $c$ Rekursionsschritten immer $n=1$ gilt. \\
|
||||
Dritter Fall: \\
|
||||
Es ist zu zeigen, dass nach endlich vielen Rekursionsschritten \textsc{Coll} mit einer 2er-Potenz aufgerufen wird.
|
||||
|
||||
Dazu lohnt es sich die verbleibenden Zahlen bis 10 anzuschauen.
|
||||
\begin{alignat*}{2}
|
||||
3 \rightarrow 10 \rightarrow 5 \rightarrow 16 \\
|
||||
5 \rightarrow 16 \\
|
||||
6 \rightarrow 3 \\
|
||||
7 \rightarrow 22 \rightarrow 11 \rightarrow 34 \rightarrow 17 \rightarrow 52 \rightarrow 26 \rightarrow 13 \rightarrow 40 \rightarrow 20 \rightarrow 10 \rightarrow 5 \rightarrow 16 \\
|
||||
9 \rightarrow 28 \rightarrow 14 \rightarrow 7 \\
|
||||
10 \rightarrow 5
|
||||
\end{alignat*}
|
||||
|
||||
Was kann aus dieser Reihe geschlossen werden? Alle Zahlen, die aus dem Produkt einer 2er-Potenz und einer dieser Zahlen entstehen, lassen sich auf eine 2er-Potenz zurückführen. Auf diese Weise könnte man für die ersten $d$ natürlichen Zahlen zeigen, dass sie sich alle auf eine 2er-Potenz zurückführen lassen.
|
||||
|
||||
Aufgrund dieser Annahme steigt die Wahrscheinlichkeit bei einem Rekursionsaufruf mit $3n+1$ auf ein solches Vielfaches einer bereits auf eine 2er-Potenz zurückgeführte Zahl zu stoßen.
|
||||
|
||||
Da es jedoch unendlich viele Primzahlen gibt, wenngleich sich deren Abstand zueinander immer weiter erhöht, findet man immer Zahlen, die noch nicht auf eine 2er-Potenz zurückgeführt sind. Aufgrund dieser Tatsache kann es keine allgemeingültige Aussage für alle natürlichen Zahlen geben. Allerdings kann dieser Algorithmus selbst als Antwort verstanden werden. Für eine beliebig große Zahl, die nicht ein gerades Vielfaches einer bereits zurückgeführten Zahl ist, muss daher nur der Algorithmus ausgeführt werden bis ein solches Vielfaches erreicht wurde.
|
||||
|
||||
Nach endlich vielen Schritten wird dies praktisch der Fall sein, wenngleich die Anzahl dieser Schritte dramatisch zunehmen wird. Es ist jedoch nicht möglich dafür einen theoretischen Beweis zu finden, der ebenjene Tatsache darlegen kann.
|
||||
\end{document}
|
||||
300
ad/AD-Gruppe_8_Koehler_Krabbe_Martens_Blatt5.tex
Normal file
300
ad/AD-Gruppe_8_Koehler_Krabbe_Martens_Blatt5.tex
Normal file
@ -0,0 +1,300 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{bytefield}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{textcomp}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usepackage{algorithm}
|
||||
\usepackage{algorithmic}
|
||||
\usepackage{minted}
|
||||
\usetikzlibrary{automata,matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{(\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
|
||||
\begin{document}
|
||||
\author{Reinhard Köhler (6425686), Tronje Krabbe (6435002), \\
|
||||
Jim Martens (6420323)}
|
||||
\title{Hausaufgaben zum 4. Dezember}
|
||||
\subtitle{Gruppe 8}
|
||||
\maketitle
|
||||
|
||||
\section{} %1
|
||||
Dieser folgende Pseudocode beschreibt eine leichte Abänderung, die vorzeitig abbricht, wenn sich nach einem kompletten Durchlauf aller Kanten nichts geändert hat. Nach $m$ Durchläufen hat der Algorithmus alle kürzeste Pfade mit maximal $m$ Kanten entdeckt. In einem weiteren Durchlauf wird sich dann nichts mehr ändern, da keine neuen kürzesten Pfade mehr gefunden werden können, wodurch die geänderte Variante abbricht. Um die Abbruchbedingung zu erreichen muss $m$ nicht bekannt sein, da nach $m+1$ Durchläufen die Abbruchbedingung immer gegeben ist.
|
||||
\begin{minted}{python}
|
||||
function BellmanFord(G,s)
|
||||
InitializeSingleSource(G,s)
|
||||
for i = 1, ... |V| - 1
|
||||
changed = false
|
||||
for all edges (u,v) in E
|
||||
changedTmp = Relax(u,v)
|
||||
if (!changed)
|
||||
changed = changedTmp
|
||||
if (!changed)
|
||||
break
|
||||
for all edges (u,v) in E
|
||||
if v.dist > u.dist + w(u,v)
|
||||
return false
|
||||
return true
|
||||
\end{minted}
|
||||
% \begin{verbatim}
|
||||
% function BellmanFord(G,s)
|
||||
% InitializeSingleSource(G,s)
|
||||
% for i = 1, ... |V| - 1
|
||||
% changed = false
|
||||
% for all edges (u,v) in E
|
||||
% changedTmp = Relax(u,v)
|
||||
% if (!changed)
|
||||
% changed = changedTmp
|
||||
% if (!changed)
|
||||
% break
|
||||
% for all edges (u,v) in E
|
||||
% if v.dist > u.dist + w(u,v)
|
||||
% return false
|
||||
% return true
|
||||
% \end{verbatim}
|
||||
\section{} %2
|
||||
\begin{minted}{python}
|
||||
function DAG-SP(G,s)
|
||||
sort vertices topologically
|
||||
InitializeSingleSource(G,s)
|
||||
for each u in V in topological sort order
|
||||
for each v in Adj(u)
|
||||
Relax(u,v)
|
||||
\end{minted}
|
||||
% \begin{verbatim}
|
||||
% function DAG-SP(G,s)
|
||||
% sort vertices topologically
|
||||
% InitializeSingleSource(G,s)
|
||||
% for each u in V in topological sort order
|
||||
% for each v in Adj(u)
|
||||
% Relax(u,v)
|
||||
% \end{verbatim}
|
||||
\section{} %3
|
||||
Wir wissen, dass der Dijkstra-Algorithmus für rein positive Kantengewichte funktioniert. Es bleibt also nur zu zeigen, dass die kürzesten Wege zu den Knoten korrekt berechnet werden, die eine Kante von dem Startknoten entfernt sind. Ferner ist bekannt, dass Dijkstra zuerst den Knoten besucht, der am billigsten zu erreichen ist. Damit geht der Algorithmus die Kante mit dem kleinsten Gewicht zu erst (einschließlich negative Gewichte). Der somit erreichte Knoten kann also gar nicht billiger zu erreichen sein, da jeder andere Pfad dorthin aus mindestens zwei Kanten besteht, die zusammen bestenfalls das gleiche Gewicht haben wie die gegangene Kante.
|
||||
|
||||
Dies ist so, da die erste Kante vom Startknoten zu einem anderen Knoten minimal so klein sein kann, wie die zuerst gegangene Kante, da andernfalls die zuerst gegangene Kante nicht das geringste Gewicht gehabt hätte. Die zweite Kante muss mindestens 0 als Gewicht haben, womit nur ein gleich großes oder größeres Gesamtgewicht entstehen kann, als durch die zuerst gegangene Kante verwendet wurde.
|
||||
\section{} %4
|
||||
\subsection{} %a
|
||||
In einem Baum gibt es keine Zyklen. Daher gibt es genau einen direkten Weg (ohne Umwege mit mehrmaligem Besuchen eines Knotens) zu jedem Knoten von dem Wurzelknoten aus. Demnach müssen einfach vom Wurzelknoten aus alle Knoten besucht werden. Dabei wird ähnlich wie in der Breitensuche vorgegangen, indem zunächst alle Knoten, die direkt mit dem Wurzelknoten per Kante verbunden sind, besucht werden und anschließend alle Knoten, die zwei Kanten vom Wurzelknoten entfernt sind, etc. Dabei wird eine Variable zu Beginn auf 0 gesetzt und bei jedem Knoten wird geschaut, ob seine Entfernung zum Wurzelknoten größer ist als diese Variable. Wenn dem so ist, dann wird die Variable entsprechend angepasst. Nach einmaligem Besuchen jedes Knotens hat man damit die längste Entfernung eines Knotens von dem Wurzelknoten ermittelt.
|
||||
|
||||
In Pseudocode sieht das dann so aus:
|
||||
|
||||
\begin{minted}{python}
|
||||
function berechneDurchmesser(G)
|
||||
longestPath = 0
|
||||
current = G.root
|
||||
queue.enqueue(current.getChilds())
|
||||
while (!empty(queue))
|
||||
current = queue.dequeue()
|
||||
parent = current.parent
|
||||
distance = parent.getDistance() + w(parent,current)
|
||||
current.setDistance(distance)
|
||||
if (distance > longestPath)
|
||||
longestPath = distance
|
||||
|
||||
childs = current.getChilds()
|
||||
if (!empty(childs))
|
||||
queue.enqueue(current.getChilds())
|
||||
\end{minted}
|
||||
% \begin{verbatim}
|
||||
% function berechneDurchmesser(G)
|
||||
% longestPath = 0
|
||||
% current = G.root
|
||||
% queue.enqueue(current.getChilds())
|
||||
% while (!empty(queue))
|
||||
% current = queue.dequeue()
|
||||
% parent = current.parent
|
||||
% distance = parent.getDistance() + w(parent,current)
|
||||
% current.setDistance(distance)
|
||||
% if (distance > longestPath)
|
||||
% longestPath = distance
|
||||
|
||||
% childs = current.getChilds()
|
||||
% if (!empty(childs))
|
||||
% queue.enqueue(current.getChilds())
|
||||
% \end{verbatim}
|
||||
\subsection{} %b
|
||||
\begin{minted}{python}
|
||||
def Durchmesser(G):
|
||||
laengsterWeg = 0
|
||||
for v1 in G.kanten:
|
||||
for v2 in G.kanten with v1 != v2:
|
||||
P = findeKuerzestenWeg(v1, v2)
|
||||
if P.laenge() > laengsterWeg:
|
||||
laengsterWeg = P.laenge()
|
||||
return laengsterWeg
|
||||
\end{minted}
|
||||
% \begin{verbatim}
|
||||
% Diam(G)
|
||||
% longestPath = 0
|
||||
% for each v1 in G.vertices
|
||||
% for each v2 in G.vertices with v1 != v2
|
||||
% find shortest path P from v1 to v2
|
||||
% if P.length > longestPath
|
||||
% longestPath = P.length
|
||||
% return longestPath
|
||||
% \end{verbatim}
|
||||
|
||||
Die Laufzeit dieses Algorithmus beträgt $\mathcal{O}(|V|^3)$.
|
||||
\section{} %5
|
||||
\subsection{} %a
|
||||
Man konstruiert einen vollständigen Graphen aus der Matrix, in welchem die Knoten Währungen repräsentieren, und als Kantengewichte die Werte verwendet werden.
|
||||
Gibt es nun in diesem Graphen einen Zyklus, in dem das Produkt aller Kantengewichte ungleich 1 ist, existiert Währungsarbitrage. Ansonsten ist dies nicht der Fall.
|
||||
\subsection{} %b
|
||||
Nein, unsere Lösung kann nicht zu negativen Zyklen führen, denn dafür müssten negative Werte in der Matrix vorhanden sein.
|
||||
Würden solche Zyklen existieren, bedeuteten sie, man verliere all sein Geld bei einem Tausch, und müsste außerdem eine Strafe zahlen.
|
||||
\section{} %6
|
||||
\begin{tikzpicture}[shorten >=1pt,node distance=1.1cm]
|
||||
\node[state] (s) {s};
|
||||
\node[state] (a) [above right=1.5 and 1.0 of s] {A};
|
||||
\node[state] (b) [below right=1.5 and 1.0 of s] {B};
|
||||
\node[state] (d) [above right=1.0 and 1.0 of a] {D};
|
||||
\node[state] (c) [right=of a] {C};
|
||||
\node[state] (f) [below right=1.0 and 1.25 of a] {F};
|
||||
\node[state] (e) [right=1.0 of c] {E};
|
||||
\node[state] (g) [right=of f] {G};
|
||||
|
||||
\path[every node/.style={font=\scriptsize},->]
|
||||
(s) edge node [above] {30} (a)
|
||||
(s) edge node [below] {18} (b)
|
||||
(a) edge node [above] {21} (c)
|
||||
(a) edge node [above] {38} (d)
|
||||
(a) edge node [below] {22} (f)
|
||||
(c) edge node [right] {22} (f)
|
||||
(c) edge node [above] {20} (e)
|
||||
(f) edge node [above] {9} (g)
|
||||
(b) edge node [left] {30} (a);
|
||||
\end{tikzpicture}
|
||||
|
||||
Da dies ein gerichteter Graph ohne Zyklen ist und auch keine negativen Kantengewichte vorkommen, kann der Dijkstra-Algorithmus angewendet werden. Da von 9 bis 17 Uhr Fahrer bezahlt werden müssen, kommen nur die Pfade in Betrachtung, die zu einer Senke führen. Senken sind D, E und G. Derjenige dieser Knoten welcher als erster vom Algorithmus gefunden wird (über den eindeutig bestimmbaren Weg), ist auch der kürzeste Pfad vom Startknoten aus, der die Bedingungen erfüllt.
|
||||
|
||||
Es ergibt sich folgende Abfolge:
|
||||
\begin{verbatim}
|
||||
S = {s}
|
||||
d(s) = 0
|
||||
while 1.
|
||||
U = {A, B}
|
||||
for all u in U -> u = A
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = s
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 0 + 30
|
||||
for all u in U -> u = B
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = s
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 0 + 18
|
||||
u* = B
|
||||
d(u*) = 18
|
||||
S = {s, B}
|
||||
while 2.
|
||||
U = {A}
|
||||
for all u in U -> u = A
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = s
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 0 + 30
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = B
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 18 + 30
|
||||
u* = A
|
||||
d(u*) = 30
|
||||
S = {S, B, A}
|
||||
while 3.
|
||||
U = {D, C, F}
|
||||
for all u in U -> u = D
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = A
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 30 + 38
|
||||
for all u in U -> u = C
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = A
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 30 + 21
|
||||
for all u in U -> u = F
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = A
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 30 + 22
|
||||
u* = C
|
||||
d(u*) = 51
|
||||
S = {s, B, A, C}
|
||||
while 4.
|
||||
U = {D, F, E}
|
||||
for all u in U -> u = D
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = A
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 30 + 38
|
||||
for all u in U -> u = F
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = A
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 30 + 22
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = C
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 51 + 22
|
||||
for all u in U -> u = E
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = C
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 51 + 20
|
||||
u* = F
|
||||
d(u*) = 52
|
||||
S = {s, B, A, C, F}
|
||||
while 5.
|
||||
U = {D, E, G}
|
||||
for all u in U -> u = D
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = A
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 30 + 38
|
||||
for all u in U -> u = E
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = C
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 51 + 20
|
||||
for all u in U -> u = G
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = F
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 52 + 9
|
||||
u* = G
|
||||
d(u*) = 61
|
||||
S = {s, B, A, C, F, G}
|
||||
while 6.
|
||||
U = {D, E}
|
||||
for all u in U -> u = D
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = A
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 30 + 38
|
||||
for all u in U -> u = E
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = C
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 51 + 22
|
||||
u* = D
|
||||
d(u*) = 68
|
||||
S = {s, B, A, C, F, G, D}
|
||||
while 7.
|
||||
U = {E}
|
||||
for all u in U -> u = E
|
||||
for all pre(u) in S that are predecessors of u -> pre(u) = C
|
||||
d'(u, pre(u)) = d(pre(u)) + w(pre(u), u)
|
||||
d'(u, pre(u)) = 51 + 20
|
||||
u* = E
|
||||
d(u*) = 71
|
||||
S = {s, B, A, C, F, G, D, E}
|
||||
\end{verbatim}
|
||||
|
||||
Wie zu sehen ist wird die Senke G zuerst erreicht. Folgt man dem Weg zu G, so ergibt sich, dass der kürzeste Pfad von s über A und F nach G führt. Weniger Kosten als 61 sind daher nicht möglich.
|
||||
\end{document}
|
||||
206
ad/AD-Gruppe_8_Koehler_Krabbe_Martens_Blatt6.tex
Normal file
206
ad/AD-Gruppe_8_Koehler_Krabbe_Martens_Blatt6.tex
Normal file
@ -0,0 +1,206 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{bytefield}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{textcomp}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usepackage{algpseudocode}
|
||||
\usepackage{algorithm}
|
||||
%\usepackage{algorithmic}
|
||||
%\usepackage{minted}
|
||||
\usetikzlibrary{automata,matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{(\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
|
||||
\begin{document}
|
||||
\author{Reinhard Köhler (6425686), Tronje Krabbe (6435002), \\
|
||||
Jim Martens (6420323)}
|
||||
\title{Hausaufgaben zum 15. Januar}
|
||||
\subtitle{Gruppe 8}
|
||||
\maketitle
|
||||
|
||||
\section{} %1
|
||||
\subsection{} %a
|
||||
\begin{tabular}{c|c|c|c|c|c|c|c|c}
|
||||
EXTRACT & 1 & 2 & 3 & 4 & 5 & 6 & 7 &\\
|
||||
\hline
|
||||
- & 0 & $\infty$ & $\infty$ & $\infty$ & $\infty$ & $\infty$ & $\infty$ & (v.dist) \\
|
||||
& - & - & - & - & - & - & - & (v.$\pi$) \\
|
||||
\hline
|
||||
1 & 0 & 4 & $\infty$ & $\infty$ & $\infty$ & 5 & $\infty$ & \\
|
||||
& - & 1 & - & - & - & 1 & - & \\
|
||||
\hline
|
||||
2 & 0 & 4 & 14 & $\infty$ & $\infty$ & 5 & 7 & \\
|
||||
& - & 1 & 2 & - & - & 1 & 2 & \\
|
||||
\hline
|
||||
6 & 0 & 4 & 14 & $\infty$ & 14 & 5 & 7 & \\
|
||||
& - & 1 & 2 & - & 6 & 1 & 2 & \\
|
||||
\hline
|
||||
7 & 0 & 4 & 13 & $\infty$ & 10 & 5 & 7 & \\
|
||||
& - & 1 & 7 & - & 7 & 1 & 2 & \\
|
||||
\hline
|
||||
5 & 0 & 4 & 12 & 15 & 10 & 5 & 7 & \\
|
||||
& - & 1 & 5 & 5 & 7 & 1 & 2 & \\
|
||||
\hline
|
||||
3 & 0 & 4 & 12 & 14 & 10 & 5 & 7 & \\
|
||||
& - & 1 & 5 & 3 & 7 & 1 & 2 & \\
|
||||
\hline
|
||||
4 & 0 & 4 & 12 & 14 & 10 & 5 & 7 & \\
|
||||
& - & 1 & 5 & 3 & 7 & 1 & 2 &
|
||||
\end{tabular}
|
||||
|
||||
Der kürzeste Pfad von 1 nach 4 verläuft über 2, 7, 5 und 3 nach 4. Insgesamt kostet der Pfad 14.
|
||||
\subsection{} %b
|
||||
In $G_{2}$ ist 3 die Quelle.
|
||||
|
||||
\begin{tabular}{c|c|c|c|c|c|c|c|c}
|
||||
EXTRACT & 3 & 1 & 2 & 4 & 5 &\\
|
||||
\hline
|
||||
- & 0 & $\infty$ & $\infty$ & $\infty$ & $\infty$ & (v.dist) \\
|
||||
& - & - & - & - & - & (v.$\pi$) \\
|
||||
\hline
|
||||
3 & 0 & $\infty$ & 9 & 4 & $\infty$ & \\
|
||||
& - & - & 3 & 3 & - & \\
|
||||
\hline
|
||||
4 & 0 & 5 & 8 & 4 & 6 & \\
|
||||
& - & 4 & 4 & 3 & 4 & \\
|
||||
\hline
|
||||
1 & 0 & 5 & 8 & 4 & 6 & \\
|
||||
& - & 4 & 4 & 3 & 4 & \\
|
||||
\hline
|
||||
5 & 0 & 1 & 8 & 4 & 6 & \\
|
||||
& - & 5 & 4 & 3 & 4 & \\
|
||||
\end{tabular}
|
||||
|
||||
Durch die negative Kante von 5 nach 1, würde sich der kürzeste Pfad von 1 von 5 auf 1 ändern, was jedoch nicht geht, da 1 bereits besucht wurde. Daher liefert Dijkstra für das Single-Source-Shortest-Path Problem in $G_{2}$ ein falsches Ergebnis.
|
||||
\section{} %2
|
||||
\begin{algorithm}
|
||||
\caption{Relax}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{Relax}{$u,v$}
|
||||
\State $maxWeight \gets max(u.maxWeight, w(u,v))$
|
||||
\If{$maxWeight < v.maxWeight$}
|
||||
\State $v.maxWeight \gets w(u,v)$
|
||||
\State $v.\pi \gets u$
|
||||
\EndIf
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
||||
\begin{algorithm}
|
||||
\caption{Initialize single source}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{InitializeSingleSource}{$G,s$}
|
||||
\ForAll{$v \in V$}
|
||||
\State $v.maxWeight \gets \infty$
|
||||
\State $v.\pi \gets NIL$
|
||||
\EndFor
|
||||
\State $s.maxWeight \gets 0$
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
||||
\begin{algorithm}
|
||||
\caption{Dijkstra für leichtest mögliche schwerste Kanten}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{Dijkstra}{$G,w,s$}
|
||||
\State $\Call{InitializeSingleSource}{G,s}$
|
||||
\State $Q \gets (V, V.maxWeight)$\Comment{ordered by the maximum weight (edge with highest weight) per path in ascending order}
|
||||
\While{$Q \neq \emptyset$}
|
||||
\State $u \gets \Call{Extract}{Q}$
|
||||
\ForAll{v adjacent to u}
|
||||
\State $\Call{Relax}{u,v}$ and update the keys in Q accordingly
|
||||
\EndFor
|
||||
\EndWhile
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
\section{} %3
|
||||
\subsection{} %a
|
||||
Es sei $B(k)$ die in der Aufgabenstellung formulierte Behauptung in Abhängigkeit von $k$.
|
||||
|
||||
\textbf{Behauptung}\\ $B(k)$ gilt für alle $k \in \mathbb{N}_{\geq 0}$.
|
||||
|
||||
\textbf{Induktionsanfang}\\ Zu Zeigen: Es gilt $B(0)$.
|
||||
|
||||
$A^0$ ist die Einheitsmatrix $E$. Ein Eintrag in $E$ ist genau dann 1, wenn er auf der Hauptdiagonalen liegt, andernfalls ist er 0.
|
||||
Das bedeutet, dass es über 0 Kanten jeweils genau einen Pfad von einem Knoten $i$ zu einem Knoten $j$ gibt, wenn $i = j$ gilt. Bei 0 Kanten sind
|
||||
dies genau die Pfade, die in einem beliebigen Graphen möglich sind, da ein Weg zu einem anderen Knoten über mindestens eine Kante gehen würde.
|
||||
Die Matrix $A^0$ ist also korrekt und $B(0)$ gilt.
|
||||
|
||||
\textbf{Induktionsschritt} Wir nehmen an, dass $B(k)$ gilt. Zu zeigen ist, dass daraus $B(k+1)$ folgt.
|
||||
|
||||
Sei $X$ eine Matrix, die erfüllt, dass jeder Eintrag $X[i,j]$ die Anzahl der verschiedenen Pfade vom Knoten $i$ über $k+1$ Kanten zum Knoten $j$ repräsentiert.
|
||||
Nun ist zu zeigen, dass $X=A^{k+1}$ gilt.
|
||||
|
||||
Wir betrachten nun einen beliebigen Eintrag $L[i,j]$. Um einen solchen Eintrag zu berechnen, summieren wir zunächst die Anzahlen aller Möglichkeiten,
|
||||
über $k$ Kanten vom Knoten $i$ zu einem beliebigen Knoten $h$ zu gelangen. Laut Induktionsannahme finden wir genau diese in der Matrix $A$,
|
||||
im Eintrag $A^k[i,h]$. Die Summe aller dieser Möglichkeiten ist wie folgt definiert:
|
||||
|
||||
$$\sum_{h=1}^{n}{A^k[i,h]}$$
|
||||
|
||||
Jetzt wollen wir eine Möglichkeit nur betrachten, wenn eine Kante $(h,j)$ existiert.
|
||||
Also betrachten wir nur noch die Möglichkeiten, über $k+1$ Kanten vom Knoten $i$ zum Knoten $j$ zu gelangen. Wir definieren das $n$-Tupel $Z$:
|
||||
|
||||
$$ Z=(z_0, z_1, \cdots, z_n), z_h = \left\{
|
||||
\begin{array}{l}
|
||||
1: (h,j) \in G \\
|
||||
0: (h,j) \notin G
|
||||
\end{array}\right.$$
|
||||
|
||||
Wir definieren nun die Einträge der Matrix $X$, in denen jeweils alle korrekten Möglichkeiten aufsummiert werden:
|
||||
|
||||
$$\sum_{h=1}^{n}{A^k[i,h] \cdot z_h} $$
|
||||
|
||||
Nun entspricht ein Eintrag der Adjazenzmatrix $A$ an der Stelle $A[h,j]$ laut ihrer Definition genau dem Eintrag $z_h$ in dem $j$ zugehörigen Tupel $Z$.
|
||||
Wir können also genauso schreiben:
|
||||
|
||||
$$ \sum_{h=1}^{n}{A^k[i,h] \cdot A[h,j]}$$
|
||||
|
||||
Dies ist nach der Definition der Matrixmultiplikation äquivalent mit:
|
||||
|
||||
$$ X = A^k \cdot A = A^{k+1} $$
|
||||
|
||||
Es wurde also gezeigt, dass $X = A^{k+1}$ gilt, und somit jede Matrix, die unsere Forderungen erfüllt, $A^{k+1}$ sein muss.
|
||||
Demnach gilt $B(k) \Rightarrow B(k+1)$.
|
||||
|
||||
Damit ist die Induktion abgeschlossen und die Behauptung bewiesen.$\square$
|
||||
\subsection{} %b
|
||||
\subsection{} %c
|
||||
\section{} %4
|
||||
\subsection{} %a
|
||||
Wäre die Last in $W$ aboslut gleich verteilt, hätte natürlich jede Kante die gleiche Last.
|
||||
$ \sum_{p \in W} l(p) $ ist die Summe aller Pfadlängen, also die Anzahl aller verwendeten Kanten.
|
||||
Diese Anzahl wird in einem optimierten Pfadsystem gleichmäßig verteilt, also ergibt sich
|
||||
$ \frac{1}{|E|} \sum_{p \in W} l(p) $ als untere Grenze von $ c(W) $.
|
||||
|
||||
Ist $ W $ jedoch nicht optimal, ist $ c(W) $ natürlich größer. Somit gilt
|
||||
$ c(W) \ge \frac{1}{|E|} \sum_{p \in W} l(p) $.
|
||||
\newpage
|
||||
\subsection{} %b
|
||||
$ c(W) $ ist die größte Kantenlast unter Berücksichtigung aller Kanten in allen Pfaden in $N$. $ c(W^*) $ ist die größte Kantenlast
|
||||
unter Berücksichtigung aller Kanten in allen kürzesten Pfaden in $N$. Dies bedeutet, dass $ c(W) $ die absolute Maximalkantenlast ist,
|
||||
während $ c(W) $ nicht unbedingt alle Kanten berücksichtigt, deswegen auch nicht unbedingt gleich $ c(W) $ ist.
|
||||
|
||||
\end{document}
|
||||
152
ad/AD-Gruppe_8_Koehler_Krabbe_Martens_Blatt7.tex
Normal file
152
ad/AD-Gruppe_8_Koehler_Krabbe_Martens_Blatt7.tex
Normal file
@ -0,0 +1,152 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{bytefield}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{textcomp}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usepackage{algpseudocode}
|
||||
\usepackage{algorithm}
|
||||
%\usepackage{algorithmic}
|
||||
%\usepackage{minted}
|
||||
\usetikzlibrary{automata,matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{(\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
|
||||
\begin{document}
|
||||
\author{Reinhard Köhler (6425686), Tronje Krabbe (6435002), \\
|
||||
Jim Martens (6420323)}
|
||||
\title{Hausaufgaben zum 22. Januar}
|
||||
\subtitle{Gruppe 8}
|
||||
\maketitle
|
||||
|
||||
\section{} %1
|
||||
\subsection{} %a
|
||||
\[
|
||||
(F, H), (E, G), (D, F), (C, E), (E, F), (I, J), (C, B), (B, A), (G, I)
|
||||
\]
|
||||
\subsection{} %b
|
||||
\begin{tikzpicture}
|
||||
\node (A) {$A^{1}$};
|
||||
\node (B) [below=of A] {$B^{0}$};
|
||||
\node (C) [above right=of A] {$C^{3}$};
|
||||
\node (D) [below=of C] {$D^{0}$};
|
||||
\node (E) [right=of D] {$E^{1}$};
|
||||
\node (F) [below=of E] {$F^{0}$};
|
||||
\node (G) [right=of E] {$G^{2}$};
|
||||
\node (H) [below=of G] {$H^{0}$};
|
||||
\node (I) [right=of H] {$I^{1}$};
|
||||
\node (J) [below=of I] {$J^{0}$};
|
||||
|
||||
\path[->,line width=1pt]
|
||||
(B) edge (A)
|
||||
(D) edge (C)
|
||||
(F) edge (E)
|
||||
(H) edge (G)
|
||||
(J) edge (I)
|
||||
(E) edge (C)
|
||||
(I) edge (G)
|
||||
(A) edge (C)
|
||||
(G) edge (C);
|
||||
\end{tikzpicture}
|
||||
\subsection{} %c
|
||||
\[
|
||||
(A, B), (B, G), (E, G), (C, E), (E, F), (F, H), (D, F), (A, I), (I, J)
|
||||
\]
|
||||
\subsection{} %d
|
||||
Beim Algorithmus von Prim wird zunächst eine for-Schleife über alle Knoten durchlaufen, welche damit die Laufzeit $\mathcal{O}(|V|)$ hat. Hinzu kommt eine while-Schleife über eine Queue mit initial $|V|$ Einträgen. Damit wird die while-Schleife genau $|V|$ mal durchlaufen, da in jedem Durchgang ein Eintrag entfernt wird. Die Operation deletemin hat eine Laufzeit von $\mathcal{O}(\log V)$, womit die Aufrufe von deletemin insgesamt $\mathcal{O}(V \cdot \log V)$ Zeit erfordern.
|
||||
|
||||
Die for each Schleife wird \underline{insgesamt} $2|E|$ mal ausgeführt, was $\mathcal{O}(E)$ entspricht. Die decreasekey-Operation hat eine Laufzeit von $\mathcal{O}(\log V)$, womit sich insgesamt eine Laufzeit von $\mathcal{O}(V + V \cdot \log V + E \cdot \log V) = \mathcal{O}(E \cdot \log V)$ ergibt.
|
||||
|
||||
\section{} %2
|
||||
\begin{algorithmic}[1]
|
||||
\Function{CanBeDivided}{s}
|
||||
\State $l \gets \Call{Length}{s}$
|
||||
\If{\Call{Dict}{s} = 1}
|
||||
\State \Return 1
|
||||
\ElsIf{$l$ = 0}
|
||||
\State \Return 0
|
||||
\Else
|
||||
\State $Q \gets \Call{CreateQueue}$
|
||||
\For{$i = 1 ... l-1$}
|
||||
\If{\Call{Dict}{$s_{1}...s_{i}$} = 1}
|
||||
\State $Q.enqueue(i+1)$
|
||||
\EndIf
|
||||
\EndFor
|
||||
\State $result \gets 0$
|
||||
\While{Q not empty}
|
||||
\State $pos \gets Q.dequeue()$
|
||||
\If{$!result$}
|
||||
\State $result \gets \Call{CanBeDivided}{s_{pos}...s_{l}}$
|
||||
\EndIf
|
||||
\EndWhile
|
||||
\State \Return $result$
|
||||
\EndIf
|
||||
\EndFunction
|
||||
\end{algorithmic}
|
||||
\setcounter{section}{6}
|
||||
\section{} %7
|
||||
\setcounter{subsection}{4}
|
||||
\subsection{} %e
|
||||
\begin{tikzpicture}
|
||||
\node (592) {6};
|
||||
\node (301) [right=of 592] {3};
|
||||
\node (297) [right=of 301] {4};
|
||||
\node (170) [right=of 297] {2};
|
||||
\node (92) [right=of 170] {1};
|
||||
\node (87) [right=of 92] {5};
|
||||
\node (86) [right=of 87] {0};
|
||||
\node (79) [right=of 86] {8};
|
||||
\node (69) [right=of 79] {9};
|
||||
\node (68) [right=of 69] {7};
|
||||
|
||||
\node[state] (137) [above right=1 and 0.3 of 69] {137};
|
||||
\node[state] (165) [above right=1 and 0.3 of 86] {165};
|
||||
\node[state] (179) [above right=1 and 0.3 of 92] {179};
|
||||
\node[state] (302) [above right=of 165] {302};
|
||||
\node[state] (349) [above left=of 179] {349};
|
||||
\node[state] (598) [above right=1 and 0.3 of 301] {598};
|
||||
\node[state] (651) [above right=2 and 3 of 349] {651};
|
||||
\node[state] (1190) [above left=of 598] {1190};
|
||||
\node[state] (1841) [above left=of 651] {1841};
|
||||
|
||||
\path (69) edge (137)
|
||||
(68) edge (137)
|
||||
(86) edge (165)
|
||||
(79) edge (165)
|
||||
(92) edge (179)
|
||||
(87) edge (179)
|
||||
(165) edge (302)
|
||||
(137) edge (302)
|
||||
(170) edge (349)
|
||||
(179) edge (349)
|
||||
(301) edge (598)
|
||||
(297) edge (598)
|
||||
(592) edge (1190)
|
||||
(598) edge (1190)
|
||||
(349) edge (651)
|
||||
(302) edge (651)
|
||||
(1190) edge (1841)
|
||||
(651) edge (1841);
|
||||
\end{tikzpicture}
|
||||
\end{document}
|
||||
611
ad/Zusammenfassung.tex
Normal file
611
ad/Zusammenfassung.tex
Normal file
@ -0,0 +1,611 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{bytefield}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{textcomp}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usepackage{algpseudocode}
|
||||
\usepackage{algorithm}
|
||||
\usepackage{mathtools}
|
||||
\usepackage{hyperref}
|
||||
%\usepackage{algorithmic}
|
||||
%\usepackage{minted}
|
||||
\usetikzlibrary{automata,matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
%\def\thesection{\arabic{section})}
|
||||
%\def\thesubsection{(\alph{subsection})}
|
||||
%\def\thesubsubsection{(\roman{subsubsection})}
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
|
||||
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
|
||||
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}
|
||||
|
||||
%switch starred and non-starred (auto-size)
|
||||
\makeatletter
|
||||
\let\oldabs\abs
|
||||
\def\abs{\@ifstar{\oldabs}{\oldabs*}}
|
||||
\makeatother
|
||||
|
||||
\hypersetup{
|
||||
colorlinks,
|
||||
citecolor=black,
|
||||
filecolor=black,
|
||||
linkcolor=black,
|
||||
urlcolor=black
|
||||
}
|
||||
|
||||
\begin{document}
|
||||
\author{Jim Martens}
|
||||
\title{Zusammenfassung AD}
|
||||
\maketitle
|
||||
|
||||
\section*{Disclaimer}
|
||||
|
||||
Diese Zusammenfassung setzt ein Belegen der AD-Veranstaltung voraus. Es kann den Besuch der Vorlesungen und Übungen durch das Semester hinweg nicht ersetzen und erhebt auch keinen Anspruch auf Vollständigkeit. Diese Zusammenfassung bezieht sich auf den Stoff der AD-Veranstaltung im Wintersemester 2013/2014 von Frau Luxburg.
|
||||
|
||||
\tableofcontents
|
||||
|
||||
\clearpage
|
||||
|
||||
\section{Landau--Notation}
|
||||
|
||||
Es gibt fünf verschiedene Abschätzungen für die asymptotische Laufzeit eines Algorithmus.
|
||||
|
||||
\[
|
||||
\mathcal{O}, o, \omega, \theta, \Omega
|
||||
\]
|
||||
|
||||
$\mathcal{O}$ gibt die obere Schranke der Laufzeit an. Ein Algorithmus, der in $\mathcal{O}(n)$ liegt, hat demnach eine asymptotische Laufzeit von höchstens $n$. $\mathcal{O}$ wird am häufigsten benutzt, weswegen die gesamte Notation häufig auch O-Notation genannt wird.
|
||||
|
||||
$o$ verhält sich ähnlich, weist aber einen kleinen Unterschied auf. Ein Algorithmus in $o(n)$ wächst asymptotisch echt langsamer als $n$.
|
||||
|
||||
$\theta$ gibt eine genaue Laufzeit an. Ein Algorithmus in $\theta(n)$ wächst asymptotisch genauso schnell wie $n$.
|
||||
|
||||
$\omega$ ist das Gegenstück zu $o$ für die untere Schranke. Ein Algorithmus in $\omega(n)$ wächst echt schneller als $n$.
|
||||
|
||||
$\Omega$ schließlich ist das Gegenstück zu $\mathcal{O}$ für die untere Schranke. Ein Algorithmus in $\Omega(n)$ wächst mindestens so schnell wie $n$.
|
||||
|
||||
Bei der Landau--Notation fallen Konstanten und niedrigere Potenzen weg. Ein Algorithmus mit der konkreten Laufzeit von $45n^{2} + 100n$ liegt demnach in $\mathcal{O}(n^{2})$.
|
||||
|
||||
Geht es um den Vergleich zweier Algorithmen und ist die Laufzeit nicht eindeutig feststellbar, dann hilft es den Limes zu bilden. Dabei gelten folgende Regeln.
|
||||
|
||||
\begin{alignat*}{2}
|
||||
f \in \mathcal{O}(g):& \limsup_{n \rightarrow \infty} \abs{\frac{f(n)}{g(n)}} &<& \infty \\
|
||||
f \in o(g):& \lim_{n \rightarrow \infty} \abs{\frac{f(n)}{g(n)}} &=& 0 \\
|
||||
f \in \Omega(g) :& \liminf_{n \rightarrow \infty} \abs{\frac{f(n)}{g(n)}} &>& 0 \\
|
||||
f \in \omega(g) :& \liminf_{n \rightarrow \infty} \abs{\frac{f(n)}{g(n)}} &=& \infty \\
|
||||
f \in \theta(g) :& 0 < \liminf_{n \rightarrow \infty} \abs{\frac{f(n)}{g(n)}} \leq \limsup_{n \rightarrow \infty} \abs{\frac{f(n)}{g(n)}} &<& \infty
|
||||
\end{alignat*}
|
||||
|
||||
\section{Mastertheorem}
|
||||
|
||||
Das Mastertheorem gehört ebenso wie die Landau--Notation zur Komplexitätstheorie und wird benutzt, um Algorithmen in Komplexität einzuteilen. Es ist jedoch wichtig zu beachten, dass es nur auf ganz bestimmte Algorithmen anwendbar ist. So kann es nur für divide-and-conquer Algorithmen benutzt werden, bei denen sich die Größe der Subprobleme in jedem Rekursionsschritt um einen festen Faktor verkleinert.
|
||||
|
||||
Das Mastertheorem behandelt Rekurrenzgleichungen dieser Form:
|
||||
|
||||
\[
|
||||
T(n) = a \cdot T\left(\ceil*{\frac{n}{b}} \right) + \mathcal{O}(n^{d})
|
||||
\]
|
||||
|
||||
In dieser Formel steht $a$ für die Anzahl der Subprobleme pro Rekursionsschritt, $b$ für den Faktor, um den sich die Subprobleme pro Schritt verkleinern, $\mathcal{O}(n^{d})$ für die Kosten des Algorithmus, die nicht in der Rekursion liegen und $n$ für die Größe des Gesamtproblems. Dabei gelten diese formalen Bedingungen für die Variablen:
|
||||
|
||||
\[
|
||||
a \geq 1, b > 1
|
||||
\]
|
||||
|
||||
Hat man solch eine Rekurrenzgleichung gefunden, so kann man daraus die Komplexität berechnen.
|
||||
|
||||
\[
|
||||
T(n) = \begin{cases}
|
||||
\mathcal{O}(n^{d}) &, \text{wenn}\, d > \log_{b}(a) \\
|
||||
\mathcal{O}(n^{d} \cdot \log(n)) &, \text{wenn}\, d = \log_{b}(a) \\
|
||||
\mathcal{O}(n^{\log_{b}(a)}) &, \text{wenn}\, d < \log_{b}(a)
|
||||
\end{cases}
|
||||
\]
|
||||
|
||||
Die Komplexität der rekursiven Berechnung der Fibonacci-Zahlen beispielsweise lässt sich nicht mit dem Mastertheorem berechnen, da sich die Größe der Subprobleme pro Rekursionsschritt nicht um einen festen Faktor verkleinern.
|
||||
|
||||
\section{Datenstrukturen}
|
||||
|
||||
\subsection{Listen}
|
||||
|
||||
Es gibt zwei unterschiedliche Arten von Listen. Zum Einen gibt es Single-Linked-Lists, die nur in eine Richtung verbunden sind. Will man das letzte Element der Liste finden, muss man demnach vom Kopfelement die gesamte Liste durchgehen, um das letzte Element zu finden. Zum Anderen gibt es die Double-Linked-Lists, die in beide Richtungen verbunden sind. Dort kann man sich in beide Richtungen bewegen und spart damit Suchzeit, wenn man ein Element am Ende der Liste sucht.
|
||||
|
||||
Neben diesen zwei grundsätzlichen Arten von Listen gibt es noch unterschiedliche Ausführungsvarianten. In der Praxis trifft man meistens auf Listen, die ein dediziertes Kopf- und Schlusselement haben, welches keinen eigentlichen Wert enthält. Diese "`Wächterknoten"' verhindern eine Reihe von Problemen (siehe SE 1). Desweiteren gibt es noch für Double-Linked-Lists die Variante mit einem und nicht zwei solcher Wächterknoten. Dabei zeigt das letzte Element der Liste wieder auf den Wächterknoten, wodurch ein Ring entsteht.
|
||||
|
||||
\subsection{Bäume}
|
||||
|
||||
Bäume sind eine besondere Art von Graphen, die keine Zyklen enthalten und ungerichtet sind. Bäume haben einen Wurzelknoten und ein oder mehrere Blätter (Knoten ohne Kindknoten). Jeder Knoten hat entweder Kindknoten oder ist ein Blatt. Bei einem Baum mit einem einzigen Knoten ist dieser sowohl Wurzel als auch Blatt.
|
||||
|
||||
Es gibt für t-näre Bäume eine Sprachregelung, die festlegt wie ein solcher Baum heißt. Bei einem vollen (engl.: full) Baum hat jeder Knoten bis auf die Blätter t Kindknoten. Auf der untersten Ebene finden sich also $t^{h}$ Knoten, wobei $h$ die Höhe des Baumes bezeichnet. Die Wurzelebene ist mit Höhe $0$ versehen. Ein vollständiger Baum (engl.: complete) ist bis auf die unterste Ebene wie ein voller Baum. Auf der untersten Ebene befinden sich $1$ bis $t^{h}$ Blätter, die von links nach rechts angeordnet sind.
|
||||
|
||||
Die Gesamtanzahl an Knoten entspricht bei einem vollen Baum $t^{h+1}-1$ und bei einem vollständigen Baum $t^{h} - 1 + c : 1 \leq c \leq t^{h}$. Die Höhe des Baumes wiederum lässt sich aus der gesamten Anzahl der Knoten berechnen. Bei einem vollen Baum entspricht die Höhe des Baumes, wenn $n$ die Anzahl der Knoten symbolisiert, $\log_{t}(n+1) - 1$. Für einen vollständigen Baum entspricht es $\ceil*{\log_{t}(n+1)-1}$.
|
||||
|
||||
\subsection{Stack}
|
||||
|
||||
Ein Stack ist nach dem LIFO--Prinzip organisiert und unterstützt zwei Operationen, die je nach Literatur anders heißen. Die erste Operation erlaubt das Einfügen eines Elementes in den Stack (\texttt{Insert(e)} bzw. \texttt{Push(e)}) und die zweite Operation erlaubt das Entnehmen des zuletzt eingefügten Elementes (\texttt{Delete()} bzw. \texttt{Pop()}).
|
||||
|
||||
Ein Stack könnte sinnvoll mit einem Array implementiert werden.
|
||||
|
||||
\subsection{Queue}
|
||||
|
||||
Eine Queue arbeitet nach dem FIFO--Prinzip und unterstützt ebenso zwei Operationen. Die erste fügt ein Element in die Queue ein (\texttt{Insert(e)} bzw. \texttt{Enqueue(e)}) und die zweite Operation entfernt das vorderste Element in der Queue (\texttt{Delete()} bzw. \texttt{Dequeue()}).
|
||||
|
||||
Queues können sinnvoll als Double--Linked--Lists implementiert werden. Alternativ könnte man ein Array nehmen, bei dem man sich immer merkt welche Position gerade vorne und welche hinten ist.
|
||||
|
||||
Es gibt Abwandlungen der Queue, die das FIFO--Prinzip verletzen. Dies sind sogenannte Priority Queues, die das vorderste Element nach einer Sortierung bestimmen. Beispielsweise sorgt eine Min-Priority-Queue dafür, dass immer das Element mit dem geringsten Wert ganz vorne steht.
|
||||
|
||||
\subsection{Heap}
|
||||
|
||||
Ein Heap ist ein besonderer Baum, der nach bestimmten Kriterien sortiert ist. Bei einem Max--Heap befindet sich an der Wurzel der Knoten mit dem höchsten Wert und alle Kindknoten haben kleinere Werte. Dies gilt aber nicht nur für die Wurzel, sondern die Kindknoten jedes Knotens haben kleinere Werte als der Knoten, von dem sie Kinder sind.
|
||||
|
||||
Für einen Heap sind fünf Operationen definiert. Die Operation \texttt{Heapify} geht vom gewählten Knoten zu den Blättern und tauscht den Knoten so lange herunter, bis die Heapeigenschaft für den gesamten Heap unter dem Knoten wieder gilt. Die Operation erfordert gültige Heaps unter dem Knoten. Das bedeutet, dass die Subbäume für sich (mit den Kindern des Knotens als Wurzelknoten) gültige Heaps sind. Die worst case Laufzeit ist $\mathcal{O}(\log n)$.
|
||||
|
||||
Die zweite Operation \texttt{BuildMaxHeap} geht von den Blättern zum Wurzelknoten und stellt die Heapeigenschaft her. Dabei wird \texttt{Heapify} auf jeden Knoten ausgeführt. In jeder Ebene wird von rechts nach links vorgegangen, angefangen bei dem am weitesten unten rechts stehenden Knoten. Effektiv passiert auf Blattebene jedoch nichts, da diese keine Kindknoten haben, mit denen sie vertauscht werden könnten. Die Laufzeit beträgt $\mathcal{O}(n)$.
|
||||
|
||||
Die dritte Operation ist \texttt{ExtractMax}. Die Operation entfernt den Wurzelknoten und zieht den am weitesten rechts unten stehenden Knoten zur Wurzelposition und wendet \texttt{Heapify} auf diesen Knoten an. Die Laufzeit beträgt $\mathcal{O}(\log n)$.
|
||||
|
||||
Die vierte Operation heißt \texttt{DecreaseKey} und setzt den betreffenden Knoten auf den gewählten geringeren Wert und wendet \texttt{Heapify} auf diesen Knoten an. Die Laufzeit beträgt $\mathcal{O}(\log n)$.
|
||||
|
||||
Das Gegenstück dazu ist \texttt{IncreaseKey}, welches nach dem Verändern des Wertes die Operation \texttt{BuildMaxHeap} ausführt. Die Laufzeit beträgt $\mathcal{O}(\log n)$.
|
||||
|
||||
\section{Hashing}
|
||||
|
||||
Hashing hat das Ziel eine große Menge an Werten auf eine kleinere Menge abzubilden. Eine der einfachsten Hashfunktionen ist die modulo-Funktion für ganze Zahlen.
|
||||
|
||||
Die Zielmenge wird durch ein Array repräsentiert, wobei die Indizes für die Werte stehen, auf die abgebildet wird. Wenn auf eine kleinere Menge abgebildet wird, sind Kollisionen natürlich unvermeidlich. Dies wird dadurch gehandhabt, dass jedes Arrayelement eine Liste ist, in die alle Werte eingetragen werden, die auf den zugehörigen Index gehasht werden.
|
||||
|
||||
Das Ziel ist natürlich die Anzahl an Kollisionen pro Index möglichst klein zu halten und möglichst gleichmäßig zu hashen. Aus diesen Anforderungen ergibt sich, dass es bessere und schlechtere Hashfunktionen gibt. Allerdings gibt es keine perfekte Hashfunktion, sondern je nach Anwendungsgebiet kommen andere Funktionen in Betracht.
|
||||
|
||||
Eine mögliche Strategie der Kollisionsvermeidung ist das Weiterlaufen bis zum nächsten freien Index. Kommt man am Ende des Arrays an, wird wieder von vorne begonnen.
|
||||
|
||||
\section{Sortierverfahren}
|
||||
|
||||
\subsection{Selection Sort}
|
||||
|
||||
Selection Sort kann man sich gut mit Karten veranschaulichen. Man hat eine Menge an Karten offen vor sich liegen und nimmt nacheinander die Karten in die Hand, beginnend mit der niedrigsten Karte, und reiht sie dort von links nach rechts auf. Die Laufzeit beträgt im worst case $\mathcal{O}(n^{2})$.
|
||||
|
||||
\subsection{Insertion Sort}
|
||||
|
||||
Insertion Sort wendet man zum Beispiel bei Skat meist intuitiv an. Man hat eine Menge an verdeckten Karten, zieht nacheinander die jeweils höchste Karte und reiht sie entsprechend in die Hand ein, wobei die niedrigste Karte links und die höchstwertige Karte rechts ist. Die worst case Laufzeit beträgt hier ebenfalls $\mathcal{O}(n^{2})$.
|
||||
|
||||
\subsection{Bubble Sort}
|
||||
|
||||
Bubble Sort ist trotz gleicher worst case Laufzeit deutlich arbeitsaufwendiger für Menschen. Denn bereits bei 4 Werten ergeben sich 16 Durchgänge, um die Werte korrekt zu sortieren.
|
||||
|
||||
Die beste Erklärung des Sortierverfahrens bietet der Pseudocode.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{Bubblesort}{A}
|
||||
\For{i $\gets$ 1 to A.length - 1}
|
||||
\For{j $\gets$ A.length downto i + 1}
|
||||
\If{A[j] < A[j - 1]}
|
||||
\State exchange A[j] with A[j - 1]
|
||||
\EndIf
|
||||
\EndFor
|
||||
\EndFor
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
|
||||
\subsection{Merge Sort}
|
||||
|
||||
Merge Sort ist mit einer worst case Laufzeit von $\mathcal{O}(n \cdot \log n)$ eines der besten vergleichsbasierten Sortierverfahren. Man nehme eine Reihe von Werten und sehe sie als einzelne Elemente an. Nun verbindet man immer zwei Elemente miteinander und bringt sie gleich in die richtige Reihenfolge. Dabei geht man rigoros von links nach rechts. Man verbindet demnach das erste und zweite Element, das dritte und vierte Element usw. Ist man damit fertig, verbindet man jeweils zwei dieser Zweierpärchen und sortiert alle enthaltenen Elemente in die richtige Reihenfolge. Auch dies wiederholt man für alle Pärchen. Diesen Vorgang wiederholt man nun solange bis am Ende nur noch eine korrekt sortierte Liste herauskommt.
|
||||
|
||||
Merge Sort kann man auch als Divide--and--conquer Verfahren bezeichnen. Es ergibt sich die folgende Rekurrenzgleichung.
|
||||
|
||||
\[
|
||||
T(n) = 2 \cdot T\left(\frac{n}{2}\right) + \mathcal{O}(n)
|
||||
\]
|
||||
|
||||
\subsection{Heap Sort}
|
||||
|
||||
Heap Sort macht sich die Heapeigenschaft zunutze und speichert alle Elemente in einem Heap. Somit lässt sich der höchste Wert (Max--Heap) einfach auslesen.
|
||||
|
||||
Der Pseudocode liest sich folgendermaßen:
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Function{HeapSort}{A}
|
||||
\State n $\gets$ \Call{length}{A}
|
||||
\State B $\gets$ empty array of length n
|
||||
\State H $\gets$ \Call{BuildMaxHeap}{A}
|
||||
\For{i $\gets$ 1 to n}
|
||||
\State B(n - i) $\gets$ \Call{ExtractMax}{H}
|
||||
\EndFor
|
||||
\State \Return B
|
||||
\EndFunction
|
||||
\end{algorithmic}
|
||||
|
||||
Das Verfahren hat eine Laufzeit von $\mathcal{O}(n \cdot \log n)$, die sowohl die sowohl worst case als auch best case Laufzeit ist.
|
||||
|
||||
\subsection{Quick Sort}
|
||||
|
||||
Quick Sort funktioniert ähnlich wie Merge Sort, nur dass es mit einer kompletten Liste anfängt und dann immer weiter aufteilt und am Ende nur noch zusammenfügen muss. Dies funktioniert durch die Wahl eines Pivotelementes. Im Idealfall teilt es die Liste in zwei gleichgroße Teillisten. Die worst case Laufzeit beträgt $\mathcal{O}(n^{2})$. In den meisten Fällen benötigt Quick Sort jedoch nur $\mathcal{O}(n \cdot \log n)$.
|
||||
|
||||
Trotz der vermeintlich schlechten Laufzeit wird Quick Sort in der Praxis viel eingesetzt, da es in der Praxis auch auf die Konstanten ankommt, die in der Landau--Notation weggelassen werden. Quick Sort hat vergleichsweise kleine Konstanten wohingegen andere Verfahren mit einer besseren worst case Laufzeit meist größere Konstanten haben.
|
||||
|
||||
\subsection{Counting Sort}
|
||||
|
||||
Counting Sort ist ein Sortierverfahren, welches nicht vergleichsbasiert ist. Es gibt zwei prominente Implementationsmöglichkeiten. Die erste Möglichkeit ist ein Array mit Countern. Die zweite Möglichkeit ist ein Array mit Listen. Im Folgenden bezeichne K den höchsten Wert in der zu sortierenden Liste (nicht unbedingt die Datenstruktur in der diese Liste an Werten gespeichert ist).
|
||||
|
||||
Zunächst der Pseudocode für die erste Variante.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Function{CountingSort}{A}
|
||||
\State n $\gets$ \Call{length}{A}
|
||||
\State Allocate array B with length K, initialize each cell with 0
|
||||
\For{i $\gets$ 1 to n}
|
||||
\State B[A[i]] $\gets$ B[A[i]] + 1
|
||||
\EndFor
|
||||
\State C $\gets$ empty list
|
||||
\For{key, count in B}
|
||||
\While{count > 0}
|
||||
\State C.append(key)
|
||||
\State count $\gets$ count - 1
|
||||
\EndWhile
|
||||
\EndFor
|
||||
\State \Return C
|
||||
\EndFunction
|
||||
\end{algorithmic}
|
||||
|
||||
Die zweite For-Schleife ist nur zum Erstellen der sortierten Liste. Die Laufzeit beträgt K für das Initialisieren des Arrays B, n für die erste For-Schleife, K für die zweite For-Schleife und maximal n für die While-Schleife. Dabei ist jedoch zu berücksichtigen, dass die While-Schleife insgesamt über alle Iterationen der For-Schleife nur n--mal aufgerufen wird, denn die Summe aller Counts entspricht der Länge der zu sortierenden Liste an Zahlen. Die Gesamtlaufzeit ist demnach $\mathcal{O}(K + n + n)$ bzw. $\mathcal{O}(K + 2n)$. Die Laufzeit K der zweiten For-Schleife ist hier nicht berücksichtigt, da die While-Schleife insgesamt nur n--mal aufgerufen wird und in den übrigen Fällen in der For-Schleife nichts ausgeführt wird. Nach den Regeln der Landau--Notation entfällt hier das zweite n bzw. die Konstante, da es nichts an der asymptotischen Laufzeit verändert. Die Gesamtlaufzeit ist damit $\mathcal{O}(K + n)$.
|
||||
|
||||
Die zweite Variante mit Listen im Array wird etwas anders implementiert, hat aber die gleiche Laufzeit.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Function{CountingSort}{A}
|
||||
\State n $\gets$ \Call{length}{A}
|
||||
\State Allocate array B with length K, initialize each cell with an empty list
|
||||
\For{i $\gets$ 1 to n}
|
||||
\State B[A[i]].append(A[i])
|
||||
\EndFor
|
||||
\State \Return concatenation of B[1], B[2], ..., B[K]
|
||||
\EndFunction
|
||||
\end{algorithmic}
|
||||
|
||||
Die Laufzeit beträgt hier K für das Initialisieren von B und n für die For-Schleife. Insgesamt ergibt sich somit $\mathcal{O}(n + K)$.
|
||||
|
||||
\subsection{Radix Sort}
|
||||
|
||||
Radix Sort ist im Prinzip Counting Sort mit ein paar Veränderungen. Die obere Grenze der Zahlen kann riesig sein ($K = \omega(n)$). Um dem beizukommen stellt man sich jede Zahl als ein String vor. Zunächst werden die Zahlen nach der letzten Ziffer sortiert, dann nach der zweitletzten und so weiter. Dieses Verfahren setzt Counting Sort in der zweiten Variante voraus.
|
||||
|
||||
Da stets nur nach Ziffern sortiert wird, kann man die Arraylänge auf 10 begrenzen, denn es gibt nur 10 Ziffern. Demzufolge braucht man auch bei einem K von einer Million nur ein Array von 10, um alle Zahlen nach der letzten Ziffer dort einzusortieren in Listen.
|
||||
|
||||
Als Beispiel nehme man die Zahlen 10, 3, 5, 15, 20, 7 , 11 und 13. Diese werden in der Reihenfolge ihres Erscheinens sortiert und ergeben folgendes Bild im Array B.
|
||||
|
||||
\begin{alignat*}{1}
|
||||
B[0]:& 10 \rightarrow 20 \\
|
||||
B[1]:& 11 \\
|
||||
B[2]:& \\
|
||||
B[3]:& 3 \rightarrow 13 \\
|
||||
B[4]:& \\
|
||||
B[5]:& 5 \rightarrow 15 \\
|
||||
B[6]:& \\
|
||||
B[7]:& 7 \\
|
||||
B[8]:& \\
|
||||
B[9]:&
|
||||
\end{alignat*}
|
||||
|
||||
Im zweiten Schritt wird nun das Array und in jeder Zelle die Liste von vorne bis hinten durchgegangen und die jeweils aktuelle Zahl wird dann nach der zweitletzten Ziffer in ein Array C einsortiert. Zahlen mit weniger Ziffern (in diesem Fall die einstelligen Zahlen) werden bei der 0 einsortiert. Am Ende ergibt sich die richtige Reihenfolge und es müssen nur noch alle Zahlen konkateniert werden, um das Ergebnis zu erhalten.
|
||||
|
||||
Allerdings kann Radix Sort auch auf andere Zahlensysteme angewendet werden. Dann ist die Menge an möglichen Ziffern nicht gleich 10. Daher wird die Anzahl an möglichen Ziffern mit k bezeichnet und die Laufzeit zum Sortieren nach einer Ziffernposition ist dementsprechend $\theta(n + k)$. Counting Sort muss n--mal ausgeführt werden und das Array mit den Listen muss k lang sein und initialisiert werden. Dies ist jedoch nur ein Durchgang. Für die insgesamte Laufzeit von Radix Sort wird eine weitere Variable namens d benötigt, die die maximal mögliche Anzahl an Ziffern in einer Zahl bezeichnet (nicht zu verwechseln mit der Menge der möglichen Ziffern). Die Laufzeit beträgt sodann auch $\theta(d(n + k))$.
|
||||
|
||||
In unserem Beispiel oben ist k konstant und d ebenso. Demnach fallen beide Weg und es bleibt $\mathcal{O}(n)$ übrig. Wenn k konstant bleibt, aber d in logarithmische Abhängigkeit zu n gestellt wird, dann ergibt sich eine Laufzeit von $\mathcal{O}(n \cdot \log n)$. Ist d sogar gleich n, dann benötigt Radix Sort $\mathcal{O}(n^{2})$.
|
||||
|
||||
Warum wird Radix Sort dann überhaupt benutzt? Mithilfe von einigen Modifikationen kann man eine lineare Laufzeit erreichen und zwar als worst case. Dies ist möglich mit dem Block-based Radix Sort. Allerdings muss man vorher wissen in welchen Bereich die zu sortierenden Zahlen fallen. Genaueres siehe AD-Folienskript.
|
||||
|
||||
\subsection{Bucket Sort}
|
||||
|
||||
Bucket Sort wird zur Sortierung von reellen Zahlen verwendet, die gleichmäßig im Intervall [0,1] vorkommen. Angenommen man bekommt ein Eingabearray der Länge n, dann kann man das Intervall in n Buckets gleicher Länge zerteilen, wobei Bucket i alle Schlüsselwerte des Intervalls $\left[\frac{i}{n}, \frac{(i + 1)}{n}\right[$ enthält.
|
||||
|
||||
Die durchschnittliche Laufzeit beträgt $\mathcal{O}(n)$ und die worst case Laufzeit beträgt $\mathcal{O}(n \cdot \log n)$.
|
||||
|
||||
\subsection{Stabilität von Sortierverfahren}
|
||||
|
||||
Die Angabe "`wie in AD"' bedeutet, dass die in AD verwendete Variante gemeint ist und es andere Varianten gibt, bei denen das Gegenteilige gilt.
|
||||
|
||||
\begin{tabular}{c|c}
|
||||
Verfahren & stabil \\
|
||||
\hline
|
||||
Merge Sort & ja \\
|
||||
Quick Sort & ja, wie in AD \\
|
||||
Insertion Sort & nein, wie in AD \\
|
||||
Selection Sort & nein, wie in AD \\
|
||||
Heap Sort & nein \\
|
||||
Bubble Sort & ja \\
|
||||
Counting Sort & ja, in der zweiten Variante
|
||||
\end{tabular}
|
||||
|
||||
\subsection{Lower bound}
|
||||
|
||||
Für alle vergleichsbasierten Sortierverfahren gilt, dass sie eine worst case Laufzeit von $\Omega(n \cdot \log n)$ haben.
|
||||
|
||||
\section{Binäre Suchbäume}
|
||||
|
||||
Binäre Suchbäume haben eine besondere Struktur, die das Suchen erleichtert. Alle linken Kindknoten sind kleiner oder gleich des Elternknoten und alle rechten Kindknoten sind größer oder gleich des Elternknoten. Diese Bedingung gilt für alle Knoten mit Kindern.
|
||||
|
||||
Aufgrund dessen ist das Einfügen in solch einen Baum relativ deterministisch. Das Löschen gestaltet sich da schon etwas komplizierter.
|
||||
|
||||
Zunächst werden jedoch die Operationen der Reihe nach durchgegangen. Die erste Operation ist \texttt{Tree-Search} mit folgendem Pseudocode.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Function{Tree-Search}{x, k}
|
||||
\If{x == NIL or k == x.key}
|
||||
\State \Return x
|
||||
\EndIf
|
||||
\If {k < x.key}
|
||||
\State \Return \Call{Tree-Search}{x.left, k}
|
||||
\Else
|
||||
\State \Return \Call{Tree-Search}{x.right, k}
|
||||
\EndIf
|
||||
\EndFunction
|
||||
\end{algorithmic}
|
||||
|
||||
Die Laufzeit beträgt $\mathcal{O}(h)$, wobei h die Höhe des Baumes angibt.
|
||||
|
||||
Das Minimum des Baumes kann gefunden werden, indem immer das linke Kind genommen wird bis ein Blatt erreicht wird. Dieses Blatt ist das minimale Element des Baumes. Die Laufzeit beträgt ebenso $\mathcal{O}(h)$. Das Maximum findet man analog, nur dass man dort immer das rechte Kind benutzt.
|
||||
|
||||
Die zweite Operation ist \texttt{Inorder-Tree-Walk} mit diesem Pseudocode.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{Inorder-Tree-Walk}{x}
|
||||
\If{x $\neq$ NIL}
|
||||
\State \Call{Inorder-Tree-Walk}{x.left}
|
||||
\State \Call{print}{x.key}
|
||||
\State \Call{Inorder-Tree-Walk}{x.right}
|
||||
\EndIf
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
|
||||
Sie hat eine Laufzeit von $\theta(n)$.
|
||||
|
||||
Nun kommen wir zum Einfügen von Elementen. Für das Einfügen wird der Baum einfach heruntergegangen und das neue Element an der richtigen Stelle eingefügt. Die Laufzeit beträgt hier ebenso $\mathcal{O}(h)$.
|
||||
|
||||
Für das Entfernen eines Blattes ist es vergleichsweise einfach. Das Blatt kann einfach entfernt werden. Wenn ein Knoten nur einen linken oder nur einen rechten Kindknoten hat, dann können diese einfach an die Position des zu löschenden Knoten rücken. Hat der zu löschende Knoten jedoch sowohl einen linken als auch einen rechten Kindknoten, dann muss dessen Nachfolger gefunden werden. Dafür wird der am weitesten links stehende Knoten im rechten Teilbaum (mit dem rechten Kind des zu löschenden Knoten als Wurzel) herangezogen. Dieser wird dann an die Stelle des zu löschenden Knoten gesetzt und dessen rechtes Kind (falls vorhanden) wird an die Stelle von dem Nachfolger gesetzt.
|
||||
|
||||
Den Nachfolger zu finden dauert $\mathcal{O}(h)$. Der Rest passiert in konstanter Zeit, sodass die insgesamte Dauer ebenfalls $\mathcal{O}(h)$ ist. Da alle Operationen nur $\mathcal{O}(h)$ benötigen, wäre es natürlich von Interesse das h so klein wie möglich zu haben. Da kommen balancierte Bäume ins Spiel. Bei balancierten Bäumen unterscheidet sich die Höhe der beiden Teilbäume unter einem Knoten um maximal 1 (Bedingung gilt für alle Knoten).
|
||||
|
||||
\subsection{AVL Bäume}
|
||||
|
||||
AVL Bäume unterstützen Operationen, um die Balanciertheit wiederherzustellen. Allerdings ist dies nicht klausurrelevant, da Frau Luxburg diesen Bereich selber nicht sonderlich versteht.
|
||||
|
||||
Dennoch wird hier eine kurze Information zu den Operationen gegeben. Die Operationen heißen \texttt{RightRotate} und \texttt{LeftRotate} und benötigen jeweils nur konstante Zeit. Wird die Balanciertheit eines Baumes durch eine Einfüge- oder Löschoperation verletzt, dann müssen maximal Balancieroperationen ausgeführt werden, um die Balanciertheit wiederherzustellen.
|
||||
|
||||
Die Laufzeit vom Einfügen in einen solchen balancierten Baum beträgt $\mathcal{O}(\log n)$. Das Standardeinfügen benötigt $\mathcal{O}(\log n)$, das checken der Balanciertheit dauert ebenfalls $\mathcal{O}(\log n)$ und für die Wiederherstellung der Balanciertheit werden maximal zwei Rotationen in je konstanter Zeit ausgeführt.
|
||||
|
||||
\subsection{Red-black tree}
|
||||
|
||||
Ein Red-black tree hat folgende Eigenschaften.
|
||||
|
||||
\begin{itemize}
|
||||
\item jeder Knoten ist gefärbt (schwarz/rot)
|
||||
\item Wurzel und Blätter sind schwarz
|
||||
\item roter Knoten hat zwei schwarze Kinder
|
||||
\item von jedem Knoten aus haben alle Pfade zu den Blättern die gleiche Anzahl schwarze Knoten
|
||||
\item ein schwarzer Knoten kann sowohl schwarze als auch rote Kinder haben
|
||||
\end{itemize}
|
||||
|
||||
\section{Binäre Suche}
|
||||
|
||||
Bei der binären Suche hat man ein sortiertes Array gegeben. Nun schaut man sich immer das mittlere Element an und wenn dies kleiner dem gesuchten Element ist, dann wird die binäre Suche auf den rechten Teilbereich des Arrays angewendet. Ist das mittlere Element größer, so wird die binäre Suche auf den linken Teil angewendet und wenn das mittlere Element dem gesuchten Element entspricht, dann wird die Indexposition zurückgegeben. Wird das gesuchte Element nicht gefunden, dann wird \texttt{not\_found} zurückgegeben.
|
||||
|
||||
Der Pseudocode sieht folgendermaßen aus.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Function{BinarySearch}{A, value}
|
||||
\State low $\gets$ 0
|
||||
\State high $\gets$ N - 1
|
||||
\While{low $\leq$ high}
|
||||
\State mid $\gets$ (low + high) / 2
|
||||
\If{A[mid] > value}
|
||||
\State high $\gets$ mid - 1
|
||||
\ElsIf{A[mid] < value}
|
||||
\State low $\gets$ mid + 1
|
||||
\Else
|
||||
\State \Return mid
|
||||
\EndIf
|
||||
\EndWhile
|
||||
\EndFunction
|
||||
\end{algorithmic}
|
||||
|
||||
Die Laufzeit beträgt $\mathcal{O}(\log n)$.
|
||||
|
||||
Es gibt jedoch auch noch andere Varianten der binären Suche, wie eine rekursive Variante und eine Variante, bei der, wenn das gesuchte Element nicht vorhanden ist, die Position zurückgegeben wird, bei der das gesuchte Element eingefügt werden kann, sodass das Array weiterhin sortiert ist.
|
||||
|
||||
\section{Graphen}
|
||||
|
||||
Bei dem Abschnitt über Bäume wurden Graphen kurz angeschnitten. Hier wird sich jetzt ausführlicher mit ihnen beschäftigt. Es gibt verschiedene Arten von Graphen.
|
||||
|
||||
Graphen können ungerichtet oder gerichtet sein und sie können gewichtet oder ungewichtet sein. Allerdings ist ein ungewichteter Graph äquivalent mit einem gewichteten Graphen, bei dem alle Kanten das Gewicht 1 haben. Ein ungerichteter Graph kann in einen gleichwertigen gerichteten Graphen überführt werden, indem jede Kante durch eine Hin- und Rückkante ersetzt wird.
|
||||
|
||||
Der Grad eines Knotens kann in einem ungerichteten Graphen durch folgende Formel errechnet werden.
|
||||
|
||||
\[
|
||||
Grad(u) = \sum\limits_{v \in V} w(u, v)
|
||||
\]
|
||||
|
||||
Bei einem gerichteten Graphen gibt es zwei Grade bei einem Knoten. Der Eingangsgrad und der Ausgangsgrad. Beide können folgendermaßen berechnet werden.
|
||||
|
||||
\begin{alignat*}{1}
|
||||
Grad-in(u) =& \sum\limits_{v \in V} w(v, u) \\
|
||||
Grad-out(u) =& \sum\limits_{v \in V} w(u, v)
|
||||
\end{alignat*}
|
||||
|
||||
Pfade sind eine beliebige Abfolge von Kanten. Ein Pfad ist ein Zyklus, wenn ein Knoten sowohl Anfangs- als auch Endknoten ist. Ein Pfad ist einfach (engl.: simple), wenn jeder Knoten nur einmal vorkommt.
|
||||
|
||||
Man kann Graphen in zusammenhängende und nicht zusammenhängende Graphen unterteilen. Dabei wird ein Graph als zusammenhängend bezeichnet, wenn von jedem Knoten zu jedem anderen Knoten ein Pfad gefunden werden kann (ungerichteter Graph). Ein gerichteter Graph heißt stark zusammenhängend, wenn von jedem Knoten zu jedem anderen ein gerichteter Pfad gefunden werden kann. Ein gerichteter Graph ist schwach zusammenhängend, wenn der zugehörige ungerichtete Graph zusammenhängend ist.
|
||||
|
||||
Eine Zusammenhangskomponente ist ein Teilgraph des Graphen und ist zusammenhängend. In einem zusammenhängenden Graphen gibt es nur eine Zusammenhangskomponente. In einem gerichteten Graphen sind die starken Zusammenhangskomponenten interessant. Dies sind Teilgraphen des Graphen, die stark zusammenhängend sind. Ein Graph kann schwach zusammenhängend sein und dennoch mehrere starke Zusammenhangskomponenten haben.
|
||||
|
||||
In einem vollständigen Graph ist jeder Knoten mit jedem anderen Knoten durch eine Kante verbunden.
|
||||
|
||||
Die Kanten eines Graphen können mithilfe von Adjazenzlisten oder einer Adjazenzmatrix dargestellt werden.
|
||||
|
||||
Desweiteren kann ein Graph dicht sein (engl.: dense). Dies bedeutet, dass der Graph sehr viele Kanten hat (ungefähr $|V|^{2}$). Außerdem kann ein Graph dünn sein (engl.: sparse). Dies bedeutet, dass der Graph sehr wenige Kanten hat.
|
||||
|
||||
\section{Graphalgorithmen}
|
||||
|
||||
\subsection{Bellman--Ford}
|
||||
|
||||
Der Bellman-Ford Algorithmus hat folgenden Pseudocode, der bereits eindrücklich zeigen sollte, wie der Algorithmus funktioniert.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Function{BellmanFord}{G, s}
|
||||
\State \Call{InitializeSingleSource}{G, s}
|
||||
\For{i $\gets$ 1 to |V| - 1}
|
||||
\ForAll{edges (u, v) $\in$ E}
|
||||
\State \Call{Relax}{u, v}
|
||||
\EndFor
|
||||
\EndFor
|
||||
\ForAll{edges (u, v) $\in$ E}
|
||||
\If{v.dist > u.dist + w(u, v)} \Comment{auf negativen Zyklus prüfen}
|
||||
\State \Return false
|
||||
\EndIf
|
||||
\EndFor
|
||||
\EndFunction
|
||||
\end{algorithmic}
|
||||
|
||||
Die Laufzeit ist wenig verwunderlich: $\mathcal{O}(|V| \cdot |E|)$.
|
||||
|
||||
Der Algorithmus wird benutzt, um kürzeste Wege zu berechnen. Genauer wird er für das Single--Source--Shortest--Path--Problem verwendet.
|
||||
|
||||
\subsection{Dijkstra}
|
||||
|
||||
Dijkstra gibt es in zwei Variationen. Beide verhalten sich gleich, haben aber Unterschiede in der Laufzeit. Die naive Variante hat diesen Pseudocode.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{DijkstraNaive}{G, w, s}
|
||||
\State S $\gets$ {s}
|
||||
\State d(s) $\gets$ 0
|
||||
\While{S $\neq$ V}
|
||||
\State U $\gets$ {u $\not\in$ S | u neighbour of a vertex $\in$ S}
|
||||
\ForAll{u $\in$ U}
|
||||
\ForAll{\Call{pre}{u} $\in$ S that are predecessors of u}
|
||||
\State d'(u, \Call{pre}{u}) $\gets$ d(\Call{pre}{u}) + w(\Call{pre}{u}, u)
|
||||
\EndFor
|
||||
\EndFor
|
||||
\State $u^{*} \gets$ argmin\{d'(u, \Call{pre}{u}) | u $\in$ U, \Call{pre}{u} $\in$ S\}
|
||||
\State d($u^{*}$) $\gets$ d'($u^{*}$)
|
||||
\State S $\gets$ S $\cup$ \{$u^{*}$\}
|
||||
\EndWhile
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
|
||||
Die Laufzeit der naiven Variante beträgt $\mathcal{O}(|V| \cdot |E|)$.
|
||||
|
||||
Die zweite Variante ist die Implementation mit der Min--Priority--Queue. Der Pseudocode dieser Variante folgt.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{Dijkstra}{G, w, s}
|
||||
\State Q $\gets$ (V, V.dist)
|
||||
\While{Q $\neq \empty$}
|
||||
\State u $\gets$ \Call{Extract}{Q}
|
||||
\ForAll{v adjacent to u}
|
||||
\State \Call{Relax}{u, v} and update the keys in Q accordingly
|
||||
\EndFor
|
||||
\EndWhile
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
|
||||
Die Laufzeit mit der Min--Priority--Queue hängt von der Implementation der Queue ab. Bei einem naiven Array beträgt die Laufzeit $\mathcal{O}(n^{2})$. Bei der Implementation mit einem binären Heap sind es nur noch $\mathcal{O}((V + E)\log V)$. Bei der Implementation mit einem t-nären Heap sind es $\mathcal{O}\left((|V| \cdot t + |E|)\frac{\log V}{\log t}\right)$. Die beste Laufzeit kann mit einem Fibonacci Heap erreicht werden: $\mathcal{O}(V \log V + E)$.
|
||||
|
||||
Wenn der Graph dicht ist, dann sollte die Arrayimplementation genommen werden. Wenn der Graph dünn ist, dann sollte die Heapimplementation bevorzugt werden. Wenn der Graph sehr dünn ist (|E| = $\Omega(|V|)$) bekommen wir die Laufzeit $\mathcal{O}(|V| \log |V|)$.
|
||||
|
||||
Auch dieser Algorithmus gehört zum Single--Source--Shortest--Path--Problem.
|
||||
|
||||
\subsection{Floyd--Warshall}
|
||||
|
||||
Floyd--Warshall ist ein Graphalgorithmus, mit dem man die kürzesten Pfade von jedem Knoten zu jedem Knoten herausfinden kann (All--Pairs--Shortest--Path--Problem). Der Pseudocode ist folgender.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Function{FloydWarshall}{}
|
||||
\State n $\gets$ |V|
|
||||
\State $D^{(0)} \gets$ new $n \times n$ matrix with all values being $\infty$
|
||||
\ForAll{v $\in$ V}
|
||||
\State $d_{0}(v,v) \gets$ 0
|
||||
\EndFor
|
||||
\ForAll{(u,v) $\in$ E}
|
||||
\State $d_{0}(u,v) \gets$ w(u,v)
|
||||
\EndFor
|
||||
\For{k $\gets$ 1 to n}
|
||||
\State $D^{k} \gets$ new $n \times n$ matrix
|
||||
\For{s $\gets$ 1 to n}
|
||||
\For{t $\gets$ 1 to n}
|
||||
\State $d_{k}(s, t) \gets$ min\{$d_{k-1}(s, t)$, $d_{k-1}(s, k) + d_{k-1}(k, t)$\}
|
||||
\EndFor
|
||||
\EndFor
|
||||
\EndFor
|
||||
\State \Return $D^{(n)}$
|
||||
\EndFunction
|
||||
\end{algorithmic}
|
||||
|
||||
Die Laufzeit beträgt $\mathcal{O}(|V|^{3})$.
|
||||
|
||||
\subsection{Bidirektionaler Dijkstra}
|
||||
|
||||
Der Bidirektionale Dijkstra besteht aus zwei Dijkstra--Algorithmen, die wechselweise ausgeführt werden. Der erste Dijkstra startet beim Startknoten und der zweite Dijkstra startet beim Zielknoten. Beide Algorithmen sind ganz normale Dijkstra--Algorithmen, die solange laufen bis ein Algorithmus einen Knoten aufnimmt, der bereits von dem anderen Algorithmus aufgenommen wurde.
|
||||
|
||||
Der kürzeste Pfad muss aber nicht über diesen Knoten laufen.
|
||||
|
||||
\subsection{A*--Suche}
|
||||
|
||||
$A^{*}$--Suche ist ein modifizierter Dijkstra--Algorithmus. Für jeden Knoten gibt es einen Wert, der die Entfernung zum Ziel angibt. Diese Entfernung muss nicht immer exakt sein, sodass auch eine untere Grenze wie die Luftlinienentfernung hinreichend ist.
|
||||
|
||||
Diese Entfernung wird bei der Auswahl des nächsten Knotens berücksichtigt. Der Knoten mit dem geringsten Abstand zum Startknoten plus der abgeschätzten Entfernung zum Ziel wird als nächstes ausgewählt.
|
||||
|
||||
\subsection{SCC--Algorithmus}
|
||||
|
||||
Der SCC--Algorithmus wird zum Bestimmen von starken Zusammenhangskomponenten beynutzt. Der Algorithmus kann in Worten wie folgt beschrieben werden.
|
||||
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{SCC}{G}
|
||||
\State Call \Call{DFS}{G} to compute the finishing times \Call{f}{u}
|
||||
\State Compute the reverse graph $G^{t}$
|
||||
\State Call \Call{DFS}{$G^{t}$}, where the vertices in the main loop are considered in order of decreasing \Call{f}{u}
|
||||
\State Output the subsets that have been discovered by the individual calls of DFS--Visit
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
|
||||
Die Laufzeit beträgt insgesamt $\mathcal{O}(|V| + |E|)$.
|
||||
|
||||
\subsection{Kruskals Algorithmus}
|
||||
|
||||
Kruskals Algorithmus geht die Kanten in nicht absteigender Reihenfolge durch und nimmt alle Kanten auf, die keinen Zyklus ergeben.
|
||||
|
||||
\subsection{Prims Algorithmus}
|
||||
|
||||
Prims Algorithmus beginnt bei einem Startknoten, der zu Beginn einziger Bestandteil der Menge $S$ ist. Prim fügt in jedem Schritt eine Kante hinzu, die $S$ mit $V \setminus S$ verbindet und von allen potentiellen Kanten die mit dem geringsten Gewicht ist.
|
||||
|
||||
\section{Dynamisches Programmieren}
|
||||
|
||||
%TODO
|
||||
|
||||
\section{Edit distance}
|
||||
|
||||
%TODO
|
||||
|
||||
\[
|
||||
E(i, j) = min\begin{cases}
|
||||
E(i - 1, j) + 1 \\
|
||||
E(i, j - 1) + 1 \\
|
||||
E(i - 1, j - 1) + \mathrm{1}_{x[i] \neq y[j]}
|
||||
\end{cases}
|
||||
\]
|
||||
\end{document}
|
||||
165
gdb/G62B3_Dittrich-Lindemann-Martens.tex
Normal file
165
gdb/G62B3_Dittrich-Lindemann-Martens.tex
Normal file
@ -0,0 +1,165 @@
|
||||
\documentclass[ngerman]{gdb-aufgabenblatt}
|
||||
\RequirePackage[utf8]{inputenc}
|
||||
\renewcommand{\Aufgabenblatt}{3}
|
||||
\renewcommand{\Ausgabedatum}{Mi. 13.11.2013}
|
||||
\renewcommand{\Abgabedatum}{Do. 28.11.2013}
|
||||
\renewcommand{\Gruppe}{Tim Dittrich, Sebastian Lindemann, Jim Martens}
|
||||
|
||||
% define how the sections are rendered
|
||||
\def\thesection{Aufgabe \arabic{section}:}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
|
||||
\usetikzlibrary{positioning}
|
||||
\usetikzlibrary{shadows}
|
||||
|
||||
\begin{document}
|
||||
\section{Konzeptioneller Entwurf}
|
||||
\begin{tikzpicture}%[node distance=1.31cm, every edge/.style={link}]
|
||||
\node[entity] (biomol) {Biomolekül};
|
||||
\node[attribut] (biomolID) [below left=0.5 and 0 of biomol] {\underline{Molekül-ID}} edge (biomol);
|
||||
\node[attribut] (biomolDesc) [below right=0.5 and 0 of biomol] {Beschreibung} edge (biomol);
|
||||
\node[relationship] (relBiomolOrg) [above=of biomol] {kommt vor} edge node [above left=-0.5 and 0.2] {[1;*]} (biomol);
|
||||
\node[entity] (organism) [above=of relBiomolOrg] {Organismus} edge node [below right=-0.5 and 0.2] {[0;*]} (relBiomolOrg);
|
||||
\node[attribut] (orgID) [left=of organism] {\underline{Taxonomie-ID}} edge (organism);
|
||||
\node[attribut] (orgName) [above left=of organism] {Name} edge (organism);
|
||||
\node[attribut] (orgTrivName) [above=of organism] {Trivialname} edge (organism);
|
||||
\node[relationship] (relBiomolArt) [left=of biomol] {veröffentlicht in} edge node [above right=0 and -0.5] {[1;1]} (biomol);
|
||||
\node[entity] (article) [left=of relBiomolArt] {Artikel} edge node [above left=0 and -0.5] {[0;*]} (relBiomolArt);
|
||||
\node[attribut] (artTitel) [above left=of article] {\underline{Titel}} edge (article);
|
||||
\node[attribut] (artDatum) [left=of article] {Datum} edge (article);
|
||||
\node[relationship] (relArtWiss) [above=of article] {geschrieben von} edge node [above right=-0.5 and 0] {[1;*]} (article);
|
||||
\node[entity] (wissen) [above=of relArtWiss] {Wissenschaftler} edge node [below right=-0.5 and 0] {[0;*]} (relArtWiss);
|
||||
\node[attribut] (wissName) [left=of wissen] {\underline{Name}} edge (wissen);
|
||||
\node[multivalentattribut] (wissKontakt) [above=of wissen] {Kontaktinformationen} edge (wissen);
|
||||
\node[attribut] (wissTel) [above left=of wissKontakt] {Telefonnummer} edge (wissKontakt);
|
||||
\node[attribut] (wissEmail) [above=of wissKontakt] {E-Mailadresse} edge (wissKontakt);
|
||||
\node[erbt] (relDNABiomol) [below=of biomol] {is-a} edge (biomol);
|
||||
\node[entity] (dnamol) [below left=0.5 and 2 of relDNABiomol] {DNA-Molekül} edge (relDNABiomol);
|
||||
\node[attribut] (dnaNuk) [above left=of dnamol] {Nukleotidsequenz} edge (dnamol);
|
||||
\node[attribut] (dnaStrang) [left=of dnamol] {Strang-Orientierung} edge (dnamol);
|
||||
\node[attribut] (dnaChrom) [below left=of dnamol] {Nummer des Chromosoms} edge (dnamol);
|
||||
\node[entity] (mrnamol) [below=of relDNABiomol] {mRNA-Molekül} edge (relDNABiomol);
|
||||
\node[attribut] (mrnaNuk) [above right=of mrnamol] {Nukleotidksequenz} edge (mrnamol);
|
||||
\node[attribut] (mrnaVien) [right=of mrnamol] {Vienna-String} edge (mrnamol);
|
||||
\node[relationship] (relDNAmRNA) [below=3.0 of dnamol] {wird übersetzt} edge node [below left=-1.5 and 0] {[1;1]} (dnamol) edge node [above right=0.4 and -0.2] {[0;*]} (mrnamol);
|
||||
\node[attribut] (relStart) [above left=0.9 and 1 of relDNAmRNA] {Startposition} edge (relDNAmRNA);
|
||||
\node[attribut] (relEnde) [left=of relDNAmRNA] {Endposition} edge (relDNAmRNA);
|
||||
\node[weakrelationship] (relRNAProt) [below=of mrnamol] {wird synthetisiert} edge node [below right=-0.5 and 0] {[1;1]} (mrnamol);
|
||||
\node[weakentity] (prot) [below right=of relRNAProt] {Protein} edge node [above left=-0.5 and 0] {[0;1]} (relRNAProt);
|
||||
\node[attribut] (protAmino) [below left=0.5 and 1 of prot] {\dashuline{Aminosäuresequenz}} edge (prot);
|
||||
\node[attribut] (protGewicht) [left=of prot] {Molekulargewicht} edge (prot);
|
||||
\node[attribut] (protCATH) [below right=0.6 and -1.3 of prot] {CATH-Klassifikation} edge (prot);
|
||||
\node[relationship] (relProtDom) [right=of organism] {enthält} edge[bend left] node [above right=5 and -1] {[1;*]} (prot);
|
||||
\node[entity] (domain) [above=of relProtDom] {Domäne} edge node [below right=-0.5 and 0] {[0;*]} (relProtDom);
|
||||
\node[attribut] (domID) [above left=of domain] {\underline{Domänen-ID}} edge (domain);
|
||||
\node[attribut] (domHMM) [above=of domain] {HMM} edge (domain);
|
||||
\end{tikzpicture}
|
||||
|
||||
\section{Logischer Entwurf}
|
||||
Person(\underline{Name}, DOB, Geschlecht) \\
|
||||
Schauspieler(\dashuline{Name $\rightarrow$ Person.Name}, Markenzeichen) \\
|
||||
Regisseur(\dashuline{Name $\rightarrow$ Person.Name}, Genre)\\
|
||||
Charakter(\underline{CID}, Name, Charakterbeschreibung)\\
|
||||
Film(\underline{Titel}, \dashuline{Regisseur $\rightarrow$ Regisseur.Name}, Zusammenfassung, 1. Drehtag,
|
||||
letzter Drehtag, Genre1, Genre2, Genre3, Genre4)\\
|
||||
Rolle(\dashuline{Charakter $\rightarrow$ Charakter.CID, Schauspieler $\rightarrow$ Schauspieler.Name, Film $\rightarrow$ Film.Titel}, Drehbeginn, Drehende, Gage)
|
||||
|
||||
\section{Relationale Algebra und SQL}
|
||||
\subsection{} %a
|
||||
\subsubsection{} %i
|
||||
Nachname des Rennfahrers, der im Malaysia GP den ersten Platz belegte.
|
||||
|
||||
\begin{tabular}{c}
|
||||
Nachname \\
|
||||
\hline
|
||||
Vettel \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\subsubsection{} %ii
|
||||
Vor- und Nachname aller Rennfahrer, die in einem Rennstall angestellt sind, der weniger als 350 Budget hat.
|
||||
|
||||
\begin{tabular}{c|c}
|
||||
Vorname & Nachname \\
|
||||
\hline
|
||||
Lewis & Hamilton \\
|
||||
Jenson & Button \\
|
||||
Kimi & Räikkonen \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\subsubsection{} %iii
|
||||
Name der Rennställe, deren Fahrer im Australien GP eine Platzierung haben.
|
||||
|
||||
\begin{tabular}{c}
|
||||
Name \\
|
||||
\hline
|
||||
RedBull \\
|
||||
Ferrari \\
|
||||
McLaren \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\subsection{} %b
|
||||
\subsubsection{} %i
|
||||
\[
|
||||
\pi_{Rennstall.Name}(\sigma_{Geburt >= 1985}(Rennfahrer) \underset{RSID=Rennstall}{\bowtie} Rennstall)
|
||||
\]
|
||||
|
||||
\begin{tabular}{c}
|
||||
Name \\
|
||||
\hline
|
||||
RedBull \\
|
||||
McLaren \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\subsubsection{} %ii
|
||||
$\pi_{Vorname, Nachname, Geburt}(\pi_{RID}(\sigma_{Name='Australien GP'}(Rennort) \bowtie Platzierung) \bowtie $\\$ Rennfahrer \underset{Rennstall=RSID}{\bowtie} (\sigma_{Name='McLaren'}(Rennstall)))$
|
||||
|
||||
\begin{tabular}{c|c|c}
|
||||
Vorname & Nachname & Geburt \\
|
||||
\hline
|
||||
Lewis & Hamilton & 1985-01-07 \\
|
||||
Jenson & Button & 1980-01-19 \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\subsubsection{} %iii
|
||||
$Rennfahrer - (Rennfahrer \bowtie (\pi_{RID}(Platzierung)))$
|
||||
|
||||
\begin{tabular}{c|c|c|c|c|c}
|
||||
RID & Vorname & Nachname & Geburt & Wohnort & Rennstall \\
|
||||
\hline
|
||||
44 & Kimi & Räikkönen & 1979-10-17 & Espoo (Finnland) & 34 \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\subsubsection{} %iv
|
||||
$\pi_{Vorname, Nachname}(\sigma_{Rennstall = 31}(Rennfahrer) - (\sigma_{Nachname='Button'}(Rennfahrer)))$
|
||||
|
||||
\begin{tabular}{c|c}
|
||||
Vorname & Nachname \\
|
||||
\hline
|
||||
Lewis & Hamilton \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\subsection{} %c
|
||||
\subsubsection{} %i
|
||||
\begin{verbatim}
|
||||
SELECT fahrer.Vorname, fahrer.Nachname, fahrer.Geburt
|
||||
FROM Platzierung platz,
|
||||
Rennort ort,
|
||||
Rennfahrer fahrer
|
||||
WHERE platz.OID = ort.OID
|
||||
AND platz.RID = fahrer.RID
|
||||
AND ort.Name = 'Australien GP'
|
||||
AND fahrer.Rennstall = 31
|
||||
\end{verbatim}
|
||||
\subsubsection{} %ii
|
||||
\begin{verbatim}
|
||||
SELECT Vorname, Nachname
|
||||
FROM Rennfahrer
|
||||
WHERE Rennstall = 31
|
||||
AND Nachname <> 'Button'
|
||||
\end{verbatim}
|
||||
|
||||
\section{Algebraische Optimierung}
|
||||
\subsection{} %a
|
||||
\subsection{} %b
|
||||
\end{document}
|
||||
206
gdb/G62B4_Dittrich-Lindemann-Martens.tex
Normal file
206
gdb/G62B4_Dittrich-Lindemann-Martens.tex
Normal file
@ -0,0 +1,206 @@
|
||||
\documentclass[ngerman]{gdb-aufgabenblatt}
|
||||
\RequirePackage[utf8]{inputenc}
|
||||
\renewcommand{\Aufgabenblatt}{3}
|
||||
\renewcommand{\Ausgabedatum}{Mi. 13.11.2013}
|
||||
\renewcommand{\Abgabedatum}{Do. 28.11.2013}
|
||||
\renewcommand{\Gruppe}{Tim Dittrich, Sebastian Lindemann, Jim Martens}
|
||||
|
||||
% define how the sections are rendered
|
||||
\def\thesection{Aufgabe \arabic{section}:}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
|
||||
\usetikzlibrary{positioning}
|
||||
\usetikzlibrary{shadows}
|
||||
|
||||
\begin{document}
|
||||
\section{Relationenalgebra}
|
||||
\subsection{} %a
|
||||
\[
|
||||
\pi_{Obst.Sorte}(Obst \underset{Obst.Entdecker=Person.PNR}{\bowtie}( \sigma_{Vorname='Horst'}(Person)))
|
||||
\]
|
||||
\subsection{} %b
|
||||
\[
|
||||
\pi_{Person.Vorname, Person.Nachname}(Person \underset{Person.PNR=Allergie.Person}{\bowtie} (\sigma_{Symptom='Halskratzen'}(Allergie)))
|
||||
\]
|
||||
\subsection{} %c
|
||||
\[
|
||||
\pi_{Obst.Sorte, Person.Nachname}((Person \underset{Obst.Entdecker=Person.PNR}{\bowtie} Obst) \underset{Allergie.Obst=Obst.ONR}{\bowtie} (\sigma_{Symptom='W"urgreiz'}(Allergie)))
|
||||
\]
|
||||
|
||||
\section{SQL - Schemadefinition}
|
||||
\subsection{} %a
|
||||
\begin{verbatim}
|
||||
CREATE TABLE Rennstall (
|
||||
RSID INT(10) NOT NULL PRIMARY KEY,
|
||||
Name VARCHAR(255) NOT NULL UNIQUE KEY,
|
||||
Teamchef VARCHAR(255) DEFAULT NULL,
|
||||
Budget INT(3) NOT NULL CHECK(Budget>=0 AND Budget <= 500)
|
||||
);
|
||||
|
||||
CREATE TABLE Rennfahrer (
|
||||
RID INT(10) NOT NULL PRIMARY KEY,
|
||||
Rennstall INT(10) NOT NULL,
|
||||
Vorname VARCHAR(255) NOT NULL,
|
||||
Nachname VARCHAR(255) NOT NULL,
|
||||
Geburt DATE NOT NULL,
|
||||
Wohnort VARCHAR(255) DEFAULT NULL,
|
||||
CONSTRAINT fk_rennstall FOREIGN KEY (Rennstall) REFERENCES Rennstall (RSID)
|
||||
);
|
||||
|
||||
CREATE TABLE Rennort (
|
||||
OID INT(10) NOT NULL PRIMARY KEY,
|
||||
Name VARCHAR(255) NOT NULL,
|
||||
Strecke VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE Platzierung (
|
||||
RID INT(10) NOT NULL,
|
||||
OID INT(10) NOT NULL,
|
||||
Platz INT(3) NOT NULL,
|
||||
CONSTRAINT pk_platzierung PRIMARY KEY (RID, OID),
|
||||
CONSTRAINT fk_rennfahrer FOREIGN KEY (RID)
|
||||
REFERENCES Rennfahrer (RID) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_rennort FOREIGN KEY (OID)
|
||||
REFERENCES Rennort (OID) ON DELETE CASCADE
|
||||
);
|
||||
\end{verbatim}
|
||||
\subsection{} %b
|
||||
Dadurch muss beim Erstellen einer Datenbankabfrage verstärkt darauf geachtet werden, dass nach jeder einzelnen Anweisung die Integrität eingehalten wird. Demnach wird eine feste Reihenfolge vorgegeben. Zyklische Verweise verhindern damit ein irgendwie geartetes Verändern auch nur eines Bestandteils, wenn durch diese Änderung irgendeine Fremdschlüsselbedingung verletzt ist.
|
||||
|
||||
Der Fremdschlüssel von Rennstall zu Rennfahrer könnte erst nach der Anlegung der Tabelle Rennfahrer erstellt werden.
|
||||
|
||||
Außerdem könnten dadurch weder Rennställe noch Rennfahrer gelöscht werden. Wenn ein Rennfahrer gelöscht werden soll und er ein Star eines Rennstalles ist, dann wird die Operation sofort abgebrochen. Umgekehrt kann kein Stall gelöscht werden, da zumindest der Star des Rennstalles selber auf den Rennstall referenziert, wodurch auch solche eine Operation abgebrochen würde.
|
||||
\subsection{} %c
|
||||
\begin{verbatim}
|
||||
INSERT INTO Rennstall
|
||||
(RSID, Name, Teamchef, Budget)
|
||||
VALUES (2, 'Red Bull', 'Christian Horner', 370),
|
||||
(5, 'Ferrari', 'Stefano Domenicali', 350),
|
||||
(31, 'McLaren', 'Martin Whitmarsh', 220),
|
||||
(34, 'Lotus F1', 'Eric Boullier', 100);
|
||||
|
||||
INSERT INTO Rennfahrer
|
||||
(RID, Rennstall, Vorname, Nachname, Geburt, Wohnort)
|
||||
VALUES (4, 2, 'Sebastian', 'Vettel', 19870703, 'Kemmental (Schweiz)'),
|
||||
(6, 5, 'Fernando', 'Alonso', 19810729, 'Lugano (Schweiz)'),
|
||||
(8, 2, 'Marc', 'Webber', 19760827, 'Aston Clinton (UK)'),
|
||||
(9, 31, 'Lewis', 'Hamilton', 19850107, 'Genf (Schweiz)'),
|
||||
(20, 31, 'Jenson', 'Button', 19800119, 'Monte Carlo (Monaco)'),
|
||||
(21, 5, 'Felipe', 'Massa', 19820425, 'São Paulo (Brasilien)'),
|
||||
(44, 34, 'Kimi', 'Räikkönen', 19791017, 'Espoo (Finnland)');
|
||||
|
||||
INSERT INTO Rennort
|
||||
(OID, Name, Strecke)
|
||||
VALUES (4, 'Australien GP', 'Albert Park Circuit'),
|
||||
(15, 'Malaysia GP', 'Sepang International Circuit'),
|
||||
(21, 'China GP', 'Shanghai International Circuit');
|
||||
|
||||
INSERT INTO Platzierung
|
||||
(RID, OID, Platz)
|
||||
VALUES (8, 4, 6),
|
||||
(4, 15, 1),
|
||||
(20, 15, 17),
|
||||
(4, 4, 3),
|
||||
(6, 4, 2),
|
||||
(8, 15, 2),
|
||||
(6, 21, 1),
|
||||
(9, 4, 5),
|
||||
(21, 15, 5),
|
||||
(20, 4, 9),
|
||||
(21, 4, 4);
|
||||
\end{verbatim}
|
||||
\subsection{} %d
|
||||
|
||||
\begin{itemize}
|
||||
\item \begin{verbatim}
|
||||
DELETE FROM Rennfahrer
|
||||
WHERE Vorname LIKE 'F%';
|
||||
\end{verbatim}
|
||||
\item \begin{verbatim}
|
||||
DROP TABLE Platzierung;
|
||||
DROP TABLE Rennort;
|
||||
DROP TABLE Rennfahrer;
|
||||
DROP TABLE Rennstall;
|
||||
\end{verbatim}
|
||||
\end{itemize}
|
||||
|
||||
\section{SQL - Anfragen}
|
||||
\subsection{} %a
|
||||
\begin{verbatim}
|
||||
SELECT DISTINCT obst.Sorte
|
||||
FROM Person pers,
|
||||
Allergie aller,
|
||||
Obst obst
|
||||
WHERE pers.PNR = aller.Person
|
||||
AND aller.Obst = obst.ONR
|
||||
AND pers.Vorname = 'Peter'
|
||||
AND pers.Nachname = 'Meyer'
|
||||
ORDER BY obst.Sorte DESC;
|
||||
\end{verbatim}
|
||||
\subsection{} %b
|
||||
\begin{verbatim}
|
||||
SELECT pers.PNR, pers.Nachname, COUNT(aller.Obst)
|
||||
FROM Person pers,
|
||||
Allergie aller
|
||||
WHERE pers.PNR = aller.Person
|
||||
GROUP BY pers.PNR;
|
||||
\end{verbatim}
|
||||
\subsection{} %c
|
||||
\begin{verbatim}
|
||||
SELECT pers.PNR
|
||||
FROM Person pers,
|
||||
Obst obst
|
||||
WHERE pers.PNR = obst.Entdecker
|
||||
GROUP BY pers.PNR
|
||||
HAVING COUNT(obst.ONR) > 6;
|
||||
\end{verbatim}
|
||||
\subsection{} %d
|
||||
\begin{verbatim}
|
||||
SELECT pers.Vorname, pers.Nachname
|
||||
FROM Person pers,
|
||||
Person entdecker,
|
||||
Obst obst
|
||||
WHERE entdecker.PNR = obst.Entdecker
|
||||
AND pers.Lieblingsobst = obst.ONR
|
||||
AND entdecker.Vorname = pers.Vorname;
|
||||
\end{verbatim}
|
||||
\subsection{} %e
|
||||
\begin{verbatim}
|
||||
SELECT pers.PNR, pers.Vorname, pers.Nachname
|
||||
FROM Person pers
|
||||
WHERE pers.PNR NOT IN (SELECT obst.Entdecker
|
||||
FROM Obst obst);
|
||||
\end{verbatim}
|
||||
|
||||
\section{Optimierung}
|
||||
anfänglicher Operatorbaum:\\
|
||||
\begin{tikzpicture}[shorten >=1pt,node distance=1.1cm,on grid]
|
||||
\node (proj) {$\pi_{Person.PNR, Person.Vorname, Person.Nachname}$};
|
||||
\node (sel) [below=2.0 of proj] {$\sigma_{Obst.Sorte\text{ LIKE 'K\%'}}$};
|
||||
\node (sel2) [below=2.0 of sel] {$\sigma_{Obst.ONR=Person.Lieblingsobst}$};
|
||||
\node (catProd) [below=2.0 of sel2] {x};
|
||||
\node (person) [below left=2.0 and 2.0 of catProd] {Person};
|
||||
\node (obst) [below right=2.0 and 2.0 of catProd] {Obst};
|
||||
\path (proj) edge node [right] {400} (sel)
|
||||
(sel) edge node [right] {2000} (sel2)
|
||||
(sel2) edge node [right] {50000} (catProd)
|
||||
(catProd) edge node [left] {2000} (person)
|
||||
(catProd) edge node [right] {25} (obst);
|
||||
\end{tikzpicture}
|
||||
|
||||
optimierter Operatorbaum:\\
|
||||
\begin{tikzpicture}[shorten >=1pt,node distance=1.1cm,on grid]
|
||||
\node (proj) {$\pi_{Person.PNR, Person.Vorname, Person.Nachname}$};
|
||||
\node (join) [below=2.0 of proj] {$\underset{Person.Lieblingsobst = Obst.ONR}{\bowtie}$};
|
||||
\node (person) [below left=2.0 and 2.0 of join] {Person};
|
||||
\node (sel) [below right=2.0 and 2.0 of join] {$\sigma_{Obst.Sorte\text{ LIKE 'K\%'}}$};
|
||||
\node (obst) [below=of sel] {Obst};
|
||||
\path (proj) edge node [right] {400} (join)
|
||||
(join) edge node [left] {2000} (person)
|
||||
(join) edge node [right] {5} (sel)
|
||||
(sel) edge node [right] {25} (obst);
|
||||
\end{tikzpicture}
|
||||
|
||||
Der zweite Operatorbaum ist klar performanter, da die Selektion der Obstsorte bereits vor dem Join stattfindet und das kartesische Produkt und die zweite Selektion zu einem Join verbunden wurde.
|
||||
\end{document}
|
||||
150
gdb/G62B5_Dittrich-Lindemann-Martens.tex
Normal file
150
gdb/G62B5_Dittrich-Lindemann-Martens.tex
Normal file
@ -0,0 +1,150 @@
|
||||
\documentclass[ngerman]{gdb-aufgabenblatt}
|
||||
\RequirePackage[utf8]{inputenc}
|
||||
\renewcommand{\Aufgabenblatt}{5}
|
||||
\renewcommand{\Ausgabedatum}{Mi. 11.12.2013}
|
||||
\renewcommand{\Abgabedatum}{Do. 09.01.2014}
|
||||
\renewcommand{\Gruppe}{Tim Dittrich, Sebastian Lindemann, Jim Martens}
|
||||
|
||||
% define how the sections are rendered
|
||||
\def\thesection{Aufgabe \arabic{section}:}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
|
||||
\usetikzlibrary{positioning}
|
||||
\usetikzlibrary{shadows}
|
||||
|
||||
\begin{document}
|
||||
\section{Referentielle Aktionen}
|
||||
\subsection{} %a
|
||||
Bei einem sicheren Schema ist das Ergebnis der Referentiellen Aktionen unabhängig von der Reihenfolge.
|
||||
\subsection{} %b
|
||||
\begin{tikzpicture}
|
||||
\node[entity] (benutzer) {Benutzer};
|
||||
\node[entity] (websites) [left=4.0 of benutzer] {Websites};
|
||||
\node[entity] (rubriken) [right=4.0 of benutzer] {Rubriken};
|
||||
\node[entity] (rubrikZuordnung) [below=9.0 of benutzer] {RubrikZuordnung};
|
||||
\node (websitesBenutzer) [above=0.5 of websites, align=left] {EingestelltVon $\rightarrow$ \\ Benutzer.UID};
|
||||
\node (benutzerWebsites) [below left=1.5 and 0.5 of benutzer, align=left] {Homepage $\rightarrow$ \\ Websites.WID};
|
||||
\node (rubrikenBenutzer) [above left=0.4 and 0.2 of rubriken,align=left] {Verwalter $\rightarrow$ \\ Benutzer.UID};
|
||||
\node (rubrikZuordnungWebsites) [above left=0.7 and 0.7 of rubrikZuordnung, align=left] {WID $\rightarrow$ \\ Websites.WID};
|
||||
\node (rubrikZuordnungRubriken) [above right=0.7 and 1.5 of rubrikZuordnung, align=left] {RID $\rightarrow$ \\ Rubriken.RID};
|
||||
\node (rubrikZuordnungBenutzer) [above right=4.0 and -1.6 of rubrikZuordnung, align=left] {ZugeordnetVon $\rightarrow$ \\ Benutzer.UID};
|
||||
\path[->] (websites) edge[bend left] node [above, align=left] {ON DELETE \\ RESTRICT} (benutzer)
|
||||
(benutzer) edge[bend left] node [below, align=left] {ON DELETE \\ SET NULL} (websites)
|
||||
(rubriken) edge node [above, align=left] {ON DELETE \\ CASCADE} (benutzer)
|
||||
(rubrikZuordnung) edge[bend left] node [left=0.5, align=left] {ON DELETE \\ CASCADE} (websites)
|
||||
(rubrikZuordnung) edge[bend right] node [right=0.5, align=left] {ON DELETE \\ RESTRICT} (rubriken)
|
||||
(rubrikZuordnung) edge node [left, align=left] {ON DELETE \\ CASCADE} (benutzer);
|
||||
\end{tikzpicture}
|
||||
\subsection{} %c
|
||||
Vorausgesetzt man hat einen Benutzer, der keine Website eingestellt hat, und möchte diesen löschen. Dieser Benutzer ist ein Verwalter einer Rubrik. Außerdem hat der Benutzer eine Website und eine Rubrik zugeordnet. Wenn der Benutzer gelöscht wird und anschließend die Rubrikzuordnung gelöscht wird, dann können die vom Benutzer verwalteten Rubriken einfach gelöscht werden. Werden hingegen zuerst die Rubriken gelöscht, dann scheitert der Vorgang am ON DELETE RESTRICT von Rubrikzuordnung zu Rubriken.
|
||||
|
||||
Daher ist das Schema nicht sicher bezüglich referentieller Aktionen.
|
||||
\subsection{} %d
|
||||
Dieses Problem könnte durch das Ändern des ON DELETE RESTRICT zwischen Rubriken und Rubrikzuordnung zu ON DELETE CASCADE behoben werden.
|
||||
\section{Änderbarkeit von Sichten}
|
||||
\subsection{} %a
|
||||
\subsubsection{} %i
|
||||
\begin{verbatim}
|
||||
CREATE VIEW EnterpriseCrew AS
|
||||
SELECT BNr, Name, Rang
|
||||
FROM Besatzungsmitglieder BM,
|
||||
Raumschiffe RS
|
||||
WHERE BM.Schiff = RS.RNr
|
||||
AND RS.Name = 'Enterprise';
|
||||
\end{verbatim}
|
||||
Die Sicht erlaubt Änderungsoperationen.
|
||||
\subsubsection{} %ii
|
||||
\begin{verbatim}
|
||||
CREATE VIEW Captains AS
|
||||
SELECT Name
|
||||
FROM Besatzungsmitglieder
|
||||
WHERE Rang = 'Captain';
|
||||
\end{verbatim}
|
||||
Die Sicht erlaubt keine Änderungsoperationen, da der primäre Schlüssel nicht enthalten ist und damit Änderungen nicht eindeutig zugeordnet werden können.
|
||||
\subsubsection{} %iii
|
||||
\begin{verbatim}
|
||||
CREATE VIEW WarpFed AS
|
||||
SELECT RNr, Fraktion, Baujahr
|
||||
FROM Raumschiffe
|
||||
WHERE Geschwindigkeit >= 1;
|
||||
\end{verbatim}
|
||||
Die Sicht erlaubt Änderungsoperationen.
|
||||
\subsection{} %b
|
||||
\subsubsection{} %i
|
||||
Die SQL-Anweisung kann auf der Sichtdefinition Fö(r)derationsschiffe\footnote{Es heißt "`Vereinige Föderation der Planeten"'. Demnach ist hier das erste r obsolet.} durchgeführt werden. Die betroffenen Tupel bleiben auf jeden Fall in der Sicht Föderationsschiffe sichtbar.
|
||||
\subsubsection{} %ii
|
||||
Die SQL-Anweisung kann auf der Sichtdefinition GalaxyKlasse nicht durchgeführt werden. Dies liegt an der CHECK OPTION für Föderationsschiffe. Die Fraktion des einzufügenden Tupels ist Bajoraner, aber Föderationsschiffe erfordert Föderation, womit die Bedingung für diese Sicht nicht gegeben ist. Da GalaxyKlasse indirekt auf Föderationsschiffe aufbaut, wird die Änderungsoperation auch dort abgelehnt.
|
||||
\subsubsection{} %iii
|
||||
Die SQL-Anweisung kann auf der Sichtdefinition Forschungsschiffe durchgeführt werden. Die betroffenen Tupel bleiben auf jeden Fall in Föderationsschiffe, Forschungsschiffe und in GalaxyKlasse sichtbar.
|
||||
\subsubsection{} %iv
|
||||
Die SQL-Anweisung kann auf der Sichtdefinition NebulaKlasse nicht durchgeführt werden. Dies liegt an der CHECK OPTION für NebulaKlasse. Durch die Änderung würden alle betroffenen Tupel nicht mehr die Bedingung Baujahr > 2365 erfüllen, weswegen die Operation abgelehnt wird.
|
||||
\subsubsection{} %v
|
||||
Die SQL-Anweisung kann auf der Sichtdefinition GalaxyKlasse durchgeführt werden. Zwar erfüllt das einzufügende Tupel nicht die Bedingung von GalaxyKlasse (Geschwindigkeit = 9.8), aber GalaxyKlasse weist keine CHECK OPTION auf. Da das Tupel die Bedingung von Föderationsschiffe erfüllt, macht die dort definierte CHECK OPTION keine Probleme. Nach dem Einfügen ist das Tupel in Föderationsschiffe, Forschungsschiffe und NebulaKlasse sichtbar.
|
||||
\section{Serialisierbarkeit und Anomalien}
|
||||
\subsection{} %a
|
||||
S\ts{1}: A = 305, B = 195 \\
|
||||
S\ts{2}: A = 195, B = 5 \\
|
||||
S\ts{3}: A = 300, B = 5 \\
|
||||
S\ts{4}: A = 190, B = 5 \\
|
||||
S\ts{5}: A = 115, B = 5 \\
|
||||
S\ts{6}: A = 300, B = 5
|
||||
\subsection{} %b
|
||||
S\ts{1}: Transaktion 2 kann A erst lesen, nachdem Transaktion 1 dort geschrieben hat. \\
|
||||
S\ts{2}: Transaktion 1 kann erst A beschreiben, nachdem Transaktion 2 A beschrieben hat. \\
|
||||
S\ts{3}: Transaktion 1 kann B erst lesen, nachdem Transaktion 2 B beschrieben hat. Transaktion 1 kann A erst lesen, nachdem Transaktion 2 A beschrieben hat. \\
|
||||
S\ts{4}: Transaktion 1 kann B erst lesen, nachdem Transaktion 2 B beschrieben hat. Transaktion 2 kann A erst beschreiben, nachdem Transaktion 1 A gelesen hat. \\
|
||||
S\ts{5}: Es existieren nur indirekte Abhängigkeiten. So kann Transaktion 2 B erst beschreiben, nachdem Transaktion 1 B gelesen hat. Außerdem kann Transaktion 2 erst A beschreiben, nachdem Transaktion 1 A beschrieben hat. \\
|
||||
S\ts{6}: Es existieren nur indirekte Abhängigkeiten. So kann Transaktion 1 B erst lesen, nachdem Transaktion 2 B beschrieben hat. Außerdem kann Transaktion 1 A erst lesen, nachdem Transaktion 2 A beschrieben hat.
|
||||
\subsection{} %c
|
||||
S\ts{1}: Der Schedule ist seriell. \\
|
||||
S\ts{2}: Der Schedule ist nicht serialisierbar, weil Transaktion 2 in A schreibt, nachdem Transaktion 1 aus A gelesen hat und bevor Transaktion 1 in A schreibt. Außerdem liest Transaktion 2 bevor Transaktion 1 in A schreibt. Somit erhält eine der beiden Leseoperationen einen anderen Wert, wenn entweder T\ts{1} vor T\ts{2} oder T\ts{2} vor T\ts{1} gilt. \\
|
||||
S\ts{3}: Der Schedule ist serialisierbar zu T\ts{2} vor T\ts{1}.\\
|
||||
S\ts{4}: Der Schedule ist nicht serialisierbar, da Transaktion 1 B liest, nachdem Transaktion 2 B beschrieben hat und Transaktion 2 A beschreibt, nachdem Transaktion 1 A gelesen hat. In jedem der beiden Fälle T\ts{1} vor T\ts{2} oder T\ts{2} vor T\ts{1} würde mindestens eine Leseoperation einen anderen Wert erhalten. \\
|
||||
S\ts{5}: Der Schedule ist nicht serialisierbar, da Transaktion 1 A beschreibt, nachdem Transaktion 2 A beschrieben hat und Transaktion 2 B beschreibt, nachdem Transaktion 1 B gelesen hat. In jedem der beiden Fälle T\ts{1} vor T\ts{2} oder T\ts{2} vor T\ts{1} würde mindestens eine Leseoperation einen anderen Wert erhalten.\\
|
||||
S\ts{6}: Der Schedule ist seriell.
|
||||
\section{Transaktionen}
|
||||
\[S = w_{1}(x)r_{2}(y)r_{3}(z)w_{3}(y)r_{2}(z)w_{3}(z)w_{1}(z)r_{2}(y)c_{3}c_{1}c_{2}\]
|
||||
|
||||
\begin{tabular}{|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{1cm}|p{1cm}|p{1cm}|p{3cm}|}
|
||||
\hline
|
||||
Zeitschritt & T\ts{1} & T\ts{2} & T\ts{3} & x & y & z & Bemerkung\\
|
||||
\hline
|
||||
0 & & & & NL & NL & NL & \\
|
||||
\hline
|
||||
1 & lock(x,X) & & & X\ts{1} & NL & NL & \\
|
||||
\hline
|
||||
2 & write(x) & lock(y,R) & & X\ts{1} & R\ts{2} & NL & \\
|
||||
\hline
|
||||
3 & & read(y) & lock(z,R) & X\ts{1} & R\ts{2} & R\ts{3} & \\
|
||||
\hline
|
||||
4 & & & read(z) & X\ts{1} & R\ts{2} & R\ts{3} & \\
|
||||
\hline
|
||||
5 & & lock(z,R) & lock(y,X) & X\ts{1} & R\ts{2} & R\ts{2,3} & T\ts{3} wartet auf Freigabe von y \\
|
||||
\hline
|
||||
6 & & read(z) & & X\ts{1} & R\ts{2} & R\ts{2,3} & \\
|
||||
\hline
|
||||
7 & lock(z,X) & & & X\ts{1} & R\ts{2} & R\ts{2,3} & T\ts{1} wartet auf Freigabe von z \\
|
||||
\hline
|
||||
8 & & read(y) & & X\ts{1} & R\ts{2} & R\ts{2,3} & \\
|
||||
\hline
|
||||
9 & & unlock(y) & & X\ts{1} & X\ts{3} & R\ts{2,3} & Benachrichtigung von T\ts{3}\\
|
||||
\hline
|
||||
10 & & unlock(z) & write(y) & X\ts{1} & X\ts{3} & R\ts{3} & \\
|
||||
\hline
|
||||
11 & & commit & lock(z,X) & X\ts{1} & X\ts{3} & X\ts{3} & \\
|
||||
\hline
|
||||
12 & & & write(z) & X\ts{1} & X\ts{3} & X\ts{3} & \\
|
||||
\hline
|
||||
13 & & & unlock(z) & X\ts{1} & X\ts{3} & X\ts{1} & Benachrichtigung von T\ts{1} \\
|
||||
\hline
|
||||
14 & write(z) & & unlock(y) & X\ts{1} & NL & X\ts{1} & \\
|
||||
\hline
|
||||
15 & unlock(x) & & commit & NL & NL & X\ts{1} & \\
|
||||
\hline
|
||||
16 & unlock(z) & & & NL & NL & NL & \\
|
||||
\hline
|
||||
17 & commit & & & NL & NL & NL & \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\end{document}
|
||||
209
gdb/G62B6_Dittrich-Lindemann-Martens.tex
Normal file
209
gdb/G62B6_Dittrich-Lindemann-Martens.tex
Normal file
@ -0,0 +1,209 @@
|
||||
\documentclass[ngerman]{gdb-aufgabenblatt}
|
||||
\RequirePackage[utf8]{inputenc}
|
||||
\renewcommand{\Aufgabenblatt}{6}
|
||||
\renewcommand{\Ausgabedatum}{Mi. 08.01.2014}
|
||||
\renewcommand{\Abgabedatum}{Do. 23.01.2014}
|
||||
\renewcommand{\Gruppe}{Tim Dittrich, Sebastian Lindemann, Jim Martens}
|
||||
|
||||
% define how the sections are rendered
|
||||
\def\thesection{Aufgabe \arabic{section}:}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{\roman{subsubsection})}
|
||||
|
||||
\usetikzlibrary{positioning}
|
||||
\usetikzlibrary{shadows}
|
||||
|
||||
\begin{document}
|
||||
\section{B-Bäume}
|
||||
\subsection{} %a
|
||||
42 kann einfach eingefügt werden. Zum Einfügen von 6 wird der Baum gesplittet. Damit ergibt sich dieser Baum:
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {13};
|
||||
\node (1-l) [below left=of root] {9};
|
||||
\node (1-r) [below right=of root] {37 42};
|
||||
\node (2-l) [below left=of 1-l] {6};
|
||||
\node (2-r) [below right=of 1-l] {11};
|
||||
\path[->,line width=1pt]
|
||||
(root) edge (1-l)
|
||||
(root) edge (1-r)
|
||||
(1-l) edge (2-l)
|
||||
(1-l) edge (2-r);
|
||||
\end{tikzpicture}
|
||||
|
||||
12 kann wieder einfach eingefügt werden. Bei 25 muss der Baum wieder gesplittet werden, womit sich dieser Baum ergibt:
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {13};
|
||||
\node (1-l) [below left=1 and 2 of root] {9};
|
||||
\node (1-r) [below right=1 and 2 of root] {37};
|
||||
\node (2-l) [below left=of 1-l] {6};
|
||||
\node (2-r) [below right=of 1-l] {11 12};
|
||||
\node (2-rl) [below left=of 1-r] {25};
|
||||
\node (2-rr) [below right=of 1-r] {42};
|
||||
\path[->,line width=1pt]
|
||||
(root) edge (1-l)
|
||||
(root) edge (1-r)
|
||||
(1-l) edge (2-l)
|
||||
(1-l) edge (2-r)
|
||||
(1-r) edge (2-rl)
|
||||
(1-r) edge (2-rr);
|
||||
\end{tikzpicture}
|
||||
\subsection{} %b
|
||||
Für das Löschen von 17 wird der Baum ausgeglichen. Es ergibt sich dieser Baum:
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {11 38};
|
||||
\node (1-l) [below left=1 and 2 of root] {4 7};
|
||||
\node (1-m) [below=of root] {13 29};
|
||||
\node (1-r) [below right=1 and 2 of root] {49 50};
|
||||
\path[->,line width=1pt]
|
||||
(root) edge (1-l)
|
||||
(root) edge (1-r)
|
||||
(root) edge (1-m);
|
||||
\end{tikzpicture}
|
||||
|
||||
29 kann mit Mischen gelöscht werden. Es ergibt sich dieser Baum:
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {11 13};
|
||||
\node (1-l) [below left=1 and 2 of root] {4 7};
|
||||
\node (1-r) [below right=1 and 2 of root] {38 49 50};
|
||||
\path[->,line width=1pt]
|
||||
(root) edge (1-l)
|
||||
(root) edge (1-r);
|
||||
\end{tikzpicture}
|
||||
|
||||
49 kann einfach gelöscht werden. 7 kann nicht mehr gelöscht werden, ohne die Bedingungen eines B-Baumes zu verletzen. Nach dem Löschen von 7 blieben noch 5 Schlüssel übrig. Da pro Knoten mindestens 2 und maximal 4 Schlüssel eingetragen sein dürfen, wäre die einzige Lösung einen Knoten mit 2 und einen mit 3 Einträgen zu haben. Dies widerspräche aber der Voraussetzung, dass die Wurzel mindestens 2 Söhne hat, sofern sie kein Blatt ist. Daher ist diese Operation nicht möglich.
|
||||
|
||||
Wenn jedoch 7 und 4 zusammen gelöscht würden, dann ergäbe sich dieser Baum:
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {11 13 38 50};
|
||||
\end{tikzpicture}
|
||||
\section{Berechnungen in B-Bäumen}
|
||||
\subsection{} %a
|
||||
\subsubsection{} %i
|
||||
Der Baum kann minimal 6 Einträge und maximal 24 Einträge haben.
|
||||
\subsubsection{} %ii
|
||||
\[
|
||||
\frac{z_{max}}{n_{max}}
|
||||
\]
|
||||
\subsection{} %b
|
||||
\subsubsection{} %i
|
||||
maximale Belegung von Bäumen der angegebenen Klasse nach Höhe:
|
||||
|
||||
\begin{itemize}
|
||||
\item h=1: 6
|
||||
\item h=2: 48
|
||||
\item h=3: 348
|
||||
\end{itemize}
|
||||
|
||||
Demnach muss der B-Baum mindestens eine Höhe von 3 haben, um alle Datensätze fassen zu können.
|
||||
\subsubsection{} %ii
|
||||
|
||||
minimale Belegung von Bäumen der angegebenen Klasse nach Höhe:
|
||||
|
||||
\begin{itemize}
|
||||
\item h=1: 3
|
||||
\item h=2: 9
|
||||
\item h=3: 33
|
||||
\item h=4: 141
|
||||
\end{itemize}
|
||||
|
||||
Demnach kann der B-Baum maximal eine Höhe von 4 haben, um alle Datensätze fassen zu können.
|
||||
\section{B*-Bäume}
|
||||
\subsection{} %a
|
||||
64 kann einfach eingefügt werden. Beim Einfügen von 3 wird gesplittet:
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {5 9};
|
||||
\node (1-l) [below left=1 and 2 of root] {1 3 5};
|
||||
\node (1-m) [below=of root] {7 8};
|
||||
\node (1-r) [below right=1 and 2 of root] {40 53 61 64};
|
||||
|
||||
\path[->,line width=1pt] (root) edge (1-l)
|
||||
(root) edge (1-m)
|
||||
(root) edge (1-r);
|
||||
\end{tikzpicture}
|
||||
|
||||
6 kann einfach eingefügt werden. Beim Einfügen von 80 wird gesplittet:
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {5 9 61};
|
||||
\node (1-l) [below left=1 and 4 of root] {1 3 5 6};
|
||||
\node (1-ml) [below left=1 and 0.5 of root] {7 8};
|
||||
\node (1-mr) [below right=1 and 0.5 of root] {40 53 61};
|
||||
\node (1-r) [below right=1 and 4 of root] {64 80};
|
||||
|
||||
\path[->,line width=1pt] (root) edge (1-l)
|
||||
(root) edge (1-ml)
|
||||
(root) edge (1-mr)
|
||||
(root) edge (1-r);
|
||||
\end{tikzpicture}
|
||||
\subsection{} %b
|
||||
14 wird einfach gelöscht.
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {54};
|
||||
\node (1-l) [below left=1 and 2 of root] {34 40};
|
||||
\node (1-r) [below right=1 and 2 of root] {66};
|
||||
\node (2-ll) [below left=1 and 1 of 1-l] {12};
|
||||
\node (2-lm) [below=of 1-l] {38};
|
||||
\node (2-lr) [below right=1 and 1 of 1-l] {44 46};
|
||||
\node (2-rl) [below left=1 and 1 of 1-r] {68};
|
||||
\node (2-rr) [below right=1 and 1 of 1-r] {86};
|
||||
\path[->,line width=1pt] (root) edge (1-l)
|
||||
(root) edge (1-r)
|
||||
(1-l) edge (2-ll)
|
||||
(1-l) edge (2-lm)
|
||||
(1-l) edge (2-lr)
|
||||
(1-r) edge (2-rl)
|
||||
(1-r) edge (2-rr);
|
||||
\end{tikzpicture}
|
||||
|
||||
38 kann einfach gelöscht werden.
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {54};
|
||||
\node (1-l) [below left=1 and 2 of root] {34 40};
|
||||
\node (1-r) [below right=1 and 2 of root] {66};
|
||||
\node (2-ll) [below left=1 and 1 of 1-l] {12};
|
||||
\node (2-lr) [below right=1 and 1 of 1-l] {44 46};
|
||||
\node (2-rl) [below left=1 and 1 of 1-r] {68};
|
||||
\node (2-rr) [below right=1 and 1 of 1-r] {86};
|
||||
\path[->,line width=1pt] (root) edge (1-l)
|
||||
(root) edge (1-r)
|
||||
(1-l) edge (2-ll)
|
||||
(1-l) edge (2-lr)
|
||||
(1-r) edge (2-rl)
|
||||
(1-r) edge (2-rr);
|
||||
\end{tikzpicture}
|
||||
|
||||
12 kann durch Mischen gelöscht werden.
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {54 66};
|
||||
\node (1-l) [below left=1 and 1 of root] {44 46};
|
||||
\node (1-r) [below right=1 and 1 of root] {68 86};
|
||||
\path[->,line width=1pt] (root) edge (1-l)
|
||||
(root) edge (1-r);
|
||||
\end{tikzpicture}
|
||||
|
||||
44 kann einfach gelöscht werden.
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (root) {54 66};
|
||||
\node (1-l) [below left=1 and 1 of root] {46};
|
||||
\node (1-r) [below right=1 and 1 of root] {68 86};
|
||||
\path[->,line width=1pt] (root) edge (1-l)
|
||||
(root) edge (1-r);
|
||||
\end{tikzpicture}
|
||||
\section{Normalformenlehre}
|
||||
\subsubsection{} %i
|
||||
Die Schlüsselkanidaten von R bezüglich F sind B und A,D.
|
||||
\subsubsection{} %ii
|
||||
Die Nicht-Primärattribute von R bezüglich F sind E und C.
|
||||
\subsubsection{} %iii
|
||||
C hängt partiell von A,D ab, aber nicht von B. Daher befindet sich die Relation nicht in der zweiten Normalform und damit auch nicht in der dritten. Da jedes der Attribute in R atomar ist, befindet sich R in der ersten Normalform.
|
||||
\end{document}
|
||||
@ -14,11 +14,17 @@
|
||||
%
|
||||
% v1.0:
|
||||
% 2009-11-09 KH: Erste Version der Makro-Sammlung
|
||||
\usepackage{ulsy}
|
||||
|
||||
|
||||
\NeedsTeXFormat{LaTeX2e}
|
||||
\ProvidesPackage{vsis-gdb}[2009/11/27 v1.2 Nuetzliche Makros fuer GDB]
|
||||
|
||||
|
||||
\RequirePackage{ulsy}
|
||||
\RequirePackage{setspace}
|
||||
\RequirePackage[fleqn]{amsmath}
|
||||
|
||||
\RequirePackage{latexsym} % F<>r Befehle wie \Join
|
||||
% Gestricheltes Unterstreichen, z.B. f<>r Relationales Datenbankmodell (Fremdschl<68>ssel)
|
||||
\RequirePackage[normalem]{ulem}
|
||||
\def\dashuline{\bgroup
|
||||
@ -29,6 +35,8 @@
|
||||
\kern.1em}\ULon}
|
||||
\def\soliduline{\bgroup \markoverwith{\hbox
|
||||
{\vtop{\kern.3ex\hrule width.2em}}}\ULon}
|
||||
% Umgebung f<>r relationale Datenbankschemata
|
||||
\newenvironment{RMSchma}{\begin{raggedright}\it\doublespacing}{\end{raggedright}}
|
||||
|
||||
% Operatoren der relationalen Algebra
|
||||
\newcommand*{\projektion}[1]{\pi_{#1}}
|
||||
@ -99,9 +107,8 @@
|
||||
font=\footnotesize,
|
||||
},
|
||||
erbt/.style={
|
||||
draw,
|
||||
>=open triangle 45,
|
||||
->,
|
||||
regular polygon, regular polygon sides=6,
|
||||
draw, black, very thick, minimum size=3em
|
||||
},
|
||||
% Layout fuer referenzgraphen
|
||||
refGraph/.style={
|
||||
@ -127,13 +134,3 @@
|
||||
align=right,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
\RequirePackage[utf8]{inputenc}
|
||||
|
||||
\RequirePackage{vsis-gdb} % Nuetzliche Makros fuer GDB
|
||||
\RequirePackage{booktabs} % Linien f<>r Tabellen
|
||||
|
||||
296
mk/VortragElektronischeDemokratie.tex
Normal file
296
mk/VortragElektronischeDemokratie.tex
Normal file
@ -0,0 +1,296 @@
|
||||
\documentclass[14pt]{beamer}
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Meta informations:
|
||||
\newcommand{\trauthor}{Jim Martens}
|
||||
\newcommand{\trtype}{} %{Proseminar} %{Seminar} %{Workshop}
|
||||
\newcommand{\trcourse}{Einführung in das wissenschaftliche Arbeiten}
|
||||
\newcommand{\trtitle}{Elektronische Demokratie}
|
||||
\newcommand{\trmatrikelnummer}{}
|
||||
\newcommand{\tremail}{2martens@informatik.uni-hamburg.de}
|
||||
\newcommand{\trinstitute}{Fachbereich Informatik}
|
||||
\newcommand{\trwebsiteordate}{}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Languages:
|
||||
|
||||
% Falls die Ausarbeitung in Deutsch erfolgt:
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
% \usepackage[latin9]{inputenc}
|
||||
\selectlanguage{ngerman}
|
||||
|
||||
% If the thesis is written in English:
|
||||
%\usepackage[english]{babel}
|
||||
%\selectlanguage{english}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Bind packages:
|
||||
\usepackage{beamerthemesplit}
|
||||
\usetheme{Boadilla}
|
||||
%\usetheme{Copenhagen}
|
||||
%\usetheme{Darmstadt}
|
||||
%\usetheme{Frankfurt}
|
||||
%\usetheme{Ilmenau}
|
||||
%\usetheme{JuanLesPins}
|
||||
%\usetheme{Madrid}
|
||||
%\usetheme{Warsaw }
|
||||
%\usecolortheme{dolphin}
|
||||
%\setbeamertemplate{sections/subsections in toc}[sections numbered]
|
||||
%\beamertemplatenavigationsymbolsempty
|
||||
%\setbeamertemplate{headline}[default] % deaktiviert die Kopfzeile
|
||||
\setbeamertemplate{navigation symbols}{}% deaktiviert Navigationssymbole
|
||||
%\useinnertheme{rounded}
|
||||
|
||||
\usepackage{acronym} % Acronyms
|
||||
\usepackage{algorithmic} % Algorithms and Pseudocode
|
||||
\usepackage{algorithm} % Algorithms and Pseudocode
|
||||
\usepackage{amsfonts} % AMS Math Packet (Fonts)
|
||||
\usepackage{amsmath} % AMS Math Packet
|
||||
\usepackage{amssymb} % Additional mathematical symbols
|
||||
\usepackage{amsthm}
|
||||
\usepackage{color} % Enables defining of colors via \definecolor
|
||||
\usepackage{fancybox} % Gleichungen einrahmen
|
||||
\usepackage{fancyhdr} % Paket zur schickeren der Gestaltung der
|
||||
\usepackage{graphicx} % Inclusion of graphics
|
||||
%\usepackage{latexsym} % Special symbols
|
||||
\usepackage{longtable} % Allow tables over several parges
|
||||
\usepackage{listings} % Nicer source code listings
|
||||
\usepackage{lmodern}
|
||||
\usepackage{multicol} % Content of a table over several columns
|
||||
\usepackage{multirow} % Content of a table over several rows
|
||||
\usepackage{rotating} % Alows to rotate text and objects
|
||||
\usepackage[section]{placeins} % Ermoeglich \Floatbarrier fuer Gleitobj.
|
||||
\usepackage[hang]{subfigure} % Allows to use multiple (partial) figures in a fig
|
||||
%\usepackage[font=footnotesize,labelfont=rm]{subfig} % Pictures in a floating environment
|
||||
\usepackage{tabularx} % Tables with fixed width but variable rows
|
||||
\usepackage{url,xspace,boxedminipage} % Accurate display of URLs
|
||||
|
||||
\definecolor{uhhRed}{RGB}{254,0,0} % Official Uni Hamburg Red
|
||||
\definecolor{uhhGrey}{RGB}{136,136,136} % Official Uni Hamburg Grey
|
||||
\definecolor{uhhLightGrey}{RGB}{180,180,180} % Official Uni Hamburg LightGrey
|
||||
\definecolor{uhhLightLightGrey}{RGB}{220,220,220} % Official Uni Hamburg LightLightGrey
|
||||
\setbeamertemplate{itemize items}[ball]
|
||||
\setbeamercolor{title}{fg=uhhRed,bg=white}
|
||||
\setbeamercolor{title in head/foot}{bg=uhhRed}
|
||||
\setbeamercolor{block title}{bg=uhhGrey,fg=white}
|
||||
\setbeamercolor{block body}{bg=uhhLightLightGrey,fg=black}
|
||||
\setbeamercolor{section in head/foot}{bg=black}
|
||||
\setbeamercolor{frametitle}{bg=white,fg=uhhRed}
|
||||
\setbeamercolor{author in head/foot}{bg=black,fg=white}
|
||||
\setbeamercolor{author in footline}{bg=white,fg=black}
|
||||
\setbeamercolor*{item}{fg=uhhRed}
|
||||
\setbeamercolor*{section in toc}{fg=black}
|
||||
\setbeamercolor*{separation line}{bg=black}
|
||||
\setbeamerfont*{author in footline}{size=\scriptsize,series=\mdseries}
|
||||
\setbeamerfont*{institute}{size=\footnotesize}
|
||||
|
||||
\newcommand{\opticalseperator}{0.0025\paperwidth}
|
||||
|
||||
\institute{Universit\"at Hamburg\\\trinstitute}
|
||||
\title{\trtitle}
|
||||
\subtitle{\trtype}
|
||||
\author{\trauthor}
|
||||
\date{}
|
||||
\logo{}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Configurationen:
|
||||
%\hypersetup{pdfpagemode=FullScreen}
|
||||
|
||||
\hyphenation{whe-ther} % Manually use: "\-" in a word: Staats\-ver\-trag
|
||||
|
||||
%\lstloadlanguages{C} % Set the default language for listings
|
||||
\DeclareGraphicsExtensions{.pdf,.svg,.jpg,.png,.eps} % first try pdf, then eps, png and jpg
|
||||
\graphicspath{{./src/}} % Path to a folder where all pictures are located
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Custom Definitions:
|
||||
\setbeamertemplate{title page}
|
||||
{
|
||||
\vbox{}
|
||||
\vspace{0.4cm}
|
||||
\begin{centering}
|
||||
\begin{beamercolorbox}[sep=8pt,center,colsep=-4bp]{title}
|
||||
\usebeamerfont{title}\inserttitle\par%
|
||||
\ifx\insertsubtitle\@empty%
|
||||
\else%
|
||||
\vskip0.20em%
|
||||
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
|
||||
\fi%
|
||||
\end{beamercolorbox}%
|
||||
\vskip0.4em
|
||||
\begin{beamercolorbox}[sep=8pt,center,colsep=-4bp,rounded=true,shadow=true]{author}
|
||||
\usebeamerfont{author}\insertauthor \\ \insertinstitute
|
||||
\end{beamercolorbox}
|
||||
|
||||
\vfill
|
||||
%\begin{beamercolorbox}[ht=8ex,center]{}
|
||||
% \includegraphics[width=0.20\paperwidth]{wtmIcon.pdf}
|
||||
% \end{beamercolorbox}%
|
||||
\begin{beamercolorbox}[sep=8pt,center,colsep=-4bp,rounded=true,shadow=true]{institute}
|
||||
\usebeamerfont{institute}%\trwebsiteordate
|
||||
\end{beamercolorbox}
|
||||
\vspace{-0.1cm}
|
||||
\end{centering}
|
||||
}
|
||||
|
||||
\setbeamertemplate{frametitle}
|
||||
{
|
||||
\begin{beamercolorbox}[wd=\paperwidth,ht=3.8ex,dp=1.2ex,leftskip=0pt,rightskip=4.0ex]{frametitle}%
|
||||
\usebeamerfont*{frametitle}\centerline{\insertframetitle}
|
||||
\end{beamercolorbox}
|
||||
\vspace{0.0cm}
|
||||
}
|
||||
|
||||
\setbeamertemplate{footline}
|
||||
{
|
||||
\leavevmode
|
||||
\vspace{-0.05cm}
|
||||
\hbox{
|
||||
\begin{beamercolorbox}[wd=.32\paperwidth,ht=4.8ex,dp=2.7ex,center]{author in footline}
|
||||
\hspace*{2ex}\usebeamerfont*{author in footline}\trauthor
|
||||
\end{beamercolorbox}%
|
||||
\begin{beamercolorbox}[wd=.60\paperwidth,ht=4.8ex,dp=2.7ex,center]{author in footline}
|
||||
\usebeamerfont*{author in footline}\trtitle
|
||||
\end{beamercolorbox}%
|
||||
\begin{beamercolorbox}[wd=.07\paperwidth,ht=4.8ex,dp=2.7ex,center]{author in footline}
|
||||
\usebeamerfont*{author in footline}\insertframenumber{}
|
||||
\end{beamercolorbox}
|
||||
}
|
||||
\vspace{0.15cm}
|
||||
}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Additional 'theorem' and 'definition' blocks:
|
||||
\newtheorem{axiom}{Axiom}[section]
|
||||
%\newtheorem{axiom}{Fakt}[section] % Wenn in Deutsch geschrieben wird.
|
||||
%Usage:%\begin{axiom}[optional description]%Main part%\end{fakt}
|
||||
|
||||
%Additional types of axioms:
|
||||
\newtheorem{observation}[axiom]{Observation}
|
||||
|
||||
%Additional types of definitions:
|
||||
\theoremstyle{remark}
|
||||
%\newtheorem{remark}[section]{Bemerkung} % Wenn in Deutsch geschrieben wird.
|
||||
\newtheorem{remark}[section]{Remark}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Provides TODOs within the margin:
|
||||
\newcommand{\TODO}[1]{\marginpar{\emph{\small{{\bf TODO: } #1}}}}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Abbreviations and mathematical symbols
|
||||
\newcommand{\modd}{\text{ mod }}
|
||||
\newcommand{\RS}{\mathbb{R}}
|
||||
\newcommand{\NS}{\mathbb{N}}
|
||||
\newcommand{\ZS}{\mathbb{Z}}
|
||||
\newcommand{\dnormal}{\mathit{N}}
|
||||
\newcommand{\duniform}{\mathit{U}}
|
||||
|
||||
\newcommand{\erdos}{Erd\H{o}s}
|
||||
\newcommand{\renyi}{-R\'{e}nyi}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Display of TOCs:
|
||||
\AtBeginSection[]
|
||||
{
|
||||
\setcounter{tocdepth}{2}
|
||||
\frame
|
||||
{
|
||||
\frametitle{Outline}
|
||||
\tableofcontents[currentsection]
|
||||
}
|
||||
}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Document:
|
||||
\begin{document}
|
||||
\renewcommand{\arraystretch}{1.2}
|
||||
|
||||
\begin{frame}[plain] % plain => kein Rahmen
|
||||
\titlepage
|
||||
\end{frame}
|
||||
%\setcounter{framenumber}{0}
|
||||
|
||||
\frame{
|
||||
\frametitle{Outline}
|
||||
\tableofcontents
|
||||
}
|
||||
|
||||
%%%%%%%%%%%%%%
|
||||
% Your Content
|
||||
|
||||
\section{Herleitung}
|
||||
|
||||
\frame[t]{
|
||||
\frametitle{Beispiele}
|
||||
\only<1-5>{
|
||||
\begin{itemize}
|
||||
\item<1-5> Terminfindung per Dudle
|
||||
\item<2-5> Petitionen
|
||||
\item<3-5> Crowdfunding - Abstimmen mit Geld
|
||||
\begin{itemize}
|
||||
\item<4-5> Star Citizen
|
||||
\item<5> Oculus Rift
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
}
|
||||
}
|
||||
|
||||
\section{3-Phasen Modell}
|
||||
|
||||
\frame[t]{
|
||||
\frametitle{3-Phasen Modell}
|
||||
\begin{itemize}
|
||||
\item<1-> Single-point-of-entry
|
||||
\item<2-> E-Government
|
||||
\item<3> eins-zu-eins Beziehung zwischen Staat und Bürger
|
||||
\end{itemize}
|
||||
}
|
||||
|
||||
\section{Kritische Diskussion}
|
||||
|
||||
\frame[t]{
|
||||
\only<1-2>{
|
||||
\frametitle{Vorteile}
|
||||
\begin{itemize}
|
||||
\item<1-> Erleichterung der Informationsbeschaffung
|
||||
\item<2> Vereinfachung der Interaktion
|
||||
\item<2> gesteigerte Effizienz
|
||||
\item<2> erhöhte Transparenz
|
||||
\end{itemize}
|
||||
}
|
||||
\only<3->{
|
||||
\frametitle{Nachteile}
|
||||
\begin{itemize}
|
||||
\item<4-> Arbeitsplatzverlust
|
||||
\item<5-> Einschnitt in Privatsphäre
|
||||
\item<6-> erhöhtes Risiko des Identitätsdiebstahls
|
||||
\item<6-> Gefahr von politischer Verfolgung
|
||||
\end{itemize}
|
||||
}
|
||||
}
|
||||
|
||||
\section{Auswertung}
|
||||
|
||||
\frame[t]{
|
||||
\frametitle{Auswertung}
|
||||
|
||||
\begin{itemize}
|
||||
\item<1-> Übertragung aufs Internet nötig
|
||||
\item<2> unter Beachtung integraler Prinzipien
|
||||
\end{itemize}
|
||||
}
|
||||
|
||||
%%%%%%%%%%%%%%
|
||||
|
||||
\frame[c]{
|
||||
\frametitle{Ende}
|
||||
\begin{center}
|
||||
Danke für Eure Aufmerksamkeit.\\[1ex]
|
||||
Fragen?\\[5ex]
|
||||
\end{center}
|
||||
}
|
||||
|
||||
\end{document}
|
||||
284
mk/bib.bib
284
mk/bib.bib
@ -1,190 +1,110 @@
|
||||
% This file was created with JabRef 2.9b2.
|
||||
% This file was created with JabRef 2.10b2.
|
||||
% Encoding: UTF-8
|
||||
|
||||
@ARTICLE{Aagren2001,
|
||||
author = {Ågren, Per-Olof},
|
||||
title = {Is online democracy in the EU for professionals only?},
|
||||
journal = {Communications of the ACM},
|
||||
year = {2001},
|
||||
volume = {44},
|
||||
pages = {36-38},
|
||||
number = {1},
|
||||
month = {January},
|
||||
abstract = {A directive of the EU protects the privacy very harsh. This directive
|
||||
forbids mentioning anything privacy related of any person without
|
||||
their declared consent. This makes e-democracy in the form of e.g.
|
||||
bulletin boards close to impossible as it isn't really possible to
|
||||
discuss a statement of a person without identifying the person.
|
||||
|
||||
|
||||
As it is a directive the EU member states have to interpret the directive
|
||||
into national law. Sweden has made a law that follows the directive
|
||||
to the letter. That resulted in 296 reports of violation of this
|
||||
law between October 1998 and August 2000. Another law in Sweden restricts
|
||||
e-democracy in another way. The person who initiates a bulletin board
|
||||
is responsible for all its content. This constraint leads to a situation
|
||||
where fear stops people from engaging in e-democracy. Fear to violate
|
||||
such rules.
|
||||
|
||||
|
||||
The EU directive allows processing of personal data only for journalistic,
|
||||
artistic and literary purposes which results in the opinion of the
|
||||
EU parliament that enough freedom of expression in virtual forums
|
||||
is achieved when authors, journalists and artists are free to engage
|
||||
in political discussions. That way democratic debate becomes a purely
|
||||
professional activity and thereby reflects a very thin democracy
|
||||
model.},
|
||||
issue = {1},
|
||||
journaltitle = {Communications of the ACM},
|
||||
owner = {jim},
|
||||
quality = {1},
|
||||
timestamp = {2013.10.28}
|
||||
|
||||
@Article{Aagren2001,
|
||||
Title = {Is online democracy in the EU for professionals only?},
|
||||
Author = {Ågren, Per-Olof},
|
||||
Journal = {Communications of the ACM},
|
||||
Year = {2001},
|
||||
|
||||
Month = {January},
|
||||
Number = {1},
|
||||
Pages = {36-38},
|
||||
Volume = {44},
|
||||
|
||||
Abstract = {A directive of the EU protects the privacy very harsh. This directive forbids mentioning anything privacy related of any person without their declared consent. This makes e-democracy in the form of e.g. bulletin boards close to impossible as it isn't really possible to discuss a statement of a person without identifying the person.
|
||||
|
||||
As it is a directive the EU member states have to interpret the directive into national law. Sweden has made a law that follows the directive to the letter. That resulted in 296 reports of violation of this law between October 1998 and August 2000. Another law in Sweden restricts e-democracy in another way. The person who initiates a bulletin board is responsible for all its content. This constraint leads to a situation where fear stops people from engaging in e-democracy. Fear to violate such rules.
|
||||
|
||||
The EU directive allows processing of personal data only for journalistic, artistic and literary purposes which results in the opinion of the EU parliament that enough freedom of expression in virtual forums is achieved when authors, journalists and artists are free to engage in political discussions. That way democratic debate becomes a purely professional activity and thereby reflects a very thin democracy model.},
|
||||
Issue = {1},
|
||||
Journaltitle = {Communications of the ACM},
|
||||
Owner = {jim},
|
||||
Quality = {1},
|
||||
Timestamp = {2013.10.28}
|
||||
}
|
||||
|
||||
@ARTICLE{Mohen2001,
|
||||
author = {Mohen, Joe and Glidden, Julia},
|
||||
title = {The case for internet voting},
|
||||
journal = {Communications of the ACM},
|
||||
year = {2001},
|
||||
volume = {44},
|
||||
pages = {72-85},
|
||||
number = {1},
|
||||
month = {January},
|
||||
abstract = {The internet voting is explored with the example of the Arizona presidential
|
||||
preference elections. That election allowed for the first time ever
|
||||
to vote from every place around the world (as long as you were a
|
||||
registered Democrat in Arizona). It also included the option to vote
|
||||
by mail, offering the same convenience as voting by Internet. But
|
||||
you were able to vote traditionally in a polling station either.
|
||||
|
||||
|
||||
A massive campaign was started to increase the awareness of the election.
|
||||
Many third parties were invited to monitor the voting process.
|
||||
|
||||
|
||||
To authenticate the voters each registered Democrat received a randomly
|
||||
generated seven digit PIN. In addition they were given two challenge
|
||||
questions (date of birth or last four digits of a social security
|
||||
number) which were randomly selected from a strictly confidential
|
||||
field of five. To prevent overvoting, the system voided ballots from
|
||||
reuse once they were cast. They were also voided when a voter requested
|
||||
a mail-in ballot or disclosed that his/her name or address was incorrect.
|
||||
In the latter case the voter had to vote in person in one of the
|
||||
polling stations.
|
||||
|
||||
|
||||
Moreover voters had to explicetly state their voting eligibility.
|
||||
A false information is a 6 class felony, worthy of jail time. Digital
|
||||
signature were used to identify the specific voting servers being
|
||||
used.
|
||||
|
||||
|
||||
The votes were encrypted and then saved encrypted in a database of
|
||||
election.com. But election.com didn't have the private key. Only
|
||||
once election was over, the encrypted set of data was given to the
|
||||
third party that was able to decrypt the votes. A single bit of error
|
||||
in the encrypted data would have led to not accepting that vote.
|
||||
It is remarkable that no single vote has been rejected.
|
||||
|
||||
|
||||
Internet voting can only be one element of a legally binding election.
|
||||
To give everyone the same opportunity to vote, the Internet voting
|
||||
took place four days prior to Election Day. On the Election Day itself
|
||||
Internet voting was not allowed. The goal was to prevent anyone from
|
||||
waiting till the last second to vote via computer.
|
||||
|
||||
|
||||
Internet voting is most useful on the small level where people able
|
||||
to sabotage the electronic voting process mostly don't bother. Still
|
||||
the PC from which the voting is performed is a security risk. Of
|
||||
the whole 96 hours available for Internet voting, the site wasn't
|
||||
available for one hour only due to a router problem. For each server
|
||||
there were backups to prevent data loss.
|
||||
|
||||
|
||||
Learned lessions:
|
||||
|
||||
|
||||
Many voters have an around-the-clock lifestyle and want to be among
|
||||
the first to vote online. Therefore even more servers are required
|
||||
to process the peak at the beginning.
|
||||
|
||||
|
||||
Current browsers are required.
|
||||
|
||||
|
||||
Internet voting at polling stations offers no extra value and increases
|
||||
the cost of elections.
|
||||
|
||||
|
||||
When should Internet voting be used? In what manner and at what cost?
|
||||
These questions should be answered by politicians and the people
|
||||
who vote them, not technology developers and vendors.},
|
||||
issue = {1},
|
||||
journaltitle = {Communications of the ACM},
|
||||
owner = {jim},
|
||||
quality = {1},
|
||||
timestamp = {2013.10.28}
|
||||
@Article{Mohen2001,
|
||||
Title = {The case for internet voting},
|
||||
Author = {Mohen, Joe and Glidden, Julia},
|
||||
Journal = {Communications of the ACM},
|
||||
Year = {2001},
|
||||
|
||||
Month = {January},
|
||||
Number = {1},
|
||||
Pages = {72-85},
|
||||
Volume = {44},
|
||||
|
||||
Abstract = {The internet voting is explored with the example of the Arizona presidential preference elections. That election allowed for the first time ever to vote from every place around the world (as long as you were a registered Democrat in Arizona). It also included the option to vote by mail, offering the same convenience as voting by Internet. But you were able to vote traditionally in a polling station either.
|
||||
|
||||
A massive campaign was started to increase the awareness of the election. Many third parties were invited to monitor the voting process.
|
||||
|
||||
To authenticate the voters each registered Democrat received a randomly generated seven digit PIN. In addition they were given two challenge questions (date of birth or last four digits of a social security number) which were randomly selected from a strictly confidential field of five. To prevent overvoting, the system voided ballots from reuse once they were cast. They were also voided when a voter requested a mail-in ballot or disclosed that his/her name or address was incorrect. In the latter case the voter had to vote in person in one of the polling stations.
|
||||
|
||||
Moreover voters had to explicetly state their voting eligibility. A false information is a 6 class felony, worthy of jail time. Digital signature were used to identify the specific voting servers being used.
|
||||
|
||||
The votes were encrypted and then saved encrypted in a database of election.com. But election.com didn't have the private key. Only once election was over, the encrypted set of data was given to the third party that was able to decrypt the votes. A single bit of error in the encrypted data would have led to not accepting that vote. It is remarkable that no single vote has been rejected.
|
||||
|
||||
Internet voting can only be one element of a legally binding election. To give everyone the same opportunity to vote, the Internet voting took place four days prior to Election Day. On the Election Day itself Internet voting was not allowed. The goal was to prevent anyone from waiting till the last second to vote via computer.
|
||||
|
||||
Internet voting is most useful on the small level where people able to sabotage the electronic voting process mostly don't bother. Still the PC from which the voting is performed is a security risk. Of the whole 96 hours available for Internet voting, the site wasn't available for one hour only due to a router problem. For each server there were backups to prevent data loss.
|
||||
|
||||
Learned lessions:
|
||||
|
||||
Many voters have an around-the-clock lifestyle and want to be among the first to vote online. Therefore even more servers are required to process the peak at the beginning.
|
||||
|
||||
Current browsers are required.
|
||||
|
||||
Internet voting at polling stations offers no extra value and increases the cost of elections.
|
||||
|
||||
When should Internet voting be used? In what manner and at what cost? These questions should be answered by politicians and the people who vote them, not technology developers and vendors.},
|
||||
Issue = {1},
|
||||
Journaltitle = {Communications of the ACM},
|
||||
Owner = {jim},
|
||||
Quality = {1},
|
||||
Timestamp = {2013.10.28}
|
||||
}
|
||||
|
||||
@ARTICLE{Watson2001,
|
||||
author = {Watson, Richard T. and Mundy, Bryan},
|
||||
title = {A strategic perspective of electronic democracy},
|
||||
journal = {Communications of the ACM},
|
||||
year = {2001},
|
||||
volume = {44},
|
||||
pages = {27-30},
|
||||
number = {1},
|
||||
month = {January},
|
||||
abstract = {E-Democracy can be introduced via a three phase structure. During
|
||||
initiation the citizens must get one portal that gives them access
|
||||
to all levels of government (from local residence to U.S. president
|
||||
or alike in other countries). This portal would give them all relevant
|
||||
info based upon their postal code. All they need to remember is the
|
||||
URL of the portal and their postal code which reduces searching effort
|
||||
significantly.
|
||||
|
||||
|
||||
Another important aspect is web-based payment. Around $3 trillion
|
||||
exchanges hands between governments and U.S. citizens each year.
|
||||
But the overwhelming majority happens via traditional checks, cash
|
||||
and money orders. Less than 0.5% are web-enabled. Web-bases payment
|
||||
allows for reduced travel to all the different agencies as many actions
|
||||
require physical presence nowadays. By reducing this travel the environment
|
||||
can profit from e-payment as well.
|
||||
|
||||
|
||||
In the second phase most governments adopt to the principles of e-government.
|
||||
Most payments are handled via the Web and governments become more
|
||||
efficient via two approaches. Small governments opt for an application
|
||||
service provider (ASP) solution whereas large governments implement
|
||||
in-house systems.
|
||||
|
||||
|
||||
Political decision making becomes more and more transparent. Citizens
|
||||
can find out what steps a certain peace of legislation takes from
|
||||
the first thoughts to signing the bill by the president. They can
|
||||
find out about all stakeholders of the process and who is involved.
|
||||
This gives citizens an inside perspective about the law making process
|
||||
and allows for increased citizen influence over the politicians.
|
||||
|
||||
|
||||
The final third phase is the customization and creates a one-to-one
|
||||
relation between government and citizen. Via a personal profile a
|
||||
citizen can manage all financial transactions with every government
|
||||
level. A change of address will be one transaction that notifies
|
||||
everyone involved. Even further it is possible to show the citizen
|
||||
how much of the paid taxes are used e.g. for education or national
|
||||
parks.
|
||||
|
||||
|
||||
This involvement into the process creates a much bigger attachment
|
||||
for democracy and the decision making process and abstracts away
|
||||
everything that one doesn't have to know.},
|
||||
issue = {1},
|
||||
journaltitle = {Communications of the ACM},
|
||||
owner = {jim},
|
||||
quality = {1},
|
||||
timestamp = {2013.10.28}
|
||||
@Article{Spirakis2010,
|
||||
Title = {The impact of electronic government on democracy: e-democracy through e-participation},
|
||||
Author = {Spirakis, Grigorios and Spiraki, Christina and Nikolopoulos, Konstantinos},
|
||||
Journal = {Electronic Government, An International Journey},
|
||||
Year = {2010},
|
||||
Number = {1},
|
||||
Pages = {75-88},
|
||||
Volume = {7},
|
||||
|
||||
Owner = {jim},
|
||||
Timestamp = {2013.12.30}
|
||||
}
|
||||
|
||||
@Article{Watson2001,
|
||||
Title = {A strategic perspective of electronic democracy},
|
||||
Author = {Watson, Richard T. and Mundy, Bryan},
|
||||
Journal = {Communications of the ACM},
|
||||
Year = {2001},
|
||||
|
||||
Month = {January},
|
||||
Number = {1},
|
||||
Pages = {27-30},
|
||||
Volume = {44},
|
||||
|
||||
Abstract = {E-Democracy can be introduced via a three phase structure. During initiation the citizens must get one portal that gives them access to all levels of government (from local residence to U.S. president or alike in other countries). This portal would give them all relevant info based upon their postal code. All they need to remember is the URL of the portal and their postal code which reduces searching effort significantly.
|
||||
|
||||
Another important aspect is web-based payment. Around $3 trillion exchanges hands between governments and U.S. citizens each year. But the overwhelming majority happens via traditional checks, cash and money orders. Less than 0.5% are web-enabled. Web-bases payment allows for reduced travel to all the different agencies as many actions require physical presence nowadays. By reducing this travel the environment can profit from e-payment as well.
|
||||
|
||||
In the second phase most governments adopt to the principles of e-government. Most payments are handled via the Web and governments become more efficient via two approaches. Small governments opt for an application service provider (ASP) solution whereas large governments implement in-house systems.
|
||||
|
||||
Political decision making becomes more and more transparent. Citizens can find out what steps a certain peace of legislation takes from the first thoughts to signing the bill by the president. They can find out about all stakeholders of the process and who is involved. This gives citizens an inside perspective about the law making process and allows for increased citizen influence over the politicians.
|
||||
|
||||
The final third phase is the customization and creates a one-to-one relation between government and citizen. Via a personal profile a citizen can manage all financial transactions with every government level. A change of address will be one transaction that notifies everyone involved. Even further it is possible to show the citizen how much of the paid taxes are used e.g. for education or national parks.
|
||||
|
||||
This involvement into the process creates a much bigger attachment for democracy and the decision making process and abstracts away everything that one doesn't have to know.},
|
||||
Issue = {1},
|
||||
Journaltitle = {Communications of the ACM},
|
||||
Owner = {jim},
|
||||
Quality = {1},
|
||||
Timestamp = {2013.10.28}
|
||||
}
|
||||
|
||||
|
||||
14
mk/feedback.txt
Normal file
14
mk/feedback.txt
Normal file
@ -0,0 +1,14 @@
|
||||
Feedback zu Vortrag Elektronische Demokratie
|
||||
|
||||
* roter Faden war nicht zu erkennen
|
||||
* Gesamtüberblick über Elektronische Demokratie
|
||||
* auf einen einzelnen Aspekt konzentrieren
|
||||
* aktuellere Quellen benutzen (z.B. Piratenpartei, etc.)
|
||||
* mehr Quellen
|
||||
* Vergleich basierend auf mehreren Quellen
|
||||
* Definition der Begriffe
|
||||
* miteinbeziehen des Publikums bei einem so populären Thema
|
||||
* mehr Strukturierung im Vortrag (eigenes Feedback) -> sonst zu schnell fertig und zu viel Ausgedachtes
|
||||
* Überblick mithilfe von unterschiedlichen Quellen zur Verfügung stellen
|
||||
* Klare Differenzierung zwischen E-Democracy und E-Government
|
||||
* sinnvolle Beispiele (was hat Star Citizen/Crowdfunding auch nur annähernd mit der vorgestellten Elektronischen Demokratie zu tun?)
|
||||
@ -8,7 +8,7 @@
|
||||
\newcommand{\trmatrikelnummer}{6420323}
|
||||
\newcommand{\tremail}{2martens@informatik.uni-hamburg.de}
|
||||
\newcommand{\trarbeitsbereich}{}
|
||||
\newcommand{\trdate}{10.02.2014}
|
||||
\newcommand{\trdate}{06.11.2013}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Languages:
|
||||
@ -151,8 +151,8 @@
|
||||
\Large\trcourse\\
|
||||
[1.5cm]
|
||||
\Large \trauthor\\
|
||||
[0.2cm]
|
||||
\normalsize Matr.Nr. \trmatrikelnummer\\
|
||||
% [0.2cm]
|
||||
% \normalsize Matr.Nr. \trmatrikelnummer\\
|
||||
[0.2cm]
|
||||
\normalsize\tremail\\
|
||||
[1.5cm]
|
||||
@ -171,7 +171,7 @@
|
||||
|
||||
% Abstract gives a brief summary of the main points of a paper:
|
||||
\section*{Abstract}
|
||||
Demokratie ist eine wichtige Errungenschaft der Menschheit. In diesem Paper wird die Erweiterung von Demokratie auf das Internet kritisch diskutiert, um anschließend zu einem Fazit zu gelangen.
|
||||
Elektronische Demokratie bietet viele Chancen zur Verbesserung der vorhandenen Interaktion mit Regierungen in Demokratien. Allerdings birgt sie auch einige Risiken, die jedoch nicht unüberwindbar sind.
|
||||
|
||||
% Lists:
|
||||
\setcounter{tocdepth}{2} % depth of the table of contents (for Seminars 2 is recommended)
|
||||
@ -189,76 +189,52 @@
|
||||
\section{Einleitung}
|
||||
\label{sec:introduction}
|
||||
|
||||
Es ist so ziemlich jedem bekannt was Demokratie ist. Demokratie bezeichnet die Herrschaft des Volkes und ist die Regierungsform in vielen Ländern, wie unter anderem die USA, Kanada, Frankreich und Deutschland. In jedem dieser Länder ist sie ein wenig anders organisiert, aber ihr Markenkern ist derselbe. Durch das Aufkommen vom Internet hat sich die Bezahlkultur längst gewandelt. Viele Menschen bestellen sich Waren aus dem Internet von Firmen wie Amazon und bekommen die Waren dann an die Tür geliefert.
|
||||
Elektronische Demokratie hat viele Bedeutungen. Die wohl eingängigste ist das Verlagern des Wahlvorganges selber auf Computer oder sogar das Internet.\cite{Mohen2001} Solch ein Vorgehen ist mit vielen Hürden verbunden, da sichergestellt werden muss, dass die Wahl nicht gefälscht werden kann, keine versehentliche doppelte Stimmabgabe möglich ist und nur Wahlberechtigte abstimmen können. Ein solches Vorgehen wird von Mohen\cite{Mohen2001} anhand einer Fallstudie aus Arizona beschrieben. Diese Art des elektronischen Wählens wird auch E-Voting genannt.\cite{Spirakis2010}
|
||||
|
||||
Diese Form des webbasierten Bezahlens nennt sich "`E-Commerce"'. Was passiert aber, wenn die Demokratie auf eben jenes Internet erweitert wird? Dabei sind nicht losgelöste Abstimmungen gemeint, sondern die Erweiterung der Demokratie in den Staaten auf das Internet. In welcher Form kann dies geschehen? Ist es überhaupt vernünftig?
|
||||
Allerdings ist dies nur ein Aspekt von elektronischer Demokratie (E-Democracy). E-Democracy hat weitaus mehr Bedeutungen. Watson\cite{Watson2001} beschreibt eine strategische Perspektive zur Umsetzung von elektronischer Demokratie. Für ihn gehört zu E-Democracy ebenso auch E-Government und E-Politics.
|
||||
|
||||
Es gibt reichlich Fragen zu diesem Thema. Im Rahmen dieses Papers wird eine Begriffserklärung für elektronische Demokratie versucht, um dann auf Basis dieses Begriffes ein Konzept von Watson\cite{Watson2001} kritisch zu diskutieren und abschließend zu einem Fazit zu kommen.
|
||||
Eine weitere Sicht auf E-Democracy wird durch Spirakis\cite{Spirakis2010} vorgenommen. Dabei wird der Einfluss von E-Government auf die Demokratie in den Fokus genommen und Literatur in drei Teilen analysiert: (a) der Definition und Bedeutung von E-Government, (b) der Informationspolitik und (c) E-Democracy durch Information und E-Participation.
|
||||
|
||||
\section{Begriffserklärung}
|
||||
\label{sec:definition}
|
||||
In diesem Paper werden Erkenntnisse von Spirakis vorgestellt und schließlich die Chancen und Risiken von E-Democracy anhand von Spirakis beleuchtet. Abschließend wird ein Fazit gezogen.
|
||||
|
||||
\section{Erkenntnisse Spirakis}
|
||||
\label{sec:erkenntnisseSpirakis}
|
||||
|
||||
Elektronische Demokratie ist also die irgendwie geartete Erweiterung der bestehenden analogen Demokratie auf das Internet. Aber wie läuft das eigentlich genau ab?
|
||||
\subsection*{Definition von E-Government}
|
||||
E-Government beschreibt die Nutzung von Informations- und Kommunikationstechnologien (IKT) während der Transformation von Regierungen zur Verbesserung der Barrierefreiheit, Effektivität und Verantwortung. Laut des Europäischen Kommittees des norwegischen Parlaments kann diese Transformation mit Veränderungen der Organisation und neuen Fähigkeiten einhergehen, sodass die öffentlichen Dienste verbessert werden, die demokratische Teilhabe vergrößert und die Implementation von öffentlichen Richtlinien gestärkt wird.\cite{Spirakis2010}
|
||||
|
||||
Diese Frage wird zum Teil durch Watson\cite{Watson2001} geklärt. Er erläutert eine strategische Perspektive zur Einführung von elektronischer Demokratie. Diese Einführung findet in Form eines 3-Phasen-Modells statt.
|
||||
Die Kernpunkte seines Konzeptes sind die Bündelung der Informationen über die einzelnen Regierungen in einem Land (von der Rathausebene bis hin zur Bundesebene) auf einer zentralen Internetseite und das Verwalten aller Amtsgeschäfte aus Bürgersicht über diese Internetseite. Diese beiden Punkte spiegeln Transparenz, Zugänglichkeit und Komfort wieder.
|
||||
|
||||
Kurz zusammengefasst bedeutet elektronische Demokratie also unter anderem, dass das Abwickeln der Amtsgeschäfte vereinheitlicht und damit vereinfacht wird und die Bürger alle Informationen an zentraler Stelle finden können und nicht erst zig Seiten und Amtsstellen abklappern müssen.
|
||||
|
||||
Diese Sicht auf elektronische Demokratie ist mit Sicherheit nicht abschließend. Es gibt auch noch den Punkt des elektronischen Wählens, wie ihn Mohen\cite{Mohen2001} anhand einer Fallstudie aus Arizona (USA) beschreibt.
|
||||
|
||||
Daran wird deutlich, dass elektronische Demokratie weit mehr ist als das, was Watson in seinem Artikel beschreibt.
|
||||
|
||||
\section{Kritische Diskussion}
|
||||
\label{sec:critDisc}
|
||||
\subsection*{Bedeutung von E-Government}
|
||||
|
||||
Die von Watson\cite{Watson2001} erläuterte strategische Perspektive klingt auf den ersten Blick sehr verlockend. Allerdings hat auch diese Idee ihre negativen Auswirkungen. In der folgenden Diskussion werden die Vor- und Nachteile von Watsons Idee gegenübergestellt. Die Pro-Argumente werden dabei aus Watsons Idee übernommen, schließlich stellt er diese Perspektive nicht vor weil sie in seinen Augen unzureichend ist, wohingegen die Contra-Argumente aus der Perspektive des Autoren dieses Papers dargelegt werden. Daraus kann jedoch nicht die Position des Autoren zu dieser Idee gefolgert werden.
|
||||
E-Government bietet wichtige Vorteile auf nationaler Ebene, wie z.B. effektiven Zugang zu den öffentlichen Diensten, Kostenreduzierung öffentlicher Dienste und erhöhte Zugangsmöglichkeiten von Bürgern für Informationen bezüglich dem nationalen Budget und anderen Regierungstätigkeiten.\cite{Spirakis2010}
|
||||
|
||||
Der erste Schritt Watsons ist die Schaffung eines zentralen Portals, von wo aus die Bürger je nach Postleitzahl zu allen relevanten Stellen verlinkt werden.
|
||||
\subsection*{Informationspolitik}
|
||||
|
||||
Der Vorteil dieses zentralen Einstiegspunktes ist offensichtlich. Die Bürger müssen sich nur noch eine URL und ihre Postleitzahl merken, um alle notwendigen Informationen zu finden.
|
||||
Es gibt keine eindeutige Definition von "`Informationspolitik"' und im Paper von Spirakis\cite{Spirakis2010} zeichnet sich auch nicht einmal eine Richtung ab. Da der Begriff der Informationspolitik bei Watson so in der Form nicht auftaucht, wird hier nicht weiter darauf eingegangen.
|
||||
|
||||
Einen direkten Nachteil gibt es dort nicht, denn die darunter liegenden Websites der einzelnen Regierungen und staatlichen Stellen existieren weiterhin. Durch den single-point-of-entry wird jedoch das Auffinden der zuständigen Stellen erheblich erleichtert.
|
||||
\subsection*{Elektronische Demokratie}
|
||||
|
||||
Elektronische Demokratie beinhaltet technische Innovationen, die eine Verbesserung und Stärkung demokratischer Institutionen mit oder ohne Benutzung des Internets erlauben. E-Democracy ist ein Mechanismus basierend auf IKT, der es Bürgern erlaubt aktiv am Entscheidungsprozess für öffentliche Angelegenheiten mitzuwirken.\cite{Spirakis2010}
|
||||
|
||||
Im zweiten Schritt haben die meisten Regierungen die Prinzipien von "`E-Government"' übernommen. Damit haben Bürger die Möglichkeit den Großteil ihrer Finanztransaktionen mit staatlichen Stellen über das Internet abzuwickeln. Kleine Regierungen und staatliche Stellen benutzen dabei dritte Dienstleister, um diesen Service anzubieten, wohingegen größere Regierungen und staatliche Stellen eigene Lösungen benutzen.
|
||||
Das Modell von E-Democracy beinhaltet vier Schritte. Im ersten Schritt machen die meisten Regierungsorganisationen Informationen im Internet verfügbar. Durch den zweiten Schritt entwickelt sich eine Kommunikation in beide Richtungen: von der Regierung zu den Bürgern und umgekehrt. Der dritte Schritt meint den Wandel von Kommunikation zu Zusammenarbeit. Schließlich zeigt der vierte Schritt den Einfluss der Bürger auf das Resultat des Entscheidungsprozesses.\cite{Spirakis2010}
|
||||
|
||||
\section{Chancen und Risiken von E-Democracy}
|
||||
\label{sec:chanceRisk}
|
||||
|
||||
E-Democracy hat wie jede Sache Chancen und Risiken. Inwieweit diese umgesetzt werden können bzw. eintreffen hängt von dem jeweiligen staatlichen Gebilde und dessen Rahmenbedingungen ab.\cite{Spirakis2010}
|
||||
|
||||
Der Vorteil ist die starke Vereinfachung der Interaktion mit dem Staat. Durch die Einsparung von physischen Besuchen bei den Ämtern sparen Bürger Zeit und Kosten und das Regieren wird effizienter.
|
||||
Dabei ist keine Sache perfekt, auch nicht Demokratie. Es gibt einen andauernden Prozess neuer Herausforderungen für Bürger und Regierungen. Die womöglich wichtigste Herausforderung ist die aktive Teilnahme der Bürger am politischen Prozess, denn traditionelle repräsentative Demokratien beschränken die Aktivität der Bürger meist auf das Wählen.\cite{Spirakis2010}
|
||||
|
||||
Der Nachteil ist, dass damit viele Mitarbeiter im staatlichen Dienst ebenfalls obsolet werden. Es werden keine Mitarbeiter mehr benötigt, die Überweisungen entgegen nehmen oder vor Ort Informationen an Bürger weitergeben.
|
||||
E-Democracy ermöglicht die aktivere Teilnahme von Bürgern am politischen Geschehen und verbessert die Kommunikation und schlussendlich die Zusammenarbeit zwischen Bürgern und Regierung, sowie Bürgern und Bürgern. Dies geschieht sowohl auf nationaler als auch auf subnationaler Ebene. Allerdings ist eine wichtige Voraussetzung für E-Democracy, dass die demokratischen Prinzipien, wie Meinungsfreiheit, Menschenrechte und Gesetz eingehalten werden. Denn E-Democracy kann nur ein Instrument oder Werkzeug für den politischen Entscheidungsprozess sein. Diese Einschränkungen sind nötig, damit das volle Potenzial ausgeschöpft werden kann.\cite{Spirakis2010}
|
||||
|
||||
Auf Seiten der Effizienz wird die politische Entscheidungsfindung zunehmend transparenter. Bürger können am Prozess teilhaben und herausfinden, wie zukünftige Gesetze entstehen. Dabei erfahren sie auch welche politischen Interessensgruppen, Industrievertreter, Lobbyisten und Politiker diese zukünftigen Gesetze entwerfen. Darüber hinaus können sie erfahren warum bestimmte Gruppen versuchen politische Vorteile zu bekommen.
|
||||
Allerdings gibt es auch einige Risiken oder Nachteile von E-Democracy. So basiert es auf Informatik, der damit verbundenen Software und der Möglichkeit von Bürgern auf diese elektronischen Dienste zuzugreifen. Wird in Betracht gezogen, dass Teile der Bevölkerung arm und schlecht gebildet sind, dann ergibt sich ein großer Nachteil, denn diese Bevölkerungsgruppen sind von E-Democracy ausgeschlossen. Die Kosten von Computern und anderen notwendigen technischen Geräten, sowie die Verfügbarkeit einer Internetverbindung sind Hauptfaktoren bei der Implementation von E-Democracy. Desweiteren ist die Technologieabdeckung auf die Welt bezogen längst nicht homogen. Viele isolierte Gebiete haben keinen Anschluss an das Internet oder neue Technologien im Allgemeinen. Dies birgt ein großes Risiko bei der Umsetzung von E-Democracy.\cite{Spirakis2010}
|
||||
|
||||
Für Bürger ist diese Steigerung an Transparenz ganz klar ein Vorteil. Durch einen transparenten Gesetzesfindungsprozess können einseitige Lobbyinteressen viel schwieriger durchgesetzt werden. Bürger haben zeitig die Möglichkeit zu intervenieren, wenn Gesetze nicht ihren Wünschen entsprechen. Damit wird den Bürgern effektiv auch eine Möglichkeit gegeben eine Lobby zu sein.
|
||||
|
||||
Bedenkenswert sind die dafür nötigen impliziten Schritte. Dafür müssen Sitzungsprotokolle von Ausschüssen sowie die Telefonate und Schriftwechsel aller Politiker veröffentlicht werden. Dies stellt einen gravierenden Einschnitt in die Privatsphäre dar und erfordert in vielen Demokratien weitgehende Änderungen. Somit ist dieses Vorhaben trotz der hehren Ziele wohl vorerst nicht erreichbar. Gerade vor dem Hintergrund des sog. NSA-Skandals ist eine solche Transparenz des Gesetzgebungsverfahrens wohl auf absehbare Zeit unrealistisch.
|
||||
Fairerweise muss gesagt werden, dass auch Watson auf diesen Missstand hinweist.
|
||||
|
||||
Der letzte Schritt bzw. die letzte Phase ist die Errichtung einer eins-zu-eins Beziehung zwischen Staat und Bürger. Alle Bürger haben ein elektronisch verwaltetes Konto über das alle Finanz- oder sonstigen Transaktionen mit dem Staat abgewickelt werden. Eine Adressänderung wäre somit eine einzige Transaktion, die dann alle beteiligten staatlichen Stellen automatisch benachrichtigen würde.
|
||||
Desweiteren bekommen Bürger in dieser Phase eine detaillierte Auflistung wofür ihre Zahlungen verwendet werden. So könnte eingesehen werden, wie viel der Steuern bspw. für Bildung ausgegeben werden.
|
||||
|
||||
Diese Phase bietet eine weitere Vereinfachung der Interaktion mit dem Staat, was ein klarer Vorteil ist. Durch die individuelle Auflistung der Verwendung der Steuern und Abgaben für jeden Bürger wird die Bedeutung eben jener Abgaben deutlich. Es ist für jeden Bürger ersichtlich was er mit seinen Abgaben unterstützt. Damit wird die Verbindung zwischen Steuerzahlungen und Wertschaffung explizit und nachvollziehbar.
|
||||
|
||||
Es gibt aber auch hier einige Bedenken. Wenn jeder Bürger alle offiziellen Tätigkeiten über ein zentrales Profil abwickelt, dann wird Identitätsdiebstahl sehr viel einfacher. Auch sind die Daten von Bürgern weitaus gefährdeter. Wenn die Datenbank mit den Daten gehackt wird, dann besteht Zugriff auf alle Daten aller Bürger, die dann meistbietend verkauft werden könnten.
|
||||
|
||||
Außerdem erlaubt dies auch für den Staat Einblicke in Sachverhalte, die ihn nichts angehen. Durch die Kombination aller staatlichen Interaktion in einem einzigen Konto, können viel leichter Profile über Personen erstellt werden. Geheimdienste hätten so auf einen Schlag alle interessanten Informationen an einem Platz.
|
||||
|
||||
Der letzte Schritt in Watsons Idee umfasst eine weitere Individualisierung. So können Bürger auswählen welche Themenfelder sie interessieren und darüber auf dem Laufen gehalten werden. Wenn sich jemand für Trends in der Verwaltung von Nationalparks interessiert, könnte er sich eines elektronischen Lobbyagenten oder Lobbybots bedienen, um dieses Themengebiet zu beobachten und den politischen Prozess zu beeinflussen.
|
||||
|
||||
Der Vorteil ist auch hier klar erkennbar. Bürger können sich aus der Fülle an Informationen die Bereiche herausnehmen, die für sie interessant sind und sich somit spezialisieren. Dies ermöglicht aktive Teilhabe am politischen Prozess ohne selber aktiv in der Politik zu sein. Damit ist die Integration der Bevölkerung in die Gesetzesfindung weitaus besser als vorher.
|
||||
|
||||
Der Vorteil ist hier der Nachteil zugleich. Denn durch die Möglichkeit der Präferenz ist es umso leichter zu ermitteln wer sich für welche Themen interessiert. Damit können oben genannte Profile weiter verfeinert werden und in Verbindung mit anderen Daten von Bürgern zu ernsthaften Problemen führen. Geheimdienste könnten diese Informationen in Verbindung mit gespeicherten Emails dazu nutzen Bürger aufgrund ihrer politischen Partizipation zu verfolgen.
|
||||
|
||||
Wenn ein Bürger sich zum Beispiel für Außenpolitik interessiert (als Präferenz in dem zentralen Konto) und sich gleichzeitig in Gesprächen mit Freunden positiv gegenüber suspekten Staaten äußert (bspw. Iran im Falle der USA), könnten die Geheimdienste vermuten, dass dieser Bürger eventuell ein Spion des Irans (in diesem Beispiel) ist. Ein komplett unschuldiger Bürger kann somit in das Fadenkreuz von entsprechenden Diensten kommen, nur wegen politischer Partizipation und einer Meinung, die nicht der offiziellen Linie der Regierung entspricht.
|
||||
|
||||
Alleine die Möglichkeit eines solchen Beispiels ist schon sehr bedenklich in einer Demokratie.
|
||||
\section{Auswertung}
|
||||
\section{Fazit}
|
||||
\label{sec:concl}
|
||||
|
||||
In der Diskussion um die Vor- und Nachteile von Watsons 3-Phasen-Konzepts ist deutlich geworden, dass es unter guten Umständen sehr helfen kann die Demokratie zu verbessern. Es ist aber auch deutlich geworden, dass eben jenes Konzept in der Lage ist die Demokratie noch weiter zu gefährden.
|
||||
E-Democracy bietet riesige Chancen für die positive Entwicklung einer Gesellschaft, indem sich Regierungen und Bürger auf Augenhöhe begegnen und als Partner ansehen und nicht als Gegner.
|
||||
Dafür ist es aber nötig, dass alle Bürger Zugang zu E-Democracy haben, was durch deren Abhängigkeit von Computertechnologie zur Zeit noch sehr schwierig ist. Mit der Entwicklung eines kostengünstigen Systems für E-Democracy kann dies jedoch behoben werden.
|
||||
|
||||
Abschließend kann daher hier weder behauptet werden, dass dieses Konzept sofort umgesetzt werden sollte, noch dass es keinen weiteren Gedanken verdient. Das Konzept zeigt eine Möglichkeit der Veränderung auf, die in Teilen heute (12 Jahre später) bereits vorhanden ist. In jedem Falle kann es als Diskussionsgrundlage für Veränderungen in der Umsetzung von Demokratie dienen.
|
||||
|
||||
Es ist in Zukunft unvermeidbar mehr und mehr die Demokratie auch über das Internet verfügbar zu machen. Entsprechende Änderungen müssen aber sorgsam und mit Rücksicht auf integrale Prinzipien der Demokratie durchgeführt werden.
|
||||
Von zentraler Wichtigkeit ist, dass die demokratischen Prinzipien auch für E-Democracy gelten.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% hier werden - zum Ende des Textes - die bibliographischen Referenzen
|
||||
|
||||
216
optimierung/Uebungsblatt10.tex
Normal file
216
optimierung/Uebungsblatt10.tex
Normal file
@ -0,0 +1,216 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\usepackage{multirow}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
% ensures that paragraphs are separated by empty lines
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
% define how the sections are rendered
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
% some matrix magic
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
|
||||
\begin{document}
|
||||
\author{Jan Branitz (6326955), Jim Martens (6420323),\\
|
||||
Stephan Niendorf (6242417)}
|
||||
\title{Hausaufgaben zum 6. Januar}
|
||||
\maketitle
|
||||
\section{} %1
|
||||
\begin{tikzpicture}[node distance=2cm]
|
||||
\node (s) {s};
|
||||
\node (a) [above right=of s] {a};
|
||||
\node (b) [right=of s] {b};
|
||||
\node (c) [below right=of s] {c};
|
||||
\node (d) [right=of c] {d};
|
||||
\node (e) [right=of b] {e};
|
||||
\node (t) [right=of e] {t};
|
||||
\node (sCap) [below=0.1 of s] {(-, $\infty$)};
|
||||
\node (aCap) [above=0.1 of a] {(s, +, 3)};
|
||||
\node (bCap) [below=0.1 of b] {(s, +, 5)};
|
||||
\node (cCap) [below=0.1 of c] {(s, +, 6)};
|
||||
\node (tCap) [above=0.1 of t] {(a, +, 3)};
|
||||
\path[->] (s) edge[line width=2pt] node [above left] {0(3)} (a)
|
||||
(s) edge node [below] {0(5)} (b)
|
||||
(s) edge node [below left] {0(6)} (c)
|
||||
(a) edge[line width=2pt] node [above right] {0(5)} (t)
|
||||
(a) edge node [left] {0(4)} (b)
|
||||
(b) edge node [below] {0(2)} (e)
|
||||
(b) edge node [below left] {0(6)} (d)
|
||||
(c) edge node [below] {0(4)} (d)
|
||||
(d) edge node [below right] {0(5)} (t)
|
||||
(e) edge node [below] {0(3)} (t);
|
||||
\end{tikzpicture}
|
||||
|
||||
\begin{tikzpicture}[node distance=2cm]
|
||||
\node (s) {s};
|
||||
\node (a) [above right=of s] {a};
|
||||
\node (b) [right=of s] {b};
|
||||
\node (c) [below right=of s] {c};
|
||||
\node (d) [right=of c] {d};
|
||||
\node (e) [right=of b] {e};
|
||||
\node (t) [right=of e] {t};
|
||||
\node (sCap) [below=0.1 of s] {(-, $\infty$)};
|
||||
\node (bCap) [below=0.1 of b] {(s, +, 5)};
|
||||
\node (cCap) [below=0.1 of c] {(s, +, 6)};
|
||||
\node (dCap) [below=0.1 of d] {(b, +, 5)};
|
||||
\node (eCap) [below=0.1 of e] {(b, +, 2)};
|
||||
\node (tCap) [above=0.1 of t] {(d, +, 5)};
|
||||
\path[->] (s) edge node [above left] {3(3)} (a)
|
||||
(s) edge[line width=2pt] node [below] {0(5)} (b)
|
||||
(s) edge node [below left] {0(6)} (c)
|
||||
(a) edge node [above right] {3(5)} (t)
|
||||
(a) edge node [left] {0(4)} (b)
|
||||
(b) edge node [below] {0(2)} (e)
|
||||
(b) edge[line width=2pt] node [below left] {0(6)} (d)
|
||||
(c) edge node [below] {0(4)} (d)
|
||||
(d) edge[line width=2pt] node [below right] {0(5)} (t)
|
||||
(e) edge node [below] {0(3)} (t);
|
||||
\end{tikzpicture}
|
||||
|
||||
\begin{tikzpicture}[node distance=2cm]
|
||||
\node (s) {s};
|
||||
\node (a) [above right=of s] {a};
|
||||
\node (b) [right=of s] {b};
|
||||
\node (c) [below right=of s] {c};
|
||||
\node (d) [right=of c] {d};
|
||||
\node (e) [right=of b] {e};
|
||||
\node (t) [right=of e] {t};
|
||||
\node (sCap) [below=0.1 of s] {(-, $\infty$)};
|
||||
\node (eCap) [below=0.1 of e] {(b, +, 2)};
|
||||
\node (cCap) [below=0.1 of c] {(s, +, 6)};
|
||||
\node (dCap) [below=0.1 of d] {(c, +, 4)};
|
||||
\node (tCap) [above=0.1 of t] {(e, +, 2)};
|
||||
\node (bCap) [below=0.1 of b] {(d, -, 4)};
|
||||
\path[->] (s) edge node [above left] {3(3)} (a)
|
||||
(s) edge node [below] {5(5)} (b)
|
||||
(s) edge[line width=2pt] node [below left] {0(6)} (c)
|
||||
(a) edge node [above right] {3(5)} (t)
|
||||
(a) edge node [left] {0(4)} (b)
|
||||
(b) edge[line width=2pt] node [below] {0(2)} (e)
|
||||
(b) edge[line width=2pt] node [below left] {5(6)} (d)
|
||||
(c) edge[line width=2pt] node [below] {0(4)} (d)
|
||||
(d) edge node [below right] {5(5)} (t)
|
||||
(e) edge[line width=2pt] node [below] {0(3)} (t);
|
||||
\end{tikzpicture}
|
||||
|
||||
\begin{tikzpicture}[node distance=2cm]
|
||||
\node (s) {s};
|
||||
\node (a) [above right=of s] {a};
|
||||
\node (b) [right=of s] {b};
|
||||
\node (c) [below right=of s] {c};
|
||||
\node (d) [right=of c] {d};
|
||||
\node (e) [right=of b] {e};
|
||||
\node (t) [right=of e] {t};
|
||||
\node (sCap) [below=0.1 of s] {(-, $\infty$)};
|
||||
\node (cCap) [below=0.1 of c] {(s, +, 4)};
|
||||
\node (dCap) [below=0.1 of d] {(c, +, 2)};
|
||||
\node (bCap) [below=0.1 of b] {(d, -, 2)};
|
||||
\path[->] (s) edge node [above left] {3(3)} (a)
|
||||
(s) edge node [below] {5(5)} (b)
|
||||
(s) edge node [below left] {2(6)} (c)
|
||||
(a) edge node [above right] {3(5)} (t)
|
||||
(a) edge node [left] {0(4)} (b)
|
||||
(b) edge node [below] {2(2)} (e)
|
||||
(b) edge node [below left] {3(6)} (d)
|
||||
(c) edge node [below] {2(4)} (d)
|
||||
(d) edge node [below right] {5(5)} (t)
|
||||
(e) edge node [below] {2(3)} (t);
|
||||
\end{tikzpicture}
|
||||
\section{} %2
|
||||
\subsection{} %a
|
||||
\begin{alignat*}{9}
|
||||
\text{minimiere}\; & 67w &+& 120k &+& 100h &+& 60f &+& 97b &+& 124n &+& 22s &+& 62m && \\
|
||||
\multicolumn{18}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
& 8w &+& 25k &+& 30h &+& 22f &+& 3b &+& 8n &+& 6s && &\geq &\, 75 \\
|
||||
& w &+& 35k &+& 8h &+& f && &+& 33n &+& 13s &+& 98m &\geq &\, 90 \\
|
||||
& 54w && && && &+& 42b &+& 4n &+& 63s && &\geq &\, 300 \\
|
||||
\multicolumn{16}{r}{$w, k, h, f, b, n, s, m$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
\subsection{} %b
|
||||
In das verlinkte Tool wird folgendes eingegeben:
|
||||
\begin{verbatim}
|
||||
Minimize p = 67w + 120k + 100h + 60f + 97b + 124n + 22s + 62m subject to
|
||||
8w + 25k + 30h + 22f + 3b + 8n + 6s + 0m >= 75
|
||||
w + 35k + 8h + f + 0b + 33n + 13s + 98m >= 90
|
||||
54w + 0k + 0h + 0f + 42b + 4n + 63s + 0m >= 300
|
||||
w >= 0
|
||||
k >= 0
|
||||
h >= 0
|
||||
f >= 0
|
||||
b >= 0
|
||||
n >= 0
|
||||
s >= 0
|
||||
m >= 0
|
||||
\end{verbatim}
|
||||
Die Ausgabe ist:
|
||||
\begin{verbatim}
|
||||
Optimal Solution: p = 6801/28; w = 0, k = 0, h = 0, f = 87/56,
|
||||
b = 0, n = 0, s = 381/56, m = 0
|
||||
\end{verbatim}
|
||||
\subsection{} %c
|
||||
In das verlinkte Tool wird folgendes eingegeben:
|
||||
\begin{verbatim}
|
||||
Minimize p = 3x1 + 24x2 + 13x3 + 9x4 + 20x5 + 19x6 subject to
|
||||
110x1 + 205x2 + 160x3 + 160x4 + 420x5 + 260x6 >= 2000
|
||||
4x1 + 32x2 + 13x3 + 8x4 + 4x5 + 14x6 >= 55
|
||||
2x1 + 12x2 + 54x3 + 285x4 + 22x5 + 80x6 >= 800
|
||||
x1 <= 4
|
||||
x2 <= 3
|
||||
x3 <= 2
|
||||
x4 <= 8
|
||||
x5 <= 2
|
||||
x6 <= 2
|
||||
x1 >= 0
|
||||
x2 >= 0
|
||||
x3 >= 0
|
||||
x4 >= 0
|
||||
x5 >= 0
|
||||
x6 >= 0
|
||||
\end{verbatim}
|
||||
Die Ausgabe ist:
|
||||
\begin{verbatim}
|
||||
Optimal Solution: p = 185/2; x1 = 4, x2 = 0, x3 = 0, x4 = 9/2, x5 = 2, x6 = 0
|
||||
\end{verbatim}
|
||||
\subsection{} %d
|
||||
In das verlinkte Tool wird folgendes eingegeben:
|
||||
\begin{verbatim}
|
||||
Maximize p = 8a1 + 3a2 + 6b1 + 3b2 + 9c1 + 5c2 subject to
|
||||
a1 + a2 <= 400
|
||||
b1 + b2 <= 480
|
||||
c1 + c2 <= 230
|
||||
a1 + b1 + c1 <= 420
|
||||
a2 + b2 + c2 <= 250
|
||||
a1 >= 0
|
||||
a2 >= 0
|
||||
b1 >= 0
|
||||
b2 >= 0
|
||||
c1 >= 0
|
||||
c2 >= 0
|
||||
\end{verbatim}
|
||||
Die Ausgabe ist:
|
||||
\begin{verbatim}
|
||||
Optimal Solution: p = 4550; a1 = 400, a2 = 0, b1 = 0, b2 = 40,
|
||||
c1 = 20, c2 = 210
|
||||
\end{verbatim}
|
||||
\end{document}
|
||||
105
optimierung/Uebungsblatt11.tex
Normal file
105
optimierung/Uebungsblatt11.tex
Normal file
@ -0,0 +1,105 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\usepackage{multirow}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
% ensures that paragraphs are separated by empty lines
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
% define how the sections are rendered
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
% some matrix magic
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
|
||||
\begin{document}
|
||||
\author{Jan Branitz (6326955), Jim Martens (6420323),\\
|
||||
Stephan Niendorf (6242417)}
|
||||
\title{Hausaufgaben zum 13. Januar}
|
||||
\maketitle
|
||||
\section{} %1
|
||||
\subsection{} %a
|
||||
\subsubsection{} %i
|
||||
Die Knoten werden in der Reihenfolge a, b, f, c, d, g, e und t markiert.
|
||||
|
||||
\begin{tabular}{c|c}
|
||||
Knoten & Markierung \\
|
||||
\hline
|
||||
s & $(-, \infty)$ \\
|
||||
a & (s, +, 38) \\
|
||||
b & (s, +, 1) \\
|
||||
f & (s, +, 2) \\
|
||||
c & (a, +, 10) \\
|
||||
d & (a, +, 38) \\
|
||||
g & (f, +, 2) \\
|
||||
e & (c, +, 10) \\
|
||||
t & (c, +, 10)
|
||||
\end{tabular}
|
||||
|
||||
Es gibt keine Knoten, die unmarkiert bleiben.
|
||||
\subsubsection{} %ii
|
||||
%s, a, b, f, d, c, g, e, t
|
||||
Der Pfad $f_{0}$ führt von s über a und c nach t. Der verbesserte Fluss $f_{1}$ weist die folgenden Markierungen auf.
|
||||
|
||||
\begin{tabular}{c|c}
|
||||
Knoten & Markierung \\
|
||||
\hline
|
||||
s & $(-, \infty)$ \\
|
||||
a & (s, +, 28) \\
|
||||
b & (s, +, 1) \\
|
||||
f & (s, +, 2) \\
|
||||
d & (a, +, 28) \\
|
||||
c & (b, +, 1) \\
|
||||
g & (f, +, 2) \\
|
||||
e & (d, +, 1) \\
|
||||
t & (d, +, 7)
|
||||
\end{tabular}
|
||||
\subsection{} %b
|
||||
Die Knoten, die zu S gehören, sind markiert und die Knoten, die zu T gehören, sind nicht markiert.
|
||||
\subsection{} %c
|
||||
(i) ist wahr und (ii) ist falsch.
|
||||
\subsection{} %d
|
||||
In jedem Graphen gilt $m(G) \leq c(G)$ (siehe Skript Seite 121, 11.1), weswegen (ii) falsch ist. Solange mindestens zwei Knoten nicht zum Matching gehören (je mindestens einer in X und einer in Y), können diese im besten Fall durch eine neue Matchingkante dem Matching hinzugefügt werden. In diesem Fall ist die Matchingzahl $m(G)$ also mindestens um eins höher als ein unter den beschriebenen Voraussetzungen vorhandenes Matching.
|
||||
\section{} %2
|
||||
\subsection{} %a
|
||||
\begin{tabular}{c|l}
|
||||
Durchgang & Matching \\
|
||||
\hline
|
||||
1 & $M = \{\{x_{1}, y_{1}\}\}$ \\
|
||||
2 & $M = \{\{x_{1}, y_{1}\}, \{x_{2}, y_{2}\}\}$ \\
|
||||
3 & $M = \{\{x_{1}, y_{4}\}, \{x_{2}, y_{2}\}, \{x_{3}, y_{1}\}\}$ \\
|
||||
4 & $M = \{\{x_{1}, y_{4}\}, \{x_{2}, y_{3}\}, \{x_{3}, y_{1}\}, \{x_{4}, y_{2}\}\}$ \\
|
||||
5 & $M = \{\{x_{1}, y_{4}\}, \{x_{2}, y_{3}\}, \{x_{3}, y_{1}\}, \{x_{4}, y_{2}\}, \{x_{5}, y_{5}\}\}$ \\
|
||||
6 & $M = \{\{x_{1}, y_{4}\}, \{x_{2}, y_{3}\}, \{x_{3}, y_{1}\}, \{x_{4}, y_{2}\}, \{x_{5}, y_{5}\}, \{x_{6}, y_{6}\}\}$ \\
|
||||
\end{tabular}
|
||||
\subsection{} %b
|
||||
\begin{tabular}{c|l}
|
||||
Durchgang & Matching \\
|
||||
\hline
|
||||
1 & $M = \{\{x_{1}, y_{1}\}\}$ \\
|
||||
2 & $M = \{\{x_{1}, y_{1}\}, \{x_{2}, y_{2}\}\}$ \\
|
||||
3 & $M = \{\{x_{1}, y_{3}\}, \{x_{2}, y_{2}\}, \{x_{3}, y_{1}\}\}$ \\
|
||||
4 & $M = \{\{x_{1}, y_{3}\}, \{x_{2}, y_{2}\}, \{x_{3}, y_{1}\}, \{x_{4}, y_{4}\}\}$ \\
|
||||
5 & $M = \{\{x_{1}, y_{3}\}, \{x_{2}, y_{5}\}, \{x_{3}, y_{1}\}, \{x_{4}, y_{4}\}, \{x_{5}, y_{2}\}\}$ \\
|
||||
6 & $M = \{\{x_{1}, y_{3}\}, \{x_{2}, y_{5}\}, \{x_{3}, y_{1}\}, \{x_{4}, y_{4}\}, \{x_{5}, y_{2}\}, \{x_{6}, y_{6}\}\}$ \\
|
||||
\end{tabular}
|
||||
\end{document}
|
||||
138
optimierung/Uebungsblatt12.tex
Normal file
138
optimierung/Uebungsblatt12.tex
Normal file
@ -0,0 +1,138 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\usepackage{multirow}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
% ensures that paragraphs are separated by empty lines
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
% define how the sections are rendered
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
% some matrix magic
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
|
||||
\begin{document}
|
||||
\author{Jan Branitz (6326955), Jim Martens (6420323),\\
|
||||
Stephan Niendorf (6242417)}
|
||||
\title{Hausaufgaben zum 20. Januar}
|
||||
\maketitle
|
||||
\section{} %1
|
||||
\subsection{} %a
|
||||
\begin{tabular}{c|c|c|c|c|c|c|c|c}
|
||||
& s & a & b & c & d & e & f & S\\
|
||||
\hline
|
||||
0 & \underline{0} & 6s & 5s & 2s & $\infty$ & $\infty$ & $\infty$ & $\{s\}$ \\
|
||||
1 & \underline{0} & 6s & 4c & \underline{2}s & $\infty$ & 3c & 5c & $\{s,c\}$ \\
|
||||
2 & \underline{0} & 5e & 4c & \underline{2}s & $\infty$ & \underline{3}c & 4e & $\{s,c,e\}$ \\
|
||||
3 & \underline{0} & 5e & \underline{4}c & \underline{2}s & 8b & \underline{3}c & 4e & $\{s,c,e,b\}$ \\
|
||||
4 & \underline{0} & 5e & \underline{4}c & \underline{2}s & 8b & \underline{3}c & \underline{4}e & $\{s,c,e,b,f\}$ \\
|
||||
5 & \underline{0} & \underline{5}e & \underline{4}c & \underline{2}s & 7a & \underline{3}c & \underline{4}e & $\{s,c,e,b,f,a\}$ \\
|
||||
6 & \underline{0} & \underline{5}e & \underline{4}c & \underline{2}s & \underline{7}a & \underline{3}c & \underline{4}e & $\{s,c,e,b,f,a,d\}$ \\
|
||||
\end{tabular}
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (s) {s};
|
||||
\node (a) [above right=of s] {a};
|
||||
\node (b) [right=of s] {b};
|
||||
\node (c) [below right=of s] {c};
|
||||
\node (d) [right=of a] {d};
|
||||
\node (e) [right=of b] {e};
|
||||
\node (f) [right=of c] {f};
|
||||
|
||||
\path[->,line width=1pt] (s) edge node [below] {2} (c)
|
||||
(c) edge node [above] {1} (e)
|
||||
(c) edge node [left] {2} (b)
|
||||
(e) edge node [right] {1} (f)
|
||||
(e) edge node [below] {2} (a)
|
||||
(a) edge node [above] {2} (d);
|
||||
\end{tikzpicture}
|
||||
\subsection{} %b
|
||||
Als Graph G sei folgender Graph angenommen.
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (s) {s};
|
||||
\node (a) [above right=of s] {a};
|
||||
\node (b) [below right=of s] {b};
|
||||
\node (t) [below right=of a] {t};
|
||||
\path[->,line width=1pt] (s) edge node [above left] {-1} (a)
|
||||
(s) edge node [below] {1000} (t)
|
||||
(s) edge node [below left] {-999} (b)
|
||||
(a) edge node [above right] {2} (t)
|
||||
(b) edge node [below right] {1500} (t);
|
||||
\end{tikzpicture}
|
||||
|
||||
Als Konstante C werde 999 angenommen. Dadurch ergibt sich dieser modifizierte Graph $G'$.
|
||||
|
||||
\begin{tikzpicture}
|
||||
\node (s) {s};
|
||||
\node (a) [above right=of s] {a};
|
||||
\node (b) [below right=of s] {b};
|
||||
\node (t) [below right=of a] {t};
|
||||
\path[->,line width=1pt] (s) edge node [above left] {998} (a)
|
||||
(s) edge node [below] {1999} (t)
|
||||
(s) edge node [below left] {0} (b)
|
||||
(a) edge node [above right] {1001} (t)
|
||||
(b) edge node [below right] {2499} (t);
|
||||
\end{tikzpicture}
|
||||
|
||||
Wendet man nun Dijkstra auf diesen modifizierten Graphen an, dann ergibt sich diese Tabelle.
|
||||
|
||||
\begin{tabular}{c|c|c|c|c|c}
|
||||
& s & a & b & t & S\\
|
||||
\hline
|
||||
0 & \underline{0} & 998s & 0s & 1999s & $\{s\}$ \\
|
||||
1 & \underline{0} & 998s & \underline{0}s & 1999s & $\{s,b\}$ \\
|
||||
2 & \underline{0} & \underline{998}s & \underline{0}s & 1999s & $\{s,b,a\}$ \\
|
||||
3 & \underline{0} & \underline{998}s & \underline{0}s & \underline{1999}s & $\{s,b,a,t\}$
|
||||
\end{tabular}
|
||||
|
||||
Wie hier erkennbar ist, wird durch den Dijkstra-Algorithmus nach Addierung einer Konstante C ein falscher kürzester Pfad zurückgegeben, der im unveränderten Graphen G um 999 länger als der kürzeste Pfad ist.
|
||||
\section{} %2
|
||||
\subsection{} %a
|
||||
Reihenfolge bei Anwendung von Kruskal:
|
||||
|
||||
\[
|
||||
(a,e), (e,f), (b,e), (f,g), (g,h), (c,g), (d,g)
|
||||
\]
|
||||
|
||||
Es gibt unterschiedliche Möglichkeiten für die Reihenfolge, denn immer wenn es zwei Kanten mit gleichen Kantengewicht gibt, die beide keinen Kreis entstehen lassen, ist es egal welche genommen wird. Damit können auch unterschiedliche Bäume dabei entstehen.
|
||||
\subsection{} %b
|
||||
\subsubsection{} %i
|
||||
Reihenfolge der Hinzunahme von Kanten:
|
||||
|
||||
\[
|
||||
(a,b), (b,c), (c,g), (g,d), (g,f), (g,h)
|
||||
\]
|
||||
\subsubsection{} %ii
|
||||
Reihenfolge der Hinzunahme von Kanten:
|
||||
|
||||
\[
|
||||
(a,b), (f,g), (g,h), (d,g), (b,c), (c,g), (a,e)
|
||||
\]
|
||||
\subsubsection{} %iii
|
||||
Reihenfolge der weggelassenen Kanten:
|
||||
|
||||
\[
|
||||
(a,f), (b,f), (b,g), (e,f), (d,h), (c,d)
|
||||
\]
|
||||
\end{document}
|
||||
75
optimierung/Uebungsblatt13.tex
Normal file
75
optimierung/Uebungsblatt13.tex
Normal file
@ -0,0 +1,75 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\usepackage{multirow}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
% ensures that paragraphs are separated by empty lines
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
% define how the sections are rendered
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
% some matrix magic
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
|
||||
\begin{document}
|
||||
\author{Jan Branitz (6326955), Jim Martens (6420323),\\
|
||||
Stephan Niendorf (6242417)}
|
||||
\title{Hausaufgaben zum 27. Januar}
|
||||
\maketitle
|
||||
|
||||
\section{} %1
|
||||
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
|
||||
\hline
|
||||
7 & 0 & 0 & 0 & 2 & 2 & 4 & 4 & 5 & 6 & 6 & 7 & 8 & 9 & 10 & 10 & 11 & 11 & 11 & 13 & \underline{13} \\
|
||||
\hline
|
||||
6 & 0 & 0 & 0 & 0 & 2 & 4 & 4 & 5 & 6 & 6 & 6 & 7 & 9 & 10 & 10 & 11 & 11 & 11 & 12 & \underline{13} \\
|
||||
\hline
|
||||
5 & 0 & 0 & 0 & 0 & 2 & 2 & 3 & 5 & 6 & 6 & 6 & 7 & 8 & 8 & 9 & 11 & 11 & 11 & 11 & \underline{13} \\
|
||||
\hline
|
||||
4 & 0 & 0 & 0 & 0 & 2 & 2 & 3 & 5 & 5 & 5 & 5 & \underline{7} & 7 & 8 & 8 & 8 & 8 & 9 & 11 & \underline{11} \\
|
||||
\hline
|
||||
3 & 0 & 0 & 0 & 0 & 2 & 2 & \underline{3} & 3 & 3 & 3 & 5 & \underline{6} & 6 & 6 & 6 & 8 & 8 & 9 & 9 & 9 \\
|
||||
\hline
|
||||
2 & 0 & 0 & 0 & 0 & 0 & 0 & \underline{3} & 3 & 3 & 3 & 3 & 6 & 6 & 6 & 6 & 6 & 6 & 9 & 9 & 9 \\
|
||||
\hline
|
||||
1 & 0 & 0 & 0 & 0 & 0 & 0 & \underline{3} & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 \\
|
||||
\hline
|
||||
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
|
||||
\hline
|
||||
\hline
|
||||
& 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
|
||||
Der Rucksack ist mit den Items 1, 4 und 5 gefüllt.
|
||||
\section{} %2
|
||||
\begin{tabular}{c|c|c|c|c|c}
|
||||
& s & a & b & c & d \\
|
||||
\hline
|
||||
0 & 0 - & $\infty$ - & $\infty$ - & $\infty$ - & $\infty$ - \\
|
||||
1 & 0 - & 6 s & 4 s & 2 b & 2 a \\
|
||||
2 & 0 - & 6 s & 3 d & 1 b & 2 a \\
|
||||
3 & 0 - & 6 s & 3 d & 1 b & 2 a \\
|
||||
4 & 0 - & 6 s & 3 d & 1 b & 2 a
|
||||
\end{tabular}
|
||||
\end{document}
|
||||
@ -93,7 +93,7 @@ Stephan Niendorf (6242417)}
|
||||
3 \cdot 0 + 0 \cdot 1 - 1 \cdot 1 + 3 \cdot 2 &=& 5 &\geq & 5 \\
|
||||
1 \cdot 0 + 3 \cdot 1 + 2 \cdot 1 - 1 \cdot 2 &=& 3 &\geq & 3
|
||||
\end{alignat*}
|
||||
Wie zu erkennen ist, sind alle drei Ungleichungen mit Gleichheit erfüllt.D amit gelten die komplementären Schlupfbedingungen, womit bestätigt ist, dass die gefundenen Lösungen optimal sind.
|
||||
Wie zu erkennen ist, sind alle drei Ungleichungen mit Gleichheit erfüllt. Damit gelten die komplementären Schlupfbedingungen, womit bestätigt ist, dass die gefundenen Lösungen optimal sind.
|
||||
\subsection{} %b
|
||||
Das duale Problem (D):
|
||||
\begin{alignat*}{3}
|
||||
|
||||
212
optimierung/Uebungsblatt7.tex
Normal file
212
optimierung/Uebungsblatt7.tex
Normal file
@ -0,0 +1,212 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
% ensures that paragraphs are separated by empty lines
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
% define how the sections are rendered
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
% some matrix magic
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
|
||||
\begin{document}
|
||||
\author{Jan Branitz (6326955), Jim Martens (6420323),\\
|
||||
Stephan Niendorf (6242417)}
|
||||
\title{Hausaufgaben zum 2. Dezember}
|
||||
\maketitle
|
||||
\section{} %1
|
||||
\subsection{} %a
|
||||
LP-Problem (P):
|
||||
|
||||
\begin{alignat*}{4}
|
||||
\text{maximiere}\; & 3x_{1} \,&+&\, x_{2} \,&+&\, 2x_{3} && \\
|
||||
\multicolumn{8}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
\;& x_{1} \,&+&\, x_{2} \,&+&\, 3x_{3} \,&\leq & 30 \\
|
||||
\;& 2x_{1} \,&+&\, 2x_{2} \,&+&\, 5x_{3} \,&\leq & 24 \\
|
||||
\;& 4x_{1} \,&+&\, x_{2} \,&+&\, 2x_{3} \,&\leq & 36 \\
|
||||
\multicolumn{6}{r}{$x_{1}, x_{2}, x_{3}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
Duales Problem (D):
|
||||
\begin{alignat*}{4}
|
||||
\text{minimiere}\; & 30y_{1} \,&+&\, 24y_{2} \,&+&\, 36y_{3} && \\
|
||||
\multicolumn{8}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
\;& y_{1} \,&+&\, 2y_{2} \,&+&\, 4y_{3} \,&\geq & 3 \\
|
||||
\;& y_{1} \,&+&\, 2y_{2} \,&+&\, y_{3} \,&\geq & 1 \\
|
||||
\;& 3y_{1} \,&+&\, 5y_{2} \,&+&\, 2y_{3} \,&\geq & 2 \\
|
||||
\multicolumn{6}{r}{$y_{1}, y_{2}, y_{3}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
|
||||
Durch Einsetzen von $x_{1}^{*}, x_{2}^{*}, x_{3}^{*}$ in die erste Ungleichung von P ergibt sich:
|
||||
\begin{alignat*}{2}
|
||||
1 \cdot \frac{33}{4} + 1 \cdot 0 + 3 \cdot \frac{3}{2} &\leq & 30 \\
|
||||
\frac{33}{4} + \frac{18}{4} &\leq & 30 \\
|
||||
\frac{51}{4} &\leq & \frac{120}{4}
|
||||
\end{alignat*}
|
||||
Die erste Ungleichung ist nicht mit Gleichheit erfüllt, somit muss $y_{1}^{*} = 0$ gelten.
|
||||
|
||||
Einsetzen in die zweite Ungleichung ergibt:
|
||||
\begin{alignat*}{2}
|
||||
2 \cdot \frac{33}{4} + 2 \cdot 0 + 5 \cdot \frac{3}{2} &\leq & 24 \\
|
||||
\frac{33}{2} + \frac{15}{2} &\leq & 24 \\
|
||||
\frac{48}{2} &\leq & \frac{48}{2}
|
||||
\end{alignat*}
|
||||
Die zweite Ungleichung ist mit Gleichheit erfüllt, woraus sich keine Schlüsse ziehen lassen.
|
||||
|
||||
Einsetzen in die dritte Ungleichung ergibt:
|
||||
\begin{alignat*}{2}
|
||||
4 \cdot \frac{33}{4} + 1 \cdot 0 + 2 \cdot \frac{3}{2} &\leq & 36 \\
|
||||
33 + 3 &\leq & 36 \\
|
||||
36 &\leq & 36
|
||||
\end{alignat*}
|
||||
Auch die dritte Ungleichung ist mit Gleichheit erfüllt. Da $x_{1}^{*}$ und $x_{3}^{*}$ größer als $0$ sind, müssen die erste und dritte Ungleichung von D mit Gleichheit erfüllt sein.
|
||||
|
||||
Unter Berücksichtigung von $y_{1}^{*} = 0$ ergibt sich daraus:
|
||||
\begin{alignat*}{2}
|
||||
I \;& 2y_{2} + 4y_{3} &=& 3 \\
|
||||
II \;& 2y_{2} + y_{3} &=& 1 \\
|
||||
I - II \;& 3y_{3} &=& 2 \\
|
||||
& y_{3} &=& \frac{2}{3} \\
|
||||
\intertext{Einsetzen von $y_{3}$ in $II$}
|
||||
II \;& 2y_{2} + \frac{2}{3} &=& 1 \\
|
||||
& 2y_{2} &=& \frac{1}{3} \\
|
||||
& y_{2} &=& \frac{1}{6}
|
||||
\end{alignat*}
|
||||
Demnach sind $y_{1}^{*} = 0, y_{2}^{*} = \frac{1}{6}, y_{3}^{*} = \frac{2}{3}$ eindeutig bestimmte Zahlen, die zusammen mit den x-Werten die komplementären Schlupfbedingungen erfüllen. Auffallend ist, dass dies die gleichen Werte sind, die bereits im ersten Beispiel auf Skript Seite 63 herauskamen. Da dort bereits überprüft wurde, ob die Zahlen eine zulässige Lösung von D sind und dies bestätigt wurde, kann diese Überprüfung hier ausgelassen werden.
|
||||
|
||||
Demnach ist $x_{1}^{*} = \frac{33}{4}, x_{2}^{*} = 0, x_{3}^{*} = \frac{3}{2}$ ebenso eine optimale Lösung für das LP-Problem.
|
||||
\subsection{} %b
|
||||
Zum Überprüfen der vorgeschlagenen Lösung werden die Werte zunächst in die Ungleichungen des LP-Problems eingesetzt.
|
||||
|
||||
Erste Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
5 + 2 &\leq & 7 \\
|
||||
7 &\leq & 7
|
||||
\end{alignat*}
|
||||
|
||||
Zweite Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
2 + 6 &\leq & 8 \\
|
||||
8 &\leq & 8
|
||||
\end{alignat*}
|
||||
|
||||
Dritte Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
2 \cdot 5 + 2 &\leq & 12 \\
|
||||
12 &\leq & 12
|
||||
\end{alignat*}
|
||||
|
||||
Da alle der Ungleichungen mit Gleichheit erfüllt sind, können keine Rückschlüsse auf y-Werte gezogen werden. Da alle x-Werte größer als 0 sind, müssen alle drei Ungleichungen von D mit Gleichheit erfüllt sein.
|
||||
|
||||
Das duale Problem:
|
||||
\begin{alignat*}{4}
|
||||
\text{minimiere}\; & 7y_{1} \,&+&\, 8y_{2} \,&+&\, 12y_{3} && \\
|
||||
\multicolumn{8}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
\;& y_{1} \,&& &+&\, 2y_{3} \,&\geq & 2 \\
|
||||
\;& y_{1} \,&+&\, y_{2} \,&+&\, y_{3} \,&\geq & 3 \\
|
||||
\;& &&\, y_{2} && &\geq & 2 \\
|
||||
\multicolumn{6}{r}{$y_{1}, y_{2}, y_{3}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
|
||||
Aus der dritten Ungleichung lässt sich ablesen, dass $y_{2}^{*} = 2$ gilt. Es ergibt sich das folgende LGS:
|
||||
\begin{alignat*}{2}
|
||||
I \;& y_{1} + 2y_{3} &=& 2 \\
|
||||
II \;& y_{1} + 2 + y_{3} &=& 3 \\
|
||||
\;& y_{1} + y_{3} &=& 1 \\
|
||||
I - II \;& y_{3} &=& 1 \\
|
||||
\intertext{Einsetzen von $y_{3}$ in $I$}
|
||||
I \;& y_{1} + 2 \cdot 1 &=& 2 \\
|
||||
\;& y_{1} &=& 0
|
||||
\end{alignat*}
|
||||
|
||||
Es ergeben sich somit die eindeutig bestimmten Zahlen $y_{1}^{*} = 0, y_{2}^{*} = 2, y_{3}^{*} = 1$. Diese Zahlen erfüllen zusammen mit der vorgeschlagenen Lösung die komplementären Schlupfbedingungen.
|
||||
Schließlich muss noch geprüft werden, ob diese Zahlen auch eine zulässige Lösung des dualen Problems sind. Dafür werden diese eingesetzt:
|
||||
|
||||
Erste Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
2 \cdot 1 &\geq & 2 \\
|
||||
2 &\geq & 2
|
||||
\end{alignat*}
|
||||
|
||||
Zweite Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
2 + 1 &\geq & 3 \\
|
||||
3 &\geq & 3
|
||||
\end{alignat*}
|
||||
|
||||
Dritte Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
2 &\geq & 2
|
||||
\end{alignat*}
|
||||
|
||||
Da alle drei Ungleichungen mit den herausgefundenen Zahlen gültig sind, stellen die gefundenen Zahlen eine zulässige Lösung des dualen Problems dar.
|
||||
\section{} %2
|
||||
Zunächst wird das eigentliche LP-Problem noch einmal aufgestellt:
|
||||
\begin{alignat*}{7}
|
||||
\text{maximiere}\; & 8x_{1} &+& 3x_{2} &+& 6x_{3} &+& 3x_{4} &+& 9x_{5} &+& 5x_{6} && \\
|
||||
\multicolumn{14}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
& x_{1} &+& x_{2} && && && && &\leq &\, 400 \\
|
||||
& && && x_{3} &+& x_{4} && && &\leq &\, 480 \\
|
||||
& && && && && x_{5} &+& x_{6} &\leq &\, 230 \\
|
||||
& x_{1} && &+& x_{3} && &+& x_{5} && &\leq &\, 420 \\
|
||||
& && x_{2} && &+& x_{4} && &+& x_{6} &\leq &\, 250 \\
|
||||
\multicolumn{12}{r}{$x_{1}, x_{2}, x_{3}, x_{4}, x_{5}, x_{6}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
Die vorgeschlagene Lösung ist $x_{1}^{*} = 400, x_{2}^{*} = 0, x_{3}^{*} = 10, x_{4}^{*} = 30, x_{5}^{*} = 10, x_{6}^{*} = 220$.
|
||||
|
||||
Es ist offensichtlich, dass die erste Ungleichung mit Gleichheit erfüllt ist. Die zweite Ungleichung ist ebenso offensichtlich nicht mit Gleichheit erfüllt ($10 + 30 = 40 < 480$). Die dritte Ungleichung ist mit Gleichheit erfüllt ($10 + 220 = 230$).
|
||||
|
||||
Die vierte Ungleichung ist ebenso mit Gleichheit erfüllt ($400 + 10 + 10 = 420$), wie die fünfte Ungleichung ($0 + 30 + 220 = 250$).
|
||||
|
||||
Daraus lässt sich schließen, dass $y_{2}^{*} = 0$ gelten muss. Ebenso müssen die erste, dritte, vierte, fünfte und sechste Ungleichung des dualen Problems mit Gleichheit erfüllt sein, da die entsprechenden Werte des primalen Problems größer $0$ sind.
|
||||
|
||||
Das duale Problem:
|
||||
\begin{alignat*}{6}
|
||||
\text{minimiere}\; & 400y_{1} &+& 480y_{2} &+& 230y_{3} &+& 420y_{4} &+& 250y_{5} && \\
|
||||
\multicolumn{12}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
& y_{1} && && &+& y_{4} && &\geq &\, 8 \\
|
||||
& y_{1} && && && &+& y_{5} &\geq &\, 3 \\
|
||||
& && y_{2} && &+& y_{4} && &\geq &\, 6 \\
|
||||
& && y_{2} && && && y_{5} &\geq &\, 3 \\
|
||||
& && && y_{3} &+& y_{4} && &\geq &\, 9 \\
|
||||
& && && y_{3} && &+& y_{5} &\geq &\, 5 \\
|
||||
\multicolumn{10}{r}{$y_{1}, y_{2}, y_{3}, y_{4}, y_{5}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
|
||||
Unter der Berücksichtigung, dass $y_{2}^{*} = 0$ gilt und alle außer die zweite Ungleichung mit Gleichheit erfüllt sein müssen, ergibt sich direkt $y_{4}^{*} = 6$ und $y_{5}^{*} = 3$.
|
||||
|
||||
Aufgrund dieser Werte lassen sich die restlichen Werte leicht errechnen:
|
||||
\begin{alignat*}{2}
|
||||
y_{1} + 6 &=& 8 \\
|
||||
y_{1} &=& 2 \\
|
||||
\intertext{Fünfte Ungleichung}
|
||||
y_{3} + 6 &=& 9 \\
|
||||
y_{3} &=& 3 \\
|
||||
\intertext{Sechste Ungleichung}
|
||||
y_{3} + 3 &=& 5 \\
|
||||
y_{3} &=& 2
|
||||
\end{alignat*}
|
||||
Bei dem Errechnen von $y_{3}$ ergibt sich ein Widerspruch, denn $y_{3}$ kann nicht sowohl 2 als auch 3 sein. Eine Alternative gibt es hier nicht, da sowohl die fünfte als auch die sechste Ungleichung mit Gleichheit erfüllt sein müssen.
|
||||
|
||||
Da es somit keine eindeutig bestimmbaren Zahlen $y_{i}^{*}$ mit $i = \{1,2,3,4,5\}$ gibt, die zusammen mit der vorgeschlagenen Lösung die komplementären Schlupfbedingungen erfüllen, entspricht die vorgeschlagene Lösung nicht der optimalen Strategie.
|
||||
\end{document}
|
||||
285
optimierung/Uebungsblatt8.tex
Normal file
285
optimierung/Uebungsblatt8.tex
Normal file
@ -0,0 +1,285 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
% ensures that paragraphs are separated by empty lines
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
% define how the sections are rendered
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
% some matrix magic
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
|
||||
\begin{document}
|
||||
\author{Jan Branitz (6326955), Jim Martens (6420323),\\
|
||||
Stephan Niendorf (6242417)}
|
||||
\title{Hausaufgaben zum 9. Dezember}
|
||||
\maketitle
|
||||
\section{} %1
|
||||
\subsection{} %a
|
||||
\begin{alignat*}{4}
|
||||
\text{minimiere}\; & y_{1} \,&+&\, 2y_{2} \,&+&\, 3y_{3} && \\
|
||||
\multicolumn{8}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
\;& 2y_{1} \,&+&\, 3y_{2} \,&+&\, y_{3} \,&\geq & 5 \\
|
||||
\;& 3y_{1} \,&+&\, y_{2} \,&+&\, y_{3} \,&\geq & -7 \\
|
||||
\;-& y_{1} \,&+&\, 4y_{2} \,&-&\, 2y_{3} \,&\geq & 3 \\
|
||||
\;& y_{1} \,&-&\, 2y_{2} \,&-&\, y_{3} \,&=& 1 \\
|
||||
\multicolumn{6}{r}{$y_{2}, y_{3}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
\subsection{} %b
|
||||
\begin{alignat*}{9}
|
||||
\text{maximiere}\; -& y_{1} &+& 16y_{2} &+& 5y_{3} &+& 8y_{4} &+& y_{5} &-& 4y_{6} &-& 10y_{7} &+& 9y_{8} && \\
|
||||
\multicolumn{18}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
& 2y_{1} &+& y_{2} &+& y_{3} &+& 2y_{4} &+& y_{5} &+& 4y_{6} &-& 4y_{7} &+& y_{8} &\leq &\, -2 \\
|
||||
-& 4y_{1} &+& 5y_{2} && &+& 4y_{4} &-& 3y_{5} &-& 3y_{6} &+& 3y_{7} &+& 2y_{8} &=&\, 3 \\
|
||||
& y_{1} &+& y_{2} &+& y_{3} &-& y_{4} &+& y_{5} && &-& 5y_{7} &+& y_{8} &=&\, 22 \\
|
||||
\multicolumn{16}{r}{$y_{4}, y_{5}, y_{6}, y_{7}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
\section{} %2
|
||||
\subsection{} %a
|
||||
Das LP-Problem:
|
||||
\begin{alignat*}{3}
|
||||
\text{maximiere}\; & 40x_{1} \,&+&\, 70x_{2} && \\
|
||||
\multicolumn{6}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
\;& x_{1} \,&+&\, x_{2} \,&\leq & 100 \\
|
||||
\;& 10x_{1} \,&+&\, 50x_{2} \,&\leq & 4000 \\
|
||||
\multicolumn{4}{r}{$x_{1}, x_{2}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
|
||||
Das duale Problem:
|
||||
\begin{alignat*}{3}
|
||||
\text{minimiere}\; & 100y_{1} \,&+&\, 4000y_{2} && \\
|
||||
\multicolumn{6}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
\;& y_{1} \,&+&\, 10y_{2} \,&\geq & 40 \\
|
||||
\;& y_{1} \,&+&\, 50y_{2} \,&\geq & 70 \\
|
||||
\multicolumn{4}{r}{$y_{1}, y_{2}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
|
||||
\subsubsection{} %i
|
||||
\underline{Starttableau}:
|
||||
\begin{alignat*}{4}
|
||||
x_{3} \,&=&\, 100 \,&-&\, x_{1} \,&-&\, x_{2} \\
|
||||
x_{4} \,&=&\, 4000 \,&-&\, 10x_{1} \,&-&\, 50x_{2} \\ \cline{1 - 7}
|
||||
z &=& &&\, 40x_{1} \,&+&\, 70x_{2}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{1. Iteration}:
|
||||
|
||||
Eingangsvariable: $x_{2}$\\
|
||||
Ausgangsvariable: $x_{4}$
|
||||
|
||||
Es folgt
|
||||
\begin{alignat*}{2}
|
||||
50x_{2} \,&=&&\, 4000 - 10x_{1} - x_{4} \\
|
||||
x_{2} \,&=&&\, 80 - \frac{1}{5}x_{1} - \frac{1}{50}x_{4} \\
|
||||
x_{3} \,&=&&\, 100 - x_{1} - \left(80 - \frac{1}{5}x_{1} - \frac{1}{50}x_{4}\right) \\
|
||||
&=&&\, 100 - x_{1} - 80 + \frac{1}{5}x_{1} + \frac{1}{50}x_{4} \\
|
||||
&=&&\, 20 - \frac{4}{5}x_{1} + \frac{1}{50}x_{4} \\
|
||||
z \,&=&&\, 40x_{1} + 70\left(80 - \frac{1}{5}x_{1} - \frac{1}{50}x_{4}\right) \\
|
||||
&=&&\, 40x_{1} + 5600 - 14x_{1} - \frac{7}{5}x_{4} \\
|
||||
&=&&\, 5600 + 26x_{1} - \frac{7}{5}x_{4}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Ergebnis der 1. Iteration}:
|
||||
\begin{alignat*}{4}
|
||||
x_{2} \,&=&\, 80 \,&-&\, \frac{1}{5}x_{1} \,&-&\, \frac{1}{50}x_{4} \\
|
||||
x_{3} \,&=&\, 20 \,&-&\, \frac{4}{5}x_{1} \,&+&\, \frac{1}{50}x_{4} \\ \cline{1 - 7}
|
||||
z &=& 5600 \,&+&\, 26x_{1} \,&-&\, \frac{7}{5}x_{4}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{2. Iteration}:
|
||||
|
||||
Eingangsvariable: $x_{1}$\\
|
||||
Ausgangsvariable: $x_{3}$
|
||||
|
||||
Es folgt
|
||||
\begin{alignat*}{2}
|
||||
\frac{4}{5}x_{1} \,&=&&\, 20 + \frac{1}{50}x_{4} - x_{3} \\
|
||||
x_{1} \,&=&&\, 25 + \frac{1}{40}x_{4} - \frac{5}{4}x_{3} \\
|
||||
x_{2} \,&=&&\, 80 - \frac{1}{5}\left(25 + \frac{1}{40}x_{4} - \frac{5}{4}x_{3}\right) - \frac{1}{50}x_{4} \\
|
||||
&=&&\, 80 - 5 - \frac{1}{200}x_{4} + \frac{1}{4}x_{3} - \frac{1}{50}x_{4} \\
|
||||
&=&&\, 75 - \frac{1}{40}x_{4} + \frac{1}{4}x_{3} \\
|
||||
z \,&=&&\, 5600 + 26\left(25 + \frac{1}{40}x_{4} - \frac{5}{4}x_{3}\right) - \frac{7}{5}x_{4} \\
|
||||
&=&&\, 5600 + 650 + \frac{13}{20}x_{4} - \frac{65}{2}x_{3} - \frac{7}{5}x_{4} \\
|
||||
&=&&\, 6250 - \frac{3}{4}x_{4} - \frac{65}{2}x_{3}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Ergebnis der 2. Iteration}:
|
||||
\begin{alignat*}{4}
|
||||
x_{1} \,&=&\, 25 \,&-&\, \frac{1}{40}x_{4} \,&-&\, \frac{5}{4}x_{3} \\
|
||||
x_{2} \,&=&\, 75 \,&-&\, \frac{1}{40}x_{4} \,&+&\, \frac{1}{4}x_{3} \\ \cline{1 - 7}
|
||||
z &=& 6250 \,&-&\, \frac{3}{4}x_{4} \,&-&\, \frac{65}{2}x_{3}
|
||||
\end{alignat*}
|
||||
|
||||
Wie hier deutlich wird, ist $x_{1}^{*} = 25, x_{2}^{*} = 75$ eine optimale Lösung des primalen Problems.
|
||||
|
||||
\underline{Startlösung ("`zulässige Basislösung am Anfang"')}:
|
||||
\[
|
||||
x_{1} = 0, x_{2} = 0, x_{3} = 100, x_{4} = 4000 \text{ mit } z = 0
|
||||
\]
|
||||
\underline{Zulässige Basislösung nach der 1. Iteration}:
|
||||
\[
|
||||
x_{1} = 0, x_{2} = 80, x_{3} = 20, x_{4} = 0 \text{ mit } z = 5600
|
||||
\]
|
||||
\underline{Zulässige Basislösung nach der 2. Iteration}:
|
||||
\[
|
||||
x_{1} = 25, x_{2} = 75, x_{3} = 0, x_{4} = 0 \text{ mit } z = 6250
|
||||
\]
|
||||
|
||||
Durch Einsetzen von $y_{1}^{*} = 32.5$ und $y_{2}^{*} = 0.75$ in die Zielfunktion des dualen Problems ergibt sich folgendes:
|
||||
\[
|
||||
100 \cdot \frac{65}{2} + 4000 \cdot \frac{3}{4} = 3250 + 3000 = 6250
|
||||
\]
|
||||
|
||||
Die beiden Zielfunktionswerte stimmen überein. Nach dem Dualitätssatz folgt daraus, dass $y_{1}^{*} = 32.5, y_{2}^{*} = 0.75$ tatsächlich eine optimale Lösung für das duale Problem darstellt.
|
||||
\subsubsection{} %ii
|
||||
Zum Überprüfen der vorgeschlagenen Lösung werden die Werte zunächst in die Ungleichungen des LP-Problems eingesetzt.
|
||||
|
||||
Erste Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
25 + 75 &\leq & 100 \\
|
||||
100 &\leq & 100
|
||||
\end{alignat*}
|
||||
|
||||
Zweite Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
10 \cdot 25 + 50 \cdot 75 &\leq & 4000 \\
|
||||
4000 &\leq & 4000
|
||||
\end{alignat*}
|
||||
|
||||
Da beide Ungleichungen mit Gleichheit erfüllt sind, lassen sich keine Rückschlüsse auf $y$-Werte ziehen. Da beide $x$-Werte größer als $0$ sind, müssen beide Ungleichungen im dualen Problem mit Gleichheit erfüllt sein.
|
||||
|
||||
\begin{alignat*}{2}
|
||||
I \;& y_{1} + 10y_{2} &=& 40 \\
|
||||
II \;& y_{1} + 50y_{2} &=& 70 \\
|
||||
II - I \;& 40y_{2} &=& 30 \\
|
||||
\;& y_{2} &=& \frac{3}{4} \\
|
||||
\intertext{Einsetzen von $y_{2}$ in $I$}
|
||||
I \;& y_{1} + 10 \cdot \frac{3}{4} &=& 40 \\
|
||||
\;& y_{1} + \frac{15}{2} &=& 40 \\
|
||||
\;& y_{1} &=& \frac{65}{2}
|
||||
\end{alignat*}
|
||||
|
||||
Es ergeben sich somit die eindeutig bestimmten Zahlen $y_{1}^{*} = \frac{65}{2}, y_{2}^{*} = \frac{3}{4}$. Diese Zahlen erfüllen zusammen mit der vorgeschlagenen Lösung die komplementären Schlupfbedingungen.
|
||||
Schließlich muss noch geprüft werden, ob diese Zahlen auch eine zulässige Lösung des dualen Problems sind. Dafür werden diese eingesetzt:
|
||||
|
||||
Erste Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
1 \cdot \frac{65}{2} + 10 \cdot \frac{3}{4} &\geq & 40 \\
|
||||
40 &\geq & 40
|
||||
\end{alignat*}
|
||||
|
||||
Zweite Ungleichung:
|
||||
\begin{alignat*}{2}
|
||||
1 \cdot \frac{65}{2} + 50 \cdot \frac{3}{4} &\geq & 70 \\
|
||||
70 &\geq & 70
|
||||
\end{alignat*}
|
||||
|
||||
Da alle zwei Ungleichungen mit den herausgefundenen Zahlen gültig sind, stellen die gefundenen Zahlen eine zulässige Lösung des dualen Problems dar.
|
||||
\subsection{} %b
|
||||
\underline{Starttableau}:
|
||||
\begin{alignat*}{4}
|
||||
x_{3} \,&=&\, 100 \,&-&\, x_{1} \,&-&\, x_{2} \\
|
||||
x_{4} \,&=&\, 4000 + t \,&-&\, 10x_{1} \,&-&\, 50x_{2} \\ \cline{1 - 7}
|
||||
z &=& &&\, 40x_{1} \,&+&\, 70x_{2}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{1. Iteration}:
|
||||
|
||||
\textbf{Es wird vorausgesetzt, dass $0 \leq t \leq 1000$ gilt.} Für $t=0$ gilt im Folgenden genau das Gleiche wie in 2a i). Für $t=1000$ kann eine der Ausgangsvariablen nach Belieben gewählt werden, da beide potentiellen Ausgangsvariablen $x_{2}$ gleichermaßen beschränken. Da in den meisten Fällen jedoch $t$ kleiner als $1000$ ist, wird $x_{4}$ als Ausgangsvariable gewählt.
|
||||
|
||||
Eingangsvariable: $x_{2}$\\
|
||||
Ausgangsvariable: $x_{4}$
|
||||
|
||||
Es folgt
|
||||
\begin{alignat*}{2}
|
||||
50x_{2} \,&=&&\, 4000 + t - 10x_{1} - x_{4} \\
|
||||
x_{2} \,&=&&\, 80 + \frac{1}{50}t - \frac{1}{5}x_{1} - \frac{1}{50}x_{4} \\
|
||||
x_{3} \,&=&&\, 100 - x_{1} - \left(80 + \frac{1}{50}t - \frac{1}{5}x_{1} - \frac{1}{50}x_{4}\right) \\
|
||||
&=&&\, 100 - x_{1} - 80 - \frac{1}{50}t + \frac{1}{5}x_{1} + \frac{1}{50}x_{4} \\
|
||||
&=&&\, 20 - \frac{1}{50}t - \frac{4}{5}x_{1} + \frac{1}{50}x_{4} \\
|
||||
z \,&=&&\, 40x_{1} + 70\left(80 + \frac{1}{50}t - \frac{1}{5}x_{1} - \frac{1}{50}x_{4}\right) \\
|
||||
&=&&\, 40x_{1} + 5600 + \frac{7}{5}t - 14x_{1} - \frac{7}{5}x_{4} \\
|
||||
&=&&\, 5600 + \frac{7}{5}t + 26x_{1} - \frac{7}{5}x_{4}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Ergebnis der 1. Iteration}:
|
||||
\begin{alignat*}{4}
|
||||
x_{2} \,&=&\, 80 + \frac{1}{50}t \,&-&\, \frac{1}{5}x_{1} \,&-&\, \frac{1}{50}x_{4} \\
|
||||
x_{3} \,&=&\, 20 - \frac{1}{50}t \,&-&\, \frac{4}{5}x_{1} \,&+&\, \frac{1}{50}x_{4} \\ \cline{1 - 7}
|
||||
z &=& 5600 + \frac{7}{5}t \,&+&\, 26x_{1} \,&-&\, \frac{7}{5}x_{4}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{2. Iteration}:
|
||||
|
||||
\textbf{Es wird vorausgesetzt, dass $t \leq 1000$ gilt.} Könnte $t$ größer sein, dann würde die Möglichkeit bestehen, dass $x_{3}$ in der Basislösung nach der ersten Iteration einen negativen Wert hat.
|
||||
|
||||
Eingangsvariable: $x_{1}$\\
|
||||
Ausgangsvariable: $x_{3}$
|
||||
|
||||
Es folgt
|
||||
\begin{alignat*}{2}
|
||||
\frac{4}{5}x_{1} \,&=&&\, 20 - \frac{1}{50}t + \frac{1}{50}x_{4} - x_{3} \\
|
||||
x_{1} \,&=&&\, 25 - \frac{1}{40}t + \frac{1}{40}x_{4} - \frac{5}{4}x_{3} \\
|
||||
x_{2} \,&=&&\, 80 + \frac{1}{50}t - \frac{1}{5}\left(25 - \frac{1}{40}t + \frac{1}{40}x_{4} - \frac{5}{4}x_{3}\right) - \frac{1}{50}x_{4} \\
|
||||
&=&&\, 80 + \frac{1}{50}t - 5 + \frac{1}{200}t - \frac{1}{200}x_{4} + \frac{1}{4}x_{3} - \frac{1}{50}x_{4} \\
|
||||
&=&&\, 75 + \frac{1}{40}t - \frac{1}{40}x_{4} + \frac{1}{4}x_{3} \\
|
||||
z \,&=&&\, 5600 + \frac{7}{5}t + 26\left(25 - \frac{1}{40}t + \frac{1}{40}x_{4} - \frac{5}{4}x_{3}\right) - \frac{7}{5}x_{4} \\
|
||||
&=&&\, 5600 + \frac{7}{5}t + 650 - \frac{13}{20}t + \frac{13}{20}x_{4} - \frac{65}{2}x_{3} - \frac{7}{5}x_{4} \\
|
||||
&=&&\, 6250 + \frac{3}{4}t - \frac{3}{4}x_{4} - \frac{65}{2}x_{3}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Ergebnis der 2. Iteration}:
|
||||
\begin{alignat*}{4}
|
||||
x_{1} \,&=&\, 25 - \frac{1}{40}t \,&+&\, \frac{1}{40}x_{4} \,&-&\, \frac{5}{4}x_{3} \\
|
||||
x_{2} \,&=&\, 75 + \frac{1}{40}t \,&-&\, \frac{1}{40}x_{4} \,&+&\, \frac{1}{4}x_{3} \\ \cline{1 - 7}
|
||||
z &=& 6250 + \frac{3}{4}t \,&-&\, \frac{3}{4}x_{4} \,&-&\, \frac{65}{2}x_{3}
|
||||
\end{alignat*}
|
||||
|
||||
Wie hier deutlich wird, ist $x_{1}^{*} = 25, x_{2}^{*} = 75$ eine optimale Lösung des primalen Problems.
|
||||
|
||||
\underline{Startlösung ("`zulässige Basislösung am Anfang"')}:
|
||||
\[
|
||||
x_{1} = 0, x_{2} = 0, x_{3} = 100, x_{4} = 4000 + t \text{ mit } z = 0
|
||||
\]
|
||||
\underline{Zulässige Basislösung nach der 1. Iteration}:
|
||||
\[
|
||||
x_{1} = 0, x_{2} = 80 + \frac{1}{50}t, x_{3} = 20 - \frac{1}{50}t, x_{4} = 0 \text{ mit } z = 5600 + \frac{7}{5}t
|
||||
\]
|
||||
\underline{Zulässige Basislösung nach der 2. Iteration}:
|
||||
\[
|
||||
x_{1} = 25 - \frac{1}{40}t, x_{2} = 75 + \frac{1}{40}t, x_{3} = 0, x_{4} = 0 \text{ mit } z = 6250 + \frac{3}{4}t
|
||||
\]
|
||||
|
||||
Wie im Folgenden zu sehen ist, entsprechen die Werte der optimalen Lösung den in (7.24) auf Skriptseite 67 angenommenen Werten.
|
||||
\[
|
||||
x_{1} = 25 - \frac{1}{40}t = 25 - \frac{25}{1000}t = 25 - 0.025t
|
||||
\]
|
||||
\[
|
||||
x_{2} = 75 + \frac{1}{40}t = 75 + \frac{25}{1000}t = 75 + 0.025t
|
||||
\]
|
||||
Im Folgenden ist zu sehen, dass tatsächlich ein zusätzlicher Gewinn von $0.75t$ erzielt wird.
|
||||
\[
|
||||
z = 6250 + \frac{3}{4}t = 6250 + \frac{75}{100}t = 6250 + 0.75t
|
||||
\]
|
||||
\end{document}
|
||||
561
optimierung/Uebungsblatt9.tex
Normal file
561
optimierung/Uebungsblatt9.tex
Normal file
@ -0,0 +1,561 @@
|
||||
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{paralist}
|
||||
\usepackage{gauss}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
||||
\usepackage{polynom}
|
||||
\usepackage{multirow}
|
||||
\polyset{style=C, div=:,vars=x}
|
||||
\pgfplotsset{compat=1.8}
|
||||
\pagenumbering{arabic}
|
||||
% ensures that paragraphs are separated by empty lines
|
||||
\parskip 12pt plus 1pt minus 1pt
|
||||
\parindent 0pt
|
||||
% define how the sections are rendered
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
% some matrix magic
|
||||
\makeatletter
|
||||
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
||||
\hskip -\arraycolsep
|
||||
\let\@ifnextchar\new@ifnextchar
|
||||
\array{#1}}
|
||||
\makeatother
|
||||
|
||||
\begin{document}
|
||||
\author{Jan Branitz (6326955), Jim Martens (6420323),\\
|
||||
Stephan Niendorf (6242417)}
|
||||
\title{Hausaufgaben zum 16. Dezember}
|
||||
\maketitle
|
||||
\section{} %1
|
||||
\subsection{} %a
|
||||
\begin{alignat*}{3}
|
||||
\text{maximiere}\; & 2x_{1} \,&+&\, 3x_{2} && \\
|
||||
\multicolumn{6}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
\;& x_{1} \,&-&\, 4x_{2} \,&\leq & 2 \\
|
||||
\;& x_{1} \,&&\, \,&\leq & 5 \\
|
||||
\;& \,&&\, x_{2} \,&\leq & 8 \\
|
||||
\multicolumn{4}{r}{$x_{1}, x_{2}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Eingangsdaten}:
|
||||
\begin{alignat*}{2}
|
||||
A &=& \begin{pmatrix}
|
||||
x_{1} & x_{2} & x_{3} & x_{4} & x_{5} \\
|
||||
1 & -4 & 1 & 0 & 0 \\
|
||||
1 & 0 & 0 & 1 & 0 \\
|
||||
0 & 1 & 0 & 0 & 1
|
||||
\end{pmatrix} \\
|
||||
c^{T} &=& \begin{pmatrix}
|
||||
x_{1} & x_{2} & x_{3} & x_{4} & x_{5} \\
|
||||
2 & 3 & 0 & 0 & 0
|
||||
\end{pmatrix} \\
|
||||
b &=& \begin{pmatrix}
|
||||
2 \\
|
||||
5 \\
|
||||
8
|
||||
\end{pmatrix}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Initialisierung}:
|
||||
\begin{alignat*}{2}
|
||||
x_{B}^{*} &=& \begin{pmatrix}
|
||||
x_{3}^{*} \\
|
||||
x_{4}^{*} \\
|
||||
x_{5}^{*}
|
||||
\end{pmatrix}
|
||||
=
|
||||
\begin{pmatrix}
|
||||
2 \\
|
||||
5 \\
|
||||
8
|
||||
\end{pmatrix} \\
|
||||
B &=& \begin{pmatrix}
|
||||
x_{3} & x_{4} & x_{5} \\
|
||||
1 & 0 & 0 \\
|
||||
0 & 1 & 0 \\
|
||||
0 & 0 & 1
|
||||
\end{pmatrix}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{1. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 0 & 0 & 0 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{3}
|
||||
y_{1} & & &=& 0 \\
|
||||
& y_{2} & &=& 0 \\
|
||||
& & y_{3} &=& 0
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 0 & 0 & 0 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{1} & x_{2} \\ 1 & -4 \\ 1 & 0 \\ 0 & 1 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 0 & 0 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 2 & 3 \end{pmatrix}$. Also kommt jede Spalte von $A_{N}$ als Eingangsspalte a infrage, wir wählen $a = \begin{pmatrix} -4 \\ 0 \\ 1 \end{pmatrix}$; die Eingangsvariable ist $x_{2}$.
|
||||
|
||||
\textbf{3. Schritt} (Lösung von $Bd = a$):\\
|
||||
Das Gleichungssystem $Bd = a$ lautet
|
||||
\begin{alignat*}{3}
|
||||
d_{1} & & &=& -4 \\
|
||||
& d_{2} & &=& 0 \\
|
||||
& & d_{3} &=& 1
|
||||
\end{alignat*}
|
||||
Es folgt $d = \begin{pmatrix}-4 \\ 0 \\ 1 \end{pmatrix}$.
|
||||
|
||||
\textbf{4. Schritt} (Bestimmung der Ausgangsvariablen):\\
|
||||
Die Ungleichung $x_{B}^{*} - td \geq 0$ lautet $\begin{pmatrix} 2 \\ 5 \\ 8\end{pmatrix} - t \begin{pmatrix}-4 \\ 0 \\ 1 \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$. Das größte t, das dies erfüllt, ist $t = 8$; für $t = 8$ gilt $\begin{pmatrix} 2 \\ 5 \\ 8\end{pmatrix} - t \begin{pmatrix}-4 \\ 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 34 \\ 5 \\ 0 \end{pmatrix}$, Ausgangsvariable ist $x_{5}$.
|
||||
|
||||
\textbf{5. Schritt} (Update von $x_{B}^{*}$ und $B$):\\
|
||||
$x_{B}^{*} = \begin{pmatrix} x_{3}^{*} \\ x_{4}^{*} \\ x_{2}^{*} \end{pmatrix} = \begin{pmatrix} 34 \\ 5 \\ 8 \end{pmatrix}$ und $B = \begin{pmatrix} x_{3} & x_{4} & x_{2} \\ 1 & 0 & -4 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$.
|
||||
|
||||
\underline{2. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 2 & 0 & 0 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{4}
|
||||
y_{1} && &-& 4y_{3} &=& 34 \\
|
||||
&& y_{2} && &=& 5 \\
|
||||
&& && y_{3} &=& 8
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 66 & 5 & 8 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{1} & x_{5} \\ 1 & 0 \\ 1 & 0 \\ 0 & 1 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 71 & 8 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 2 & 0 \end{pmatrix}$. Also kommt nur die erste Spalte von $A_{N}$ als Eingangsspalte a infrage, wir wählen $a = \begin{pmatrix} 1 \\ 1 \\ 0 \end{pmatrix}$; die Eingangsvariable ist $x_{1}$.
|
||||
|
||||
\textbf{3. Schritt} (Lösung von $Bd = a$):\\
|
||||
Das Gleichungssystem $Bd = a$ lautet
|
||||
\begin{alignat*}{4}
|
||||
d_{1} && &-& 4d_{3} &=& 1 \\
|
||||
&& d_{2} && &=& 1 \\
|
||||
&& && d_{3} &=& 0
|
||||
\end{alignat*}
|
||||
Es folgt $d = \begin{pmatrix}1 \\ 1 \\ 0 \end{pmatrix}$.
|
||||
|
||||
\textbf{4. Schritt} (Bestimmung der Ausgangsvariablen):\\
|
||||
Die Ungleichung $x_{B}^{*} - td \geq 0$ lautet $\begin{pmatrix} 34 \\ 5 \\ 8\end{pmatrix} - t \begin{pmatrix}1 \\ 1 \\ 0 \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$. Das größte t, das dies erfüllt, ist $t = 5$; für $t = 5$ gilt $\begin{pmatrix} 34 \\ 5 \\ 8\end{pmatrix} - t \begin{pmatrix}1 \\ 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 29 \\ 0 \\ 8 \end{pmatrix}$, Ausgangsvariable ist $x_{4}$.
|
||||
|
||||
\textbf{5. Schritt} (Update von $x_{B}^{*}$ und $B$):\\
|
||||
$x_{B}^{*} = \begin{pmatrix} x_{3}^{*} \\ x_{1}^{*} \\ x_{2}^{*} \end{pmatrix} = \begin{pmatrix} 29 \\ 5 \\ 8 \end{pmatrix}$ und $B = \begin{pmatrix} x_{3} & x_{1} & x_{2} \\ 1 & 1 & -4 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$.
|
||||
|
||||
\underline{3. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 0 & 2 & 3 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{4}
|
||||
y_{1} && && &=& 0 \\
|
||||
y_{1} &+& y_{2} && &=& 2 \\
|
||||
-4y_{1} && &+& y_{3} &=& 3
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 0 & 2 & 3 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{4} & x_{5} \\ 0 & 0 \\ 1 & 0 \\ 0 & 1 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 2 & 3 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 0 & 0 \end{pmatrix}$. Wegen $2 \geq 0, 3 \geq 0$ ist die aktuelle Lösung optimal. Die optimale Lösung lautet $x_{1}^{*} = 5, x_{2}^{*} = 8$ mit $z^{*} = 2x_{1}^{*} + 3x_{2}^{*} = 34$.
|
||||
\subsection{} %b
|
||||
\begin{alignat*}{4}
|
||||
\text{maximiere}\; & 3x_{1} \,&+&\, 2x_{2} \,&+&\, 2x_{3} && \\
|
||||
\multicolumn{8}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
\;& x_{1} \,&&\, \,&+&\, x_{3} \,&\leq & 8 \\
|
||||
\;& x_{1} \,&+&\, x_{2} \,&&\, \,&\leq & 7 \\
|
||||
\;& x_{1} \,&+&\, 2x_{2} \,&&\, \,&\leq & 12 \\
|
||||
\multicolumn{6}{r}{$x_{1}, x_{2}, x_{3}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Eingangsdaten}:
|
||||
\begin{alignat*}{2}
|
||||
A &=& \begin{pmatrix}
|
||||
x_{1} & x_{2} & x_{3} & x_{4} & x_{5} & x_{6} \\
|
||||
1 & 0 & 1 & 1 & 0 & 0 \\
|
||||
1 & 1 & 0 & 0 & 1 & 0\\
|
||||
1 & 2 & 0 & 0 & 0 & 1
|
||||
\end{pmatrix} \\
|
||||
c^{T} &=& \begin{pmatrix}
|
||||
x_{1} & x_{2} & x_{3} & x_{4} & x_{5} & x_{6} \\
|
||||
3 & 2 & 2 & 0 & 0 & 0
|
||||
\end{pmatrix} \\
|
||||
b &=& \begin{pmatrix}
|
||||
8 \\
|
||||
7 \\
|
||||
12
|
||||
\end{pmatrix}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Initialisierung}:
|
||||
\begin{alignat*}{2}
|
||||
x_{B}^{*} &=& \begin{pmatrix}
|
||||
x_{4}^{*} \\
|
||||
x_{5}^{*} \\
|
||||
x_{6}^{*}
|
||||
\end{pmatrix}
|
||||
=
|
||||
\begin{pmatrix}
|
||||
8 \\
|
||||
7 \\
|
||||
12
|
||||
\end{pmatrix} \\
|
||||
B &=& \begin{pmatrix}
|
||||
x_{4} & x_{5} & x_{6} \\
|
||||
1 & 0 & 0 \\
|
||||
0 & 1 & 0 \\
|
||||
0 & 0 & 1
|
||||
\end{pmatrix}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{1. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 0 & 0 & 0 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{3}
|
||||
y_{1} & & &=& 0 \\
|
||||
& y_{2} & &=& 0 \\
|
||||
& & y_{3} &=& 0
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 0 & 0 & 0 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{1} & x_{2} & x_{3} \\ 1 & 0 & 1 \\ 1 & 1 & 0 \\ 1 & 2 & 0 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 0 & 0 & 0 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 3 & 2 & 2 \end{pmatrix}$. Also kommt jede Spalte von $A_{N}$ als Eingangsspalte a infrage, wir wählen $a = \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix}$; die Eingangsvariable ist $x_{1}$.
|
||||
|
||||
\textbf{3. Schritt} (Lösung von $Bd = a$):\\
|
||||
Das Gleichungssystem $Bd = a$ lautet
|
||||
\begin{alignat*}{3}
|
||||
d_{1} & & &=& 1 \\
|
||||
& d_{2} & &=& 1 \\
|
||||
& & d_{3} &=& 1
|
||||
\end{alignat*}
|
||||
Es folgt $d = \begin{pmatrix}1 \\ 1 \\ 1 \end{pmatrix}$.
|
||||
|
||||
\textbf{4. Schritt} (Bestimmung der Ausgangsvariablen):\\
|
||||
Die Ungleichung $x_{B}^{*} - td \geq 0$ lautet $\begin{pmatrix} 8 \\ 7 \\ 12\end{pmatrix} - t \begin{pmatrix}1 \\ 1 \\ 1 \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$. Das größte t, das dies erfüllt, ist $t = 7$; für $t = 7$ gilt $\begin{pmatrix} 8 \\ 7 \\ 12\end{pmatrix} - t \begin{pmatrix}1 \\ 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 1 \\ 0 \\ 5 \end{pmatrix}$, Ausgangsvariable ist $x_{5}$.
|
||||
|
||||
\textbf{5. Schritt} (Update von $x_{B}^{*}$ und $B$):\\
|
||||
$x_{B}^{*} = \begin{pmatrix} x_{4}^{*} \\ x_{1}^{*} \\ x_{6}^{*} \end{pmatrix} = \begin{pmatrix} 1 \\ 7 \\ 5 \end{pmatrix}$ und $B = \begin{pmatrix} x_{4} & x_{1} & x_{6} \\ 1 & 1 & 0 \\ 0 & 1 & 0 \\ 0 & 1 & 1 \end{pmatrix}$.
|
||||
|
||||
\underline{2. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 0 & 3 & 0 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{4}
|
||||
y_{1} && && &=& 0 \\
|
||||
y_{1} &+& y_{2} &+& y_{3} &=& 3 \\
|
||||
&& && y_{3} &=& 0
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 0 & 3 & 0 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{5} & x_{2} & x_{3} \\ 0 & 0 & 1 \\ 1 & 1 & 0 \\ 0 & 2 & 0 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 3 & 3 & 0 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 0 & 2 & 2 \end{pmatrix}$. Also kommt nur die dritte Spalte von $A_{N}$ als Eingangsspalte a infrage, wir wählen $a = \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix}$; die Eingangsvariable ist $x_{3}$.
|
||||
|
||||
\textbf{3. Schritt} (Lösung von $Bd = a$):\\
|
||||
Das Gleichungssystem $Bd = a$ lautet
|
||||
\begin{alignat*}{4}
|
||||
d_{1} &+& d_{2} && &=& 1 \\
|
||||
&& d_{2} && &=& 0 \\
|
||||
&& d_{2} &+& d_{3} &=& 0
|
||||
\end{alignat*}
|
||||
Es folgt $d = \begin{pmatrix}1 \\ 0 \\ 0 \end{pmatrix}$.
|
||||
|
||||
\textbf{4. Schritt} (Bestimmung der Ausgangsvariablen):\\
|
||||
Die Ungleichung $x_{B}^{*} - td \geq 0$ lautet $\begin{pmatrix} 1 \\ 7 \\ 5\end{pmatrix} - t \begin{pmatrix}1 \\ 0 \\ 0 \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$. Das größte t, das dies erfüllt, ist $t = 1$; für $t = 1$ gilt $\begin{pmatrix} 1 \\ 7 \\ 5\end{pmatrix} - t \begin{pmatrix}1 \\ 0 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 7 \\ 5 \end{pmatrix}$, Ausgangsvariable ist $x_{4}$.
|
||||
|
||||
\textbf{5. Schritt} (Update von $x_{B}^{*}$ und $B$):\\
|
||||
$x_{B}^{*} = \begin{pmatrix} x_{3}^{*} \\ x_{1}^{*} \\ x_{6}^{*} \end{pmatrix} = \begin{pmatrix} 1 \\ 7 \\ 5 \end{pmatrix}$ und $B = \begin{pmatrix} x_{3} & x_{1} & x_{6} \\ 1 & 1 & 0 \\ 0 & 1 & 0 \\ 0 & 1 & 1 \end{pmatrix}$.
|
||||
|
||||
\underline{3. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 2 & 3 & 0 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{4}
|
||||
y_{1} && && &=& 2 \\
|
||||
y_{1} &+& y_{2} &+& y_{3} &=& 3 \\
|
||||
&& && y_{3} &=& 0
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 2 & 1 & 0 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{5} & x_{2} & x_{4} \\ 0 & 0 & 1 \\ 1 & 1 & 0 \\ 0 & 2 & 0 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 1 & 1 & 2 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 0 & 2 & 0\end{pmatrix}$. Also kommen nur die ersten beiden Spalten von $A_{N}$ als Eingangsspalte a infrage, wir wählen $a = \begin{pmatrix} 0 \\ 1 \\ 2 \end{pmatrix}$; die Eingangsvariable ist $x_{2}$.
|
||||
|
||||
\textbf{3. Schritt} (Lösung von $Bd = a$):\\
|
||||
Das Gleichungssystem $Bd = a$ lautet
|
||||
\begin{alignat*}{4}
|
||||
d_{1} &+& d_{2} && &=& 0\\
|
||||
&& d_{2} && &=& 1 \\
|
||||
&& d_{2} &+& d_{3} &=& 2
|
||||
\end{alignat*}
|
||||
Es folgt $d = \begin{pmatrix} -1 \\ 1 \\ 1 \end{pmatrix}$.
|
||||
|
||||
\textbf{4. Schritt} (Bestimmung der Ausgangsvariablen):\\
|
||||
Die Ungleichung $x_{B}^{*} - td \geq 0$ lautet $\begin{pmatrix} 1 \\ 7 \\ 5\end{pmatrix} - t \begin{pmatrix}-1 \\ 1 \\ 1 \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$. Das größte t, das dies erfüllt, ist $t = 5$; für $t = 5$ gilt $\begin{pmatrix} 1 \\ 7 \\ 5\end{pmatrix} - t \begin{pmatrix} -1 \\ 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 6 \\ 2 \\ 0 \end{pmatrix}$, Ausgangsvariable ist $x_{6}$.
|
||||
|
||||
\textbf{5. Schritt} (Update von $x_{B}^{*}$ und $B$):\\
|
||||
$x_{B}^{*} = \begin{pmatrix} x_{3}^{*} \\ x_{1}^{*} \\ x_{2}^{*} \end{pmatrix} = \begin{pmatrix} 6 \\ 2 \\ 5 \end{pmatrix}$ und $B = \begin{pmatrix} x_{3} & x_{1} & x_{2} \\ 1 & 1 & 0 \\ 0 & 1 & 1 \\ 0 & 1 & 2 \end{pmatrix}$.
|
||||
|
||||
\underline{4. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 2 & 3 & 2 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{4}
|
||||
y_{1} && && &=& 2 \\
|
||||
y_{1} &+& y_{2} &+& y_{3} &=& 3 \\
|
||||
&& y_{2} &+& 2y_{3} &=& 2
|
||||
\end{alignat*}
|
||||
Es ergibt sich dieses LGS:
|
||||
\begin{alignat*}{3}
|
||||
I & y_{2} &+& y_{3} &=& 1 \\
|
||||
II & y_{2} &+& 2y_{3} &=& 2 \\
|
||||
II - I & && y_{3} &=& 1
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 2 & 0 & 1 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{5} & x_{6} & x_{4} \\ 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 0 & 1 & 2 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 0 & 0 & 0\end{pmatrix}$. Wegen $0 \geq 0, 1 \geq 0, 2 \geq 0$ ist die aktuelle Lösung optimal. Die optimale Lösung lautet $x_{1}^{*} = 2, x_{2}^{*} = 5, x_{3}^{*} = 6$ mit $z^{*} = 3x_{1}^{*} + 2x_{2}^{*} + 2x_{3}^{*} = 28$.
|
||||
\section{} %2
|
||||
\begin{alignat*}{5}
|
||||
\text{maximiere}\; & 5x_{1} \,&+&\, 6x_{2} \,&+&\, 9x_{3} \,&+&\, 8x_{4} && \\
|
||||
\multicolumn{10}{l}{\text{unter den Nebenbedingungen}} && \\
|
||||
\;& x_{1} \,&+&\, 2x_{2} \,&+&\, 3x_{3} \,&+&\, x_{4} \,&\leq & 5 \\
|
||||
\;& x_{1} \,&+&\, x_{2} \,&+&\, 2x_{3} \,&+&\, 3x_{4} \,&\leq & 3 \\
|
||||
\multicolumn{8}{r}{$x_{1}, x_{2}, x_{3}, x_{4}$} \,&\geq &\, 0
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Eingangsdaten}:
|
||||
\begin{alignat*}{2}
|
||||
A &=& \begin{pmatrix}
|
||||
x_{1} & x_{2} & x_{3} & x_{4} & x_{5} & x_{6} \\
|
||||
1 & 2 & 3 & 1 & 1 & 0 \\
|
||||
1 & 1 & 2 & 3 & 0 & 1\\
|
||||
\end{pmatrix} \\
|
||||
c^{T} &=& \begin{pmatrix}
|
||||
x_{1} & x_{2} & x_{3} & x_{4} & x_{5} & x_{6} \\
|
||||
5 & 6 & 9 & 8 & 0 & 0
|
||||
\end{pmatrix} \\
|
||||
b &=& \begin{pmatrix}
|
||||
5 \\
|
||||
3
|
||||
\end{pmatrix}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{Initialisierung}:
|
||||
\begin{alignat*}{2}
|
||||
x_{B}^{*} &=& \begin{pmatrix}
|
||||
x_{5}^{*} \\
|
||||
x_{6}^{*}
|
||||
\end{pmatrix}
|
||||
=
|
||||
\begin{pmatrix}
|
||||
5 \\
|
||||
3
|
||||
\end{pmatrix} \\
|
||||
B &=& \begin{pmatrix}
|
||||
x_{5} & x_{6} \\
|
||||
1 & 0 \\
|
||||
0 & 1
|
||||
\end{pmatrix}
|
||||
\end{alignat*}
|
||||
|
||||
\underline{1. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 0 & 0 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{2}
|
||||
y_{1} & &=& 0 \\
|
||||
& y_{2} &=& 0
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 0 & 0 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{1} & x_{2} & x_{3} & x_{4} \\ 1 & 2 & 3 & 1 \\ 1 & 1 & 2 & 3 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 0 & 0 & 0 & 0\end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 5 & 6 & 9 & 8 \end{pmatrix}$. Also kommt jede Spalte von $A_{N}$ als Eingangsspalte a infrage, wir wählen $a = \begin{pmatrix} 3 \\ 2 \end{pmatrix}$; die Eingangsvariable ist $x_{3}$.
|
||||
|
||||
\textbf{3. Schritt} (Lösung von $Bd = a$):\\
|
||||
Das Gleichungssystem $Bd = a$ lautet
|
||||
\begin{alignat*}{2}
|
||||
d_{1} & &=& 3 \\
|
||||
& d_{2} &=& 2
|
||||
\end{alignat*}
|
||||
Es folgt $d = \begin{pmatrix}3 \\ 2 \end{pmatrix}$.
|
||||
|
||||
\textbf{4. Schritt} (Bestimmung der Ausgangsvariablen):\\
|
||||
Die Ungleichung $x_{B}^{*} - td \geq 0$ lautet $\begin{pmatrix} 5 \\ 3 \end{pmatrix} - t \begin{pmatrix}3 \\ 2 \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \end{pmatrix}$. Das größte t, das dies erfüllt, ist $t = \frac{3}{2}$; für $t = \frac{3}{2}$ gilt $\begin{pmatrix} 5 \\ 3 \end{pmatrix} - t \begin{pmatrix}3 \\ 2 \end{pmatrix} = \begin{pmatrix} \frac{1}{2} \\ 0 \end{pmatrix}$, Ausgangsvariable ist $x_{6}$.
|
||||
|
||||
\textbf{5. Schritt} (Update von $x_{B}^{*}$ und $B$):\\
|
||||
$x_{B}^{*} = \begin{pmatrix} x_{5}^{*} \\ x_{3}^{*} \end{pmatrix} = \begin{pmatrix} \frac{1}{2} \\ \frac{3}{2} \end{pmatrix}$ und $B = \begin{pmatrix} x_{5} & x_{3} \\ 1 & 3 \\ 0 & 2 \end{pmatrix}$.
|
||||
|
||||
\underline{2. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 0 & 9 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{3}
|
||||
y_{1} && &=& 0 \\
|
||||
3y_{1} &+& 2y_{2} &=& 9
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 0 & \frac{9}{2} \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{1} & x_{2} & x_{6} & x_{4} \\ 1 & 2 & 0 & 1 \\ 1 & 1 & 1 & 3 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} \frac{9}{2} & \frac{9}{2} & \frac{9}{2} & \frac{27}{2} \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 5 & 6 & 0 & 8 \end{pmatrix}$. Also kommen nur die ersten drei Spalten von $A_{N}$ als Eingangsspalte a infrage, wir wählen $a = \begin{pmatrix} 2 \\ 1 \end{pmatrix}$; die Eingangsvariable ist $x_{2}$.
|
||||
|
||||
\textbf{3. Schritt} (Lösung von $Bd = a$):\\
|
||||
Das Gleichungssystem $Bd = a$ lautet
|
||||
\begin{alignat*}{3}
|
||||
d_{1} &+& 3d_{2} &=& 2 \\
|
||||
&& 2d_{2} &=& 1
|
||||
\end{alignat*}
|
||||
Es folgt $d = \begin{pmatrix}\frac{1}{2} \\ \frac{1}{2}\end{pmatrix}$.
|
||||
|
||||
\textbf{4. Schritt} (Bestimmung der Ausgangsvariablen):\\
|
||||
Die Ungleichung $x_{B}^{*} - td \geq 0$ lautet $\begin{pmatrix} \frac{1}{2} \\ \frac{3}{2}\end{pmatrix} - t \begin{pmatrix}\frac{1}{2} \\ \frac{1}{2} \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \end{pmatrix}$. Das größte t, das dies erfüllt, ist $t = 1$; für $t = 1$ gilt $\begin{pmatrix} \frac{1}{2} \\ \frac{3}{2}\end{pmatrix} - t \begin{pmatrix}\frac{1}{2} \\ \frac{1}{2} \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$, Ausgangsvariable ist $x_{5}$.
|
||||
|
||||
\textbf{5. Schritt} (Update von $x_{B}^{*}$ und $B$):\\
|
||||
$x_{B}^{*} = \begin{pmatrix} x_{2}^{*} \\ x_{3}^{*} \end{pmatrix} = \begin{pmatrix} 1 \\ 1 \end{pmatrix}$ und $B = \begin{pmatrix} x_{2} & x_{3} \\ 2 & 3 \\ 1 & 2 \end{pmatrix}$.
|
||||
|
||||
\underline{3. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 6 & 9 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{3}
|
||||
2y_{1} &+& y_{2} &=& 6 \\
|
||||
3y_{1} &+& 2y_{2} &=& 9
|
||||
\end{alignat*}
|
||||
Daraus ergibt sich dieses LGS:
|
||||
\begin{alignat*}{3}
|
||||
I & 2y_{1} &+& y_{2} &=& 6 \\
|
||||
II & 3y_{1} &+& 2y_{2} &=& 9 \\
|
||||
II - I & y_{1} &+& y_{2} &=& 3 \\
|
||||
\Leftrightarrow & y_{1} && &=& 3 - y_{2} \\
|
||||
\intertext{Einsetzen in I}
|
||||
\Rightarrow & 2(3 - y_{2}) &+& y_{2} &=& 6 \\
|
||||
\Leftrightarrow & 6 - 2y_{2} &+& y_{2} &=& 6 \\
|
||||
\Leftrightarrow & &-& y_{2} &=& 0 \\
|
||||
\intertext{Einsetzen in I}
|
||||
\Rightarrow & 2y_{1} && &=& 6 \\
|
||||
\Leftrightarrow & y_{1} && &=& 3 \\
|
||||
\intertext{Einsetzen in II}
|
||||
\Rightarrow & 3 \cdot 3 && &=& 9 \\
|
||||
\Leftrightarrow & 9 && &=& 9
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 3 & 0 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{1} & x_{6} & x_{5} & x_{4} \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 3 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 3 & 0 & 3 & 3 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 5 & 0 & 0 & 8\end{pmatrix}$. Also kommen nur die erste und die letzte Spalte von $A_{N}$ als Eingangsspalte a infrage, wir wählen $a = \begin{pmatrix} 1 \\ 3 \end{pmatrix}$; die Eingangsvariable ist $x_{4}$.
|
||||
|
||||
\textbf{3. Schritt} (Lösung von $Bd = a$):\\
|
||||
Das Gleichungssystem $Bd = a$ lautet
|
||||
\begin{alignat*}{3}
|
||||
2d_{1} &+& 3d_{2} &=& 1\\
|
||||
d_{1} &+& 2d_{2} &=& 3
|
||||
\end{alignat*}
|
||||
Daraus ergibt sich dieses LGS:
|
||||
\begin{alignat*}{3}
|
||||
I & 2d_{1} &+& 3d_{2} &=& 1 \\
|
||||
II & d_{1} &+& 2d_{2} &=& 3 \\
|
||||
I - II & d_{1} &+& d_{2} &=& -2 \\
|
||||
\Leftrightarrow & d_{1} && &=& -2 - d_{2} \\
|
||||
\intertext{Einsetzen in II}
|
||||
\Rightarrow & -2 - d_{2} &+& 2d_{2} &=& 3 \\
|
||||
\Leftrightarrow & && d_{2} &=& 5 \\
|
||||
\intertext{Einsetzen in I}
|
||||
\Rightarrow & 2d_{1} &+& 3 \cdot 5 &=& 1 \\
|
||||
\Leftrightarrow & 2d_{1} && &=& - 14 \\
|
||||
\Leftrightarrow & d_{1} && &=& -7 \\
|
||||
\intertext{Einsetzen in II}
|
||||
\Rightarrow & -7 &+& 2 \cdot 5 &=& 3 \\
|
||||
\Leftrightarrow & -7 &+& 10 &=& 3 \\
|
||||
\Leftrightarrow & && 3 &=& 3
|
||||
\end{alignat*}
|
||||
Es folgt $d = \begin{pmatrix} -7 \\ 5 \end{pmatrix}$.
|
||||
|
||||
\textbf{4. Schritt} (Bestimmung der Ausgangsvariablen):\\
|
||||
Die Ungleichung $x_{B}^{*} - td \geq 0$ lautet $\begin{pmatrix} 1 \\ 1 \end{pmatrix} - t \begin{pmatrix}-7 \\ 5 \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \end{pmatrix}$. Das größte t, das dies erfüllt, ist $t = \frac{1}{5}$; für $t = \frac{1}{5}$ gilt $\begin{pmatrix} 1 \\ 1\end{pmatrix} - t \begin{pmatrix} -7 \\ 5 \end{pmatrix} = \begin{pmatrix} \frac{12}{5} \\ 0 \end{pmatrix}$, Ausgangsvariable ist $x_{3}$.
|
||||
|
||||
\textbf{5. Schritt} (Update von $x_{B}^{*}$ und $B$):\\
|
||||
$x_{B}^{*} = \begin{pmatrix} x_{2}^{*} \\ x_{4}^{*} \end{pmatrix} = \begin{pmatrix} \frac{12}{5} \\ \frac{1}{5} \end{pmatrix}$ und $B = \begin{pmatrix} x_{2} & x_{4} \\ 2 & 1 \\ 1 & 3 \end{pmatrix}$.
|
||||
|
||||
\underline{4. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 6 & 8 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{3}
|
||||
2y_{1} &+& y_{2} &=& 6 \\
|
||||
y_{1} &+& 3y_{2} &=& 8
|
||||
\end{alignat*}
|
||||
Es ergibt sich dieses LGS:
|
||||
\begin{alignat*}{3}
|
||||
I & 2y_{1} &+& y_{2} &=& 6 \\
|
||||
II & y_{1} &+& 3y_{2} &=& 8 \\
|
||||
II & y_{1} && &=& 8 - 3y_{2} \\
|
||||
\intertext{Einsetzen in I}
|
||||
\Rightarrow & 2(8 - 3y_{2}) &+& y_{2} &=& 6 \\
|
||||
\Leftrightarrow & 16 - 6y_{2} &+& y_{2} &=& 6 \\
|
||||
\Leftrightarrow & &-& 5y_{2} &=& -10 \\
|
||||
\Leftrightarrow & && y_{2} &=& 2 \\
|
||||
\intertext{Einsetzen in II}
|
||||
\Rightarrow & y_{1} &+& 3 \cdot 2 &=& 8 \\
|
||||
\Leftrightarrow & y_{1} && &=& 2
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 2 & 2 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{1} & x_{5} & x_{6} & x_{3} \\ 1 & 1 & 0 & 3 \\ 1 & 0 & 1 & 2 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 4 & 2 & 2 & 10 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 5 & 0 & 0 & 8\end{pmatrix}$. Also kommt nur die erste Spalte von $A_{N}$ als Eingangsspalte a infrage, wir wählen $a = \begin{pmatrix} 1 \\ 1 \end{pmatrix}$; die Eingangsvariable ist $x_{1}$.
|
||||
|
||||
\textbf{3. Schritt} (Lösung von $Bd = a$):\\
|
||||
Das Gleichungssystem $Bd = a$ lautet
|
||||
\begin{alignat*}{3}
|
||||
2d_{1} &+& d_{2} &=& 1\\
|
||||
d_{1} &+& 3d_{2} &=& 1
|
||||
\end{alignat*}
|
||||
Daraus ergibt sich dieses LGS:
|
||||
\begin{alignat*}{3}
|
||||
I & 2d_{1} &+& d_{2} &=& 1 \\
|
||||
II & d_{1} &+& 3d_{2} &=& 1 \\
|
||||
II & d_{1} && &=& 1 - 3d_{2} \\
|
||||
\intertext{Einsetzen in I}
|
||||
\Rightarrow & 2(1 - 3d_{2}) &+& d_{2} &=& 1 \\
|
||||
\Leftrightarrow & 2 - 6d_{2} &+& d_{2} &=& 1 \\
|
||||
\Leftrightarrow & &-& 5d_{2} &=& -1 \\
|
||||
\Leftrightarrow & && d_{2} &=& \frac{1}{5} \\
|
||||
\intertext{Einsetzen in II}
|
||||
\Rightarrow & d_{1} &+& 3 \cdot \frac{1}{5} &=& 1 \\
|
||||
\Leftrightarrow & d_{1} && &=& \frac{2}{5} \\
|
||||
\intertext{Einsetzen in I}
|
||||
\Rightarrow & 2 \cdot \frac{2}{5} &+& \frac{1}{5} &=& 1 \\
|
||||
\Leftrightarrow & \frac{4}{5} &+& \frac{1}{5} &=& 1 \\
|
||||
\Leftrightarrow & && 1 &=& 1
|
||||
\end{alignat*}
|
||||
Es folgt $d = \begin{pmatrix} \frac{2}{5} \\ \frac{1}{5} \end{pmatrix}$.
|
||||
|
||||
\textbf{4. Schritt} (Bestimmung der Ausgangsvariablen):\\
|
||||
Die Ungleichung $x_{B}^{*} - td \geq 0$ lautet $\begin{pmatrix} \frac{12}{5} \\ \frac{1}{5} \end{pmatrix} - t \begin{pmatrix} \frac{2}{5} \\ \frac{1}{5} \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \end{pmatrix}$. Das größte t, das dies erfüllt, ist $t = 1$; für $t = 1$ gilt $\begin{pmatrix} \frac{12}{5} \\ \frac{1}{5}\end{pmatrix} - t \begin{pmatrix} \frac{2}{5} \\ \frac{1}{5} \end{pmatrix} = \begin{pmatrix} 2 \\ 0 \end{pmatrix}$, Ausgangsvariable ist $x_{4}$.
|
||||
|
||||
\textbf{5. Schritt} (Update von $x_{B}^{*}$ und $B$):\\
|
||||
$x_{B}^{*} = \begin{pmatrix} x_{2}^{*} \\ x_{1}^{*} \end{pmatrix} = \begin{pmatrix} 2 \\ 1 \end{pmatrix}$ und $B = \begin{pmatrix} x_{2} & x_{1} \\ 2 & 1 \\ 1 & 1 \end{pmatrix}$.
|
||||
|
||||
\underline{5. Iteration}
|
||||
|
||||
\textbf{1. Schritt} (Lösung von $y^{T}B = c_{B}^{T}$):\\
|
||||
Es gilt $c_{B}^{T} = \begin{pmatrix} 6 & 5 \end{pmatrix}$. Das Gleichungssystem $y^{T}B = c_{B}^{T}$ lautet
|
||||
\begin{alignat*}{3}
|
||||
2y_{1} &+& y_{2} &=& 6 \\
|
||||
y_{1} &+& y_{2} &=& 5
|
||||
\end{alignat*}
|
||||
Es ergibt sich dieses LGS:
|
||||
\begin{alignat*}{3}
|
||||
I & 2y_{1} &+& y_{2} &=& 6 \\
|
||||
II & y_{1} &+& y_{2} &=& 5 \\
|
||||
I - II & y_{1} && &=& 1 \\
|
||||
\intertext{Einsetzen in II}
|
||||
\Rightarrow & 1 &+& y_{2} &=& 5 \\
|
||||
\Leftrightarrow & && y_{2} &=& 4 \\
|
||||
\intertext{Einsetzen in I}
|
||||
\Rightarrow & 2 \cdot 1 &+& 4 &=& 6 \\
|
||||
\Leftrightarrow & && 6 &=& 6
|
||||
\end{alignat*}
|
||||
Also gilt $y^{T} = \begin{pmatrix} 1 & 4 \end{pmatrix}$.
|
||||
|
||||
\textbf{2. Schritt} (Bestimmung der Eingangsspalte a und gleichzeitig der Eingangsvariablen):\\
|
||||
Es gilt $A_{N} = \begin{pmatrix} x_{4} & x_{5} & x_{6} & x_{3} \\ 1 & 1 & 0 & 3 \\ 3 & 0 & 1 & 2 \end{pmatrix},\; y^{T}A_{N} = \begin{pmatrix} 13 & 1 & 4 & 11 \end{pmatrix}$ und $c_{N}^{T} = \begin{pmatrix} 8 & 0 & 0 & 9\end{pmatrix}$. Wegen $13 \geq 8, 1 \geq 0, 4 \geq 0, 11 \geq 9$ ist die aktuelle Lösung optimal. Die optimale Lösung lautet $x_{1}^{*} = 1, x_{2}^{*} = 2, x_{3}^{*} = 0, x_{4}^{*} = 0$ mit $z^{*} = 5x_{1}^{*} + 6x_{2}^{*} + 9x_{3}^{*} + 8x_{4}^{*} = 17$.
|
||||
|
||||
\end{document}
|
||||
411
prosem/VortragProsem.tex
Normal file
411
prosem/VortragProsem.tex
Normal file
@ -0,0 +1,411 @@
|
||||
\documentclass[14pt]{beamer}
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Meta informations:
|
||||
\newcommand{\trauthor}{Jim Martens}
|
||||
\newcommand{\trtype}{Proseminar} %{Proseminar} %{Seminar} %{Workshop}
|
||||
\newcommand{\trcourse}{Proseminar Artificial Intelligence}
|
||||
\newcommand{\trtitle}{Methods for understanding natural language}
|
||||
\newcommand{\trmatrikelnummer}{6420323}
|
||||
\newcommand{\tremail}{2martens@informatik.uni-hamburg.de}
|
||||
\newcommand{\trinstitute}{}
|
||||
\newcommand{\trwebsiteordate}{26.02.2014}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Languages:
|
||||
|
||||
% Falls die Ausarbeitung in Deutsch erfolgt:
|
||||
% \usepackage[german]{babel}
|
||||
% \usepackage[T1]{fontenc}
|
||||
% \usepackage[latin1]{inputenc}
|
||||
% \usepackage[latin9]{inputenc}
|
||||
% \selectlanguage{german}
|
||||
|
||||
% If the thesis is written in English:
|
||||
\usepackage[english]{babel}
|
||||
\selectlanguage{english}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Bind packages:
|
||||
\usepackage{beamerthemesplit}
|
||||
\usetheme{Boadilla}
|
||||
%\usetheme{Copenhagen}
|
||||
%\usetheme{Darmstadt}
|
||||
%\usetheme{Frankfurt}
|
||||
%\usetheme{Ilmenau}
|
||||
%\usetheme{JuanLesPins}
|
||||
%\usetheme{Madrid}
|
||||
%\usetheme{Warsaw }
|
||||
%\usecolortheme{dolphin}
|
||||
%\setbeamertemplate{sections/subsections in toc}[sections numbered]
|
||||
%\beamertemplatenavigationsymbolsempty
|
||||
%\setbeamertemplate{headline}[default] % deaktiviert die Kopfzeile
|
||||
\setbeamertemplate{navigation symbols}{}% deaktiviert Navigationssymbole
|
||||
%\useinnertheme{rounded}
|
||||
|
||||
\usepackage{acronym} % Acronyms
|
||||
\usepackage{algorithmic} % Algorithms and Pseudocode
|
||||
\usepackage{algorithm} % Algorithms and Pseudocode
|
||||
\usepackage{amsfonts} % AMS Math Packet (Fonts)
|
||||
\usepackage{amsmath} % AMS Math Packet
|
||||
\usepackage{amssymb} % Additional mathematical symbols
|
||||
\usepackage{amsthm}
|
||||
\usepackage{color} % Enables defining of colors via \definecolor
|
||||
\usepackage{fancybox} % Gleichungen einrahmen
|
||||
\usepackage{fancyhdr} % Paket zur schickeren der Gestaltung der
|
||||
\usepackage{graphicx} % Inclusion of graphics
|
||||
\usepackage{tikz}
|
||||
%\usepackage{wrapfig}
|
||||
%\usepackage{latexsym} % Special symbols
|
||||
\usepackage{longtable} % Allow tables over several parges
|
||||
\usepackage{listings} % Nicer source code listings
|
||||
\usepackage{lmodern}
|
||||
\usepackage{multicol} % Content of a table over several columns
|
||||
\usepackage{multirow} % Content of a table over several rows
|
||||
\usepackage{rotating} % Alows to rotate text and objects
|
||||
\usepackage[section]{placeins} % Ermoeglich \Floatbarrier fuer Gleitobj.
|
||||
\usepackage[hang]{subfigure} % Allows to use multiple (partial) figures in a fig
|
||||
%\usepackage[font=footnotesize,labelfont=rm]{subfig} % Pictures in a floating environment
|
||||
\usepackage{tabularx} % Tables with fixed width but variable rows
|
||||
\usepackage{url,xspace,boxedminipage} % Accurate display of URLs
|
||||
|
||||
\definecolor{uhhRed}{RGB}{254,0,0} % Official Uni Hamburg Red
|
||||
\definecolor{uhhGrey}{RGB}{136,136,136} % Official Uni Hamburg Grey
|
||||
\definecolor{uhhLightGrey}{RGB}{180,180,180} % Official Uni Hamburg LightGrey
|
||||
\definecolor{uhhLightLightGrey}{RGB}{220,220,220} % Official Uni Hamburg LightLightGrey
|
||||
\setbeamertemplate{itemize items}[ball]
|
||||
\setbeamercolor{title}{fg=uhhRed,bg=white}
|
||||
\setbeamercolor{title in head/foot}{bg=uhhRed}
|
||||
\setbeamercolor{block title}{bg=uhhGrey,fg=white}
|
||||
\setbeamercolor{block body}{bg=uhhLightLightGrey,fg=black}
|
||||
\setbeamercolor{section in head/foot}{bg=black}
|
||||
\setbeamercolor{frametitle}{bg=white,fg=uhhRed}
|
||||
\setbeamercolor{author in head/foot}{bg=black,fg=white}
|
||||
\setbeamercolor{author in footline}{bg=white,fg=black}
|
||||
\setbeamercolor*{item}{fg=uhhRed}
|
||||
\setbeamercolor*{section in toc}{fg=black}
|
||||
\setbeamercolor*{separation line}{bg=black}
|
||||
\setbeamerfont*{author in footline}{size=\scriptsize,series=\mdseries}
|
||||
\setbeamerfont*{institute}{size=\footnotesize}
|
||||
|
||||
\newcommand{\opticalseperator}{0.0025\paperwidth}
|
||||
|
||||
\institute{Universit\"at Hamburg\\\trinstitute}
|
||||
\title{\trtitle}
|
||||
\subtitle{\trtype}
|
||||
\author{\trauthor}
|
||||
\date{}
|
||||
\logo{}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Configurationen:
|
||||
%\hypersetup{pdfpagemode=FullScreen}
|
||||
|
||||
\hyphenation{whe-ther} % Manually use: "\-" in a word: Staats\-ver\-trag
|
||||
|
||||
%\lstloadlanguages{C} % Set the default language for listings
|
||||
\DeclareGraphicsExtensions{.pdf,.svg,.jpg,.png,.eps} % first try pdf, then eps, png and jpg
|
||||
\graphicspath{{./src/} {/home/jim/Pictures/}} % Path to a folder where all pictures are located
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Costom Definitions:
|
||||
\setbeamertemplate{title page}
|
||||
{
|
||||
\vbox{}
|
||||
\vspace{0.4cm}
|
||||
\begin{centering}
|
||||
\begin{beamercolorbox}[sep=8pt,center,colsep=-4bp]{title}
|
||||
\usebeamerfont{title}\inserttitle\par%
|
||||
\ifx\insertsubtitle\@empty%
|
||||
\else%
|
||||
\vskip0.20em%
|
||||
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
|
||||
\fi%
|
||||
\end{beamercolorbox}%
|
||||
\vskip0.4em
|
||||
\begin{beamercolorbox}[sep=8pt,center,colsep=-4bp,rounded=true,shadow=true]{author}
|
||||
\usebeamerfont{author}\insertauthor \\ \insertinstitute
|
||||
\end{beamercolorbox}
|
||||
|
||||
\vfill
|
||||
%\begin{beamercolorbox}[ht=8ex,center]{}
|
||||
% \includegraphics[width=0.20\paperwidth]{wtmIcon.pdf}
|
||||
%\end{beamercolorbox}%
|
||||
\begin{beamercolorbox}[sep=8pt,center,colsep=-4bp,rounded=true,shadow=true]{institute}
|
||||
\usebeamerfont{institute}\trwebsiteordate
|
||||
\end{beamercolorbox}
|
||||
\vspace{-0.1cm}
|
||||
\end{centering}
|
||||
}
|
||||
|
||||
\setbeamertemplate{frametitle}
|
||||
{
|
||||
\begin{beamercolorbox}[wd=\paperwidth,ht=3.8ex,dp=1.2ex,leftskip=0pt,rightskip=4.0ex]{frametitle}%
|
||||
\usebeamerfont*{frametitle}\centerline{\insertframetitle}
|
||||
\end{beamercolorbox}
|
||||
\vspace{0.0cm}
|
||||
}
|
||||
|
||||
\setbeamertemplate{footline}
|
||||
{
|
||||
\leavevmode
|
||||
\vspace{-0.05cm}
|
||||
\hbox{
|
||||
\begin{beamercolorbox}[wd=.32\paperwidth,ht=4.8ex,dp=2.7ex,center]{author in footline}
|
||||
\hspace*{2ex}\usebeamerfont*{author in footline}\trauthor
|
||||
\end{beamercolorbox}%
|
||||
\begin{beamercolorbox}[wd=.60\paperwidth,ht=4.8ex,dp=2.7ex,center]{author in footline}
|
||||
\usebeamerfont*{author in footline}\trtitle
|
||||
\end{beamercolorbox}%
|
||||
\begin{beamercolorbox}[wd=.07\paperwidth,ht=4.8ex,dp=2.7ex,center]{author in footline}
|
||||
\usebeamerfont*{author in footline}\insertframenumber{}
|
||||
\end{beamercolorbox}
|
||||
}
|
||||
\vspace{0.15cm}
|
||||
}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Additional 'theorem' and 'definition' blocks:
|
||||
\newtheorem{axiom}{Axiom}[section]
|
||||
%\newtheorem{axiom}{Fakt}[section] % Wenn in Deutsch geschrieben wird.
|
||||
%Usage:%\begin{axiom}[optional description]%Main part%\end{fakt}
|
||||
|
||||
%Additional types of axioms:
|
||||
\newtheorem{observation}[axiom]{Observation}
|
||||
|
||||
%Additional types of definitions:
|
||||
\theoremstyle{remark}
|
||||
%\newtheorem{remark}[section]{Bemerkung} % Wenn in Deutsch geschrieben wird.
|
||||
\newtheorem{remark}[section]{Remark}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Provides TODOs within the margin:
|
||||
\newcommand{\TODO}[1]{\marginpar{\emph{\small{{\bf TODO: } #1}}}}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Abbreviations and mathematical symbols
|
||||
\newcommand{\modd}{\text{ mod }}
|
||||
\newcommand{\RS}{\mathbb{R}}
|
||||
\newcommand{\NS}{\mathbb{N}}
|
||||
\newcommand{\ZS}{\mathbb{Z}}
|
||||
\newcommand{\dnormal}{\mathit{N}}
|
||||
\newcommand{\duniform}{\mathit{U}}
|
||||
|
||||
\newcommand{\erdos}{Erd\H{o}s}
|
||||
\newcommand{\renyi}{-R\'{e}nyi}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Display of TOCs:
|
||||
%\AtBeginSection[]
|
||||
%{
|
||||
% \setcounter{tocdepth}{2}
|
||||
% \frame
|
||||
% {
|
||||
% \frametitle{Outline}
|
||||
% \tableofcontents[currentsection]
|
||||
% }
|
||||
%}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Document:
|
||||
\begin{document}
|
||||
\renewcommand{\arraystretch}{1.2}
|
||||
|
||||
\begin{frame}[plain] % plain => kein Rahmen
|
||||
\titlepage
|
||||
\end{frame}
|
||||
%\setcounter{framenumber}{0}
|
||||
|
||||
%%%%%%%%%%%%%%
|
||||
% Your Content
|
||||
|
||||
\section*{Motivation and Question}
|
||||
|
||||
\begin{frame}[t]{Motivation}
|
||||
\begin{columns}[t]
|
||||
\begin{column}{0.5\textwidth}
|
||||
\begin{itemize}
|
||||
\item<2-> Dialogue in computer games
|
||||
\begin{itemize}
|
||||
\item<3-> spoken
|
||||
\item<4-> written
|
||||
\end{itemize}
|
||||
\item<5-> Ambiguity
|
||||
\item<5-> Disambiguation
|
||||
%\item Use references \textsuperscript{[Author, 2010]}
|
||||
\end{itemize}
|
||||
\end{column}
|
||||
\begin{column}{68mm}\centering
|
||||
\begin{pgfpicture}{0cm}{3cm}{1cm}{0cm}
|
||||
\pgfbox[center,center]{\includegraphics[scale=0.15]{massEffectDialogScreenshot}}
|
||||
\end{pgfpicture}
|
||||
\end{column}
|
||||
|
||||
\end{columns}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Outline}
|
||||
\tableofcontents
|
||||
\end{frame}
|
||||
|
||||
\section{Definitions}
|
||||
|
||||
\begin{frame}[t]{Definitions}
|
||||
\begin{itemize}
|
||||
\item Syntax
|
||||
\begin{itemize}
|
||||
\item Describes the sentence structure (e.g. simple subject--predicate--object order) and kind (e.g. declarative, question, order)
|
||||
\end{itemize}
|
||||
\item Grammar
|
||||
\begin{itemize}
|
||||
\item Specifies valid sentences
|
||||
\end{itemize}
|
||||
\item Semantics
|
||||
\begin{itemize}
|
||||
\item Meaning of the written words
|
||||
\end{itemize}
|
||||
\item Pragmatics
|
||||
\begin{itemize}
|
||||
\item Meaning of words in a given context or actual meaning
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Syntactic Parsing}
|
||||
|
||||
\begin{frame}[t,fragile]{Lexicon}
|
||||
\begin{columns}[t]
|
||||
\begin{column}{0.5\textwidth}
|
||||
\begin{itemize}
|
||||
\item Allowed words \textsuperscript{[Russel, 2009]}
|
||||
\item Probabilities
|
||||
\end{itemize}
|
||||
\end{column}
|
||||
\begin{column}{0.5\textwidth}
|
||||
Example:
|
||||
\begin{alignat*}{2}
|
||||
Noun &\rightarrow && \text{tree [1.00]} \\
|
||||
Verb &\rightarrow && \text{is [1.00]} \\
|
||||
Adjective &\rightarrow && \text{high [1.00]} \\
|
||||
Article &\rightarrow && \text{the [1.00]} \\
|
||||
\end{alignat*}
|
||||
\end{column}
|
||||
\end{columns}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[t]{Grammar}
|
||||
\begin{itemize}
|
||||
\item Combines words into valid phrases \textsuperscript{[Russel, 2009]}
|
||||
\item Base for all kinds of parsing
|
||||
\item Probabilities
|
||||
\item Defines valid syntax
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
\begin{frame}[t,fragile]{Grammar}
|
||||
Example:
|
||||
\begin{alignat*}{2}
|
||||
S \;&\rightarrow &\; NP\;\;VP \;&[1.00] \\
|
||||
NP \;&\rightarrow &\; A\;N \;&[1.00]\\
|
||||
A \;&\rightarrow &\; Article\;&[1.00]\\
|
||||
N \;&\rightarrow &\; Noun\;&[1.00]\\
|
||||
VP \;&\rightarrow &\; Verb \;&[0.40] \\
|
||||
\;&|&\; VP\;Adjs \;&[0.60] \\
|
||||
Adjs \;&\rightarrow &\; Adjective \;&[0.80] \\
|
||||
\;&|&\; Adjective\;Adjs \;&[0.20]
|
||||
\end{alignat*}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[t]{Cocke Younger Kasami (CYK)}
|
||||
\begin{itemize}
|
||||
\item Named after inventors \textsuperscript{[Russel, 2009]}
|
||||
\begin{itemize}
|
||||
\item John Cocke (1925--2002)
|
||||
\item Daniel H. Younger
|
||||
\item Tadeo Kasami (1930--2007)
|
||||
\end{itemize}
|
||||
\item Dynamic programming parsing algorithm \textsuperscript{[Russel, 2009]}
|
||||
\item Works only with grammars in CNF \textsuperscript{[Russel, 2009]}
|
||||
\item Probabilities serve as disambiguation \textsuperscript{[Russel, 2009]}
|
||||
\item Best algorithm for general CFGs \textsuperscript{[Russel, 2009]}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[t]{CYK Example}
|
||||
\centering
|
||||
\begin{tabular}{|c|c|c|c|}
|
||||
\hline
|
||||
X & start & length & p \\
|
||||
\hline
|
||||
\hline
|
||||
A & 1 & 1 & 1.00 \\
|
||||
\hline
|
||||
N & 2 & 1 & 1.00 \\
|
||||
\hline
|
||||
VP & 3 & 1 & 0.40 \\
|
||||
\hline
|
||||
Adjs & 4 & 1 & 0.80 \\
|
||||
\hline
|
||||
Adjs & 5 & 1 & 0.80 \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\end{frame}
|
||||
|
||||
\section{Semantic Analysis}
|
||||
|
||||
\begin{frame}[t]{Semantic Analysis}
|
||||
\begin{itemize}
|
||||
\item Syntax-driven semantic analysis \textsuperscript{[Jurafsky, 2009]}
|
||||
\item Syntax representation
|
||||
\begin{itemize}
|
||||
\item Parse trees \textsuperscript{[Jurafsky, 2009]}
|
||||
\item Dependency structures \textsuperscript{[Jurafsky, 2009]}
|
||||
\item etc
|
||||
\end{itemize}
|
||||
\item First--Order Logic
|
||||
\item Lambda notation
|
||||
\item Semantic attachments
|
||||
\item Meaning representation
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[t,fragile]{Semantic Analysis}
|
||||
Example of semantic attachment:
|
||||
\[
|
||||
A \rightarrow the \;\{\lambda x.\lambda P.\exists x.P(x)\}
|
||||
\]
|
||||
Example of meaning representation:
|
||||
\[
|
||||
\exists x.Tree(x) \Rightarrow \exists a.Very(a) \wedge HighThing(a, x)
|
||||
\]
|
||||
\end{frame}
|
||||
|
||||
|
||||
\section{Conclusion}
|
||||
|
||||
\begin{frame}[t]{Conclusion}
|
||||
\begin{itemize}
|
||||
\item Ambiguity remains large problem
|
||||
\item Parsing and semantic analysis need restriction
|
||||
\item Context is key
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
%%%%%%%%%%%%%%
|
||||
|
||||
\begin{frame}[c]{The End}
|
||||
\begin{center}
|
||||
Thank you for your attention.\\[1ex]
|
||||
Any questions?\\[5ex]
|
||||
\end{center}
|
||||
\footnotesize
|
||||
Literature:
|
||||
\begin{itemize}
|
||||
\item Daniel Jurafsky and James H. Martin. \emph{Speech and Language processing}. Pearson, 2009
|
||||
\item Stuart J. Russel and Peter Norvig. \emph{Artificial intelligence: A Modern Approach}. Pearson, 2009
|
||||
\end{itemize}
|
||||
Pictures:
|
||||
\begin{itemize}
|
||||
\item Motivation: Mass Effect 1 Screenshot from IGN.com
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\end{document}
|
||||
154
prosem/notices.txt
Normal file
154
prosem/notices.txt
Normal file
@ -0,0 +1,154 @@
|
||||
Method for understanding natural language
|
||||
=========================================
|
||||
|
||||
title slide: present title and lead to motivation (Why is it interesting?)
|
||||
-----------
|
||||
|
||||
Motivation
|
||||
----------
|
||||
|
||||
- explain Mass Effect 1 screenshot (short and concise without story details)
|
||||
-1- it's a dialogue with predefined options
|
||||
- click
|
||||
-1- what about a game where I can freely decide what I say?
|
||||
-1- speech recognition would be necessary
|
||||
- but there are also other kinds of dialogue in computer games
|
||||
-2- Shroud of the Avatar uses a dialogue box (similar to chat bot) to enter your sentences
|
||||
-2- the NPCs react appropriately
|
||||
-2- behind the hood they just use keyword searching
|
||||
- click
|
||||
- if this is developed further, you come pretty quickly to the methods used to understand natural language
|
||||
- but there is an imminent problem: Ambiguity (click)
|
||||
- Disambiguation is used to address ambiguity
|
||||
|
||||
Outline
|
||||
-------
|
||||
|
||||
- start with some basic definitions
|
||||
- then Syntactic Parsing which is the key aspect of this presentation
|
||||
- Semantic Analysis is next but only the key points are presented
|
||||
- Conclusion (refers to critical discussion in paper)
|
||||
|
||||
Definitions
|
||||
-----------
|
||||
|
||||
syntax: describes sentence structure (for example subject-predicate-object order) and kind (declarative, question, order)
|
||||
|
||||
grammar: specifies valid sentences
|
||||
|
||||
semantics: meaning of the written words
|
||||
|
||||
pragmatics: meaning of words in a given context/actual meaning
|
||||
|
||||
- explain ambiguity on semantic level with the word "order"
|
||||
- as you can see this ambiguity can easily be resolved if the context is given
|
||||
- but without the context, the word "order" has different possible meanings
|
||||
- which one to choose?
|
||||
- that's a question that belongs to the semantic analysis
|
||||
|
||||
Syntactic Parsing (Lexicon)
|
||||
---------------------------
|
||||
|
||||
- first we come to syntactic parsing
|
||||
- a lexicon is very important there
|
||||
- it defines the set of allowed words divided into categories
|
||||
- open and closed categories
|
||||
-1- open: new words are added constantly, complete list not feasible
|
||||
-1- closed: change over course of centuries, complete list possible
|
||||
|
||||
- each word is attached a probability
|
||||
- all probabilities in one category sum up to 1
|
||||
|
||||
Syntactic Parsing (Grammar)
|
||||
---------------------------
|
||||
|
||||
- the grammar is somewhat the brother of the lexicon
|
||||
- defines how the allowed words can be brought into a sentence structure
|
||||
- contains multiple rules
|
||||
- base for all kinds of parsing as every algorithm must be able to determine if the input is valid
|
||||
|
||||
- in our case the grammar is a "Probabilistic context free grammar"
|
||||
-1- it has probabilities for each rule
|
||||
-1- the probabilities of all rules starting with the same non-terminal sum up to 1
|
||||
|
||||
- click
|
||||
|
||||
- this is example from paper
|
||||
- it's a very simplistic grammar that does only allow the simplest forms of sentences
|
||||
- Article, Noun, Verb, Adjective stand for a word from these categories in lexicon
|
||||
- as you can see the probabilities of the VP and Adjs rules sum up to 1 each
|
||||
- these probabilities are used to calculate the total probability of a parse tree in the (click) Cocke-Younger-Kasami or short CYK algorithm
|
||||
|
||||
Syntactic Parsing (CYK)
|
||||
-----------------------
|
||||
|
||||
- it is named after the inventors John Cocke, Daniel H. Younger and Tadeo Kasami
|
||||
- Cocke was awarded the ACM Turing Award and National Medal of Science of the United States
|
||||
- Kasami was the first to publish the ideas of the CYK algorithm
|
||||
|
||||
- it's a dynamic programming parsing algorithm
|
||||
-1- in short: it utilizes the results from earlier iterations
|
||||
- it's got the drawback that it only works with grammars in CNF
|
||||
-2- in theory no problem as every CFG can be converted to CNF without loss in expressiveness
|
||||
-2- in practice it poses non-trivial problems as the resulting trees do not fit to original grammar
|
||||
-2- solution to this is a modification of the CYK algorithm to handle unit productions (A->C->B) directly (Jurafsky Chapter 13 Section 4 Page 475)
|
||||
|
||||
- probabilities are used for disambiguation (if two things are possible, the one with higher probability does make probably more sense and comes closer to the intended meaning)
|
||||
- probabilities are gained from a treebank (like Penn Treebank)
|
||||
|
||||
- CYK is the best algorithm for general CFGs
|
||||
|
||||
- click
|
||||
|
||||
- here's an example for the table used by CYK to determine parse trees (excerpt from table in paper)
|
||||
- begins with length 1 and looks at every word (here it's the sentence "The tree is very high")
|
||||
- next it looks at length 2, 3, 4 and finally 5
|
||||
|
||||
- in the end there should be at least one entry in the table with S in column X, 1 in start and 5 in length.
|
||||
- If there is no such entry and the algorithm was performed correctly, the input is not valid.
|
||||
- if there is more than one such entry, there are multiple parse trees and therefore we have ambiguity
|
||||
- the probability is then used to decide which one is used to determine the parse tree (for example with the help of backpointers)
|
||||
|
||||
- this parse tree is then given to (click) the Semantic Analysis
|
||||
|
||||
Semantic Analysis
|
||||
-----------------
|
||||
|
||||
- there are multiple approaches for Semantic Analysis, the syntax-driven is presented
|
||||
- it requires a syntax representation as input
|
||||
-1- can be parse trees
|
||||
-1- but also dependency structures or other things
|
||||
|
||||
- the analysis utilizes First-Order Logic
|
||||
-2- connectives: and, or, implies
|
||||
-2- quantifiers: for all, exists
|
||||
-2- predicates, functions, variables
|
||||
|
||||
- and lambda notation (example can be seen in paper)
|
||||
|
||||
- the grammar is augmented with semantic attachments (click)
|
||||
- these are now combined starting with S and going down
|
||||
- in the example of the paper, the final meaning representation is this (showing on representation on slide)
|
||||
- one can also see here the elements of the logic (at least partially)
|
||||
- the whole process (step-by-step) can be seen in the paper
|
||||
|
||||
- the meaning representation can then be computationally used to react to the input
|
||||
|
||||
- click
|
||||
|
||||
Conclusion
|
||||
----------
|
||||
|
||||
- even though there are means to minimize ambiguity like probabilities, it is by far not possible to use the full grammar of a natural language (with no hint of the context, there are meany parses that make syntactically sense but not necessarily context-wise)
|
||||
- there is simply to much ambiguity and the known methods of disambiguation don't solve the problem completely
|
||||
- a restriction of the context and allowed words is therefore necessary to be able to parse and/or compute the meaning
|
||||
|
||||
- if we manage to find a way to tell the computer the context without hardcoding it by limiting the input, the problem could be solved altogether
|
||||
- cognitive inspired methods could be the key here
|
||||
|
||||
- click
|
||||
|
||||
End
|
||||
---
|
||||
|
||||
Thank you for your attention
|
||||
File diff suppressed because one or more lines are too long
@ -8,7 +8,7 @@
|
||||
\newcommand{\trmatrikelnummer}{6420323}
|
||||
\newcommand{\tremail}{2martens@informatik.uni-hamburg.de}
|
||||
\newcommand{\trarbeitsbereich}{Knowledge Technology, WTM}
|
||||
\newcommand{\trdate}{10.02.2014}
|
||||
\newcommand{\trdate}{26.01.2014}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Languages:
|
||||
@ -27,7 +27,8 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Bind packages:
|
||||
\usepackage{acronym} % Acronyms
|
||||
\usepackage{algorithmic} % Algorithms and Pseudocode
|
||||
%\usepackage{algorithmic} % Algorithms and Pseudocode
|
||||
\usepackage{algpseudocode}
|
||||
\usepackage{algorithm} % Algorithms and Pseudocode
|
||||
\usepackage{amsfonts} % AMS Math Packet (Fonts)
|
||||
\usepackage{amsmath} % AMS Math Packet
|
||||
@ -60,6 +61,10 @@
|
||||
\usepackage{tabularx} % Tables with fixed width but variable rows
|
||||
\usepackage{url,xspace,boxedminipage} % Accurate display of URLs
|
||||
|
||||
\usepackage{float}
|
||||
\floatstyle{boxed}
|
||||
\restylefloat{figure}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Configurationen:
|
||||
|
||||
@ -170,10 +175,10 @@
|
||||
|
||||
% Abstract gives a brief summary of the main points of a paper:
|
||||
\section*{Abstract}
|
||||
Your text here...
|
||||
Syntactic parsing and semantic analysis are two important methods for understanding natural language. Each of them has their individual strengths and weaknesses. But both of them have major issues with ambiguity once a restricted environment is left.
|
||||
|
||||
% Lists:
|
||||
\setcounter{tocdepth}{2} % depth of the table of contents (for Seminars 2 is recommented)
|
||||
\setcounter{tocdepth}{2} % depth of the table of contents (for Seminars 2 is recommended)
|
||||
\tableofcontents
|
||||
\pagenumbering{arabic}
|
||||
\clearpage
|
||||
@ -188,54 +193,188 @@
|
||||
\section{Introduction}
|
||||
\label{sec:introduction}
|
||||
|
||||
\begin{itemize}
|
||||
\item two kinds of natural language: spoken language and written language
|
||||
\item will concentrate on written language
|
||||
\item definition of syntax, semantics and pragmatics
|
||||
\item two important methods: syntactic parsing and semantic analysis
|
||||
\end{itemize}
|
||||
It's the dream of many Science-Fiction fans: A fully sentient AI. Let's ignore for a moment all the odds that are against it (morality, physics, etc.) and concentrate on one aspect that is mandatory for even much less ambitious dreams. Imagine a computer game in which you can talk natural language to the NPC counterparts so that they react appropriately to it. Well maybe that is still too ambitious. What about writing what you want to say? In that case the computer needs to understand what you are writing so that it can react to it.
|
||||
|
||||
The input in this case is plain text, following the grammar of a natural language like English. Without loss of generality it is assumed that the input is syntactically correct and follows the grammar of the natural language. The computer therefore gets a certain amount of text that follows a specified grammar. The grammar of modern English is assumed for the scope of this paper. With this information available, the computer still knows nothing about the meaning of the text. You could ask for a hot chocolate or you could write nasty things, it won't make a difference at this point.
|
||||
|
||||
In order to make the computer react properly to your input, it needs to understand and therefore process the input in the first place. This can be achieved by the usage of some methods for natural language understanding. For the scope of this paper ``natural language understanding'' contains all the methods used for understanding natural language. These include both methods to understand written natural language and methods used to understand spoken natural language. This paper looks closer at two of the methods used to understand written language. The first one is the syntactic parsing, the second one the semantic analysis. To understand how these methods work, you need to know the basic terminology of the subject matter. In the following paragraphs the terms syntax, semantics and pragmatics are explained with respect to the two mentioned methods.
|
||||
|
||||
The first method syntactic parsing relies on a grammar that describes the set of possible input, also called syntax. The syntax specifies what are allowed sentence structures and how these are built.
|
||||
|
||||
The semantic analysis relies on the semantics of a given input. That means what the given input means. An example: ``You run around the bush''. The semantic meaning of this sentence is that you are running around a bush.
|
||||
The pragmatics though define what is the intended meaning of an input. In this example it's not that you run around the bush but actually that you take a long time to get to the point in a discussion. It's a so called idiom. This difference between semantic meaning, where just the sentence as it is written is considered, and pragmatic meaning, where the intended meaning is considered, generates ambiguity that is easy for humans to resolve but difficult for computers. But even the pragmatics in this example are ambiguous, because it depends on the context what it actually means. If two persons are walking around in a forest and one starts running around the bush, the pragmatic meaning of the sentence in this example would be the previously mentioned semantic meaning.
|
||||
|
||||
On top of that the semantic meaning itself isn't always clear either. Sometimes words have multiple meanings, so that even the semantic meaning can have different possible interpretations.
|
||||
|
||||
The basic terminology should be clear by now. Whenever there are additional prerequisites to understand a method, these are explained in the section of that method.
|
||||
|
||||
Before the actual evaluation of the methods starts, the usage of the result of both methods is shortly described. After both syntactic parsing and semantic analysis have been executed, in this order, you have a semantic representation of the input. This representation could be used for example for an interface to a knowledge database where the user just inserts the question and gets an appropriate answer.
|
||||
|
||||
But there are other possible use cases as well. The two described methods could be used in a chatbot.
|
||||
|
||||
In this paper both syntactic parsing and semantic analysis are presented. After the presentation of the methods, they are critically discussed to finally come to a conclusion.
|
||||
|
||||
\section{Evaluation of methods}
|
||||
\label{sec:evalMethods}
|
||||
|
||||
Syntactic parsing and semantic analysis offer each a broad range of approaches. In this paper the ``syntax-driven semantic analysis''\cite[p.~617]{Jurafsky2009} is evaluated. It's especially interesting because it utilizes the output of the syntactic parsing to analyze the meaning. Therefore the two methods can be lined up in chronological order. First comes the syntactic parsing and then the semantic analysis. The methods are presented here in the same order.
|
||||
|
||||
They will be explained with the help of an example. Let's take the sentence ``The tree is very high''. For every method the theory is introduced first and the practical application with the example comes after it.
|
||||
|
||||
\subsection{Syntactic Parsing}
|
||||
\label{subSec:syntacticParsing}
|
||||
Syntactic Parsing is used to create parse trees. These can be used for grammar checks in a text editor: ``A sentence that cannot be parsed may have grammatical errors''\footnote{\cite{Jurafsky2009b}, page 461}. But they more likely ``serve as an important intermediate stage of representation for semantic analysis''\footnote{\cite{Jurafsky2009b}, page 461}. There are different algorithms available to create such trees. The CYK\footnote{named after inventors John Cocke, Daniel Younger and Tadeo Kasami} algorithm will be explained further. But before the CYK algorithm is explained, the reason for its existance is presented.
|
||||
Syntactic Parsing is used to create parse trees. These can be used for grammar checks in a text editor: ``A sentence that cannot be parsed may have grammatical errors''\cite[p.~461]{Jurafsky2009b}. But they more likely ``serve as an important intermediate stage of representation for semantic analysis''\cite[p.~461]{Jurafsky2009b}. There are different algorithms available to create such trees. The CYK\footnote{named after inventors John Cocke, Daniel Younger and Tadeo Kasami\cite[p.~893]{Russel2010}} algorithm will be explained further. But before the CYK algorithm is explained, the reason for its existance is presented.
|
||||
|
||||
There are two classical ways of parsing a sentence. The one is bottom-up and the other one is top-down. Both approaches have their own advantages and disadvantages. In addition the ambiguity creates problems. To implement bottom-up and top-down search algorithms in the face of ambiguity, ``an agenda-based backtracking strategy''\footnote{\cite{Jurafsky2009b}, page 468} is used. The problem here is that every time the parser recognizes that the current parse tree is wrong, it has to backtrack and explore other parts of the sentence. This creates a huge amount of work duplication and is therefore inefficient.
|
||||
\begin{figure}
|
||||
\begin{alignat*}{2}
|
||||
Noun &\rightarrow && \text{tree [1.00]} \\
|
||||
Verb &\rightarrow && \text{is [1.00]} \\
|
||||
Adjective &\rightarrow && \text{high [0.50]} \;|\; \text{very [0.50]} \\
|
||||
Article &\rightarrow && \text{the [1.00]} \\
|
||||
\end{alignat*}
|
||||
\caption{The lexicon for $\varepsilon_{0}$. The sum of the probabilities for each category is 1.}
|
||||
\label{fig:lexicon}
|
||||
\end{figure}
|
||||
|
||||
A solution to these problems is offered by ``dynamic programming parsing methods''\footnote{\cite{Jurafsky2009b}, page 469}. The CYK algorithm is one of multiple algorithms based on dynamic programming.
|
||||
\begin{figure}
|
||||
\begin{alignat*}{3}
|
||||
\varepsilon_{0}:& S \;&\rightarrow &\; NP\;\;VP \;&[1.00]&\; \text{The tree + is very high} \\
|
||||
& NP \;&\rightarrow &\; A\;N \;&[1.00]&\; \text{The + tree}\\
|
||||
& A \;&\rightarrow &\; Article\;&[1.00]&\; \text{the}\\
|
||||
& N \;&\rightarrow &\; Noun\;&[1.00]&\; \text{tree}\\
|
||||
& VP \;&\rightarrow &\; Verb \;&[0.40]&\; \text{is} \\
|
||||
& \;&|&\; VP\;Adjs \;&[0.60]&\; \text{is + very high} \\
|
||||
& Adjs \;&\rightarrow &\; Adjective \;&[0.80]&\; \text{very} \\
|
||||
& \;&|&\; Adjective\;Adjs \;&[0.20]&\; \text{very + high}
|
||||
\end{alignat*}
|
||||
|
||||
\caption{The grammar for $\varepsilon_{0}$ with example phrases for each rule. The syntactic categories are sentence (S), noun phrase (NP), verb phrase (VP), article (A), noun (N) and list of adjectives (Adjs). The categories article and noun have been added to allow a CNF grammar.}
|
||||
\label{fig:grammar}
|
||||
\end{figure}
|
||||
|
||||
\subsubsection*{Bottom-up and Top-down}
|
||||
\label{subSubSec:bottomUpTopDown}
|
||||
|
||||
There are two classical ways of parsing a sentence. The one is bottom-up and the other one is top-down. Both approaches have their own advantages and disadvantages. In addition the ambiguity creates problems. To implement bottom-up and top-down search algorithms in the face of ambiguity, ``an agenda-based backtracking strategy''\cite[p.~468]{Jurafsky2009b} is used. The problem here is that every time the parser recognizes that the current parse tree is wrong, it has to backtrack and explore other parts of the sentence. This creates a huge amount of work duplication and is therefore inefficient.
|
||||
|
||||
\subsubsection*{CYK algorithm}
|
||||
\label{subSubSec:cykAlgorithm}
|
||||
|
||||
A solution to these problems is offered by ``dynamic programming parsing methods''\cite[p.~469]{Jurafsky2009b}. The CYK algorithm is one of multiple algorithms based on dynamic programming.
|
||||
|
||||
The CYK does only work with grammars in the Chomsky Normal Form (CNF). Every context-free grammar can be converted to CNF without loss in expressiveness. Therefore this restriction does no harm but simplifies the parsing. For information on how context-free grammars can be converted to CNF, refer to Jurafsky\cite{Jurafsky2009b}.
|
||||
|
||||
CYK requires $\mathcal{O}(n^{2}m)$ space for the $P$ table (a table with probabilities), where ``$m$ is the number of nonterminal symbols in the grammar''\footnote{\cite{Russel2010}, page 893}, and uses $\mathcal{O}(n^{3}m)$ time. ``$m$ is constant for a particular grammar, [so it] is commonly described as $\mathcal{O}(n^{3})$''\footnote{\cite{Russel2010}, page 893}. There is no algorithm that is better than CYK for general context-free grammars\cite{Russel2010}.
|
||||
CYK requires $\mathcal{O}(n^{2}m)$ space for the $P$ table (a table with probabilities), where ``$m$ is the number of nonterminal symbols in the grammar''\cite[p.~893]{Russel2010}, and uses $\mathcal{O}(n^{3}m)$ time. ``$m$ is constant for a particular grammar, [so it] is commonly described as $\mathcal{O}(n^{3})$''\cite[p.~893]{Russel2010}. But these values are of no value if there is no benchmark. How good is $\mathcal{O}(n^{3})$ in comparison? To give a better idea of the relations, here a small comparison to the ``Earley Algorithm''\cite[p.~477]{Jurafsky2009b}. The Earley algorithm performs better with all unambiguous grammars.\cite{Li} It has the same upper bound in time but in most cases it is quicker. Furthermore it has a space complexity of $\mathcal{O}(n)$ which is definitely better than CYK.\cite{Li} For ambiguous grammars though the Earley algorithm uses more space than CYK and the real space used is dependent on the length of the input.\cite{Li} In time complexity the CYK algorithm can only compete with Earley if ambiguous grammars are used.\cite{Li} But CYK is still of use for parsing of natural language, because natural language grammars are always ambiguous. Therefore there is no algorithm that is better than CYK for general context-free grammars.\cite{Russel2010}
|
||||
|
||||
But how does CYK work? CYK doesn't examine all parse trees. It just examines the most probable one and computes the probability of that tree. All the other parse trees are present in the $P$ table and could be enumerated with a little work (in exponential time). But the strength and beauty of CYK is, that they don't have to be enumerated. CYK defines ``the complete state space defined by the `apply grammar rule' operator''\footnote{\cite{Russel2010}, page 894}. You can search just a part of this space with $A^{*}$ search.\cite{Russel2010} ``With the $A^{*}$ algorithm [...] the first parse found will be the most probable''\footnote{\cite{Russel2010}, page 895}.
|
||||
But how does CYK work? CYK doesn't examine all parse trees. It just examines the most probable one and computes the probability of that tree. All the other parse trees are present in the $P$ table and could be enumerated with a little work (in exponential time). But the strength and beauty of CYK is, that they don't have to be enumerated. CYK defines ``the complete state space defined by the `apply grammar rule' operator''\cite[p.~894]{Russel2010}. You can search just a part of this space with $A^{*}$ search.\cite{Russel2010} ``With the $A^{*}$ algorithm [...] the first parse found will be the most probable''\cite[p.~895]{Russel2010}. The actual pseudo code can be found in figure 23.5 in Russel\cite[p.~894]{Russel2010}.
|
||||
|
||||
But these probabilities need to be learned from somewhere. This somewhere is usually a ``treebank''\footnote{\cite{Russel2010}, page 895}, which contains a corpus of correctly parsed sentences. The best known is the Penn Treebank\cite{Russel2010}, which ``consists of 3 million words which have been annotated with part of speech and parse-tree structure, using human labor assisted by some automated tools''\footnote{\cite{Russel2010}, page 895}. The probabilities are then computed by counting and smoothing in the given data.\cite{Russel2010} There are other ways to learn the probabilities that are more difficult. For more information refer to Russel\cite{Russel2010}.
|
||||
\subsubsection*{Treebank}
|
||||
\label{subSubSec:treebank}
|
||||
|
||||
But these probabilities need to be learned from somewhere. This somewhere is usually a ``treebank''\cite[p.~895]{Russel2010}, which contains a corpus of correctly parsed sentences. The best known is the Penn Treebank\cite{Russel2010}, which ``consists of 3 million words which have been annotated with part of speech and parse-tree structure, using human labor assisted by some automated tools''\cite[p.~895]{Russel2010}. The probabilities are then computed by counting and smoothing in the given data.\cite{Russel2010} There are other ways to learn the probabilities that are more difficult. For more information refer to Russel\cite{Russel2010}.
|
||||
|
||||
\subsubsection*{Application}
|
||||
\label{subSubSec:application}
|
||||
|
||||
Now it is time to use the CYK algorithm with our example. For this case a restricted language called $\varepsilon_{0}$ is defined that is suitable to form one sentence about a tree. Next a lexicon (figure \ref{fig:lexicon}), ``or list of allowable words''\cite[p.~890]{Russel2010}, is defined. Furthermore a grammar (figure \ref{fig:grammar}) for $\varepsilon_{0}$ is defined. The lexicon and the grammar are based upon the lexicon and grammar in figures 23.1 and 23.2 of \cite{Russel2010} respectively.
|
||||
|
||||
The CYK algorithm is given the words and the grammar and returns the table $P$ containing the probabilities for the whole sentence and it's subsequences.\cite{Russel2010} The pseudo code can bee seen in algorithm \ref{alg:cyk}.
|
||||
|
||||
\begin{algorithm}
|
||||
\caption{Application of CYK for our problem}
|
||||
\label{alg:cyk}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{CYK-Parse}{$words, grammar$}
|
||||
\State $N \gets \Call{Length}{Words}$\Comment{N = 5}
|
||||
\State $M \gets$ the number of nonterminal symbols in $grammar$\Comment{M = 6}
|
||||
\State $P \gets$ an array of size [M, N, N], initially all 0
|
||||
\For{$i = 1$ to $N$}
|
||||
\ForAll{rules of form ($X \rightarrow words_{i}[p]$)}
|
||||
\State $P[X, i, 1] \gets p$
|
||||
\EndFor
|
||||
\EndFor
|
||||
\For{$length = 2$ to $N$}
|
||||
\For{$start = 1$ to $N - length + 1$}
|
||||
\For{$len1 = 1$ to $N - 1$}
|
||||
\State $len2 \gets length - len1$
|
||||
\ForAll{rules of the form ($X \rightarrow$ $Y$ $Z$ [$p$])}
|
||||
\State $P[X, start, length] \gets \Call{Max}{P[X, start, length], P[Y, start, len1] \times P[Z, start + len1, len2] \times p}$
|
||||
|
||||
\EndFor
|
||||
\EndFor
|
||||
\EndFor
|
||||
\EndFor
|
||||
\State \Return $P$
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
||||
The resulting P table is depicted in table \ref{tab:p}. As you can see in the table there is just one possible parse for the whole sentence. In linear form the sentence can be parsed as [$S$ [$NP$ [$A$ the] [$N$ tree]][$VP$ [$VP$ is][$Adjs$ [$Adjs$ very][$Adjs$ high]]]. With this information given a parse tree could be easily constructed.
|
||||
|
||||
\begin{table}
|
||||
\caption{Table of probabilities from the CYK parse. The entries with probability 0 have been left out.}
|
||||
\label{tab:p}
|
||||
\centering
|
||||
\begin{tabular}{|c|c|c|c|}
|
||||
\hline
|
||||
X & start & length & p \\
|
||||
\hline
|
||||
\hline
|
||||
A & 1 & 1 & 1.00 \\
|
||||
\hline
|
||||
N & 2 & 1 & 1.00 \\
|
||||
\hline
|
||||
VP & 3 & 1 & 0.40 \\
|
||||
\hline
|
||||
Adjs & 4 & 1 & 0.80 \\
|
||||
\hline
|
||||
Adjs & 5 & 1 & 0.80 \\
|
||||
\hline
|
||||
NP & 1 & 2 & 1.00 \\
|
||||
\hline
|
||||
VP & 3 & 2 & 0.192 \\
|
||||
\hline
|
||||
Adjs & 4 & 2 & 0.128 \\
|
||||
\hline
|
||||
S & 1 & 3 & 0.40 \\
|
||||
\hline
|
||||
VP & 3 & 3 & 0.09216 \\
|
||||
\hline
|
||||
S & 1 & 4 & 0.192 \\
|
||||
\hline
|
||||
S & 1 & 5 & 0.09216 \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
\subsection{Semantic Analysis}
|
||||
\label{subSec:semanticAnalysis}
|
||||
|
||||
Semantic analysis provides multiple approaches. In this paper the approach of ``syntax-driven semantic analysis''\footnote{\cite{Jurafsky2009}, page 617} is explained further. In this approach the output of a parser, the syntactic analysis, ``is passed as input to a semantic analyzer to produce a meaning representation''\footnote{\cite{Jurafsky2009}, page 618}.
|
||||
Semantic analysis provides multiple approaches. In this paper the approach of ``syntax-driven semantic analysis''\cite[p.~617]{Jurafsky2009} is explained further. In this approach the output of a parser, the syntactic analysis, ``is passed as input to a semantic analyzer to produce a meaning representation''\cite[p.~618]{Jurafsky2009}.
|
||||
|
||||
Therefore context-free grammar rules are augmented with ``semantic attachments''\footnote{\cite{Jurafsky2009}, page 618}. Every word and syntactic structure in a sentence gets such a semantic attachment. The tree with syntactic components is now traversed in a bottom-up manner. On the way the semantic attachments are combined to finally produce ``First-Order Logic''\footnote{\cite{Jurafsky2009a}, page 589} that can be interpreted in a meaningful way. This procedure has some prerequisites that will be explained first.
|
||||
Therefore context-free grammar rules are augmented with ``semantic attachments''\cite[p.~618]{Jurafsky2009}. Every word and syntactic structure in a sentence gets such a semantic attachment. The tree with syntactic components is now traversed in a bottom-up manner. On the way the semantic attachments are combined to finally produce ``First-Order Logic''\cite[p.~589]{Jurafsky2009a} that can be interpreted in a meaningful way. This procedure has some prerequisites that will be explained first.
|
||||
|
||||
\subsubsection*{First-Order Logic}
|
||||
\label{subSubSec:firstOrderLogic}
|
||||
|
||||
The mentioned \textit{First-Order Logic} can be represented by a context-free grammar specification. It is beyond this paper to describe this specification completely. Jurafsky\cite{Jurafsky2009a} provides a detailed picture of the specification with all elements in figure 17.3. The most important aspects of this specification are explained here. The logic provides terms which can be functions, constants and variables. Functions have a term as argument. Syntactically they are the same as single-argument predicates. But functions represent one unique object.
|
||||
Predicates can have multiple terms as arguments. In addition the logic provides quantifiers ($\forall, \exists$) and connectives ($\wedge, \vee, \Rightarrow$).
|
||||
|
||||
Another prerequisite is the ``lambda notation''\footnote{\cite{Jurafsky2009a}, page 593}. A simple example of this notation is an expression of the following form\footnote{examples taken from Jurafsky\cite{Jurafsky2009a}, pp. 593-594}:
|
||||
\subsubsection*{Lambda notation}
|
||||
\label{subSubSec:lambdaNotation}
|
||||
|
||||
Another prerequisite is the ``lambda notation''\cite[p.~593]{Jurafsky2009a}. A simple example of this notation is an expression of the following form\footnote{examples taken from Jurafsky\cite[pp.~593-594]{Jurafsky2009a}}:
|
||||
\[
|
||||
\lambda x.P(x)
|
||||
\]
|
||||
|
||||
The $\lambda$ can be reduced in a so called ``$\lambda$-reduction''\footnote{\cite{Jurafsky2009a}, page 593}. The expression above could be reduced in the following way:
|
||||
The $\lambda$ can be reduced in a so called ``$\lambda$-reduction''\cite[p.~593]{Jurafsky2009a}. The expression above could be reduced in the following way:
|
||||
|
||||
\begin{alignat*}{2}
|
||||
\lambda x.&P(x)&(A) \\
|
||||
&P(A)&
|
||||
\end{alignat*}
|
||||
|
||||
Those expressions can be extended to $n$ such $\lambda$s. An example is this expression:
|
||||
Those expressions can be extended to $n$ such $\lambda$s. An example is this expression (where $x$ and $y$ denote things from which a distance to each other can be calculated):
|
||||
\[
|
||||
\lambda x.\lambda y.Near(x,y)
|
||||
\]
|
||||
@ -247,50 +386,127 @@
|
||||
&Near(Bacaro, Centro)
|
||||
\end{alignat*}
|
||||
|
||||
This technique is called ``currying''\footnote{\cite{Jurafsky2009a}, page 594} and is used to convert ``a predicate with multiple arguments into a sequence of single-argument predicates''\footnote{\cite{Jurafsky2009a}, page 594}.
|
||||
This technique is called ``currying''\cite[p.~594]{Jurafsky2009a} and is used to convert ``a predicate with multiple arguments into a sequence of single-argument predicates''\cite[p.~594]{Jurafsky2009a}.
|
||||
|
||||
After the prerequisites are now explained, it is time to start with the actual syntax-driven semantic analysis. It will be shown with an example provided by Jurafsky. Assume the sentence \textit{Every restaurant closed}. ``The target representation for this example should be the following''\footnote{\cite{Jurafsky2009}, page 621}.
|
||||
\subsubsection*{Syntax-driven semantic analysis}
|
||||
\label{subSubSec:syntaxDrivenSemanticAnalysis}
|
||||
|
||||
\begin{equation}
|
||||
\label{eq:tarRep}
|
||||
\forall x \,Restaurant(x) \Rightarrow \exists e \,Closed(e) \wedge ClosedThing(e,x)
|
||||
\end{equation}
|
||||
After the prerequisites are now explained, it is time to start with the actual syntax-driven semantic analysis. It is shown with the previously introduced example and starts there, where the syntactic parsing left.
|
||||
|
||||
The grammar rules have to be augmented with the semantic attachments. This process goes through all involed rules in a bottom-up way. To remind you of the sentence, here it is again: ``The tree is very high''. The first rule is the $A$ rule, which produces ``The''. The article implies that are is exactly one entity which is therefore easily identified. If there were multiple entities of the same type, ``the'' won't be enough to specify which entity is meant.
|
||||
|
||||
The first step is to determine what the meaning representation of \textit{Every restaurant} should be. \textit{Every} is responsible for the $\forall$ quantifier and \textit{restaurant} specifies the category over which is quantified. This is called the ``restriction''\footnote{\cite{Jurafsky2009}, page 622} of the noun phrase. The meaning representation could be $\forall x\,Restaurant(x)$. It is a valid logical formula but it doesn't make much sense. ``It says that everything is a restaurant.''\footnote{\cite{Jurafsky2009}, page 622} ``Noun phrases like [this] are [usually] embedded in expressions that [say] something about the universally quantified variable. That is, we're probably trying to \textit{say something} about all restaurants. This notion is traditionally referred to as the \textit{NP}'s nuclear scope''\footnote{\cite{Jurafsky2009}, page 622}. In the given example, the nuclear scope is \textit{closed}. To represent this notion in the target representation, a dummy predicate $Q$ is added, which results in this expression:
|
||||
\[
|
||||
\forall x\,Restaurant(x) \Rightarrow Q(x)
|
||||
A \rightarrow the \;\{\lambda x.\lambda P.\exists x.P(x)\}
|
||||
\]
|
||||
To replace $Q$ with something meaningful, the $\lambda$ notation is needed.
|
||||
\[
|
||||
\lambda Q.\forall x\,Restaurant(x) \Rightarrow Q(x)
|
||||
\]
|
||||
After more generalization, this is the result:
|
||||
\[
|
||||
\lambda P.\lambda Q.\forall x\,P(x) \Rightarrow Q(x)
|
||||
\]
|
||||
What happened? The descriptor \textit{every} gets this last expression as semantic attachment. The noun \textit{restaurant} gets $\lambda x.Restaurant(x)$. When combined, the second expression is the result. The verb is still missing. Therefore the verb \textit{closed} gets the following expression.
|
||||
\[
|
||||
\lambda x.\exists e\,Closed(e) \wedge ClosedThing(e,x)
|
||||
\]
|
||||
After combining the formulas of the verb and the noun phrase, the previously shown target representation\eqref{eq:tarRep} is the result.
|
||||
|
||||
This example is just one of many, but it shows how semantic meaning can be attached to syntactic components. Furthermore it should be clear now, how semantic analysis in a syntax-driven approach works.
|
||||
The next rule is the one responsible for ``tree''.
|
||||
|
||||
\[
|
||||
N \rightarrow tree \;\{\lambda x.Tree(x)\}
|
||||
\]
|
||||
|
||||
NP is the combination of the two previous rules and will therefore have to combine the meaning somehow. This is done by using the N semantic attachment as argument for the A attachment.
|
||||
|
||||
\[
|
||||
NP \rightarrow A\;N \;\{A.sem(N.sem)\}
|
||||
\]
|
||||
|
||||
Next are the Adjs rules. The first is the one that handles ``very''.
|
||||
|
||||
\[
|
||||
Adjs \rightarrow very \;\{\lambda x.Very(x)\}
|
||||
\]
|
||||
|
||||
It states that there is an adjective that is increased in meaning by ``very''. The rule for ``high'' gets augmented with an attachment that describes a thing that is high.
|
||||
|
||||
\[
|
||||
Adjs \rightarrow high \;\{\lambda x.HighThing(a, x)\}
|
||||
\]
|
||||
|
||||
Here the x stands for an entity that is high. Another Adjs rule brings these two together. To differentiate the semantic attachments of the previous two Adjs rules, the affected adjective is noted in square brackets.
|
||||
|
||||
\[
|
||||
Adjs \rightarrow Adjs\;Adjs \;\{\lambda x.\exists a.Adjs[very].sem(a) \wedge Adjs[high].sem(x) \}
|
||||
\]
|
||||
|
||||
The VP rules are next to be augmented. First comes the one that is responsible for ``is''. ``is'' implies that there is an entity with a state.
|
||||
|
||||
\[
|
||||
VP \rightarrow is \;\{\lambda P.\lambda Q.Q(x) \Rightarrow P(x)\}
|
||||
\]
|
||||
|
||||
In the next step the VP rule for ``is'' and the adjectives are combined. Here applies the same as for the Adjs case. As there are two VP rules, the ``is'' rule is identified by the verb in square brackes. As there are no square brackets after Adjs in the following attachment, the Adjs rule, that combines the adjective rules, is meant.
|
||||
|
||||
\[
|
||||
VP \rightarrow VP\;Adjs \;\{VP[is].sem(Adjs.sem)\}
|
||||
\]
|
||||
|
||||
Last comes the S rule that combines both NP and VP. VP means the rule that combines the ``is'' rule and the Adjs rules.
|
||||
|
||||
\[
|
||||
S \rightarrow NP\;\;VP \;\{VP.sem(NP.sem)\}
|
||||
\]
|
||||
|
||||
With the semantic attachments in place, the final meaning representation can easily be retrieved. The replacement happens from top to bottom, by starting with the semantic attachment from S and going down to the semantic attachments of the rules that produce the actual output. The critical part is the $\lambda$-reduction in the first VP rule. The intermediate steps are shown below.
|
||||
|
||||
\begin{alignat*}{1}
|
||||
\lambda P.\lambda Q.Q(x) \Rightarrow P(x)(\lambda x.\exists a.Adjs[very].sem(a) \wedge Adjs[high].sem(x)) \\
|
||||
\lambda Q.Q(x) \Rightarrow \lambda x.\exists a.Adjs[very].sem(a) \wedge Adjs[high].sem(x)(x) \\
|
||||
\lambda Q.Q(x) \Rightarrow \exists a.Adjs[very].sem(a) \wedge Adjs[high].sem(x) \\
|
||||
\lambda Q.Q(x) \Rightarrow \exists a.\lambda x.Very(x)(a) \wedge Adjs[high].sem(x) \\
|
||||
\lambda Q.Q(x) \Rightarrow \exists a.Very(a) \wedge \lambda x.HighThing(a, x)(x) \\
|
||||
\lambda Q.Q(x) \Rightarrow \exists a.Very(a) \wedge HighThing(a, x) \\
|
||||
\intertext{inserting the NP attachments}
|
||||
\lambda Q.Q(x) \Rightarrow \exists a.Very(a) \wedge HighThing(a, x)(\lambda x.\lambda P.\exists x.P(x)) \\
|
||||
\lambda x.\lambda P.\exists x.P(x)(x) \Rightarrow \exists a.Very(a) \wedge HighThing(a, x)(\lambda x.Tree(x)) \\
|
||||
\exists x.\lambda x.Tree(x)(x) \Rightarrow \exists a.Very(a) \wedge HighThing(a, x) \\
|
||||
\exists x.Tree(x) \Rightarrow \exists a.Very(a) \wedge HighThing(a, x)
|
||||
\end{alignat*}
|
||||
|
||||
The final meaning representation is therefore the following.
|
||||
|
||||
\[
|
||||
\exists x.Tree(x) \Rightarrow \exists a.Very(a) \wedge HighThing(a, x)
|
||||
\]
|
||||
|
||||
If you translate this logic into words, it'd be something similar to this: ``There is a tree that is a high thing, a very high thing''. This complete run-through from the syntactic parsing up to the meaning representation hopefully showed the two presented methods in action and let you understand them better. Furthermore this overarching example should have put you in the situation to follow a critical discussion, which is next in the paper.
|
||||
|
||||
\section{Critical discussion}
|
||||
\label{sec:critDiscussion}
|
||||
|
||||
Now that both methods have been presented with one selected approach each, it is time to discuss them critically. The CYK algorithm solves many problems like ambiguity; at least to a certain degree. But it also is problematic, because of the restriction to CNF. While in theory every context-free grammar can be converted to CNF, in practice it poses ``some non-trivial problems''\footnote{\cite{Jurafsky2009b}, page 475}. One of this problems can be explored in conjunction with the second presented method (semantic analysis). ``[T]he conversion to CNF will complicate any syntax-driven approach to semantic analysis''\footnote{\cite{Jurafsky2009b}, page 475}. A solution to this problem is some kind of post-processing in which the trees are converted back to the original grammar.\cite{Jurafsky2009b} Another option is to use a more complex dynamic programming algorithm that accepts any kind of context-free grammar. Such an algorithm is the ``Earley Algorithm''\footnote{\cite{Jurafsky2009b}, page 477}.
|
||||
|
||||
\begin{itemize}
|
||||
\item compares syntactic parsing and semantic analysis based on these criteria: meaning, complexity, usability for actual communication
|
||||
\end{itemize}
|
||||
%TODO back up every claim (reference after first sentence)
|
||||
|
||||
Now that both methods have been presented with one selected approach each, it is time to discuss them critically. The CYK algorithm solves many problems like ambiguity; at least to a certain degree. But it also is problematic, because of the restriction to CNF. While in theory every context-free grammar can be converted to CNF, in practice it poses ``some non-trivial problems''\cite[p.~475]{Jurafsky2009b}. One of this problems can be explored in conjunction with the second presented method (semantic analysis). ``[T]he conversion to CNF will complicate any syntax-driven approach to semantic analysis''\cite[p.~475]{Jurafsky2009b}. A solution to this problem is some kind of post-processing in which the trees are converted back to the original grammar.\cite{Jurafsky2009b} Another option is to use a more complex dynamic programming algorithm that accepts any kind of context-free grammar. Such an algorithm is the ``Earley Algorithm''\cite[p.~477]{Jurafsky2009b}.
|
||||
|
||||
The syntax-driven semantic analysis, as it has been presented, is a powerful method that is easy to understand. But it has one essential problem. It relies upon an existing set of grammar rules with semantic attachments to them. In a real world example such a table would contain thousands of grammar rules.\cite{Russel2010} While it is relatively easy to compute the final meaning representation with such a given table, it is very hard to create the table in the first place. The difficulty to create this table is split into two main issues. The first one being that you must find a grammar specification that fits all your use cases. This problem applies for the syntactic parsing as well. The second issue is that one has to find out the semantic attachments to the grammar rules.
|
||||
|
||||
This initial workload to create a state, in which the semantic analysis works, is a unique effort.\cite{Jurafsky2009} A restricted environment has a limited set of words and topics compared to an unrestricted environment. An example is a flight check-in automaton that only needs to process a subset of the full English grammar. Therefore this workload is of low importance in such an environment. Even if it takes one month to create such a table by hand or by computing it, the subsequent analysis of input based on this table is rather quick and the initial workload is therefore acceptable. But this is only true for restricted environments. If someone tried to use syntax-driven semantic analysis for the complete language of modern English, the creation of such a table would outweigh any possible usage.
|
||||
|
||||
%TODO three options: add reference to claim, introduce necessary knowledge prior to this point or drop it
|
||||
|
||||
Comparing the complexity of the two methods it shows a mirror-like image. For the parsing the creation of the grammar is comparatively easy. The presented CYK algorithm works with context-free grammars which are a very restricted set compared to natural languages. But even within these context-free grammars there are ambiguities inside the texts themselves. The creation of the parse trees is therefore more of a problem.
|
||||
|
||||
Syntax-driven semantic analysis on the other hand requires a decent amount of work to add semantic attachments to grammar rules.\cite{Jurafsky2009} But once this has been done, it works very fast.
|
||||
|
||||
Both methods require an initial workload for every usage domain. This unique workload is the grammar creation for the parsing and the extension of the grammar with semantic attachments for the semantic analysis. The less restricted the usage environment, the more complex the initial workload becomes. The same is true for the recurring workload for every actual usage inside one usage domain.
|
||||
|
||||
Judging by the state-of-the-art of computer technology, parsing does still pose a significant challenge once the restricted field of programming languages is left. The semantic analysis as the second method in the chain has therefore even more problems to date. As the presented syntax-driven approach does only work with syntactic representations\cite{Jurafsky2009}, a semantic analysis can only be undertaken once the syntactic parsing succeeds.
|
||||
|
||||
The ambiguity remains one of the bigges issues for both methods. Especially the syntax-driven semantic analysis does only consider the semantic meaning alone. It's not it's fault as the analysis doesn't know the context. The presented approach looks at each sentence in a sandbox. The generated meaning representations are therefore only of limited use for a less restricted grammar.
|
||||
|
||||
\section{Conclusion}
|
||||
\label{sec:concl}
|
||||
|
||||
\begin{itemize}
|
||||
\item
|
||||
\end{itemize}
|
||||
|
||||
Syntactic parsing is an important method on the way to understand natural language. The usage of dynamic programming algorithms circumvents many of the issues that classical top-down or bottom-up parsing algorithms face. Ambiguity is the most prominent of those issues. The best algorithm for context-free grammars is the CYK algorithm, which is a dynamic programming algorithm. But in practice it is very restricted, because it only works with grammars in CNF. But there are more complex dynamic programming algorithms that allow any kind of context-free grammar. Such an algorithm is the ``Earley Algorithm''\cite[p.~477]{Jurafsky2009b} which was already introduced in the critical discussion.
|
||||
|
||||
Semantic analysis is the second method in the chain to understand natural language, as it is presented here, and therefore important as well. There are different approaches to the analysis. One of them is the syntax-driven approach that depends on parse trees. This dependency creates a delay effect: As long as a certain peace of text cannot be parsed, it definitely can't be analyzed for it's semantic meaning either. This is not an issue for restricted environments like programming languages or a very restricted subset of a natural language's grammar. But it is a major issue for real natural language, because there already the parsing does pose significant challenges.
|
||||
|
||||
Looking into the future both methods require substantial improvements on the algorithm side to reach a point where understanding non-restricted natural languages becomes possible. But as it is right now it is not possible to create dialog systems that interact fully natural with humans. To make any kind of language interaction, the set of possible words and sentence structures must be restricted. But even if that is given (like in a flight check-in automaton), the computer has only a finite set of possible cases. The programmer can add tons of if-clauses or comparable statements to check for different cases but in the end it's all finite so that many of the user inputs must lead to the same output or no output at all. This fact has led to the current situation in which the most interaction with a computer happens via a restricted interface in which the user can only choose from a limited set of options (by clicking on a button, selecting an item of a list, etc.).
|
||||
|
||||
Furthermore the ambiguity of natural language is a major issue. The solution to it could lie in the understanding of the context. Even though natural language is full of ambiguity, we manage to communicate very successfully. Therefore the solution to ambiguity lies probably somewhere in our brain functionality. Cognitively-inspired methods that don't use traditional AI and First--Order logic but instead are inspired by our brain and try to understand and model natural language based on the context, might as well be the solution to ambiguity altogether. The method presented by Gnjatovic\cite{Gnjatovic2012} could be such a method.
|
||||
|
||||
In a mission critical environment this ambiguity could lead to catastrophic results, because the computer, simply put, ``didn't get it''. This risk limits the usability of natural language communication with a computer for propably a long time to a very restricted set of use cases.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% hier werden - zum Ende des Textes - die bibliographischen Referenzen
|
||||
% eingebunden
|
||||
|
||||
@ -13,131 +13,105 @@ Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
; Die Rückgabe einer Liste mit dem Buchstaben an erster Stelle und einer
|
||||
; Liste als zweitem Element, die wiederum den Schlüssel an erster Stelle
|
||||
; enthält, erlaubt ein einfaches Auswerten der Zuordnung.
|
||||
(define (daten char)
|
||||
(case (char->integer char)
|
||||
([65] (list char 'Alfa))
|
||||
([66] (list char 'Bravo))
|
||||
([67] (list char 'Charlie))
|
||||
([68] (list char 'Delta))
|
||||
([69] (list char 'Echo))
|
||||
([70] (list char 'Foxtrott))
|
||||
([71] (list char 'Golf))
|
||||
([72] (list char 'Hotel))
|
||||
([73] (list char 'India))
|
||||
([74] (list char 'Juliett))
|
||||
([75] (list char 'Kilo))
|
||||
([76] (list char 'Lima))
|
||||
([77] (list char 'Mike))
|
||||
([78] (list char 'November))
|
||||
([79] (list char 'Oscar))
|
||||
([80] (list char 'Papa))
|
||||
([81] (list char 'Quebec))
|
||||
([82] (list char 'Romeo))
|
||||
([83] (list char 'Sierra))
|
||||
([84] (list char 'Tango))
|
||||
([85] (list char 'Uniform))
|
||||
([86] (list char 'Viktor))
|
||||
([87] (list char 'Whiskey))
|
||||
([88] (list char 'X-ray))
|
||||
([89] (list char 'Yankee))
|
||||
([90] (list char 'Zulu))
|
||||
([48] (list char 'Nadazero))
|
||||
([49] (list char 'Unaone))
|
||||
([50] (list char 'Bissotwo))
|
||||
([51] (list char 'Terrathree))
|
||||
([52] (list char 'Kartefour))
|
||||
([53] (list char 'Pantafive))
|
||||
([54] (list char 'Sosisix))
|
||||
([55] (list char 'Setteseven))
|
||||
([56] (list char 'Oktoeight))
|
||||
([57] (list char 'Novenine))
|
||||
([44] (list char 'Decimal))
|
||||
([46] (list char 'Stop))
|
||||
)
|
||||
)
|
||||
(define buchstabiertafel
|
||||
'((#\A . Alfa)
|
||||
(#\B . Bravo)
|
||||
(#\C . Charlie)
|
||||
(#\D . Delta)
|
||||
(#\E . Echo)
|
||||
(#\F . Foxtrott)
|
||||
(#\G . Golf)
|
||||
(#\H . Hotel)
|
||||
(#\I . India)
|
||||
(#\J . Juliett)
|
||||
(#\K . Kilo)
|
||||
(#\L . Lima)
|
||||
(#\M . Mike)
|
||||
(#\N . November)
|
||||
(#\O . Oscar)
|
||||
(#\P . Papa)
|
||||
(#\Q . Quebec)
|
||||
(#\R . Romeo)
|
||||
(#\S . Sierra)
|
||||
(#\T . Tango)
|
||||
(#\U . Uniform)
|
||||
(#\V . Viktor)
|
||||
(#\W . Whiskey)
|
||||
(#\X . X-ray)
|
||||
(#\Y . Yankee)
|
||||
(#\Z . Zulu)
|
||||
(#\0 . Nadazero)
|
||||
(#\1 . Unaone)
|
||||
(#\2 . Bissotwo)
|
||||
(#\3 . Terrathree)
|
||||
(#\4 . Kartefour)
|
||||
(#\5 . Pantafive)
|
||||
(#\6 . Sosisix)
|
||||
(#\7 . Setteseven)
|
||||
(#\8 . Oktoeight)
|
||||
(#\9 . Novenine)
|
||||
(#\, . Decimal)
|
||||
(#\. . Stop)
|
||||
))
|
||||
|
||||
; 1.2
|
||||
(define (char->schlüssel char)
|
||||
(car (cdr (daten char))))
|
||||
(define (char->schlüssel char tafel)
|
||||
(cdr (assoc (char->upper char) tafel)))
|
||||
|
||||
; 1.3
|
||||
(define char_to_upperCase (λ (myChar)
|
||||
; x als ASCII Wert für myChar definieren
|
||||
(define x (char->integer myChar))
|
||||
; y als x-32 definieren
|
||||
(define y (- x 32))
|
||||
; wenn x < 91 (bereits upperCase) myChar direkt zurückgeben
|
||||
(if (< x 91)
|
||||
; wenn myChar bereits upperCase ist, direkt zurückgeben
|
||||
myChar
|
||||
; andernfalls wird y zurückgegeben
|
||||
(when (> x 96)
|
||||
; y stellt den gleichen Buchstaben wie x dar, bloß in upperCase
|
||||
; daher wird y zurückgegeben
|
||||
(integer->char y)))))
|
||||
|
||||
(define (char->upper char)
|
||||
(let ([charInt (char->integer char)])
|
||||
(cond ([<= 96 charInt 122] (integer->char (- charInt 32)))
|
||||
([<= 65 charInt 90] (integer->char charInt))
|
||||
(else char))))
|
||||
|
||||
; 1.4
|
||||
(define (buchstabiere text)
|
||||
(let ([xs (string->list text)])
|
||||
(if [empty? xs]
|
||||
'()
|
||||
(cons (char->schlüssel (char_to_upperCase(car xs))) (buchstabiere (list->string (cdr xs))))
|
||||
)
|
||||
))
|
||||
(define (buchstabiere text tafel)
|
||||
(letrec ((rec (λ (xs)
|
||||
(if (null? xs)
|
||||
null
|
||||
(cons (char->schlüssel (car xs) tafel)
|
||||
(rec (cdr xs)))))))
|
||||
(rec (string->list text))))
|
||||
|
||||
(require se3-bib/flaggen-module)
|
||||
; 2.1
|
||||
; Analoger Entwurf wie bei 1.1, diesmal mit den Flaggen.
|
||||
(define (flaggenData char)
|
||||
(case (char->integer char)
|
||||
([65] (list char A))
|
||||
([66] (list char B))
|
||||
([67] (list char C))
|
||||
([68] (list char D))
|
||||
([69] (list char E))
|
||||
([70] (list char F))
|
||||
([71] (list char G))
|
||||
([72] (list char H))
|
||||
([73] (list char I))
|
||||
([74] (list char J))
|
||||
([75] (list char K))
|
||||
([76] (list char L))
|
||||
([77] (list char M))
|
||||
([78] (list char N))
|
||||
([79] (list char O))
|
||||
([80] (list char P))
|
||||
([81] (list char Q))
|
||||
([82] (list char R))
|
||||
([83] (list char S))
|
||||
([84] (list char T))
|
||||
([85] (list char U))
|
||||
([86] (list char V))
|
||||
([87] (list char W))
|
||||
([88] (list char X))
|
||||
([89] (list char Y))
|
||||
([90] (list char Z))
|
||||
([48] (list char Z0))
|
||||
([49] (list char Z1))
|
||||
([50] (list char Z2))
|
||||
([51] (list char Z3))
|
||||
([52] (list char Z4))
|
||||
([53] (list char Z5))
|
||||
([54] (list char Z6))
|
||||
([55] (list char Z7))
|
||||
([56] (list char Z8))
|
||||
([57] (list char Z9))
|
||||
)
|
||||
)
|
||||
|
||||
; 2.2
|
||||
(define (char->flagge char)
|
||||
(car (cdr (flaggenData char))))
|
||||
|
||||
; 2.3
|
||||
(define (buchstabiereFlagge text)
|
||||
(let ([xs (string->list text)])
|
||||
(if [empty? xs]
|
||||
'()
|
||||
(cons (char->flagge (char_to_upperCase(car xs))) (buchstabiereFlagge (list->string (cdr xs))))
|
||||
)
|
||||
(define flaggentafel
|
||||
`((#\A . ,A)
|
||||
(#\B . ,B)
|
||||
(#\C . ,C)
|
||||
(#\D . ,D)
|
||||
(#\E . ,E)
|
||||
(#\F . ,F)
|
||||
(#\G . ,G)
|
||||
(#\H . ,H)
|
||||
(#\I . ,I)
|
||||
(#\J . ,J)
|
||||
(#\K . ,K)
|
||||
(#\L . ,L)
|
||||
(#\M . ,M)
|
||||
(#\N . ,N)
|
||||
(#\O . ,O)
|
||||
(#\P . ,P)
|
||||
(#\Q . ,Q)
|
||||
(#\R . ,R)
|
||||
(#\S . ,S)
|
||||
(#\T . ,T)
|
||||
(#\U . ,U)
|
||||
(#\V . ,V)
|
||||
(#\W . ,W)
|
||||
(#\X . ,X)
|
||||
(#\Y . ,Y)
|
||||
(#\Z . ,Z)
|
||||
(#\0 . ,Z0)
|
||||
(#\1 . ,Z1)
|
||||
(#\2 . ,Z2)
|
||||
(#\3 . ,Z3)
|
||||
(#\4 . ,Z4)
|
||||
(#\5 . ,Z5)
|
||||
(#\6 . ,Z6)
|
||||
(#\7 . ,Z7)
|
||||
(#\8 . ,Z8)
|
||||
(#\9 . ,Z9)
|
||||
))
|
||||
198
se3/G08_B04_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
198
se3/G08_B04_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
@ -0,0 +1,198 @@
|
||||
#lang racket
|
||||
|
||||
#|
|
||||
SE 3 Funktional Blatt 4
|
||||
Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
|#
|
||||
|
||||
; 1)
|
||||
; 1. (max (min 2 (- 2 5)) 0) -> 0
|
||||
; zunächst wird (- 2 5) ausgeführt, was -3 ergibt
|
||||
; als nächstes wird (min 2 -3) ausgeführt, was -3 ergibt
|
||||
; dann kommt (max -3 0) mit dem Ergebnis 0
|
||||
; 2. '(+ (- 2 13) 2) -> (+ (- 2 13) 2)
|
||||
; das Quote verzögert die Auswertung, wodurch der Ausdruck nicht ausgewertet wird
|
||||
; 3. (cadr '(Alle Jahre wieder)) -> 'Jahre
|
||||
; zunächst wird (cdr '(Alle Jahre wieder)) ausgeführt mit dem Ergebnis '(Jahre wieder)
|
||||
; anschließend wird (car '(Jahre wieder)) mit dem Ergebnis 'Jahre ausgeführt
|
||||
; 4. (cddr '(kommt (das Weihnachtfest))) -> '()
|
||||
; zunächst wird (cdr '(kommt (das Weihnachtfest))) ausgeführt mit dem Ergebnis '((das Weihnachtfest))
|
||||
; anschließend wird (cdr '((das Weihnachtfest))) ausgeführt mit dem Ergebnis '()
|
||||
; dies liegt an der doppelt geschachtelten Liste:
|
||||
; (cons 'kommt (list (list 'das 'Weihnachtfest))) -> '(kommt (das Weihnachtfest))
|
||||
; 5. (cons 'Listen '(ganz einfach und)) -> '(Listen ganz einfach und)
|
||||
; da '(ganz einfach und) eine Liste ist, verkettet cons 'Listen schlichtweg mit der Liste
|
||||
; 6. (cons 'Paare 'auch) -> '(Paare . auch)
|
||||
; hier verkettet cons zwei einfache Elemente, wodurch ein Paar entsteht, welches keine Liste ist
|
||||
; 7. (equal? (list 'Racket 'Prolog 'Java) '(Racket Prolog Java)) -> #t
|
||||
; list erzeugt eine Liste mit den angegebenen Elementen und '(Racket Prolog Java) ist ebenfalls eine Liste mit den gleichen Elementen
|
||||
; 8. (eq? (list 'Racket 'Prolog 'Java) (cons 'Racket '(Prolog Java))) -> #f
|
||||
; list erzeugt wieder eine Liste und cons verknüpft hier ein einfaches Element mit einer Liste, wodurch wieder eine Liste entsteht;
|
||||
; allerdings sind die beiden Listen nicht identisch, aber genau das prüft eq?
|
||||
|
||||
; 2)
|
||||
; 1.
|
||||
; <notmeldung> ::= <ueberschrift><notfallort><notfallart><hilfeleistung><peilzeichen><unterschrift><over>
|
||||
; <ueberschrift> ::= <hierist><line-end><schiffname3mal><rufzeichen><line-end><summary><line-end>
|
||||
; <summary> ::= "MAYDAY "<schiffname>" ICH BUCHSTABIERE "<snamechars>" "<rufzeichen>
|
||||
; <snamechars> ::= <string>
|
||||
; <schiffname3mal>::= <schiffname>" "<schiffname>" "<schiffname>
|
||||
; <schiffname> ::= <word>
|
||||
; <notfallort> ::= <standort><zeitpunkt>
|
||||
; <notfallart> ::= <string><line-end>
|
||||
; <hilfeleistung> ::= <string><line-end><lines>
|
||||
; <peilzeichen> ::= "ICH SENDE DEN TRÄGER --"<line-end>
|
||||
; <unterschrift> ::= <word>" "<rufzeichen><line-end>
|
||||
; <rufzeichen> ::= <word>" "<word>" "<word>" "<word>
|
||||
; <lines> ::= <string><line-end> | <string><line-end><lines>
|
||||
; <standort> ::= "NOTALLPOSITION "<string><line-end>
|
||||
; <zeitpunkt> ::= "NOTFALLZEIT "<time>" UTC"<line-end>
|
||||
; <time> ::= <hour><minute>
|
||||
; <hour> ::= "0"<digit> | "1"<digit> | "2"<hdigit>
|
||||
; <minute> ::= "0"<digit> | "1"<digit> | "2"<digit> | "3"<digit> | "4"<digit> | "5"<digit>
|
||||
; <digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
||||
; <hdigit> ::= "0" | "1" | "2" | "3"
|
||||
; <string> ::= <word> | <word>" "<string>
|
||||
; <word> ::= <letter> | <letter><word>
|
||||
; <line-end> ::= <EOL>
|
||||
; <over> ::= "OVER"
|
||||
|
||||
; 2.2
|
||||
(define buchstabiertafel
|
||||
'((#\A . ALFA)
|
||||
(#\B . BRAVO)
|
||||
(#\C . CHARLIE)
|
||||
(#\D . DELTA)
|
||||
(#\E . ECHO)
|
||||
(#\F . FOXTROTT)
|
||||
(#\G . GOLF)
|
||||
(#\H . HOTEL)
|
||||
(#\I . INDIA)
|
||||
(#\J . JULIETT)
|
||||
(#\K . KILO)
|
||||
(#\L . LIMA)
|
||||
(#\M . MIKE)
|
||||
(#\N . NOVEMBER)
|
||||
(#\O . OSCAR)
|
||||
(#\P . PAPA)
|
||||
(#\Q . QUEBEC)
|
||||
(#\R . ROMEO)
|
||||
(#\S . SIERRA)
|
||||
(#\T . TANGO)
|
||||
(#\U . UNIFORM)
|
||||
(#\V . VIKTOR)
|
||||
(#\W . WHISKEY)
|
||||
(#\X . X-RAY)
|
||||
(#\Y . YANKEE)
|
||||
(#\Z . ZULU)
|
||||
(#\0 . NADAZERO)
|
||||
(#\1 . UNAONE)
|
||||
(#\2 . BISSOTWO)
|
||||
(#\3 . TERRATHREE)
|
||||
(#\4 . KARTEFOUR)
|
||||
(#\5 . PANTAFIVE)
|
||||
(#\6 . SOSISIX)
|
||||
(#\7 . SETTESEVEN)
|
||||
(#\8 . OKTOEIGHT)
|
||||
(#\9 . NOVENINE)
|
||||
(#\, . DECIMAL)
|
||||
(#\. . STOP)
|
||||
))
|
||||
|
||||
(define (char->schlüssel char tafel)
|
||||
(cdr (assoc (char->upper char) tafel)))
|
||||
|
||||
(define (char->upper char)
|
||||
(let ([charInt (char->integer char)])
|
||||
(cond ([<= 96 charInt 122] (integer->char (- charInt 32)))
|
||||
([<= 65 charInt 90] (integer->char charInt))
|
||||
(else char))))
|
||||
|
||||
(define (liste->string liste)
|
||||
(letrec ((rec (λ (string xs)
|
||||
(if (null? xs)
|
||||
string
|
||||
(if (empty? string)
|
||||
(rec (symbol->string (car xs)) (cdr xs))
|
||||
(rec (string-append string " " (symbol->string (car xs))) (cdr xs)))))))
|
||||
|
||||
(rec "" liste)))
|
||||
|
||||
(define (buchstabiere text tafel)
|
||||
(letrec ((rec (λ (xs)
|
||||
(if (null? xs)
|
||||
null
|
||||
(cons (char->schlüssel (car xs) tafel)
|
||||
(rec (cdr xs)))))))
|
||||
(liste->string (rec (string->list text)))))
|
||||
|
||||
|
||||
|
||||
(define mayday "MAYDAY")
|
||||
(define notposition "NOTFALLPOSITION")
|
||||
(define notzeit "NOTFALLZEIT")
|
||||
(define space " ")
|
||||
(define linebreak "\n")
|
||||
(define hierist "HIER IST")
|
||||
(define buchstabieren "ICH BUCHSTABIERE")
|
||||
(define ruf "RUFZEICHEN")
|
||||
(define senden "ICH SENDE DEN TRÄGER --")
|
||||
|
||||
(define (generiereNotmeldung schiffname rufzeichen position weitereAngaben)
|
||||
(display (string-append mayday space mayday space mayday linebreak
|
||||
hierist linebreak
|
||||
schiffname space schiffname space schiffname (buchstabiere rufzeichen buchstabiertafel) linebreak
|
||||
mayday space schiffname space buchstabieren (buchstabiere schiffname buchstabiertafel) (buchstabiere rufzeichen buchstabiertafel) linebreak
|
||||
ruf (buchstabiere rufzeichen buchstabiertafel) linebreak
|
||||
notposition space position linebreak
|
||||
weitereAngaben
|
||||
senden linebreak
|
||||
schiffname (buchstabiere rufzeichen buchstabiertafel) linebreak
|
||||
"OVER")))
|
||||
; 2.3
|
||||
(display "BABETTE:\n")
|
||||
(generiereNotmeldung "BABETTE" "DEJY" "UNGEFÄHR 10 SM NORDÖSTLICH LEUCHTTURM KIEL" "SCHWERER WASSEREINBRUCH WIR SINKEN\nKEINE VERLETZTEN\nVIER MANN GEHEN IN DIE RETTUNGSINSEL\nSCHNELLE HILFE ERFORDERLICH\n")
|
||||
(display "\n\nAMIRA:\n")
|
||||
(generiereNotmeldung "AMIRA" "AMRY" "57°46'N, 006°31'E\nNOTFALLZEIT 0640 UTC" "KENTERUNG WIR SINKEN\n9 MANN AN BORD\nSCHIFF 15 M LANG\nGRÜNER RUMPF\n")
|
||||
|
||||
; 3)
|
||||
; bei innerer Reduktion werden die Terme von innen nach außen reduziert
|
||||
; bei äußerer Reduktion werden die Terme von außen nach innen reduziert
|
||||
; innere Reduktion:
|
||||
; (hoch3 (* 3 (+ 1 (hoch3 2))))
|
||||
; -> (hoch3 (* 3 (+ 1 (* 2 2 2)))) ; (hoch3)
|
||||
; -> (hoch3 (* 3 (+ 1 8))) ; (*)
|
||||
; -> (hoch3 (* 3 9)) ; (+)
|
||||
; -> (hoch3 27) ; (*)
|
||||
; -> (* 27 27 27) ; (hoch3)
|
||||
; -> 19683 ; (*)
|
||||
; äußere Reduktion:
|
||||
; (* (* 3 (+ 1 (hoch3 2))) (* 3 (+ 1 (hoch3 2))) (* 3 (+ 1 (hoch3 2)))) ; (hoch3)
|
||||
; -> (* (* 3 (+ 1 (* 2 2 2))) (* 3 (+ 1 (hoch3 2))) (* 3 (+ 1 (hoch3 2)))) ; (hoch3)
|
||||
; -> (* (* 3 (+ 1 8)) (* 3 (+ 1 (hoch3 2))) (* 3 (+ 1 (hoch3 2)))) ; (*)
|
||||
; -> (* (* 3 9) (* 3 (+ 1 (hoch3 2))) (* 3 (+ 1 (hoch3 2)))) ; (+)
|
||||
; -> (* 27 (* 3 (+ 1 (hoch3 2))) (* 3 (+ 1 (hoch3 2)))) ; (*)
|
||||
; -> (* 27 (* 3 (+ 1 (* 2 2 2))) (* 3 (+ 1 (hoch3 2)))) ; (hoch3)
|
||||
; -> (* 27 (* 3 (+ 1 8)) (* 3 (+ 1 (hoch3 2)))) ; (*)
|
||||
; -> (* 27 (* 3 9) (* 3 (+ 1 (hoch3 2)))) ; (+)
|
||||
; -> (* 27 27 (* 3 (+ 1 (hoch3 2)))) ; (*)
|
||||
; -> (* 27 27 (* 3 (+ 1 (* 2 2 2)))) ; (hoch3)
|
||||
; -> (* 27 27 (* 3 (+ 1 8))) ; (*)
|
||||
; -> (* 27 27 (* 3 9)) ; (+)
|
||||
; -> (* 27 27 27) ; (*)
|
||||
; -> 19683 ; (*)
|
||||
|
||||
; In Racket wird die strikte innere Reduktion für Funktionen angewendet.
|
||||
; Für Spezialformen wird je nach Spezialform eine andere Strategie angewendet.
|
||||
; Allgemein kann jedoch gesagt werden, dass dort von außen nach innen gegangen wird.
|
||||
|
||||
; Wenn Alyssa das Programm benutzt, dann entsteht eine Endlosschleife, da
|
||||
; cond aufgrund der inneren Reduktion niemals aufgerufen wird. Pro Rekursionsaufruf
|
||||
; werden zunächst alle drei Parameter ausgewertet. Ab dem fünften Rekursionsschritt
|
||||
; wird (> counter max-count) zwar zu false ausgewertet, aber erst wenn der faculty
|
||||
; Aufruf komplett ausgewertet ist, wird new-if aufgerufen. Da in jedem Rekursionsschritt
|
||||
; faculty aufgerufen wird, entsteht eine Endlosschleife.
|
||||
|
||||
; Anhand dieses Beispiels wird deutlich, dass zunächst die Bedingung ausgewertet werden muss
|
||||
; und abhängig von dieser dann entweder nur die then-clause oder nur die else-clause. Bei jeder Rekursion
|
||||
; muss dies passieren, da sonst die Abbruchbedingung nie zum Abbruch führt.
|
||||
220
se3/G08_B05_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
220
se3/G08_B05_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
@ -0,0 +1,220 @@
|
||||
#lang racket
|
||||
|
||||
#|
|
||||
SE 3 Funktional Blatt 5
|
||||
Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
|#
|
||||
|
||||
; 1)
|
||||
; Folgende Teilprobleme sind zu lösen:
|
||||
; - bestimmen der rezessiven Merkmale des Vaters
|
||||
; - bestimmen der rezessiven Merkmale der Mutter
|
||||
; - bestimmen der vererbten Merkmale des Vaters
|
||||
; - bestimmen der vererbten Merkmale der Mutter
|
||||
; - bestimmen der sichtbaren Merkmale von Kindern
|
||||
; - anzeigen eines Schmetterlings
|
||||
; - bestimmen von beliebig vielen Kindern
|
||||
|
||||
; Das Programm hat die Hauptfunktion mendel, die als Parameter die dominanten
|
||||
; Merkmale des Vaters und der Mutter, sowie die Anzahl der Kinder bekommt.
|
||||
|
||||
; Davon ausgehend werden dann zufällig die rezessiven Merkmale des Vaters bzw. der Mutter
|
||||
; gewählt. Dafür wird eine Funktion randomRezessiv benötigt, die ebendies bewerkstelligt.
|
||||
|
||||
; randomRezessiv greift auf die Dominanzliste zurück. Dafür wird eine Zugriffsfunktion
|
||||
; key->wert benutzt. Zusätzlich wird eine Hilfsfunktion (randomList) benutzt, um
|
||||
; von der Liste der dominierten Merkmale ein zufälliges Merkmal auszuwählen.
|
||||
|
||||
; randomSelection wählt aus gegebenen dominanten und rezessiven Merkmalen zufällig eine Liste
|
||||
; an Merkmalen aus, die dann die vererbten Merkmale darstellen.
|
||||
|
||||
; sichtbar ermittelt bei gegebenen Merkmalen des Vaters und der Mutter
|
||||
; die sichtbaren Elemente.
|
||||
|
||||
; zeigeSchmetterling zeigt einen Schmetterling bei gegebenen Merkmalen in einer Liste an.
|
||||
|
||||
; Die Datenstruktur zum Speichern des Genoms ist sehr einfach:
|
||||
; Es ist eine Liste von Listen, deren erstes Element jeweils ein Merkmal darstellt
|
||||
; und deren zweites Element jeweils eine Liste von Merkmalen darstellt,
|
||||
; die von dem Merkmal an erster Stelle dominiert werden.
|
||||
|
||||
; Durch diesen Entwurf lassen sich die Teilprobleme leicht lösen und es
|
||||
; wird eine optimale Anzahl an Funktionen erreicht, die nicht mehr aber auch
|
||||
; nicht weniger machen, als benötigt wird.
|
||||
|
||||
; Datenstruktur der Dominanzabhängigkeiten, wobei der Wert immer eine Liste
|
||||
; all jener Merkmale ist, die von dem key dominiert werden
|
||||
(define dominanzliste
|
||||
'((punkte . (streifen sterne))
|
||||
(streifen . (sterne))
|
||||
(sterne . (sterne))
|
||||
(rot . (gruen blau gelb))
|
||||
(gruen . (blau gelb))
|
||||
(blau . (gelb))
|
||||
(gelb . (gelb))
|
||||
(gerade . (gekruemmt geschweift))
|
||||
(gekruemmt . (geschweift))
|
||||
(geschweift . (geschweift))
|
||||
(rhombisch . (hexagonal elliptisch))
|
||||
(hexagonal . (elliptisch))
|
||||
(elliptisch . (elliptisch))
|
||||
))
|
||||
|
||||
; Datenstruktur für Übersetzung, um show-butterfly korrekt aufzurufen
|
||||
(define translationlist
|
||||
'((punkte . dots)
|
||||
(streifen . stripes)
|
||||
(sterne . stars)
|
||||
(rot . red)
|
||||
(gruen . green)
|
||||
(blau . blue)
|
||||
(gelb . yellow)
|
||||
(gerade . straight)
|
||||
(gekruemmt . curved)
|
||||
(geschweift . curly)
|
||||
(rhombisch . rhomb)
|
||||
(hexagonal . hexagon)
|
||||
(elliptisch . ellipse)
|
||||
))
|
||||
|
||||
; gibt den Wert von key in tafel zurück
|
||||
(define (key->wert key tafel)
|
||||
(cdr (assoc key tafel)))
|
||||
|
||||
; wählt ein zufälliges Element einer Liste aus
|
||||
(define (randomListe xs)
|
||||
(car (shuffle xs)))
|
||||
|
||||
; wählt zu einer gegebenen Liste an dominanten Merkmalen die rezessiven Merkmale aus
|
||||
(define (randomRezessiv dominant)
|
||||
(letrec ((help (λ (xs result)
|
||||
(if (empty? xs)
|
||||
result
|
||||
(help
|
||||
(cdr xs)
|
||||
(cons
|
||||
(randomListe (key->wert (car xs) dominanzliste))
|
||||
result
|
||||
))
|
||||
))))
|
||||
(reverse (help dominant '()))))
|
||||
|
||||
; wählt von den gegebenen Elementen zufällig eines aus
|
||||
(define (randomElement x y)
|
||||
(let ((r (random 2)))
|
||||
(if (= r 0)
|
||||
x
|
||||
y)))
|
||||
|
||||
; wählt aus der Liste der dominanten und rezessiven Merkmale zufällig
|
||||
; Merkmale aus
|
||||
(define (randomSelection dominant rezessiv)
|
||||
(letrec ((select (λ (xs ys result)
|
||||
(if (empty? xs)
|
||||
result
|
||||
(select (cdr xs) (cdr ys) (cons (randomElement (car xs) (car ys))
|
||||
result))
|
||||
))))
|
||||
(reverse (select dominant rezessiv '()))))
|
||||
|
||||
; bestimmt aus den zufälligen Merkmalen des Vaters und der Mutter die sichtbaren Elemente
|
||||
; beim Kind
|
||||
(define (sichtbar vaterMerkmale mutterMerkmale)
|
||||
(letrec ((rec (λ (xs ys result)
|
||||
(if (empty? xs)
|
||||
result
|
||||
(if (empty? (filter (λ (x) (equal? x (car ys))) (key->wert (car xs) dominanzliste)))
|
||||
(rec (cdr xs) (cdr ys) (cons (car ys) result))
|
||||
(rec (cdr xs) (cdr ys) (cons (car xs) result))
|
||||
)))))
|
||||
(reverse (rec vaterMerkmale mutterMerkmale '()))))
|
||||
|
||||
(require se3-bib/butterfly-module)
|
||||
|
||||
(define (zeigeSchmetterling merkmale)
|
||||
(show-butterfly (key->wert (cadr merkmale) translationlist)
|
||||
(key->wert (car merkmale) translationlist)
|
||||
(key->wert (caddr merkmale) translationlist)
|
||||
(key->wert (cadddr merkmale) translationlist)
|
||||
))
|
||||
; zeigt (in dieser Reihenfolge) den Vater, die Mutter und die Kinder
|
||||
(define (mendel vaterDominant mutterDominant anzahlKinder)
|
||||
(let ((vaterRezessiv (randomRezessiv vaterDominant))
|
||||
(mutterRezessiv (randomRezessiv mutterDominant))
|
||||
)
|
||||
(letrec ((rec (λ (counter result)
|
||||
(if (= 0 counter)
|
||||
result
|
||||
(rec (- counter 1)
|
||||
(cons (sichtbar
|
||||
(randomSelection vaterDominant vaterRezessiv)
|
||||
(randomSelection mutterDominant mutterRezessiv))
|
||||
result))))))
|
||||
(map zeigeSchmetterling (cons vaterDominant (cons mutterDominant (rec anzahlKinder '()))))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Austesten des Falles von einem Vater, der als dominante Merkmale die absolut
|
||||
; dominantesten Merkmale hat und einer Mutter, die als dominante Merkmale die absolut
|
||||
; schwächsten Merkmale hat
|
||||
|
||||
; diese Daten testen einen möglichen Extremfall
|
||||
; bei diesem Fall sind die vererbten Merkmale der Mutter immer dieselben
|
||||
; ein Merkmal der Mutter wird sich daher nur durchsetzen, wenn der Vater dies als
|
||||
; rezessives Merkmal hat und das rezessive Merkmal vom Vater vererbt wird
|
||||
(mendel '(punkte rot gerade rhombisch) '(sterne gelb geschweift elliptisch) 2)
|
||||
|
||||
; Austesten des Falles, dass sowohl Vater als auch Mutter die schwächsten Merkmale
|
||||
; als dominante Merkmale haben
|
||||
; bei diesem Extremfall sehen die Kinder genau gleich aus (alle von 1 bis n)
|
||||
(mendel '(sterne gelb geschweift elliptisch) '(sterne gelb geschweift elliptisch) 2)
|
||||
|
||||
; Austesten des Falles, dass beide Elternteile die dominantesten Merkmale
|
||||
; als dominante Merkmale haben. Die Kinder können hier die größten Unterschiede aufweisen.
|
||||
; In den meisten Fällen werden sie aber so aussehen, wie die Eltern.
|
||||
(mendel '(punkte rot gerade rhombisch) '(punkte rot gerade rhombisch) 2)
|
||||
|
||||
; 2)
|
||||
; überprüft, ob ein Element in einer Liste ist
|
||||
(define (in-list? element list)
|
||||
(if (pair? (member element list))
|
||||
#t
|
||||
#f))
|
||||
|
||||
(define erbbarliste
|
||||
'((punkte . (punkte streifen sterne))
|
||||
(streifen . (streifen sterne))
|
||||
(sterne . (sterne))
|
||||
(rot . (rot gruen blau gelb))
|
||||
(gruen . (gruen blau gelb))
|
||||
(blau . (blau gelb))
|
||||
(gelb . (gelb))
|
||||
(gerade . (gerade gekruemmt geschweift))
|
||||
(gekruemmt . (gekruemmt geschweift))
|
||||
(geschweift . (geschweift))
|
||||
(rhombisch . (rhombisch hexagonal elliptisch))
|
||||
(hexagonal . (hexagonal elliptisch))
|
||||
(elliptisch . (elliptisch))
|
||||
))
|
||||
|
||||
; überprüft, ob das Kind von den Eltern abstammen kann
|
||||
(define (testeElternschaft sichtbarVater sichtbarMutter sichtbarKind)
|
||||
(letrec ((rec (λ (xs ys zs valid)
|
||||
(if (or (not valid) (empty? xs))
|
||||
valid
|
||||
(rec (cdr xs)
|
||||
(cdr ys)
|
||||
(cdr zs)
|
||||
(or (in-list? (car zs) (key->wert (car xs) erbbarliste))
|
||||
(in-list? (car zs) (key->wert (car ys) erbbarliste))
|
||||
))
|
||||
))))
|
||||
(rec sichtbarVater sichtbarMutter sichtbarKind #t)))
|
||||
|
||||
(display "\nKönnen Anton und Antonia die Eltern von Toni sein:")
|
||||
(testeElternschaft '(sterne gruen geschweift rhombisch) '(streifen blau gekruemmt hexagonal) '(sterne rot gekruemmt rhombisch))
|
||||
(display "\nKönnen Anton und Antonia die Eltern von Tini sein:")
|
||||
(testeElternschaft '(sterne gruen geschweift rhombisch) '(streifen blau gekruemmt hexagonal) '(punkte gruen gerade rhombisch))
|
||||
(display "\nKönnen Anton und Antonia die Eltern von Tina sein:")
|
||||
(testeElternschaft '(sterne gruen geschweift rhombisch) '(streifen blau gekruemmt hexagonal) '(streifen gelb geschweift elliptisch))
|
||||
115
se3/G08_B06_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
115
se3/G08_B06_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
@ -0,0 +1,115 @@
|
||||
#lang racket
|
||||
|
||||
#|
|
||||
SE 3 Funktional Blatt 6
|
||||
Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
|#
|
||||
|
||||
; 1)
|
||||
;
|
||||
; kopfstueck ist eine lineare Rekursion, da pro else-Aufruf,
|
||||
; die Funktion nur einmal sich selbst aufruft.
|
||||
; Daher kann kopfstueck keine Baumrekursion sein.
|
||||
; kopfstueck wird auch nicht als Argument für kopfstueck verwendet,
|
||||
; womit auch geschachtelte Rekursion mit nein zu beantworten ist.
|
||||
; Da sich kopfstueck direkt rekursiv aufruft, ist es eine direkte
|
||||
; und keine indirekte Rekursion.
|
||||
|
||||
; endstueck ist ebenso linear, keine Baumrekursion, keine geschachtelte
|
||||
; Rekursion, eine direkte Rekursion und keine indirekte Rekursion.
|
||||
|
||||
; merge ist eine lineare Rekursion, da pro Fallunterscheidung
|
||||
; merge nur einmal aufgerufen wird. Demnach ist es keine Baumrekursion.
|
||||
; Es ist ebenso wenig eine geschachtelte Rekursion, da es sich selbst
|
||||
; nicht als Argument übergeben wird.
|
||||
; merge ist eine direkte Rekursion, da es sich direkt aufruft.
|
||||
; Deswegen ist merge keine indirekte Rekursion.
|
||||
|
||||
; merge-sort ist keine lineare Rekursion, da es in jeder Fallunterscheidung
|
||||
; zweimal aufgerufen wird. merge-sort ist keine geschachtelte Rekursion,
|
||||
; da es sich selbst nicht als Argument übergeben wird.
|
||||
; merge-sort ist eine direkte Rekursion, da es sich direkt aufruft.
|
||||
; Demnach ist merge-sort keine indirekte Rekursion.
|
||||
|
||||
; ___________________________________________________________________________________________________________________
|
||||
; | | lineare Rekursion | Baumrekursion | geschachtelte Rekursion | direkte Rekursion | indirekte Rekursion|
|
||||
; |____________|___________________|_______________|_________________________|___________________|____________________|
|
||||
; | kopfstueck | ja | nein | nein | ja | nein |
|
||||
; | endstueck | ja | nein | nein | ja | nein |
|
||||
; | merge | ja | nein | nein | ja | nein |
|
||||
; | merge-sort | nein | ja | nein | ja | nein |
|
||||
; --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
; 2)
|
||||
(require 2htdp/image)
|
||||
(require lang/posn)
|
||||
|
||||
; erzeugt einen Tannenbaum mit n Ebenen
|
||||
(define (tannenbaum n)
|
||||
(letrec ((leaves (λ (width x result)
|
||||
(if [= x 0]
|
||||
result
|
||||
; rekursiver Aufruf, um die nächsthöhere Ebene zu generieren
|
||||
(leaves
|
||||
(/ width 1.5)
|
||||
(- x 1)
|
||||
(cons
|
||||
; erzeugt ein Trapez, welches als eine Ebene fungiert
|
||||
(polygon
|
||||
(list (make-posn 0 0)
|
||||
(make-posn width 0)
|
||||
(make-posn (+ (/ width 2) (* (/ width 2) 0.2)) (* -1 (/ width 4)))
|
||||
(make-posn (- (/ width 2) (* (/ width 2) 0.2)) (* -1 (/ width 4))))
|
||||
"solid"
|
||||
"darkgreen")
|
||||
result)))
|
||||
)))
|
||||
; Anwenden von above/align auf alle Blätter, den Stamm und den Stern
|
||||
(apply above/align
|
||||
(cons "center"
|
||||
(cons (star-polygon 20 5 2 "solid" "gold")
|
||||
(leaves 180 n `(,(rectangle 30 30 "solid" "brown") . ()))
|
||||
)))
|
||||
|
||||
))
|
||||
|
||||
; erzeugt einen Monitor
|
||||
(define (monitor content)
|
||||
(above/align
|
||||
"center"
|
||||
(overlay
|
||||
(text content 24 "red")
|
||||
(rectangle 160 90 "solid" "blue")
|
||||
(rectangle 165 95 "solid" "gray")
|
||||
)
|
||||
(polygon
|
||||
(list (make-posn 0 0)
|
||||
(make-posn 80 0)
|
||||
(make-posn 55 -10)
|
||||
(make-posn 25 -10))
|
||||
"solid"
|
||||
"gray")
|
||||
))
|
||||
|
||||
; erzeugt ein Star Citizen Poster
|
||||
(define scPoster (overlay
|
||||
(above
|
||||
(text "Star Citizen" 34 "gold")
|
||||
(text "Squadron 42" 28 "gold"))
|
||||
(rectangle 185 85 "solid" "royalblue")
|
||||
(rectangle 200 100 "solid" "black")))
|
||||
|
||||
; linker Tannenbaum
|
||||
(display (tannenbaum 8))
|
||||
; Monitor
|
||||
(display (monitor "cout << 0x2a;"))
|
||||
; Abstand zwischen Monitor und Poster
|
||||
(display " ")
|
||||
; Star Citizen Poster
|
||||
(display scPoster)
|
||||
; Abstand zwischen Monitor und Poster
|
||||
(display " ")
|
||||
; Monitor
|
||||
(display (monitor "6.12.13"))
|
||||
; rechter Tannenbaum
|
||||
(display (tannenbaum 8))
|
||||
197
se3/G08_B07_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
197
se3/G08_B07_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
@ -0,0 +1,197 @@
|
||||
#lang racket
|
||||
|
||||
#|
|
||||
SE 3 Funktional Blatt 7
|
||||
Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
|#
|
||||
|
||||
; 1)
|
||||
|
||||
; allgemeine rekursive Version
|
||||
(define (produkt1 n f)
|
||||
(letrec ((rec (λ (xs r)
|
||||
(if [empty? xs]
|
||||
r
|
||||
(rec
|
||||
(cdr xs)
|
||||
(cons (* (car xs) f) r))))))
|
||||
(reverse (rec n '()))))
|
||||
|
||||
; endrekursive Version
|
||||
(define (produkt2 n f)
|
||||
(let ((revList (reverse n)))
|
||||
(letrec ((rec (λ (xs acc)
|
||||
(if (empty? xs)
|
||||
acc
|
||||
(rec
|
||||
(cdr xs)
|
||||
(cons (* (car xs) f) acc)
|
||||
)
|
||||
))))
|
||||
(rec revList '()))))
|
||||
|
||||
; Funktionen höherer Ordnung
|
||||
(define (produkt3 n f)
|
||||
(map (curryr * f) n))
|
||||
|
||||
; 2)
|
||||
|
||||
; 2.1
|
||||
; Eine Liste mit sieben Elementen, die je eine Leuchtdiode
|
||||
; repräsentieren. Jedes Element ist entweder #f oder #t.
|
||||
; -1-
|
||||
;| |
|
||||
;2 3
|
||||
;| |
|
||||
; -4-
|
||||
;| |
|
||||
;5 6
|
||||
;| |
|
||||
; -7-
|
||||
|
||||
; Die Leuchtdioden werden in dieser Reihenfolge in der Liste
|
||||
; angegeben.
|
||||
|
||||
; Die möglichen Zustände für die Zahlen 0-9 werden mithilfe
|
||||
; einer Liste von oben beschriebenen Listen realisiert.
|
||||
|
||||
(define zustandstabelle
|
||||
'((0 . (#t #t #t #f #t #t #t))
|
||||
(1 . (#f #f #t #f #f #t #f))
|
||||
(2 . (#t #f #t #t #t #f #t))
|
||||
(3 . (#t #f #t #t #f #t #t))
|
||||
(4 . (#f #t #t #t #f #t #f))
|
||||
(5 . (#t #t #f #t #f #t #t))
|
||||
(6 . (#t #t #f #t #t #t #t))
|
||||
(7 . (#t #f #t #f #f #t #f))
|
||||
(8 . (#t #t #t #t #t #t #t))
|
||||
(9 . (#t #t #t #t #f #t #t))))
|
||||
|
||||
(define (key->value key tabelle)
|
||||
(cdr (assoc key tabelle)))
|
||||
|
||||
; 2.2
|
||||
(require 2htdp/image)
|
||||
|
||||
; erzeugte ein senkrechtes Segment
|
||||
(define (zeichneSegmentSenkrecht active)
|
||||
(if active
|
||||
(rectangle 10 80 "solid" "Red")
|
||||
(rectangle 10 80 "solid" "DimGray")
|
||||
))
|
||||
|
||||
; erzeugt ein waagerechtes Segment
|
||||
(define (zeichneSegmentWaagerecht active)
|
||||
(if active
|
||||
(rectangle 80 10 "solid" "Red")
|
||||
(rectangle 80 10 "solid" "DimGray")
|
||||
))
|
||||
|
||||
; zeichnet die Segmente
|
||||
(define (zeichneSegmente zustand)
|
||||
(beside
|
||||
; Segmente 2 und 5
|
||||
(above
|
||||
(zeichneSegmentSenkrecht (cadr zustand))
|
||||
(rectangle 10 10 "solid" "Black")
|
||||
(zeichneSegmentSenkrecht (cadddr (cdr zustand)))
|
||||
)
|
||||
; Segmente 1, 4 und 7
|
||||
(above
|
||||
(zeichneSegmentWaagerecht (car zustand))
|
||||
(rectangle 80 80 "solid" "Black")
|
||||
(zeichneSegmentWaagerecht (cadddr zustand))
|
||||
(rectangle 80 80 "solid" "Black")
|
||||
(zeichneSegmentWaagerecht (cadddr (cdddr zustand)))
|
||||
)
|
||||
; Segmente 3 und 6
|
||||
(above
|
||||
(zeichneSegmentSenkrecht (caddr zustand))
|
||||
(rectangle 10 10 "solid" "Black")
|
||||
(zeichneSegmentSenkrecht (cadddr (cddr zustand)))
|
||||
)
|
||||
))
|
||||
|
||||
; zeigt eine Sieben-Segment-Anzeige
|
||||
(define (zeigeSiebenSegment zustand)
|
||||
(overlay
|
||||
(zeichneSegmente zustand)
|
||||
(rectangle 100 200 "solid" "Black")
|
||||
))
|
||||
|
||||
; 2.3
|
||||
(define (zeige-7segment t)
|
||||
(let ((zustand (floor (/ t 28))))
|
||||
(if (and [exact? zustand]
|
||||
[< zustand 10])
|
||||
(zeigeSiebenSegment (key->value zustand zustandstabelle))
|
||||
(zeigeSiebenSegment (key->value (- zustand 10) zustandstabelle)))))
|
||||
|
||||
(require 2htdp/universe)
|
||||
; zum Animieren auskommentieren
|
||||
;(animate zeige-7segment)
|
||||
|
||||
; 2.4
|
||||
; Für die Darstellung von 6 Anzeigen müssen 6 Zustands-
|
||||
; variablen eingeführt werden, die den Zustand für jede
|
||||
; der sechs Anzeigen repräsentieren.
|
||||
|
||||
; Dazu muss die eben definierte Funktion dahingehend
|
||||
; erweitert werden.
|
||||
|
||||
; Die Anzeigen seien von links nach rechts mit 1 bis 6 bezeichnet.
|
||||
; modT entspricht dem Rest der Division t durch 2419200.
|
||||
; Anzeige 6 schaltet auf 1, wenn modT 28 ist und auf 2 wenn modT 56 ist, etc.
|
||||
; Anzeige 5 schaltet auf 1, wenn Anzeige 1 auf 10 ist und
|
||||
; auf 2 wenn 6 auf 20 ist, etc.
|
||||
; Anzeige 4 schaltet auf 1, wenn Anzeige 5 auf 6 ist und
|
||||
; auf 2 wenn 5 auf 12 ist, etc.
|
||||
; Anzeige 3 schaltet auf 1, wenn Anzeige 4 auf 10 ist und
|
||||
; auf 2 wenn 4 auf 20 ist, etc.
|
||||
; Anzeige 2 schaltet auf 1, wenn Anzeige 3 auf 6 ist und
|
||||
; auf 2 wenn 3 auf 12 ist, etc.
|
||||
; Anzeige 1 schaltet auf 1, wenn Anzeige 2 auf 10 ist und
|
||||
; auf 2 wenn 2 auf 20 ist, etc.
|
||||
|
||||
(define trenner
|
||||
(underlay/xy
|
||||
(underlay/xy
|
||||
(rectangle 100 200 'solid 'black)
|
||||
40
|
||||
70
|
||||
(rectangle 20 20 'solid 'red)
|
||||
)
|
||||
40
|
||||
140
|
||||
(rectangle 20 20 'solid 'red)
|
||||
))
|
||||
|
||||
(define trenner2
|
||||
(rectangle 10 200 "solid" "Black"))
|
||||
|
||||
; diese Funktion wird bis 99h 59m 59s zählen und dann wieder bei 0
|
||||
; anfangen
|
||||
(define (zeigedauer t)
|
||||
(let* ((modT (modulo t 10080000)) ; 10080000 entspricht 100h
|
||||
(zustand6 (floor (/ modT 28)))
|
||||
(zustand5 (floor (/ zustand6 10)))
|
||||
(zustand4 (floor (/ zustand5 6)))
|
||||
(zustand3 (floor (/ zustand4 10)))
|
||||
(zustand2 (floor (/ zustand3 6)))
|
||||
(zustand1 (floor (/ zustand2 10))))
|
||||
(beside
|
||||
(zeigeSiebenSegment (key->value (modulo zustand1 10) zustandstabelle))
|
||||
trenner2
|
||||
(zeigeSiebenSegment (key->value (modulo zustand2 10) zustandstabelle))
|
||||
trenner
|
||||
(zeigeSiebenSegment (key->value (modulo zustand3 6) zustandstabelle))
|
||||
trenner2
|
||||
(zeigeSiebenSegment (key->value (modulo zustand4 10) zustandstabelle))
|
||||
trenner
|
||||
(zeigeSiebenSegment (key->value (modulo zustand5 6) zustandstabelle))
|
||||
trenner2
|
||||
(zeigeSiebenSegment (key->value (modulo zustand6 10) zustandstabelle)))
|
||||
))
|
||||
|
||||
; zum Animieren auskommentieren
|
||||
; (animate zeigedauer)
|
||||
222
se3/G08_B08_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
222
se3/G08_B08_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
@ -0,0 +1,222 @@
|
||||
#lang racket
|
||||
|
||||
#|
|
||||
SE 3 Funktional Blatt 8
|
||||
Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
|#
|
||||
|
||||
; 1)
|
||||
|
||||
; 1.
|
||||
|
||||
; Wenn die Funktion mindestens eine Funktion als Parameter erwartet oder
|
||||
; eine Funktion zurückgibt.
|
||||
|
||||
; 2.
|
||||
; (a): foldl ist eine Funktion höherer Ordnung, da als erster Parameter
|
||||
; eine Funktion erwartet wird.
|
||||
|
||||
; (b): Die Funktion ist eine Funktion höherer Ordnung, da
|
||||
; sie entweder car oder cdr zurückgibt, welches jeweils Funktionen sind.
|
||||
|
||||
; (c) ist eine Funktion höherer Ordnung, da für den Parameter f
|
||||
; eine Funktion erwartet wird und eine Funktion zurückgegeben wird.
|
||||
|
||||
; (d) ist keine Funktion höherer Ordnung, da keine Funktion
|
||||
; zurückgegeben wird und auch keine Funktion erwartet wird.
|
||||
|
||||
; 3.
|
||||
|
||||
; Nach der inneren Reduktion wird zunächst (pimento + 1) ausgeführt.
|
||||
; Dabei wird f an + gebunden und arg1 wird an 1 gebunden.
|
||||
; Der zurückgegebenen Closure wird nun 3 als Argument übergeben.
|
||||
; Damit wird arg2 an 3 gebunden. Schließlich wird (+ 1 3) ausgeführt
|
||||
; und als Ergebnis 4 zurückgegeben.
|
||||
|
||||
; 4.
|
||||
|
||||
; (foldl (curry * 2) 1 '(1 2 3)) -> 48, weil zunächst (curry * 2)
|
||||
; aufgelöst wird zu einer Closure, die sich wie * verhält, aber
|
||||
; bereits den Faktor 2 auf jeden Fall im Endprodukt hat.
|
||||
; Anschließend wird foldl ausgeführt und verwendet die Elemente der Liste
|
||||
; als Argumente für die Closure. 1 wird als letztes Argument verwendet.
|
||||
; (* 2 1 2 3 1) -> 48
|
||||
|
||||
; (map cons '(1 2 3) '(1 2 3)) -> '((1 . 1) (2 . 2) (3 . 3)),
|
||||
; weil cons auf die Elemente der übergebenen Listen angewendet wird.
|
||||
; Es wird mit dem jeweils ersten Element der Listen begonnen.
|
||||
; Daraus ergibt sich dann:
|
||||
; (cons 1 1) -> (1 . 1)
|
||||
; (cons 2 2) -> (2 . 2)
|
||||
; (cons 3 3) -> (3 . 3)
|
||||
; Die Ergebnisse der Aufrufe von cons landen dann in der Reihenfolge
|
||||
; in der Ergebnisliste.
|
||||
|
||||
; (filter pair? '((a b ) () 1 (()))) -> '((a b) (())), weil
|
||||
; filter eine Liste solcher Elemente zurückgibt, für die pair?
|
||||
; true zurückgibt.
|
||||
; (pair? '(a b)) -> #t
|
||||
; (pair? '()) -> #f
|
||||
; (pair? 1) -> #f
|
||||
; (pair? '(())) -> #t
|
||||
; Daraus ergibt sich die oben genannte Rückgabeliste.
|
||||
|
||||
; (map (compose (curry - 32) (curry * 1.8))
|
||||
; '(5505 100 0 -273.15)) -> '(-9877.0 -148.0 32 523.67), weil
|
||||
; zunächst nach der inneren Reduktion die beiden curry-Aufrufe
|
||||
; je eine Closure zurückgeben. Anschließend wird compose ausgeführt
|
||||
; und erzeugt eine Nacheinanderausführung (closure) der beiden Closures,
|
||||
; wobei die zweite Closure zuerst und die erste Closure danach
|
||||
; ausgeführt wird.
|
||||
; Schließlich wird map aufgerufen und führt die erstellte Nacheinanderausführung
|
||||
; nacheinander für jedes Listenelement aus.
|
||||
; Daraus ergibt sich:
|
||||
; (closure 5505) -> (- 32 (* 1.8 5505)) -> -9877.0
|
||||
; (closure 100) -> (- 32 (* 1.8 100)) -> -148.0
|
||||
; (closure 0) -> (- 32 (* 1.8 0)) -> 32
|
||||
; (closure -273.15) -> (- 32 (* 1.8 -273.15)) -> 523.67
|
||||
|
||||
; 2)
|
||||
(define xs '(1 -2 3 -4 5 -6 7 9))
|
||||
; 1.
|
||||
(map abs xs)
|
||||
|
||||
; 2.
|
||||
(filter
|
||||
(λ (x)
|
||||
(= 0 (modulo x 7)))
|
||||
xs)
|
||||
|
||||
; 3.
|
||||
(foldl +
|
||||
0
|
||||
(filter
|
||||
(λ (x)
|
||||
(and [odd? x]
|
||||
[> x 3])
|
||||
)
|
||||
xs))
|
||||
|
||||
; 4.
|
||||
(define (split pred xs)
|
||||
(letrec ((rec (λ (xs acc1 acc2)
|
||||
(if (empty? xs)
|
||||
(list acc1 acc2)
|
||||
(if (pred (car xs))
|
||||
(rec
|
||||
(cdr xs)
|
||||
(cons (car xs) acc1)
|
||||
acc2)
|
||||
(rec
|
||||
(cdr xs)
|
||||
acc1
|
||||
(cons (car xs) acc2))
|
||||
)))))
|
||||
(rec xs '() '())))
|
||||
(split odd? xs)
|
||||
|
||||
; 3)
|
||||
|
||||
; 1.
|
||||
|
||||
(define (key->wert key tafel)
|
||||
(cdr (assoc key tafel)))
|
||||
|
||||
; Datenstruktur für mögliche Ausprägungen
|
||||
(define ausprägungen
|
||||
`((Form . ,'(Oval Rechteck Welle))
|
||||
(Farbe . ,'(rot blau grün))
|
||||
(Anzahl . ,'(ein zwei drei))
|
||||
(Füllung . ,'(Linie Schraffur Fläche))))
|
||||
|
||||
(define translationList
|
||||
`((Oval . oval)
|
||||
(Rechteck . rectangle)
|
||||
(Welle . waves)
|
||||
(rot . red)
|
||||
(blau . blue)
|
||||
(grün . green)
|
||||
(ein . 1)
|
||||
(zwei . 2)
|
||||
(drei . 3)
|
||||
(Linie . outline)
|
||||
(Schraffur . hatched)
|
||||
(Fläche . solid)))
|
||||
|
||||
; Eine Spielkarte ist repräsentiert durch eine Liste, die von vorne
|
||||
; nach hinten die Form, Farbe, Anzahl und Füllung durch ihre Elemente angibt.
|
||||
|
||||
; 2.
|
||||
; erzeugt die Spielkarten
|
||||
(define (erzeugeSpielkarten)
|
||||
(letrec ((rec (λ (acc cards)
|
||||
(if (= -1 cards)
|
||||
acc
|
||||
(let ((d (modulo cards 3))
|
||||
(c (modulo (floor (/ cards 3)) 3))
|
||||
(b (modulo (floor (/ cards 9)) 3))
|
||||
(a (modulo (floor (/ cards 27)) 3)))
|
||||
(rec (cons (list
|
||||
(list-ref (key->wert 'Form ausprägungen) a)
|
||||
(list-ref (key->wert 'Farbe ausprägungen) b)
|
||||
(list-ref (key->wert 'Anzahl ausprägungen) c)
|
||||
(list-ref (key->wert 'Füllung ausprägungen) d))
|
||||
acc)
|
||||
(- cards 1)))))))
|
||||
(rec '() 80)))
|
||||
|
||||
(require se3-bib/setkarten-module)
|
||||
|
||||
; zeigt eine Set-Karte
|
||||
(define (zeigeKarte karte)
|
||||
(show-set-card
|
||||
(key->wert (third karte) translationList)
|
||||
(key->wert (first karte) translationList)
|
||||
(key->wert (fourth karte) translationList)
|
||||
(key->wert (second karte) translationList)))
|
||||
|
||||
(define (zeigeKarten karten)
|
||||
(map zeigeKarte karten))
|
||||
|
||||
; 3.
|
||||
|
||||
(define (is-a-set? karten)
|
||||
(let* ([gleich (λ (wert1 wert2 wert3)
|
||||
(and
|
||||
(equal? wert1 wert2)
|
||||
(equal? wert1 wert3)
|
||||
))]
|
||||
[verschieden (λ (wert1 wert2 wert3)
|
||||
(and
|
||||
(not (equal? wert1 wert2))
|
||||
(not (equal? wert1 wert3))
|
||||
(not (equal? wert2 wert3))
|
||||
))]
|
||||
[qualified (λ (wert1 wert2 wert3)
|
||||
(or
|
||||
(gleich wert1 wert2 wert3)
|
||||
(verschieden wert1 wert2 wert3)
|
||||
))])
|
||||
(and
|
||||
(qualified (first (first karten))
|
||||
(first (second karten))
|
||||
(first (third karten)))
|
||||
(qualified (second (first karten))
|
||||
(second (second karten))
|
||||
(second (third karten)))
|
||||
(qualified (third (first karten))
|
||||
(third (second karten))
|
||||
(third (third karten)))
|
||||
(qualified (fourth (first karten))
|
||||
(fourth (second karten))
|
||||
(fourth (third karten))))))
|
||||
|
||||
(display "is-a-set?(#t): ")
|
||||
(is-a-set? '((Oval rot ein Linie)
|
||||
(Rechteck rot zwei Linie)
|
||||
(Welle rot drei Linie)))
|
||||
(display "is-a-set?(#f): ")
|
||||
(is-a-set? '((Oval rot ein Linie)
|
||||
(Oval blau zwei Fläche)
|
||||
(Welle rot drei Linie)))
|
||||
|
||||
387
se3/G08_B09_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
387
se3/G08_B09_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
@ -0,0 +1,387 @@
|
||||
#lang swindle
|
||||
|
||||
(require swindle/setf
|
||||
swindle/misc)
|
||||
|
||||
#|
|
||||
SE 3 Funktional Blatt 9
|
||||
Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
|#
|
||||
|
||||
; 1)
|
||||
|
||||
; 1.1
|
||||
|
||||
; allgemeine wissenschaftliche Publikation
|
||||
(defclass* publikation ()
|
||||
(schlüssel
|
||||
:reader publikation-schlüssel
|
||||
:writer set-publikation-schlüssel!
|
||||
:initvalue 0
|
||||
:initarg :pubSchlüssel
|
||||
:documentation "Der Schlüssel der Publikation"
|
||||
)
|
||||
(autoren
|
||||
:reader publikation-autoren
|
||||
:writer set-publikation-autoren!
|
||||
:initvalue '()
|
||||
:initarg :pubAutoren
|
||||
:type <list>
|
||||
:documentation "Die Autoren der Publikation"
|
||||
)
|
||||
(jahr
|
||||
:reader publikation-jahr
|
||||
:writer set-publikation-jahr!
|
||||
:initvalue "0"
|
||||
:initarg :pubJahr
|
||||
:type <string>
|
||||
:documentation "Das Erscheinungsjahr"
|
||||
)
|
||||
(titel
|
||||
:reader publikation-titel
|
||||
:writer set-publikation-titel!
|
||||
:initvalue ""
|
||||
:initarg :pubTitel
|
||||
:type <string>
|
||||
:documentation "Der Titel"
|
||||
)
|
||||
:autopred #t
|
||||
:printer #t
|
||||
:documentation "The top class of all publications"
|
||||
)
|
||||
|
||||
; Buch erbt von Publikation
|
||||
(defclass* buch (publikation)
|
||||
(verlag
|
||||
:reader buch-verlag
|
||||
:writer set-buch-verlag!
|
||||
:initvalue ""
|
||||
:initarg :buchVerlag
|
||||
:type <string>
|
||||
:documentation "Der Verlag des Buches"
|
||||
)
|
||||
(verlagort
|
||||
:reader buch-verlagort
|
||||
:writer set-buch-verlagort!
|
||||
:initvalue ""
|
||||
:initarg :buchVerlagort
|
||||
:type <string>
|
||||
:documentation "Der Ort des Verlages"
|
||||
)
|
||||
(reihe
|
||||
:reader buch-reihe
|
||||
:writer set-buch-reihe!
|
||||
:initvalue ""
|
||||
:initarg :buchReihe
|
||||
:type <string>
|
||||
:documentation "Die Reihe des Buches"
|
||||
)
|
||||
(reihe-seriennummer
|
||||
:reader buch-reihe-seriennummer
|
||||
:writer set-buch-reihe-seriennummer!
|
||||
:initvalue "0"
|
||||
:initarg :buchSeriennummer
|
||||
:type <string>
|
||||
:documentation "Die Seriennummer in der Reihe"
|
||||
)
|
||||
(edition
|
||||
:reader buch-edition
|
||||
:writer set-buch-edition!
|
||||
:initvalue "1"
|
||||
:initarg :buchEdition
|
||||
:type <string>
|
||||
:documentation "Die Edition des Buches"
|
||||
)
|
||||
:autopred #t
|
||||
:printer #t
|
||||
:documentation "Ein Buch"
|
||||
)
|
||||
|
||||
; Sammelbände erbt von Buch
|
||||
(defclass* sammelband (buch)
|
||||
(herausgeber
|
||||
:reader sammelband-herausgeber
|
||||
:writer set-sammelband-herausgeber!
|
||||
:initvalue ""
|
||||
:initarg :sammelbandHerausgeber
|
||||
:type <string>
|
||||
:documentation "Herausgeber des Sammelbands"
|
||||
)
|
||||
(seitenangabe
|
||||
:reader sammelband-seitenangabe
|
||||
:writer set-sammelband-seitenangabe!
|
||||
:initvalue ""
|
||||
:initarg :sammelbandSeitenangabe
|
||||
:type <string>
|
||||
:documentation "Die Seiten des Artikels"
|
||||
)
|
||||
(name
|
||||
:reader sammelband-name
|
||||
:writer set-sammelband-name!
|
||||
:initvalue ""
|
||||
:initarg :sammelbandName
|
||||
:type <string>
|
||||
:documentation "Name des Sammelbandes"
|
||||
)
|
||||
:autopred #t
|
||||
:printer #t
|
||||
:documentation "Ein Sammelband"
|
||||
)
|
||||
|
||||
; Zeitschriftenartikel
|
||||
(defclass* zeitschrift (publikation)
|
||||
(name
|
||||
:reader zeitschrift-name
|
||||
:writer set-zeitschrift-name!
|
||||
:initvalue ""
|
||||
:initarg :zeitschriftName
|
||||
:type <string>
|
||||
:documentation "Der Name der Zeitschrift"
|
||||
)
|
||||
(band-nummer
|
||||
:reader zeitschrift-band-nummer
|
||||
:writer set-zeitschrift-band-nummer!
|
||||
:initvalue "0"
|
||||
:initarg :zeitschriftBandnummer
|
||||
:type <string>
|
||||
:documentation "Die Bandnummer der Zeitschrift"
|
||||
)
|
||||
(heft-nummer
|
||||
:reader zeitschrift-heft-nummer
|
||||
:writer set-zeitschrift-heft-nummer!
|
||||
:initvalue "0"
|
||||
:initarg :zeitschriftHeftnummer
|
||||
:type <string>
|
||||
:documentation "Die Nummer des Heftes"
|
||||
)
|
||||
(monat
|
||||
:reader zeitschrift-monat
|
||||
:writer set-zeitschrift-monat!
|
||||
:initvalue 'Januar
|
||||
:initarg :zeitschriftMonat
|
||||
:type <symbol>
|
||||
:documentation "Der Erscheinungsmonat der Zeitschrift"
|
||||
)
|
||||
:autopred #t
|
||||
:printer #t
|
||||
:documentation "Ein Zeitschriftenartikel"
|
||||
)
|
||||
|
||||
; Nessie
|
||||
(define nessie
|
||||
(make buch :pubTitel "Mein Leben im Loch Ness: Verfolgt als Ungeheuer"
|
||||
:pubJahr "1790"
|
||||
:pubSchlüssel 'Nessie1790
|
||||
:pubAutoren '("Nessie")
|
||||
:buchVerlag "Minority-Verlag"
|
||||
:buchVerlagort "Inverness"
|
||||
:buchReihe "Die besondere Biographie"
|
||||
:buchSeriennummer "Band 1 der Reihe"))
|
||||
|
||||
; Prefect, F.
|
||||
(define prefect
|
||||
(make sammelband
|
||||
:pubTitel "Mostly harmless - some observations concerning the third planet of the solar system"
|
||||
:pubJahr "1979"
|
||||
:pubSchlüssel 'Prefect1979
|
||||
:pubAutoren '("Prefect, F.")
|
||||
:buchVerlag "Galactic Press"
|
||||
:buchVerlagort "Vega-System, 3rd planet"
|
||||
:buchReihe "\"Travel in Style\""
|
||||
:buchSeriennummer "volume 5 of"
|
||||
:buchEdition "1500 edition"
|
||||
:sammelbandHerausgeber "Adams D., editor"
|
||||
:sammelbandSeitenangabe "p. 500"
|
||||
:sammelbandName "The Hitchhiker's Guide to the Galaxy"
|
||||
))
|
||||
|
||||
; Wells
|
||||
(define wells
|
||||
(make zeitschrift
|
||||
:pubSchlüssel 'Wells3200
|
||||
:pubTitel "Zeitmaschinen leicht gemacht"
|
||||
:pubAutoren '("Wells, H. G.")
|
||||
:pubJahr "3200"
|
||||
:zeitschriftName "Heimwerkerpraxis für Anfänger"
|
||||
:zeitschriftBandnummer "500"
|
||||
:zeitschriftHeftnummer "3"
|
||||
))
|
||||
; 1.2
|
||||
|
||||
(defgeneric cite ((pub publikation)))
|
||||
; cite Methode für Bücher
|
||||
(defmethod cite ((pub buch))
|
||||
"Display the correct citation for given book"
|
||||
(display (string-append
|
||||
(car (publikation-autoren pub))
|
||||
" (" (publikation-jahr pub) "). "
|
||||
(publikation-titel pub) ", "
|
||||
(buch-reihe-seriennummer pub) ": "
|
||||
(buch-reihe pub) ". "
|
||||
(buch-verlag pub) ", " (buch-verlagort pub)
|
||||
".")))
|
||||
; cite Methode für Sammelbände
|
||||
(defmethod cite ((pub sammelband))
|
||||
"Display the correct citation for given collection"
|
||||
(display (string-append
|
||||
(car (publikation-autoren pub))
|
||||
" (" (publikation-jahr pub) "). "
|
||||
(publikation-titel pub) ". In "
|
||||
(sammelband-herausgeber pub) ", "
|
||||
(sammelband-name pub) ", "
|
||||
(buch-reihe-seriennummer pub)" "
|
||||
(buch-reihe pub) ". "
|
||||
(buch-verlag pub) ", " (buch-verlagort pub)
|
||||
", " (buch-edition pub) ", "
|
||||
(sammelband-seitenangabe pub) ".")))
|
||||
|
||||
; cite Methode für Zeitschriften
|
||||
(defmethod cite ((pub zeitschrift))
|
||||
"Display the correct citation for given magazine article"
|
||||
(display (string-append
|
||||
(car (publikation-autoren pub))
|
||||
" (" (publikation-jahr pub) "). "
|
||||
(publikation-titel pub) ". "
|
||||
(zeitschrift-name pub) ", "
|
||||
(zeitschrift-band-nummer pub) "("
|
||||
(zeitschrift-heft-nummer pub) ").")))
|
||||
|
||||
; 1.3
|
||||
|
||||
; Eine Ergänzungsmethode kann vor und nach der Methode der Oberklasse
|
||||
; ausgeführt werden. Außerdem kann sie einhüllend wirken und wird sowohl vor
|
||||
; als auch nach der Elternmethode aufgerufen.
|
||||
|
||||
; Die Vorteile sind, dass jede Ergänzungsmethode ausgeführt wird
|
||||
; und damit keine Initialisierungen vergessen oder unterdrückt
|
||||
; werden können, die in den Oberklassen definiert wurden.
|
||||
; Desweiteren brauchen die geerbten Methoden nicht durch
|
||||
; Modifikationen überladen zu werden, sondern werden nur
|
||||
; ergänzt.
|
||||
|
||||
; Ergänzungsmethoden könnten dazu genutzt werden die Basis-cite
|
||||
; Methode zu ergänzen, sodass nicht eine Methode für jede Publikationsform
|
||||
; von Nöten ist. Dabei könnten die Informationen schrittweise
|
||||
; aufgebaut werden. Allgemeine Information zu Beginn, dann buchspezifische,
|
||||
; dann sammelbandspezifische. Für Zeitschriften würde eine alternative
|
||||
; Reihenfolge von allgemeinen und zeitschriftenspezifischen
|
||||
; Informationen genutzt werden.
|
||||
|
||||
; Allerdings käme es dort zu Problemen, wo Informationen zwischendrin
|
||||
; eingefügt werden müssen. Die Sammelbandseitenangabe zum Beispiel erfolgt
|
||||
; am Schluss, die restlichen Informationen jedoch in der Mitte vor den
|
||||
; Buchinformationen wie Reihe und Verlag.
|
||||
|
||||
; 2)
|
||||
|
||||
; 2.1
|
||||
|
||||
;(defclass fahrzeug ())
|
||||
|
||||
; allgemeine Landfahrzeuge
|
||||
;(defclass landfahrzeug (fahrzeug))
|
||||
; Schienenfahrzeuge
|
||||
;(defclass schienenfahrzeug (fahrzeug))
|
||||
; Straßenfahrzeuge
|
||||
;(defclass straßenfahrzeug (fahrzeug))
|
||||
;(defclass wasserfahrzeug (fahrzeug))
|
||||
;(defclass luftfahrzeug (fahrzeug))
|
||||
|
||||
;(defclass amphibienfahrzeug (wasserfahrzeug landfahrzeug))
|
||||
;(defclass amphibienflugzeug (luftfahrzeug wasserfahrzeug straßenfahrzeug))
|
||||
;(defclass zweiwegefahrzeug (schienenfahrzeug straßenfahrzeug))
|
||||
;(defclass zeitzug (schienenfahrzeug luftfahrzeug))
|
||||
|
||||
; 2.2
|
||||
|
||||
; da ein Fahrzeug mehrere Medien aufweisen kann, ist es sinnvoll
|
||||
; diese in einer Liste zurückzugeben
|
||||
(defgeneric getMedium ((fz fahrzeug))
|
||||
:combination generic-list-combination)
|
||||
; von allen Medien muss die geringste Höchstgeschwindigkeit genommen werden
|
||||
; daher ist die min combination hier richtig
|
||||
(defgeneric getMaxSpeed ((fz fahrzeug))
|
||||
:combination generic-min-combination)
|
||||
; auch bei der Tragfähigkeit ist die geringst mögliche Tragfähigkeit
|
||||
; von Interesse
|
||||
(defgeneric getTragfähigkeit ((fz fahrzeug))
|
||||
:combination generic-min-combination)
|
||||
; beim Verbrauch hingegen ist der maximale Verbrauch über alle
|
||||
; Medien interessant
|
||||
(defgeneric getVerbrauchPro100km ((fz fahrzeug))
|
||||
:combination generic-max-combination)
|
||||
; die Passagierzahl wiederum ist durch die geringste Größe unter allen Medien
|
||||
; limitiert, womit hier ebenso eine min combination anzuwenden ist
|
||||
(defgeneric getPassagierzahl ((fz fahrzeug))
|
||||
:combination generic-min-combination)
|
||||
|
||||
; 2.3
|
||||
|
||||
; Implementation zur Abfrage des Mediums
|
||||
|
||||
(defclass fahrzeug ()
|
||||
:printer #t)
|
||||
(defclass landfahrzeug (fahrzeug)
|
||||
(check
|
||||
:reader landfahrzeug-check
|
||||
:initvalue #t
|
||||
)
|
||||
:printer #t)
|
||||
(defmethod getMedium ((fz landfahrzeug))
|
||||
'Land)
|
||||
|
||||
(defclass schienenfahrzeug (fahrzeug)
|
||||
:printer #t)
|
||||
(defmethod getMedium ((fz schienenfahrzeug))
|
||||
'Schiene)
|
||||
|
||||
(defclass straßenfahrzeug (fahrzeug)
|
||||
:printer #t)
|
||||
(defmethod getMedium ((fz straßenfahrzeug))
|
||||
'Straße)
|
||||
|
||||
(defclass wasserfahrzeug (fahrzeug))
|
||||
(defmethod getMedium ((fz wasserfahrzeug))
|
||||
'Wasser)
|
||||
|
||||
(defclass luftfahrzeug (fahrzeug))
|
||||
(defmethod getMedium ((fz luftfahrzeug))
|
||||
'Luft)
|
||||
|
||||
(defclass amphibienfahrzeug (wasserfahrzeug landfahrzeug))
|
||||
(defclass amphibienflugzeug (luftfahrzeug wasserfahrzeug straßenfahrzeug))
|
||||
(defclass zweiwegefahrzeug (schienenfahrzeug straßenfahrzeug))
|
||||
(defclass zeitzug (schienenfahrzeug luftfahrzeug))
|
||||
|
||||
; Die Funktion getMedium wird bei ampFahrzeug zunächst für
|
||||
; Wasserfahrzeuge aufgerufen, da nach der Klassenpräzedenz-
|
||||
; liste Wasserfahrzeug vor Landfahrzeug kommt.
|
||||
; Anschließend wird die Funktion für Landfahrzeuge aufgerufen.
|
||||
|
||||
; Da die generische Funktion getMedium mit der list combination
|
||||
; verwendet wird, werden die Ausgaben der einzelnen Funktionsaufrufe
|
||||
; in eine Liste kombiniert und zurückgegeben. Das wären in diesem
|
||||
; Fall also 'Wasser und 'Land, die insgesamte Rückgabe sieht dann
|
||||
; so aus: '(Wasser Land)
|
||||
; Da Fahrzeug die generische Funktion nicht implementiert,
|
||||
; bleibt es bei den beiden Funktionsaufrufen.
|
||||
|
||||
; Bei ampFlugzeug funktioniert es analog und es wird
|
||||
; '(Luft Wasser Straße) zurückgegeben.
|
||||
|
||||
; Bei schienenbus verhält es sich analog und die Rückgabe
|
||||
; ist '(Schiene Straße).
|
||||
|
||||
; Für zug wird '(Schiene Luft) zurückgegeben.
|
||||
|
||||
; Die Klassenpräzedenzliste ist hier unerlässlich, um die Reihenfolge
|
||||
; der Funktionen zu bestimmen. Wenn die combination der jeweiligen
|
||||
; generischen Funktion nur ein Ergebnis zurückgibt (bspw. begin combination),
|
||||
; dann bestimmt die Liste auch das Ergebnis.
|
||||
; Ohne eine combination wird auch nur die Funktion ausgeführt,
|
||||
; deren zugehörige Klasse in der Präzendenzliste ganz vorne steht.
|
||||
|
||||
(define ampFahrzeug (make amphibienfahrzeug))
|
||||
(define ampFlugzeug (make amphibienflugzeug))
|
||||
(define schienenbus (make zweiwegefahrzeug))
|
||||
(define zug (make zeitzug))
|
||||
248
se3/G08_B10_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
248
se3/G08_B10_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
@ -0,0 +1,248 @@
|
||||
#lang lazy
|
||||
|
||||
#|
|
||||
SE 3 Funktional Blatt 10
|
||||
Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
|#
|
||||
|
||||
; 1)
|
||||
|
||||
; 1.1
|
||||
(define (every pred xs)
|
||||
(foldl (λ (x best) (and x best))
|
||||
#t
|
||||
(map pred xs))
|
||||
)
|
||||
|
||||
(define (some pred xs)
|
||||
(foldl (λ (x best)
|
||||
(if [pred x]
|
||||
x
|
||||
best))
|
||||
#f
|
||||
xs)
|
||||
)
|
||||
|
||||
; 1.2
|
||||
(define (symmetrisch? r)
|
||||
(every (λ (x)
|
||||
(some (λ (y)
|
||||
(and (eq? (cdr y)
|
||||
(car x))
|
||||
(eq? (car y)
|
||||
(cdr x))))
|
||||
r))
|
||||
r))
|
||||
|
||||
(define (asymmetrisch? r)
|
||||
(every (λ (x)
|
||||
(let ((t1 (some (λ (y)
|
||||
(and (eq? (cdr y)
|
||||
(car x))
|
||||
(eq? (car y)
|
||||
(cdr x)))
|
||||
))))
|
||||
r))))
|
||||
|
||||
(define (reflexiv? r)
|
||||
(every (λ (x)
|
||||
(and (some (λ (y)
|
||||
(and (eq? (car y)
|
||||
(car x))
|
||||
(eq? (cdr y)
|
||||
(car x))))
|
||||
r)
|
||||
(some (λ (y)
|
||||
(and (eq? (car y)
|
||||
(cdr x))
|
||||
(eq? (cdr y)
|
||||
(cdr x))))
|
||||
r)))
|
||||
r))
|
||||
|
||||
(define (transitiv? r)
|
||||
(every (λ (x)
|
||||
(let ((t1 (some (λ (y)
|
||||
(and (eq? (cdr x)
|
||||
(car y))
|
||||
(not (eq? (cdr x)
|
||||
(cdr y)))))
|
||||
r)))
|
||||
(if t1
|
||||
(some (λ (z)
|
||||
(and (eq? (car x)
|
||||
(car z))
|
||||
(eq? (cdr t1)
|
||||
(cdr z))))
|
||||
r)
|
||||
#t)))
|
||||
r))
|
||||
|
||||
(define (aequi? r)
|
||||
(and (reflexiv? r)
|
||||
(symmetrisch? r)
|
||||
(transitiv? r)))
|
||||
|
||||
(define (ord? r)
|
||||
(and (reflexiv? r)
|
||||
(not (symmetrisch? r))
|
||||
(transitiv? r)))
|
||||
; 2)
|
||||
|
||||
; 1.
|
||||
(define (Kreuzprodukt m1 m2)
|
||||
(letrec ((inner (λ (x ys acc)
|
||||
(if (empty? ys)
|
||||
acc
|
||||
(inner x
|
||||
(cdr ys)
|
||||
(cons (list x
|
||||
(car ys))
|
||||
acc)))))
|
||||
(outer (λ (xs ys acc)
|
||||
(if (empty? xs)
|
||||
acc
|
||||
(outer (cdr xs)
|
||||
ys
|
||||
(inner (car xs)
|
||||
ys
|
||||
acc))))))
|
||||
(outer (reverse m1) (reverse m2) '())))
|
||||
|
||||
; 2.
|
||||
|
||||
;(define (Produkt xs)
|
||||
|
||||
; 3.
|
||||
; abhängig von k machen.
|
||||
(define (Kombination k M)
|
||||
(letrec ((inner (λ (x ys acc)
|
||||
(if (empty? ys)
|
||||
acc
|
||||
(inner x
|
||||
(cdr ys)
|
||||
(cons (list x (car ys))
|
||||
acc)))))
|
||||
(outer (λ (xs acc)
|
||||
(if (empty? xs)
|
||||
acc
|
||||
(outer (cdr xs)
|
||||
(inner (car xs)
|
||||
(cdr xs)
|
||||
acc))))))
|
||||
(reverse (outer M '()))))
|
||||
|
||||
|
||||
; 3)
|
||||
|
||||
; 1.
|
||||
|
||||
; (a) -> -1, weil 2-3 = -1 und -1 < 2 und -1 >= -1
|
||||
; (b) -> '(+ -2 2), weil quasi-quote und (- 2 4) dennoch ausgeführt wird (wg. ,)
|
||||
; (c) -> Alle, weil Alle erstes Element der Liste
|
||||
; (d) -> '(auf (dem See))
|
||||
; (e) -> '(Listen sind einfach)
|
||||
; (f) -> '(Paare . auch)
|
||||
; (g) -> #t, da beide Listen gleiche Werte haben
|
||||
; (h) -> #f, da die beiden Listen nicht identisch sind
|
||||
; (i) -> '(1 8 27)
|
||||
; (j) -> '(1 3 5)
|
||||
; (k) -> 2, da 2 < 6
|
||||
; (l) -> #t, da 2 = 2
|
||||
|
||||
; 2.
|
||||
|
||||
; *a* hat ein wohldefinierten Wert und evaluiert zu 10
|
||||
; (+ *a* *b*) hat keinen wohldefinierten Wert
|
||||
; (+ (eval *a*) (eval *b*)) hat keinen wohldefinierten Wert
|
||||
; (and (> *a* 10) (> *b* 3)) hat wohldefinierten Wert und evaluiert zu #f
|
||||
; (or (> *a* 10) (/ *a* 0)) hat keinen wohldefinierten Wert
|
||||
; (+ 2 (merke 3)) hat keinen wohldefinierten Wert
|
||||
; (+ 2 ((merke 3))) hat einen wohldefinierten Wert und evaluiert zu 5
|
||||
; (test 4) hat keinen wohldefinierten Wert
|
||||
|
||||
; 3.
|
||||
; (a)
|
||||
(+ (* 3 4) (* 5 6))
|
||||
; (b)
|
||||
(define wurzel (λ (x) (sqrt (- 1 (sqr (sin x))))))
|
||||
|
||||
; 4.
|
||||
(define (c a b)
|
||||
(sqrt (+ (sqr a) (sqr b))))
|
||||
(define (mythan a)
|
||||
(/ (sin a)
|
||||
(sqrt (- 1 (sqr (sin a))))))
|
||||
|
||||
; 5.
|
||||
; (a)
|
||||
(- (+ 1 (/ 4 2)) 1)
|
||||
; (b)
|
||||
(/ (- 2 (/ (+ 1 3) (+ 3 (* 2 3)))) (sqrt 3))
|
||||
|
||||
; 6.
|
||||
; (1 + 2 + 3) * (2 - 3 - (2 - 1))
|
||||
|
||||
; 7.
|
||||
(define (laengen xss)
|
||||
(map length xss))
|
||||
|
||||
(define (laengenRekEnd xss)
|
||||
(letrec ((rec (λ (xs acc)
|
||||
(if (empty? xs)
|
||||
acc
|
||||
(rec (cdr xs)
|
||||
(cons (length (car xs))
|
||||
acc))))))
|
||||
(reverse (rec xss '()))))
|
||||
|
||||
(define (laengenRekNorm xss)
|
||||
(if (empty? xss)
|
||||
'()
|
||||
(cons (length (car xss))
|
||||
(laengenRekNorm (cdr xss)))))
|
||||
|
||||
|
||||
; 8.
|
||||
; (a)
|
||||
(define (make-length value unit)
|
||||
(list value unit))
|
||||
; (b)
|
||||
(define (value-of-length len)
|
||||
(car len))
|
||||
(define (unit-of-length len)
|
||||
(cadr len))
|
||||
; (c)
|
||||
(define (scale-length len fac)
|
||||
(list (* (car len) fac) (cadr len)))
|
||||
; (d)
|
||||
(define *conversiontable* ;
|
||||
'( ; (unit . factor)
|
||||
(m . 1)
|
||||
(cm . 0.01)
|
||||
(mm . 0.001)
|
||||
(km . 1000)
|
||||
(inch . 0.0254)
|
||||
(feet . 0.3048)
|
||||
(yard . 0.9144)))
|
||||
(define (factor unit)
|
||||
(cdr (assoc unit *conversiontable*)))
|
||||
(define (length->meter len)
|
||||
(list (car (scale-length len (factor (cadr len))))
|
||||
'm))
|
||||
(define (length< len1 len2)
|
||||
(< (car (length->meter len1)) (car (length->meter len2))))
|
||||
(define (length= len1 len2)
|
||||
(= (car (length->meter len1)) (car (length->meter len2))))
|
||||
(define (length+ len1 len2)
|
||||
(list (+ (car (length->meter len1)) (car (length->meter len2)))
|
||||
'm))
|
||||
(define (length- len1 len2)
|
||||
(list (- (car (length->meter len1)) (car (length->meter len2)))
|
||||
'm))
|
||||
; (e)
|
||||
(define xs '((6 km) (2 feet) (1 cm) (3 inch)))
|
||||
|
||||
(map length->meter xs)
|
||||
(filter (λ (x) (< (car x) 1)) (map length->meter xs))
|
||||
(foldl (λ (x best) (+ (car x) best)) 0 (map length->meter xs))
|
||||
95
se3/G08_B11_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
95
se3/G08_B11_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
@ -0,0 +1,95 @@
|
||||
#lang lazy
|
||||
|
||||
#|
|
||||
SE 3 Funktional Blatt 11
|
||||
Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
|#
|
||||
|
||||
(require (lib "prologDB.ss" "se3-bib" "prolog")
|
||||
(lib "unify.ss" "se3-bib" "prolog")
|
||||
(lib "prolog.ss" "se3-bib" "prolog")
|
||||
(lib "prologInScheme.ss" "se3-bib" "prolog"))
|
||||
(require racket/stream)
|
||||
|
||||
; 1)
|
||||
|
||||
; 1.1
|
||||
|
||||
; Ausdruck1 | Variablenbindungen:
|
||||
; Ausdruck2
|
||||
|
||||
; (gebaeude ?Haus weiss) | '((?Farbe . weiss) (?Haus . Informatikum))
|
||||
; (gebaeude Informatikum ?Farbe)
|
||||
|
||||
; (Karten ((k Pik As) (k Herz Dame))) | #f
|
||||
; (Karten ((k Pik As) (k Herz Koenig)))
|
||||
|
||||
; (Karten ((k Pik As) (k Herz Dame))) | '((?Farbe . Dame))
|
||||
; (Karten ((k Pik As) (k Herz ?Farbe)))
|
||||
|
||||
; (Karten ((k Pik As) (k Herz Dame))) | '((?Farbe . Dame))
|
||||
; (Karten ((k Pik As) (k Herz ?Farbe)))
|
||||
|
||||
; (Karten ((k Pik As) . ?andere)) | '((?andere (k Herz Koenig) (k Kreuz Dame)))
|
||||
; (Karten ((k Pik As) (k Herz Koenig) (k Kreuz Dame)))
|
||||
|
||||
; (Paar (k ?farbe As) (k Pik ?wert)) | '((?wert . As) (?farbe . Pik))
|
||||
; (Paar (k Pik ?wert) (k ?farbe As))
|
||||
|
||||
; (Paar (k ?farbe As) (k Pik ?wert2)) | '((?wert2 . As) (?wert . As) (?farbe . Pik))
|
||||
; (Paar (k Pik ?wert) (k ?farbe ?wert))
|
||||
|
||||
; 1.2
|
||||
(<- (ausleihe "K 110" 100))
|
||||
(<- (ausleihe "P 30" 102))
|
||||
(<- (ausleihe "P 32" 104))
|
||||
(<- (ausleihe "P 50" 104))
|
||||
; (vorbestellung Signatur Lesernummer)
|
||||
(<- (vorbestellung "K 110" 104))
|
||||
(<- (vorbestellung "K 110" 102))
|
||||
(<- (vorbestellung "P 30" 100))
|
||||
(<- (vorbestellung "P 30" 104))
|
||||
; (leser Name Vorname Lesernummer Geburtsjahr)
|
||||
(<- (leser Neugierig Nena 100 1989))
|
||||
(<- (leser Linux Leo 102 1990))
|
||||
(<- (leser Luator Eva 104 1988))
|
||||
|
||||
; 1.
|
||||
; Im interactions view laufen alle Abfragen. Einige jedoch laufen nicht hier.
|
||||
|
||||
|
||||
;(?- (ausleihe "K 110" ?))
|
||||
|
||||
; 2.
|
||||
;(?- (leser Linux Leo ?lesernummer ?))
|
||||
|
||||
; 3.
|
||||
;(?- (vorbestellung "P 30" ?lesernummer)
|
||||
; (leser ?nachname ?vorname ?lesernummer ?))
|
||||
|
||||
; 4.
|
||||
;(?- (test (< ?jahr 1954))
|
||||
; (leser ?nachname ?vorname ?lesernummer ?geburtsjahr)
|
||||
; (ausleihe ? ?lesernummer))
|
||||
|
||||
; 5.
|
||||
;(?- (leser ?nachname ?vorname ?lesernummer ?)
|
||||
; (count ?c (ausleihe ? ?lesernummer))
|
||||
; (test (> ?c 1)))
|
||||
|
||||
; 2)
|
||||
|
||||
(define memo-fac (memo fac))
|
||||
|
||||
; 3)
|
||||
(define natNumb (in-naturals 1))
|
||||
(define evilSeven (stream-map (λ (x)
|
||||
(if (or
|
||||
(= [modulo x 7] 0)
|
||||
(pair? (member #\7
|
||||
(string->list (number->string x)))))
|
||||
'sum
|
||||
x))
|
||||
natNumb))
|
||||
|
||||
|
||||
72
se3/G08_B12_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
72
se3/G08_B12_Jim-2martens_Britta-2noack_Jan-Simon-0giesel.rkt
Normal file
@ -0,0 +1,72 @@
|
||||
#lang racket
|
||||
|
||||
#|
|
||||
SE 3 Funktional Blatt 12
|
||||
Abgebende: Jim 2martens, Britta 2noack, Jan-Simon 0giesel
|
||||
|#
|
||||
|
||||
; 1)
|
||||
|
||||
; 1.
|
||||
(define (wert-rec xs)
|
||||
(letrec ((rec (λ (ys potenz acc)
|
||||
(if (empty? ys)
|
||||
acc
|
||||
(rec
|
||||
(cdr ys)
|
||||
(+ 1 potenz)
|
||||
(+ (* (car ys) (expt 10 potenz)) acc))))))
|
||||
(rec xs 0 0)))
|
||||
; 2.
|
||||
(define (wert-higher xs)
|
||||
(foldl
|
||||
+
|
||||
0
|
||||
(map * xs
|
||||
(let ((l (length xs)))
|
||||
(letrec ((rec (λ (x acc)
|
||||
(if (= x 0) acc
|
||||
(rec (- x 1)
|
||||
(cons
|
||||
(expt 10 (- x 1))
|
||||
acc))))))
|
||||
(rec l '()))))
|
||||
))
|
||||
|
||||
; 2)
|
||||
|
||||
; 2.1
|
||||
(define kryptoStructure
|
||||
'((A . 1)
|
||||
(B . 2)
|
||||
(C . 3)
|
||||
(D . 4)
|
||||
(E . 5)
|
||||
(F . 6)
|
||||
(G . 7)
|
||||
(H . 8)
|
||||
(I . 9)
|
||||
(J . 10)
|
||||
(K . 11)
|
||||
(L . 12)
|
||||
(M . 13)
|
||||
(N . 14)
|
||||
(O . 15)
|
||||
(P . 16)
|
||||
(Q . 17)
|
||||
(R . 18)
|
||||
(S . 19)
|
||||
(T . 20)
|
||||
(U . 21)
|
||||
(V . 22)
|
||||
(W . 23)
|
||||
(X . 24)
|
||||
(Y . 25)
|
||||
(Z . 26)))
|
||||
|
||||
(define (key->wert key struktur)
|
||||
(cdr (assoc key struktur)))
|
||||
|
||||
; 2.2
|
||||
|
||||
(andmap (λ (x) #t) '(1 2 3))
|
||||
31
se3/probeklausur0809.rkt
Normal file
31
se3/probeklausur0809.rkt
Normal file
@ -0,0 +1,31 @@
|
||||
#lang swindle
|
||||
|
||||
(require swindle/setf
|
||||
swindle/misc)
|
||||
|
||||
; CLOS
|
||||
|
||||
(defclass* messgeraet ())
|
||||
(defgeneric* einheit ((messgeraet))
|
||||
:combination generic-append-combination)
|
||||
(defgeneric* messwert ((messgeraet))
|
||||
:combination generic-append-combination)
|
||||
(defgeneric* genauigkeit ((messgeraet))
|
||||
:combination generic-min-combination)
|
||||
|
||||
(defclass* thermometer (messgeraet))
|
||||
(defclass* barometer (messgeraet))
|
||||
(defclass* regenmesser (messgeraet))
|
||||
|
||||
(defclass* wetterstation (thermometer barometer regenmesser))
|
||||
|
||||
; Logik
|
||||
|
||||
(?- (kamera ?kamID ? ? 24 ?))
|
||||
(?- (kamera ?kamID ? ? 18 ?)
|
||||
(angebot ?kamID ? ?preis))
|
||||
(?- (anbieter ?anbID ?anbName ?lieferzeit ? ?)
|
||||
(test (<= ?lieferzeit 1))
|
||||
(angebot ?kamID ?anbID ?)
|
||||
(kamera ?kamID ?kameraname ?hersteller ? ?))
|
||||
|
||||
86
sonstiges/Spieleindustrie.tex
Normal file
86
sonstiges/Spieleindustrie.tex
Normal file
@ -0,0 +1,86 @@
|
||||
\documentclass{beamer}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
%\usepackage{paralist}
|
||||
\useoutertheme{infolines}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{listings}
|
||||
\usetheme{Berkeley}
|
||||
\pagenumbering{arabic}
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
\setbeamertemplate{navigation symbols}{}
|
||||
\graphicspath{ {src/} }
|
||||
\lstset{language=PHP}
|
||||
|
||||
\begin{document}
|
||||
\author{Jim Martens}
|
||||
\title{Verwandlung der Spieleindustrie}
|
||||
|
||||
\section{Wie es war}
|
||||
\begin{frame}{Wie es war}
|
||||
\begin{itemize}
|
||||
\item tolle Spiele(reihen), die teilweise noch immer gespielt werden
|
||||
\begin{itemize}
|
||||
\item<2-> Wing Commander
|
||||
\item<2-> Privateer
|
||||
\item<2-> Freelancer
|
||||
\item<3-> Independence War 2
|
||||
\item<4-> Ultima
|
||||
\item<4-> Baldurs Gate
|
||||
\item<4-> Neverwinter Nights
|
||||
\item<4-> Knights of the Old Republic
|
||||
\item<5-> Gothic (1-3)
|
||||
\item<5-> Morrowind, Oblivion, Nehrim (Total Conversion von Oblivion, fanmade)
|
||||
\end{itemize}
|
||||
\item<6-> viele kleine Studios mit motivierten Entwicklern (meistens selber leidenschaftliche Spieler)
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Wie es ist}
|
||||
\begin{frame}{Wie es ist}
|
||||
\begin{itemize}
|
||||
\item wenige große Studios mit vielen Entwicklern, für die es ein ganz normaler Beruf ist
|
||||
\item<2-> übermächtige Publisher (EA, Ubisoft, Microsoft, ...), für die allein der Profit zählt
|
||||
\item<3-> Spiele werden zu Gewinnbringern, der Inhalt gerät in den Hintergrund
|
||||
\item<4-> Release-Patches, Käufer sind eigentliche Betatester, vernachlässigte Qualitätskontrolle
|
||||
\item<5-> kurze Entwicklungszeiten
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Wie es sein sollte}
|
||||
\begin{frame}{Wie es sein sollte (allgemein)}
|
||||
\begin{itemize}
|
||||
\item ausreichende Betatests
|
||||
\item<2-> Entwickler, die ihr ganzes Herzblut in ein Spiel hineinstecken
|
||||
\item<3-> den Spielinhalt in den Mittelpunkt rücken, Gewinn ist Nebenprodukt
|
||||
\item<4-> keine Vercasualisierung
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Wie es sein sollte (für Spiele mit Story)}
|
||||
\begin{itemize}
|
||||
\item vor Erschaffung eines Spieles sollte ein glaubwürdiges Universum geschaffen werden
|
||||
\item<2-> dieses Universum enthält unterschiedliche Völker und deren Historie
|
||||
\item<3-> erst nach Schaffung eines Universums, das für sich alleine existieren kann, wird mit der Planung einer Spielereihe begonnen
|
||||
\item<4-> die Spielereihe fügt sich in das Universum ein, nicht umgekehrt
|
||||
\item<5-> Spiele dürfen keine Storys haben, die das Universum an sich beschädigen
|
||||
\item<6-> Ergebnis: ein Universum, dass nach einer Spielereihe nicht ausgelaugt ist
|
||||
\item<7-> Nachteil: es erfordert eine Menge an initialer Arbeit
|
||||
\item<7-> Vorteil: großes Potenzial unterschiedlichster Storys
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Schlussfolgerungen}
|
||||
\begin{itemize}
|
||||
\item Jene Spiele unterstützen, die eine reichhaltige Lore aufweisen
|
||||
\item Jene Spiele unterstützen, bei denen der Inhalt im Mittelpunkt steht
|
||||
\item Jene Spiele nicht unterstützen, die reine Abzocke sind
|
||||
\item Jene Spiele nicht unterstützen, die den Spieler zu einem Konsumenten degradieren
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\end{document}
|
||||
136
sonstiges/Wordpress-Vortrag.tex
Normal file
136
sonstiges/Wordpress-Vortrag.tex
Normal file
@ -0,0 +1,136 @@
|
||||
\documentclass{beamer}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[ngerman]{babel}
|
||||
%\usepackage{paralist}
|
||||
\useoutertheme{infolines}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{listings}
|
||||
\usetheme{Berkeley}
|
||||
\pagenumbering{arabic}
|
||||
\def\thesection{\arabic{section})}
|
||||
\def\thesubsection{\alph{subsection})}
|
||||
\def\thesubsubsection{(\roman{subsubsection})}
|
||||
\setbeamertemplate{navigation symbols}{}
|
||||
\graphicspath{ {src/} }
|
||||
\lstset{language=PHP}
|
||||
|
||||
\begin{document}
|
||||
\author{Jim Martens}
|
||||
\title{Warum sich ein eigenes CMS lohnt}
|
||||
|
||||
\section{Situation}
|
||||
\begin{frame}{Situation}
|
||||
\begin{itemize}
|
||||
\item Wordpress erhielt 2009 den Overall Best Open Source CMS Award
|
||||
\item 2010 folgte Hall of Fame CMS
|
||||
\item gilt als eines der beliebtesten CMS weltweit
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\centering
|
||||
Warum man dennoch ein eigenes CMS schreiben sollte?
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile]{Darum}
|
||||
aus wp-login.php Zeile 207 ff. (etwas HTML ausgelassen, gekennzeichnet durch Kommentar)
|
||||
\begin{lstlisting}
|
||||
function login_footer($input_id = '') {
|
||||
global $interim_login;
|
||||
if ( ! $interim_login ): ?>
|
||||
<p id="backtoblog"><!-- something --></p>
|
||||
<?php endif; ?>
|
||||
\end{lstlisting}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\centering
|
||||
Warum ist der gezeigte Code nicht so toll?
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Deswegen}
|
||||
\begin{itemize}
|
||||
\item \texttt{global} is Bad Practice
|
||||
\begin{itemize}
|
||||
\item stammt aus PHP 4 Zeiten
|
||||
\item nicht objektorientiert
|
||||
\end{itemize}
|
||||
\item keine Trennung zwischen Businesslogik und Ausgabe
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Verbesserung}
|
||||
\begin{frame}
|
||||
\centering
|
||||
Wie kann man es besser machen?
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{So kann man es besser machen}
|
||||
\begin{itemize}
|
||||
\item OOP-Framework wie Symfony 2 nutzen
|
||||
\begin{itemize}
|
||||
\item[$\rightarrow$] klare Trennung zwischen Businesslogik und Ausgabe
|
||||
\item[$\rightarrow$] Object-Relational Mapping (Doctrine)
|
||||
\item[$\rightarrow$] Templateengine (Twig)
|
||||
\item[$\rightarrow$] Dependency Management (Composer)
|
||||
\item[$\rightarrow$] einfache Konfigurierbarkeit
|
||||
\item[$\rightarrow$] Unterstützung für Unit- und Integrationstests (PHPUnit)
|
||||
\item[$\rightarrow$] hohe Code Coverage der Unittests
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Call for Action}
|
||||
\begin{frame}
|
||||
\centering
|
||||
Warum erzähle ich euch das eigentlich alles?
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Planung}
|
||||
\begin{itemize}
|
||||
\item habe bereits ein CMS auf Basis des WoltLab Community Framework (WCF) entwickelt
|
||||
\item das wird vsl. Januar/Februar RC-Status erreichen (Betaseite: beta.plugins-zum-selberbauen.de)
|
||||
\item nächstes Projekt: WCF-Funktionen mit Symfony mergen
|
||||
\begin{itemize}
|
||||
\item ACP, Paketsystem, einfache Installation
|
||||
\item Mehrsprachigkeit, User und Benutzergruppen
|
||||
\item flexibles Stilsystem, Event Listener
|
||||
\end{itemize}
|
||||
\item und dann, ja dann: CMS mit Symfony und WCF-Erweiterungen
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\centering
|
||||
Warum interessiert euch das?
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Anforderungsprofil}
|
||||
\begin{itemize}
|
||||
\item praktische Erfahrung sammeln mit OOP-Entwicklung
|
||||
\item Voraussetzungen: PHP-Kenntnis (>= 5.3), OOP-Kenntnis, Bereitschaft sich einzuarbeiten, Coding-Standards einhalten
|
||||
\item Git als VCS (github.com/frmwrk123/symfony-wcf)
|
||||
\item Lizenz: LGPL
|
||||
\item keine Zeitvorgabe - it's done when it's done
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Fertig}
|
||||
\begin{frame}{Ich habe fertig}
|
||||
\centering
|
||||
Vielen Dank für Eure Aufmerksamkeit!
|
||||
\end{frame}
|
||||
|
||||
|
||||
\section{Quellen}
|
||||
\begin{frame}{Quellen}
|
||||
\begin{itemize}
|
||||
\item http://webdesign.about.com/b/2010/11/22/wordpress-wins-best-cms-award.html
|
||||
\item http://wordpress.org/news/2009/11/wordpress-wins-cms-award/
|
||||
\item http://symfony.com/doc/master
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\end{document}
|
||||
Reference in New Issue
Block a user