aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2020-11-07 03:26:40 +0300
committerYigit Sever2020-11-07 03:26:40 +0300
commit5ec601c489f943c45d7df967e9d5f1490a0db62a (patch)
tree2c2993982c298f64c99d3e443272d1df5707d3b8
parentc36174beb18a6afe2d7ccb8b6dd2803bd898a1a2 (diff)
downloadhw1-5ec601c489f943c45d7df967e9d5f1490a0db62a.tar.gz
hw1-5ec601c489f943c45d7df967e9d5f1490a0db62a.tar.bz2
hw1-5ec601c489f943c45d7df967e9d5f1490a0db62a.zip
Added answer 1.e fully
-rw-r--r--main.tex137
-rw-r--r--structure.tex32
2 files changed, 161 insertions, 8 deletions
diff --git a/main.tex b/main.tex
index 0fa91ec..3778cd4 100644
--- a/main.tex
+++ b/main.tex
@@ -1,4 +1,4 @@
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2% Lachaise Assignment 2% Lachaise Assignment
3% LaTeX Template 3% LaTeX Template
4% Version 1.0 (26/6/2018) 4% Version 1.0 (26/6/2018)
@@ -158,26 +158,147 @@ The algorithm in this instance runs in $\mathcal{O}(n)$ iterations, every propos
158 158
159% 1}}} % 159% 1}}} %
160 160
161% question e TODO {{{1 % 161% question e {{{1 %
162 162
163\begin{question} 163\begin{question}
164 Give another instance for which the algorithm requires $\Omega(n^{2})$ iterations (that is, it requires at least $cn^{2}$ iterations for some constant $0 < c \le 1)$, and prove this fact. 164 Give another instance for which the algorithm requires $\Omega(n^{2})$ iterations (that is, it requires at least $cn^{2}$ iterations for some constant $0 < c \le 1)$, and prove this fact.
165\end{question} 165\end{question}
166 166
167Arrange the preference lists such as every student arranges their preference \emph{exactly the same}; 167\begin{infor}
168 We have collaborated with CENG567 student Manolya Atalay for this question and used the answers and explanations given in the linked Mathematics Stack Exchange question\footnote{\url{https://math.stackexchange.com/questions/1410898/worst-case-for-the-stable-marriage-problem}}.
169\end{infor}
170
171The worst problem instance for the algorithm (the instance that requires the largest number of steps) can be inferred as follows;
172
173The highest number of times a man $m$ can \emph{propose} (every iteration has one proposal in it) to $n$ many women is $n-1$. It cannot be $n$ because it would mean that $m$ did not find a suitable partner (rejected by everyone), which is contradictory with the algorithm's perfect matching guarantee.
174
175For $n$ men, in the worst case, each one can propose $n-1$ times; $n(n-1)$. One man has to propose one last time after getting rejected by $n-1$ women, giving the total number of proposals;
176
177\begin{equation}
178 n (n-1) + 1
179\end{equation}
180
181As the theoretical highest number of iterations \emph{Gale-Shapley} can have.
182
183As for the instance that produces this run time;
184
185Men have to arrange their preference list as follows for $n>2$.
168 186
169\begin{equation} 187\begin{equation}
170 \label{eq:student_prefs_2} 188 M_{k} \rightarrow
171 C_1, C_2, \dots, C_{n} 189 \begin{cases}
190 W_{k}, W_{k+1}, \dots, W_{n-1}, W_{1}, W_{2}, \dots, W_{n} &\mbox{if } k \ne n \\
191 W_{k-1}, W_{k}, \dots, W_{n-1}, W_{1}, W_{2}, \dots, W_{n} &\mbox{if } k = n \\
192 \end{cases}
172\end{equation} 193\end{equation}
173 194
174Whereas every college should arrange their preference list as; 195In other words, the \emph{last} man's preference list is identical to one above them.
196
197Women have to arrange their preference list as follows for $n>2$;
175 198
176\begin{equation} 199\begin{equation}
177 \label{eq:college_prefs_2} 200 W_{k} \rightarrow
178 S_n, S_{n-1}, S_{n-2}, \dots, S_{1} 201 \begin{cases}
202 M_{k+1}, M_{k}, \dots &\mbox{if } k \ne n-1 \\
203 M_{1}, M_{n}, \dots &\mbox{if } k = n-1 \\
204 \end{cases}
179\end{equation} 205\end{equation}
180 206
207The preference list of the last women $W_{n}$ does not matter neither does the order of the rest of the men in the preference list of the women given.
208
209We have implemented \emph{Gale-Shapley} and an instance set creation script to test our findings;
210
211\begin{commandline}[n=3]
212 \begin{verbatim}
213 n: Men Preference Table
214 A | 1 2 3
215 B | 2 1 3
216 C | 2 1 3
217 ----
218 Women Preference Table
219 1| B A C
220 2| A C B
221 3| A B C
222 ----
223 Matching B with 2 (a)
224 Matching C with 2, B is now free (b)
225 Matching A with 1 (a)
226 Matching B with 1, A is now free (b)
227 Matching A with 2, C is now free (b)
228 C is rejected by 1 because B is more preffered (c)
229 Matching C with 3 (a)
230 Final pairings:
231 A - 2
232 B - 1
233 C - 3
234
235 A proposed 2 times
236 B proposed 2 times
237 C proposed 3 times
238 total of 7 times with n(n-1) + 1 = 7
239 \end{verbatim}
240\end{commandline}
241
242\begin{commandline}[n=6]
243 \begin{verbatim}
244 n: Men Preference Table
245 A | 1 2 3 4 5 6
246 B | 2 3 4 5 1 6
247 C | 3 4 5 1 2 6
248 D | 4 5 1 2 3 6
249 E | 5 1 2 3 4 6
250 F | 5 1 2 3 4 6
251 ----
252 Women Preference Table
253 1| B A C D E F
254 2| C B A D E F
255 3| D C A B E F
256 4| E D A B C F
257 5| A F B C D E
258 6| A B C D E F
259 ----
260 Matching D with 4 (a)
261 Matching A with 1 (a)
262 Matching F with 5 (a)
263 E is rejected by 5 because F is more preffered (c)
264 Matching C with 3 (a)
265 Matching B with 2 (a)
266 // --- edited out for space ---
267 C is rejected by 1 because A is more preffered (c)
268 Matching C with 2, B is now free (b)
269 B is rejected by 3 because D is more preffered (c)
270 B is rejected by 4 because E is more preffered (c)
271 B is rejected by 5 because F is more preffered (c)
272 Matching B with 1, A is now free (b)
273 A is rejected by 2 because C is more preffered (c)
274 A is rejected by 3 because D is more preffered (c)
275 A is rejected by 4 because E is more preffered (c)
276 Matching A with 5, F is now free (b)
277 F is rejected by 1 because B is more preffered (c)
278 F is rejected by 2 because C is more preffered (c)
279 F is rejected by 3 because D is more preffered (c)
280 F is rejected by 4 because E is more preffered (c)
281 Matching F with 6 (a)
282 Final pairings:
283 E - 4
284 B - 1
285 A - 5
286 D - 3
287 C - 2
288 F - 6
289
290 A proposed 5 times
291 B proposed 5 times
292 C proposed 5 times
293 D proposed 5 times
294 E proposed 5 times
295 F proposed 6 times
296 total of 31 times with n(n-1) + 1 = 31
297 \end{verbatim}
298\end{commandline}
299
300
301
181% 1}}} % 302% 1}}} %
182 303
183\section{Stable Matching Variation}% 304\section{Stable Matching Variation}%
diff --git a/structure.tex b/structure.tex
index ae1765b..5f53a93 100644
--- a/structure.tex
+++ b/structure.tex
@@ -23,6 +23,8 @@
23\usepackage[T1]{fontenc} % Output font encoding for international characters 23\usepackage[T1]{fontenc} % Output font encoding for international characters
24\usepackage{csquotes} 24\usepackage{csquotes}
25\usepackage{amsmath,amsfonts} % Math packages 25\usepackage{amsmath,amsfonts} % Math packages
26\usepackage{url}
27\usepackage{hyperref}
26\usepackage{enumerate} % Custom item numbers for enumerations 28\usepackage{enumerate} % Custom item numbers for enumerations
27\usepackage[ruled]{algorithm2e} % Algorithms 29\usepackage[ruled]{algorithm2e} % Algorithms
28\usepackage[makeroom]{cancel} 30\usepackage[makeroom]{cancel}
@@ -223,3 +225,33 @@
223}{ 225}{
224 \end{mdframed} 226 \end{mdframed}
225} 227}
228
229%----------------------------------------------------------------------------------------
230% NOT FUCKED UP INFORMATION ENVIRONMENT
231%----------------------------------------------------------------------------------------
232
233
234% Usage:
235% \begin{info}[optional title, defaults to "Info:"]
236% contents
237% \end{info}
238
239\mdfdefinestyle{infor}{%
240 topline=false, bottomline=false,
241 leftline=false, rightline=false,
242 nobreak,
243 singleextra={%
244 \fill[black](P-|O)circle[radius=0.4em];
245 \node at(P-|O){\color{white}\scriptsize\bf i};
246 \draw[very thick](P-|O)++(0,-0.8em)--(O);%--(O-|P);
247 }
248}
249
250% Define a custom environment for information
251\newenvironment{infor}[1][Disclaimer:]{ %
252 \medskip
253 \begin{mdframed}[style=infor]
254 \noindent{\textbf{#1}}
255}{
256 \end{mdframed}
257}