tex: add NFB(D)P drawings
This commit is contained in:
parent
dcda7297e0
commit
bcfbec57ba
2 changed files with 72 additions and 1 deletions
|
@ -110,6 +110,42 @@ 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.
|
||||
|
@ -170,7 +206,41 @@ were needed to store $ n $ items.
|
|||
|
||||
\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.
|
||||
|
||||
\subsection{La giga demo}
|
||||
|
||||
|
|
|
@ -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