201 lines
9.3 KiB
TeX
201 lines
9.3 KiB
TeX
\twocolumn[
|
|
\title{\bf \acronym (High end, Advanced, Data driven, Enterprise grade Sock sorting algorithm) - An algorithm for faster sock sorting}
|
|
\author{
|
|
CelloClemens$^{1,2}$,
|
|
Henri\emoji{duck}$^{1}$,
|
|
}
|
|
\date{\today}
|
|
% List of institutions
|
|
\maketitle
|
|
$^{1}$Department for theoretical laundry science, Karlsruhe institute of suffering and sorrow (KISS), Karlsruhe, Germany \\
|
|
$^{2}$Institute of laundry sorting, Department for socks, Karlsruhe institute of suffering and sorrow (KISS), Karlsruhe, Germany
|
|
\begin{psummary}
|
|
Sorting socks can often be a time consuming task. This paper introduces the fastest method known in the scientific community to tackle
|
|
this challanging task. To be able to implement this new algorithm
|
|
a new datastructure will be introduced and discussed. Abundant application of this novel algorithm may be able to
|
|
reduce the time required for sorting socks considerably.
|
|
\end{psummary}
|
|
\vspace{2mm}
|
|
]
|
|
\fancypagestyle{firstpage}{%
|
|
\lhead{Please help I am stuck in the basement sorting socks}
|
|
\rhead{Journal of Immaterial Science}
|
|
}
|
|
\thispagestyle{firstpage}
|
|
|
|
% The introduction
|
|
\section{Introduction}
|
|
While sorting algorithms are one of the most discussed algorithms in the
|
|
computer science community, application of this field to laundry is still quite new.
|
|
In fact no research is known to the authors connecting the fields of computer science
|
|
and laundry sorting. A few definitions are required in order to establish a baseline
|
|
for the algorithm discussed in the following paper.
|
|
|
|
\subsection{Definitions}
|
|
In this section a few definitions, common in the field of theoretical laundry science shall be
|
|
introduced. These are required to understand the algorithm and its advantages.
|
|
|
|
\subsubsection{Sock}
|
|
Let $\Lambda_a$ be the Set of laundry. The set of socks, $\Sigma\subset\Lambda_a$
|
|
is defined as $\Sigma:=\{s\in\Lambda_a|\chi(s)=1\}$\footnote{Yes, some socks have holes. So what?!}, where $\chi(s)$ is the Euler
|
|
characteristic of $s$. For every sock $s$ there is an equal counterpart $s^{-1}$ giving rise
|
|
to the identity $s\cong s^{-1}$. The task commonly known as "sock sorting" is in fact the
|
|
search for this isomorphism $\eta$ and matching every sock $s$ to its inverse
|
|
$s^{-1}$.
|
|
\begin{figure}[h]
|
|
\centering
|
|
\includegraphics[width=\columnwidth]{\projectpath figs/Sock.jpeg}
|
|
\vspace{0.1in}
|
|
\caption{A pair of blue socks and a single orange sock.}
|
|
\label{fig:Sock}
|
|
\vspace{0.1in}
|
|
\end{figure}
|
|
\subsubsection{Laundry basket}
|
|
Let $\Lambda\subseteq\Lambda_a$ be a set of laundry items. Then a laundry basket is a
|
|
triplet $(\Lambda, +, -)$ representing a datastructure that implements
|
|
the following functions:
|
|
\begin{itemize}
|
|
\item \texttt{get: }$\mathscr{L}\in\Lambda_a$, returns a uniformly random
|
|
laundry item from the basket or $\mathscr{L}_0$, the Zero element of laundry, iff
|
|
There are no items left.
|
|
\item \texttt{put($\mathscr{L}\in\Lambda_a$)}, deposits the given laundry item
|
|
into the basket.
|
|
\end{itemize}
|
|
Note that both operations run in $\mathcal{O}(1)$. Because of the nature of
|
|
a laundry basket finding a unique item requires transferring the content of
|
|
the whole basket to a new basket thus requiring $\mathcal{O}(n)$ operations,
|
|
$n$ being the number of items currently inside the basket.
|
|
\subsection{Ongoing and latest research}
|
|
To fully appreciate the gravity of \acronym it has to first be discussed
|
|
how most resent research tackles the problem of sock sorting.
|
|
The following code describes the most recently developed sock sorting
|
|
algorithm from the paper by my colleague which is the current
|
|
industry standard. Notice the code has a runtime complexity of $\mathcal{O}(n^2)$.
|
|
|
|
\begin{algorithm}
|
|
\caption{Conventional sock sorting}
|
|
\begin{algorithmic}[1]
|
|
\State\Comment initialize a new laundry basket with a given set of laundry
|
|
\State $A\gets\Lambda$\Comment WLOG assume $\forall\mathscr{L}\in\Lambda|\mathscr{L}$ is a sock
|
|
\State $\text{matches}\gets []$
|
|
\Repeat
|
|
\State $\mathscr{L}\gets$ A.get
|
|
|
|
\Repeat\Comment find the inverse Sock by checking all other socks
|
|
\State $\mathscr{L}^\prime\gets$ A.get
|
|
\Until{$\mathscr{L}^\prime =\mathscr{L}^{-1}$}
|
|
\State matches.append(($\mathscr{L}, \mathscr{L}^\prime$))
|
|
\Until{$\mathscr{L}\ne\mathscr{L}_0$}
|
|
\end{algorithmic}
|
|
\end{algorithm}
|
|
|
|
\section{Concepts}
|
|
The basis for every fast algorithm are simple yet equally fast
|
|
datastructures. To enable the low runtime achieved by \acronym,
|
|
the introduction of a new datastructure, the "laundry rack" is integral.
|
|
|
|
\subsection{Laundry rack}
|
|
Let $\Lambda\subseteq\Lambda_a$ be a set of laundry. A laundry rack (See figure \ref{fig:Rack}) is a
|
|
triplet $(\Lambda, +, -)$ representing a datastructure that implements the
|
|
following methods:
|
|
\begin{itemize}
|
|
\item \texttt{get($\mathscr{L}\in\Lambda$)}: $\mathscr{L}\in\Lambda$, gets
|
|
a specific laundry item from the laundry rack.
|
|
\item \texttt{put($\mathscr{L}\in\Lambda$)}, deposits a laundry item onto
|
|
the laundry rack.
|
|
\item \texttt{match($\mathscr{L}\in\Lambda$)}: $(\mathscr{P}\in\Lambda\times\Lambda)|\mathscr{L}_0$,
|
|
returns a tuple $(\mathscr{L}, \mathscr{L}^{-1})$ representing
|
|
a pair of socks iff $\mathscr{L}^{-1}$ is already on the laundry rack,
|
|
$\mathscr{L}_0$ otherwise.
|
|
\end{itemize}
|
|
All these operations (especially \texttt{match}) run in $\mathcal{O}(1)$,
|
|
making iteration over all $n$ laundry items to find a pair $(\mathscr{L}, \mathscr{L}^{-1})$
|
|
obsolete.
|
|
\begin{figure}[h]
|
|
\centering
|
|
\includegraphics[width=\columnwidth]{\projectpath figs/rack.jpeg}
|
|
\vspace{0.1in}
|
|
\caption{A blue drying rack, found in many housholds.}
|
|
\label{fig:Rack}
|
|
\vspace{0.2in}
|
|
\end{figure}
|
|
|
|
\section{Algorithm}
|
|
Making use of the novel advanced features of a "drying rack" we are able to
|
|
implement the following algorithm in $\mathscr{O}(n)$:\\
|
|
\begin{algorithm}
|
|
\caption{\acronym}
|
|
\begin{algorithmic}[1]
|
|
\State\Comment initialize a new laundry basket with a given set of laundry
|
|
\State $A\gets\Lambda$\Comment WLOG assume $\forall\mathscr{L}\in\Lambda|\mathscr{L}$ is a sock
|
|
\State $\text{matches}\gets []$
|
|
\State $\daleth\gets []$ \Comment{Create a new empty drying rack}
|
|
\Repeat
|
|
\State $\mathscr{L}\gets $ A.get
|
|
\State result $\gets$ $\daleth$.match($\mathscr{L}$)
|
|
\If{result $\ne\mathscr{L}_0$}
|
|
\State matches.append(result)
|
|
\Else
|
|
\State $\daleth$.put($\mathscr{L}$)
|
|
\EndIf
|
|
|
|
\Until{$\mathscr{L}\ne\mathscr{L}_0$}
|
|
\end{algorithmic}
|
|
\end{algorithm}
|
|
As evident from the algorithm above, only one loop performing
|
|
operations which are all in $\mathscr{O}(1)$ is required thus
|
|
putting the algorithm in a $\mathscr{O}(n)$ runtime complexity
|
|
class. Assuming that $\forall\mathscr{L}\in\Lambda\exists\mathscr{L}^{-1}|\mathscr{L}\cong\mathscr{L}^{-1}$
|
|
the algorithm always yields a correct solution for the problem
|
|
(proof is left as an exercise to the reader).
|
|
\section{Discussion and Results}
|
|
To evaluate the algorithms performance it has been executed
|
|
on different platforms consisting of diverse hardware:\\
|
|
\resizebox*{\linewidth}{!}{
|
|
\begin{tabular}[]{l||l|c}
|
|
\textbf{Hardware} & \textbf{Algorithm} & \textbf{Runtime [s]} \\
|
|
\hline
|
|
Myself & Conventional (n=20) & 352.7 \\
|
|
Myself & \acronym (n=20) & 92.3 \\
|
|
Myself & Conventional (n=100) & 42069 \\
|
|
Myself & \acronym (n=100) & 420.69 \\
|
|
\hline
|
|
My roommate & Conventional (n=10) & 91.7 \\
|
|
My roommate & \acronym (n=10) & -2 \\
|
|
\hline
|
|
Girlfriend & n.a. & n.a.
|
|
\end{tabular}
|
|
}\\
|
|
\begin{figure}[h]
|
|
\begin{center}
|
|
\includegraphics[width=\linewidth]{figs/graph.png}
|
|
\bigskip
|
|
\caption{Comparative statistical time analysis of both algorithms.
|
|
The graph depicts algorithm runtime (y-axis) and graphs it against
|
|
input size (x-axis). Data for
|
|
\acronym in blue, for conventional sock sorting in green.}
|
|
\end{center}
|
|
\end{figure}\\
|
|
From the above data it is evident that \acronym bears a clear advantage in comparison
|
|
to the conventional algorithm when it comes to sock sorting. Utilizing advanced statistical modelling we calculated a
|
|
speedup factor of about $3.1415926535897932384626433\cdot n$. The data also illustrates
|
|
the scalability of the algorithm and its adaptability to different hardware.
|
|
\section{Conclusion}
|
|
It can be concluded that the algorithm presented in this paper is
|
|
greatly superior to the conventional method of sorting socks.
|
|
It will probably revolutionize not only the field of laundry science but
|
|
also have great impact in the industry.\\
|
|
The datastructures outlined above may become abundantly used and be the future
|
|
industry standard. Although the field of laundry science is still rather new
|
|
there are still a lot of open questions to be answered. However it is unlikely
|
|
that a faster sock sorting algorithm than \acronym can be developed.
|
|
\section{Acknowledgements}
|
|
We shall use this historic opportunity to thank the Journal of immaterial science
|
|
for publishing great \st{memes} research. We also want to thank our university
|
|
for giving us this great opportunity for \st{depression and self loathing}
|
|
research and personal advancement.\\
|
|
It is also only appropriate to thank the air. Without it no laundry would be
|
|
dry and we would not have written this paper.\\
|
|
|
|
|
|
\printbibliography[]
|