2009 IEEE International Advance Computing Conference (IACC 2009) Patiala, India, 6-7 March 2009 Better-Fit Heuristic for One-Dimensional Bin-Packing Problem A. K. Bhatia M. Hazra, S. K. Basu* National Bureau of Animal Genetic Resources Dept. of Computer Science, Banaras Hindu University Karnal- 132001 (India) Varanasi-221005 (INDIA) Email: avnish@lycos.com Email*: swapankb@bhu.ac.in Abstract- This paper reports a study on better-fit heuristic for Time complexity of NF is 0(n) while those of FF and BF classical bin-packing problem, proposed in [1]. Better-fit replaces is 0 (n log n). NF produces a worst packing of 2 * optimum. an existing object from a bin with the next object in the list, if it FF and BF produce a worst packing of 1.7 * optimum. can fill the bin better than the object replaced. It takes O(n2m) time~~ whr n.stenme fojct n stenme Off-line algorithms have all the objects available before the time whlere n IS thle number of objects and m IS thle number of distinct object sizes in the list. It behaves as off-line as well packing starts. Two common off-line algorithms are described as on-line heuristic with the condition of permanent assignment below. of objects to a bin removed. Experiments have been conducted First-Fit Decreasing (FFD): After sorting the list of objects in on representative problem instances in terms of expected waste rates. It outperforms off-line best-fit-decreasing heuristic on most non-increasing of the instances. It always performs better than the on-line best-fit to the FF heuristic. heuristic. Best-Fit Decreasing (BFD): After sorting the list of objects in Keywords: Bin Packing Problem, Combinatorial Optimiza- non-increasing order of sizes, the BFD packs objects according tion, Heuristics. to the BF heuristic. Time complexity of FFD as well as BFD is O(nlogn). I. INTRODUCTION Worst case performance of both the algorithms is (11/9) * optimum. Given a list of objects and their sizes, one-dimensional bin- In this paper, we present better-fit heuristic for the one- packing problem (BPP) consists of finding a packing of the dimensional bin packing problem initially proposed in [1]. objects using a minimum number of bins of pre-specified Experiments have been conducted on benchmark problem capacity. Formally, given a list L of objects o° with sizes instances from the literature [4]. The results obtained with s , i 1, n and sufficient number of bins B1, B2, B3,., better-fit heuristic have been compared with those obtained each of capacity C, we want a minimum number (z) of bins using best-fit-decreasing and best-fit heuristics representing to pack all the n items. off-line and on-line heuristics, respectively. Bin packing models several applications such as storage We organize the paper as follows: section II introduces allocation of computer networks, assigning commercial breaks the better-fit heuristic, section III describes experiments and on television, copying a collection of files to magnetic tapes the results obtained, and section IV contains our concluding and floppy disks, etc. [2]. remarks. BPP is an NP-hard problem. Various heuristics are reported in the literature for solving on-line as well as off-line version II. BETTERFIT HEURISTIC of bin packing problem [3], [2]. A new heuristic for the one-dimensional bin packing called On-line algorithms permanently assign the objects to a better-fit has been introduced in [1]. It has been derived from bin in the sequence of arrival. Three most popular on-line dominance criterion [5], [6] with importance given to a single algorithms are described below. All the on-line heuristics have object. the initial condition that the first object is already packed in a Better-fit heuristic packs next object from the list in the first bin. bin that it can fill better than any of the existing objects in Next-Fit (NF): NF packs the next object into an active bin if that bin. The object replaces one existing object from the bin. it fits in the bin; otherwise the heuristic uses a new bin for the The replaced object is again packed with better-fit heuristic, object, which is marked as the active bin. starting with the first bin in the current solution. The process First-Fit (FF): FF packs the next object in the first bin in continues till a replaced object cannot perform better-fit in any which it fits; otherwise FF packs the object in a new bin, of the bins. The last replaced object is then packed with the Best-Fit (BF): BF packs the next object into a bin which is best-fit heuristic. filled to the maximum extent but having adequate vacant space Each object in the given list is packed using better-fit heuris- to pack the object; otherwise BF packs the object in a new tic. Algorithmic description of better-fit heuristic is provided bin, below. 978-1-4244-2928-8/09/$25.OO ( 2009 IEEE 193