Bin packing First-fit algorithm

Bin packing First-fit algorithm

Télécharger la présentation

Bin packing First-fit algorithm

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

1. Bin packingFirst-fit algorithm

2. Bin packing First-fit algorithm A B C D E F Each block will be fitted into the first bin that has room for it. 6 5 4 3 3 3 2 2 1

3. Bin packing First-fit algorithm 4 A B C D E F The first block fits into the first bin. 6 5 3 3 3 2 2 1

4. Bin packing First-fit algorithm 1 4 A B C D E F The second block fits into the first bin. 6 5 3 3 3 2 2

5. Bin packing First-fit algorithm 2 1 4 2 A B C D E F The third block will not fit in the first bin But there is room in the second bin. 6 5 3 3 3 2

6. Bin packing First-fit algorithm 5 5 1 5 4 2 A B C D E F The third bin is the first one the 5 will fit into. 6 3 3 3 2

7. Bin packingFirst-fit algorithm 3 1 3 5 4 2 A B C D E F The second bin has room for the 3. 6 3 3 2

8. Bin packingFirst-fit algorithm 2 2 2 1 3 5 4 2 2 A B C D E F The fourth bin is the first one with room for the 2. 6 3 3

9. Bin packingFirst-fit algorithm 3 3 3 3 5 3 1 4 2 2 A B C D E F The 3 also fits into the fourth bin. 6 3

10. Bin packingFirst-fit algorithm 6 6 6 6 6 1 3 5 3 4 2 2 A B C D E F 3 No room until the fifth bin for the 6.

11. Bin packingFirst-fit algorithm 3 3 3 3 3 6 1 3 5 3 4 3 2 2 A B C D E F The 3 has to start a new bin Total usage is 6 bins.

12. Bin Packing Examples of first-fit algorithm

13. Example 1Pack the following items into bins of size 20:11, 7, 3, 4, 3, 5, 1, 8, 9How many bins are required?

14. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 Bins 11 9 8 7 5 4 3 3 1

15. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 11 Bins 9 8 7 5 4 3 3 1

16. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 7 11 Bins 9 8 5 4 3 3 1

17. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 3 7 11 Bins 9 8 5 4 3 1

18. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 7 11 3 Bins 9 8 5 4 3 1

19. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 7 11 4 3 Bins 9 8 5 3 1

20. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 7 3 11 4 3 Bins 9 8 5 1

21. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 5 7 3 11 4 3 Bins 9 8 1

22. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 1 5 7 3 11 4 3 Bins 9 8

23. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 8 1 5 7 3 11 4 3 Bins 9

24. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 1 5 7 3 11 4 8 3 Bins 9

25. 11, 7, 3, 4, 3, 5, 1, 8, 9 Bin size 20 1 5 9 7 3 11 4 8 3 Bins We need 3 bins.

26. Example 2Pack the following items into bins of size 20:5, 8, 12, 4, 11, 17, 7, 9, 7How many bins are required?

27. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 Bins 17 12 11 9 8 7 7 5 4

28. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 5 Bins 17 12 11 9 8 7 7 4

29. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 8 5 Bins 17 12 11 9 7 7 4

30. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 12 8 5 Bins 17 11 9 7 7 4

31. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 8 12 5 Bins 17 11 9 7 7 4

32. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 4 8 12 5 Bins 17 11 9 7 7

33. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 11 4 8 12 5 Bins 17 9 7 7

34. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 4 8 12 11 5 Bins 17 9 7 7

35. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 17 4 8 12 11 5 Bins 9 7 7

36. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 17 4 8 12 11 5 Bins 9 7 7

37. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 7 17 4 8 12 11 5 Bins 9 7

38. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 9 7 17 4 8 12 11 5 Bins 7

39. 5, 8, 12, 4, 11, 17, 7, 9, 7Bin size 20 9 7 17 4 8 12 11 7 5 Bins We need 5 bins.

40. Example 3A wholesale greengrocer is packing the following items into crates that will carry 24 kg: How many crates will the greengrocer need?

41. Crates (24 kg)

42. Crates (24 kg)

43. Crates (24 kg)

44. Crates (24 kg)

45. Crates (24 kg)

46. Crates (24 kg)

47. Crates (24 kg)

48. Crates (24 kg)

49. Crates (24 kg)

50. Crates (24 kg)