Compare commits
3 commits
06b9500efc
...
8921d8c5df
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8921d8c5df | ||
|
|
bcfbec57ba | ||
|
|
dcda7297e0 |
2 changed files with 97 additions and 7 deletions
|
|
@ -110,9 +110,44 @@ Our goal is to study the number of bins $ H_n $ required to store $ n $ items
|
|||
for each algorithm. We first consider the Next Fit Bin Packing algorithm, where
|
||||
we store each item in the next bin if it fits, otherwise we open a new bin.
|
||||
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
\begin{tikzpicture}[scale=0.8]
|
||||
% Bins
|
||||
\draw[thick] (0,0) rectangle (2,6);
|
||||
\draw[thick] (3,0) rectangle (5,6);
|
||||
\draw[thick] (6,0) rectangle (8,6);
|
||||
|
||||
% Items
|
||||
\draw[fill=red] (0.5,0.5) rectangle (1.5,3.25);
|
||||
\draw[fill=blue] (0.5,3.5) rectangle (1.5,5.5);
|
||||
\draw[fill=green] (3.5,0.5) rectangle (4.5,1.5);
|
||||
\draw[fill=orange] (3.5,1.75) rectangle (4.5,3.75);
|
||||
\draw[fill=purple] (6.5,0.5) rectangle (7.5,2.75);
|
||||
\draw[fill=yellow] (6.5,3) rectangle (7.5,4);
|
||||
|
||||
% arrow
|
||||
\draw[->, thick] (8.6,3.5) -- (7.0,3.5);
|
||||
\draw[->, thick] (8.6,1.725) -- (7.0,1.725);
|
||||
|
||||
% Labels
|
||||
\node at (1,-0.75) {Bin 0};
|
||||
\node at (4,-0.75) {Bin 1};
|
||||
\node at (7,-0.75) {Bin 2};
|
||||
\node at (10.0,3.5) {Yellow item};
|
||||
\node at (10.0,1.725) {Purple item};
|
||||
|
||||
\end{tikzpicture}
|
||||
\label{fig:nfbp}
|
||||
\caption{Next Fit Bin Packing example}
|
||||
\end{figure}
|
||||
|
||||
\paragraph{} The example in figure \ref{fig:nfbp} shows the limitations of the
|
||||
NFBP algorithm. The yellow item is stored in bin 2, while it could fit in bin
|
||||
1, because the purple item is considered first and is too large to fit.
|
||||
|
||||
\paragraph{} Each bin will have a fixed capacity of $ 1 $ and items and items
|
||||
will be of random sizes between $ 0 $ and $ 1 $. We will run X simulations % TODO
|
||||
with 10 packets.
|
||||
will be of random sizes between $ 0 $ and $ 1 $.
|
||||
|
||||
\subsection{Variables used in models}
|
||||
|
||||
|
|
@ -135,8 +170,8 @@ We use the following variables in our algorithms and models :
|
|||
Mathematically, the NFBP algorithm imposes the following constraint on the first box :
|
||||
|
||||
\begin{align*}
|
||||
T_1 = k \iff & U_1 + U_2 + \ldots + U_{k-1} < 1 \\
|
||||
\text{ and } & U_1 + U_2 + \ldots + U_{k} \geq 1 \qquad \text{ with } k \geq 2
|
||||
T_1 = k \iff & U_1 + U_2 + \ldots + U_{k} < 1 \\
|
||||
\text{ and } & U_1 + U_2 + \ldots + U_{k+1} \geq 1 \qquad \text{ with } k \geq 1 \\
|
||||
\end{align*}
|
||||
|
||||
|
||||
|
|
@ -145,10 +180,22 @@ Mathematically, the NFBP algorithm imposes the following constraint on the first
|
|||
We implemented the NFBP algorithm in Python \footnotemark, for its ease of use
|
||||
and broad recommendation. We used the \texttt{random} library to generate
|
||||
random numbers between $ 0 $ and $ 1 $ and \texttt{matplotlib} to plot the
|
||||
results.
|
||||
results in the form of histograms. We ran $ R = 10^6 $ simulations with
|
||||
$ N = 10 $ different items each.
|
||||
|
||||
\footnotetext{The code is available in Annex \ref{annex:probabilistic}}
|
||||
|
||||
\paragraph{Distribution of $ T_i $} We first studied how many items were
|
||||
present per bin.
|
||||
|
||||
\paragraph{Distribution of $ V_i $} We then looked at the size of the first
|
||||
item in each bin.
|
||||
|
||||
\paragraph{Asymptotic behavior of $ H_n $} Finally, we analyzed how many bins
|
||||
were needed to store $ n $ items.
|
||||
|
||||
% TODO histograms
|
||||
% TODO analysis histograms
|
||||
|
||||
|
||||
|
||||
|
|
@ -158,7 +205,49 @@ results.
|
|||
|
||||
\section{Next Fit Dual Bin Packing algorithm}
|
||||
|
||||
The variables used are the same as for NFBP.
|
||||
Next Fit Dual Bin Packing is a variation of NFBP in which we allow the bins to
|
||||
overflow. A bin must be fully filled, unless it is the last bin.
|
||||
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
\begin{tikzpicture}[scale=0.8]
|
||||
% Bins
|
||||
\draw[thick] (0,0) rectangle (2,6);
|
||||
\draw[thick] (3,0) rectangle (5,6);
|
||||
|
||||
% Transparent Tops
|
||||
\fill[white,opacity=1.0] (0,5.9) rectangle (2,6.5);
|
||||
\fill[white,opacity=1.0] (3,5.9) rectangle (5,6.5);
|
||||
|
||||
% Items
|
||||
\draw[fill=red] (0.5,0.5) rectangle (1.5,3.25);
|
||||
\draw[fill=blue] (0.5,3.5) rectangle (1.5,5.5);
|
||||
\draw[fill=green] (0.5,5.75) rectangle (1.5,6.75);
|
||||
\draw[fill=orange] (3.5,0.5) rectangle (4.5,2.5);
|
||||
\draw[fill=purple] (3.5,2.75) rectangle (4.5,5.0);
|
||||
\draw[fill=yellow] (3.5,5.25) rectangle (4.5,6.25);
|
||||
|
||||
% Labels
|
||||
\node at (1,-0.75) {Bin 0};
|
||||
\node at (4,-0.75) {Bin 1};
|
||||
|
||||
\end{tikzpicture}
|
||||
\caption{Next Fit Dual Bin Packing example}
|
||||
\label{fig:nfdbp}
|
||||
\end{figure}
|
||||
|
||||
\paragraph{} The example in figure \ref{fig:nfdbp} shows how NFDBP utilizes
|
||||
less bins than NFBP, due to less stringent constraints. The top of the bin is
|
||||
effectively removed, allowing for an extra item to be stored in the bin. We can
|
||||
easily see how with NFDBP each bin can at least contain two items.
|
||||
|
||||
\paragraph{} The variables used are the same as for NFBP. Mathematically, the
|
||||
new constraints on the first bin can be expressed as follows :
|
||||
|
||||
\begin{align*}
|
||||
T_1 = k \iff & U_1 + U_2 + \ldots + U_{k-1} < 1 \\
|
||||
\text{ and } & U_1 + U_2 + \ldots + U_{k} \geq 1 \qquad \text{ with } k \geq 2 \\
|
||||
\end{align*}
|
||||
|
||||
\subsection{La giga demo}
|
||||
|
||||
|
|
@ -206,7 +295,7 @@ $ U_1 $ and $ U_2 $ are independent, so
|
|||
& = \begin{cases}
|
||||
1 & \text{if } x \in [0, 1] \text{ and } y \in [0, 1] \\
|
||||
0 & \text{otherwise} \\
|
||||
\end{cases} \\
|
||||
\end{cases} \\
|
||||
\end{align*}
|
||||
|
||||
Hence,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
\usepackage[english]{babel}
|
||||
\usepackage{eso-pic} % for background on cover
|
||||
\usepackage{listings}
|
||||
\usepackage{tikz}
|
||||
|
||||
% Define colors for code
|
||||
\definecolor{codegreen}{rgb}{0,0.4,0}
|
||||
|
|
|
|||
Loading…
Reference in a new issue