Advertisement
Guest User

Alternative algorithms

a guest
Dec 7th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. \documentclass{article}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage{amsmath}
  4. \begin{document}
  5. \section{Alternative algorithm B1}
  6. The first problem noticed about a) as an algorithm was that if there was a vehicle of length shorter than that of the remaining length in the left column behind a vehicle of length longer, then the shorter vehicle would not use the space available in the left column. This is because the algorithm states they fill only the left column and then only the right column. This is easily remedied by changing the algorithm to the following:\par
  7. \begin{align*}
  8. \text{Let V}&=\text{the length of the vehicle at the front of the queue}\\
  9. \text{Let L}&= \text{the remaining length of the left hand side of the deck}\\
  10. \text{Let R}&=\text{the remaining length of the right hand side of the deck}
  11. \end{align*}
  12.  
  13. \begin{align*}
  14. \text{If } V\leq L&:\text{V goes to the left}\\
  15. Then&: New\text{ } L=L-V\\
  16. \text{Else if } L\leq V\leq R&: \text{V goes to the right}\\
  17. Then&: New\text{ } R=R-V\\
  18. \text{Else if } L<V, R<V&:\text{Ferry leaves}\\
  19. \text{Repeat for future V}\\
  20. \end{align*}
  21. This could add up to 2 extra cars or even a lorry to the ferry. However it is unlikely to be the optimum solution.
  22. \section{Alternative algorithm B2 (First Fit decreasing)}
  23. Another alternative may be to treat this as a bin packing problem. There are several algorithms to solve this type of problem. The first alternative in the previous section was a first fit algorithm. Now consider the first fit decreasing algorithm. This requires reordering the vehicles into decreasing order, which of course in practice is not possible, but will be symbolically achieved.\par
  24. Consider the first n vehicles such that we have the set V$=\{v_{i}\text{ } i=1,...,n|\text{ } \sum_{i=1}^{n}|v_{i}|\leq 64<\sum_{i=1}^{n+1}|v_{i}| \}$ where $|v_{i}|$ is the length of a vehicle $v_{i}$.\par
  25. This set, V, will include the first ferry load of vehicles. If we now symbolically reorder this set from the longest vehicle to the shortest (with equal sized vehicles sorted by their size of their $i$), then we can sort them more efficiently into the columns. Now the first fit algorithm (B1) is applied to this set. Once they have each been assigned a column, the columns are reordered by increasing $|i|$ to preserve the condition whereby only the first vehicle can enter the ferry at any one time.\par
  26. However this can lead to the smallest vehicle, which we shall denote $v_{s}$ if it's not the very last in this set, V, potentially not being sorted into either column as there may be enough length in the two columns' leftover space put together, but individually they come out to less than the shortest vehicle's length (i.e. there may be 2m left on the left and 3m left on the right but a vehicle of 3.5m cannot fit in either of these). To combat this problem with the algorithm, the vehicle, $|v_{s}|$, will be swapped with the vehicle with the last vehicle in the queue, $v_{n}$.\par
  27. We have now two cases:
  28. \begin{enumerate}
  29. \item The vehicle $v_{n}$ is longer than $v_{s}$ (i.e. $|v_{s}|<|v_{n}|$)
  30. \item The vehicles are the same length (and therefore $n=s$ as the $v_{i}$ with the same length are ordered by increasing i)
  31. \end{enumerate}
  32. Either one of these cases will make the vehicle $v_{n}$ have to wait until the next ferry. This is preferable to the vehicle $v_{s}$ having to wait as that would cause all vehicles $v_{s}, V_{s+1}, ... , v_{n}$ also having to wait for the next ferry. Wasting a lot of space.
  33. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement