tex: move and write performance part
This commit is contained in:
parent
4c74dd7877
commit
c0abf64ee0
1 changed files with 34 additions and 9 deletions
|
@ -117,11 +117,19 @@ with 10 packets.
|
|||
\subsubsection{Variables used in models}
|
||||
|
||||
|
||||
\subsubsection{Complexity and implementation optimization}
|
||||
|
||||
\cite{hofri:1987}
|
||||
% TODO mettre de l'Histoire
|
||||
|
||||
\section{Next Fit Dual Bin Packing algorithm}
|
||||
|
||||
\section{Complexity and implementation optimization}
|
||||
|
||||
The NFBP algorithm has a linear complexity $ O(n) $, as we only need to iterate
|
||||
over the items once.
|
||||
|
||||
\subsection{Performance optimization}
|
||||
|
||||
When implementing the statistical analysis, the intuitive way to do it is to
|
||||
run $ R $ simulations, store the results, then conduct the analysis. However,
|
||||
when running a large number of simulations, this can be very memory
|
||||
|
@ -129,17 +137,34 @@ consuming. We can optimize the process by computing the statistics on the fly,
|
|||
by using sum formulae. This uses nearly constant memory, as we only need to
|
||||
store the current sum and the current sum of squares for different variables.
|
||||
|
||||
While the mean can easily be calculated by summing then dividing, the variance
|
||||
can be calculated using the following formula:
|
||||
|
||||
\begin{align}
|
||||
{S_N}^2 & = \frac{1}{N-1} \sum_{i=1}^{N} (X_i - \overline{X})^2 \\
|
||||
& = \frac{1}{N-1} \sum_{i=1}^{N} X_i^2 - \frac{N}{N-1} \overline{X}^2
|
||||
\end{align}
|
||||
|
||||
The sum $ \frac{1}{N-1} \sum_{i=1}^{N} X_i^2 $ can be calculated iteratively
|
||||
after each simulation.
|
||||
|
||||
\subsection{Effective resource consumption}
|
||||
|
||||
We set out to study the resource consumption of the algorithms. We implemented
|
||||
the above formulae to calculate the mean and variance of $ N = 10^6 $ random
|
||||
numbers. We wrote the following algorithms :
|
||||
|
||||
\begin{lstlisting}[language=python]
|
||||
N = 10**6
|
||||
values = [random() for _ in range(N)]
|
||||
mean = mean(values)
|
||||
variance = variance(values)
|
||||
\end{lstlisting}
|
||||
|
||||
|
||||
% TODO : code
|
||||
% TODO : move this somewhere else ?
|
||||
% TODO : add a graph
|
||||
|
||||
\cite{hofri:1987}
|
||||
% TODO mettre de l'Histoire
|
||||
|
||||
\section{Next Fit Dual Bin Packing algorithm}
|
||||
|
||||
\section{Algorithm comparisons and optimization}
|
||||
|
||||
\subsection{NFBP vs NFDBP}
|
||||
|
||||
\subsection{Optimal algorithm}
|
||||
|
|
Loading…
Reference in a new issue