4 views

Uploaded by Anurag Jain

save

- Image Processing
- Lab Handout
- Senarios.ds
- c++programs
- Assignment 9.pdf
- JF_V02_S02_L09_try
- Ultrasonic obstacle avoidance robot car
- Bk Edctn SparkCharts Computer Java
- Clearing the Faults and Understanding Led Status on Sun Sparc Enterprise Mx000 Servers
- IFEM.HW04
- Jienosa54
- IS-U Data Model
- Django Cheat Sheet
- Clients
- Re_ Understanding Caffe.io
- 1-1 practice_c
- CallingupapartsprogramfromDNC
- huffman coding
- Imp_View
- Festive Gift
- Definitions for phylogenetics
- Cid 2 Code
- How to estimate square root --for school students
- Articulo Paper26561574
- PCP_setup
- 110316
- php3.docx
- ddsdsdd
- Log
- My Apogee Paper
- Sapiens: A Brief History of Humankind
- The Unwinding: An Inner History of the New America
- Yes Please
- Dispatches from Pluto: Lost and Found in the Mississippi Delta
- Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
- The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution
- John Adams
- Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
- A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
- Grand Pursuit: The Story of Economic Genius
- This Changes Everything: Capitalism vs. The Climate
- The Emperor of All Maladies: A Biography of Cancer
- The Prize: The Epic Quest for Oil, Money & Power
- Team of Rivals: The Political Genius of Abraham Lincoln
- The New Confessions of an Economic Hit Man
- The World Is Flat 3.0: A Brief History of the Twenty-first Century
- Rise of ISIS: A Threat We Can't Ignore
- Smart People Should Build Things: How to Restore Our Culture of Achievement, Build a Path for Entrepreneurs, and Create New Jobs in America
- The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
- How To Win Friends and Influence People
- Angela's Ashes: A Memoir
- Steve Jobs
- Bad Feminist: Essays
- The Light Between Oceans: A Novel
- The Silver Linings Playbook: A Novel
- Leaving Berlin: A Novel
- Extremely Loud and Incredibly Close: A Novel
- The Sympathizer: A Novel (Pulitzer Prize for Fiction)
- You Too Can Have a Body Like Mine: A Novel
- The Incarnations: A Novel
- Life of Pi
- The Love Affairs of Nathaniel P.: A Novel
- A Man Called Ove: A Novel
- Bel Canto
- The Master
- The Blazing World: A Novel
- The Rosie Project: A Novel
- The First Bad Man: A Novel
- We Are Not Ourselves: A Novel
- Brooklyn: A Novel
- The Flamethrowers: A Novel
- Wolf Hall: A Novel
- The Art of Racing in the Rain: A Novel
- The Wallcreeper
- Interpreter of Maladies
- Beautiful Ruins: A Novel
- The Kitchen House: A Novel
- The Perks of Being a Wallflower
- Lovers at the Chameleon Club, Paris 1932: A Novel
- The Bonfire of the Vanities: A Novel
- A Prayer for Owen Meany: A Novel
- The Cider House Rules
- Mislaid: A Novel

You are on page 1of 13

3

More approximation algorithms

Dept of Computer Science, University of Bristol.

COMS21101. Chapter 6.3 Slide 1

The bin-packing problem has been shown to be intractable. COMS21101. The number of possible partitions of the n objects into n or fewer subsets is exponential in n. Chapter 6. They have to be packed into bins each of which has capacity of 1. Solution: the minimum number of bins required to pack the n objects.3 Slide 2 . University of Bristol.Bin Packing The bin-packing problem is stated as follows: There are n objects whose sizes range between 0 and 1. (see Baase and Van Gelder. chapter 13) Dept of Computer Science.

University of Bristol. COMS21101.Applications of Bin-packing Packing data in computers with minimum empty storage space placing files in disk blocks/tracks program segments in memory pages Filling orders for a product to be cut from large standard-size pieces e.g. cutting lengths of fabric or timber with minimum waste Dept of Computer Science.3 Slide 3 . Chapter 6.

3 Slide 4 . COMS21101.The First-Fit Strategy Simple first-fit strategy: take the objects in any order place each object in the first bin in which it fits. University of Bristol. First-fit decreasing (FFD) strategy: Sort the objects into descending order Then apply the simple strategy above. Chapter 6. Dept of Computer Science.

2.2. 0. 0.FFD-strategy: example Given objects 0. 0.5 0.5. 0.2.3 Sorted into decreasing order 0.4 0. 0.4.2 0. 0. 0. University of Bristol.4.2 Note: this is not optimal.8.4. COMS21101.4.3 0. 0.2.8 0. 0. The objects would fit into 3 bins.4 0. 0.2. 0. 0.8. Dept of Computer Science. 0.3. Chapter 6.2 0.5. 0.3 Slide 5 .2 0.

Chapter 6.3 Slide 6 . since n2 + n log n is O(n2).FFD complexity The objects are sorted in O(n log n) The first fit strategy is O(n2). it usually gives solutions much closer to the optimal one.e. In practice. since each of the n objects must be ³tried´ in at most n bins. University of Bristol. It has been proved that the FFD strategy gives a solution that is at worst about 22% sub-optimal (i. requires at most 22% more bins than necessary). Dept of Computer Science. Hence overall complexity is O(n2). COMS21101.

Dept of Computer Science. University of Bristol. we could put it in the fullest of those bins in which it fits. it works only about as well as the FFD strategy.3 Slide 7 . COMS21101. Chapter 6. in practice. Intuitively. it attempts to fill bins as much as possible. this ³best-fit´ strategy might be expected to give better solutions. However.Best-fit strategy Instead of placing an object in the first bin in which it fits. since.

University of Bristol. Chapter 6. COMS21101. given available resources C (e. and a set of n objects each of which has a size and a value. on a space flight). Dept of Computer Science.g. Applications: creating an investment portfolio for a sum of money C to achieve the greatest profit.3 Slide 8 .The Knapsack problem Given a ³knapsack´ with capacity C. Find the ³most valuable´ set of objects that fit in the knapsack. selecting the most ³profitable´ tasks.

3 Slide 9 . Hence. Chapter 6. we consider only the size. The general knapsack algorithm as stated above can be obtained by extending this simple version (see Baase and Van Gelder. Chapter 13). where we assume that the value of each object is proportional to its size. University of Bristol. Dept of Computer Science.An approximate knapsack algorithm We present an algorithm for simple version of the knapsack algorithm. COMS21101.

k-th approximation Let S be the given set of n objects. COMS21101. For fixed k < n. for k=2. The maximum value so obtained is the k-th approximation. we then try to fill up the knapsack by picking the objects in some fixed order until it is full.g. we first consider all subsets of S with at most k elements. Chapter 6. However. University of Bristol. For each subset of k objects which fits in the knapsack. Clearly. by increasing k. Let C be the size of the knapsack. we get a better and better approximation. E. whose total size is less than C.3 Slide 10 . the complexity is O(knk+1) Dept of Computer Science. we consider all pairs of objects that fit in the knapsack.

. Chapter 6. COMS21101..} } if (maxSum < sum) {maxSum = sum} } } return maxSum.. University of Bristol.n} with k elements { sum = the sum of the values S[i] such that i T. T = T {j}. j.S) // S an array with n values (the sizes) int maxSum. for each subset T {1.. take = .3 Slide 11 . maxSum = 0. if (sum e C) { for each j not in T { if (sum + S[j] e C){ sum = sum + S[j]. // C is the size of the knapsack Set T = new Set.Algorithm for k-th approximation knapSack_k(C. Dept of Computer Science. sum.

1} {54.23.29.1} {54.3 Slide 12 .1} {54. Chapter 6.1} {54.45.14.29.Example: 1-approximation Consider objects {54.43.1} {54.45} sum 100 100 98 107 107 105 98 100 Thus maxSum = 107. COMS21101.1} Let C = 110 Consider all singleton sets (k=1) Subset {54} {45} {43} {29} {23} {21} {14} {1} Objects added by inner ³for´ loop {45.21. Dept of Computer Science.29.23.29.1} {54.1} {54. University of Bristol.

1} or {43.29} ..14.21.Example .29. {45.1} 107 {21.45} {54.3 Slide 13 . {23.1} 110 110 106 Since C=110. Objects added by inner ³for´ loop sum {1} 100 {23.1} {23.14} ..1} {54.29} .14.23... Some examples of the 28 pairs considered are Subset {54..1} completely fill the knapsack and hence either is optimal (assuming size and value are the same). {45.43.continued In fact the optimal solution to the above example is found by the approximation with k=2.14. COMS21101. University of Bristol.43} {43.. Dept of Computer Science. Chapter 6.

- Image ProcessingUploaded byChetan Patil
- Lab HandoutUploaded byRoshan Ajith
- Senarios.dsUploaded bySrikanth Reddy
- c++programsUploaded byVipin
- Assignment 9.pdfUploaded bysubba
- JF_V02_S02_L09_tryUploaded byAnggi Putra Permana
- Ultrasonic obstacle avoidance robot carUploaded byCraig McClure
- Bk Edctn SparkCharts Computer JavaUploaded byEH
- Clearing the Faults and Understanding Led Status on Sun Sparc Enterprise Mx000 ServersUploaded byMohaideen
- IFEM.HW04Uploaded bygman
- Jienosa54Uploaded bydavidson123524
- IS-U Data ModelUploaded bycgodor75
- Django Cheat SheetUploaded byNathaniel Sim
- ClientsUploaded byjoseph david
- Re_ Understanding Caffe.ioUploaded byjustme8
- 1-1 practice_cUploaded byStanley
- CallingupapartsprogramfromDNCUploaded byearlgreydb
- huffman codingUploaded byNazeer Baba
- Imp_ViewUploaded byAnutosh Mishra
- Festive GiftUploaded byAlok Verma
- Definitions for phylogeneticsUploaded bySergio Rojo
- Cid 2 CodeUploaded byकमल कुलश्रेष्ठ
- How to estimate square root --for school studentsUploaded byDr Srinivasan Nenmeli -K
- Articulo Paper26561574Uploaded byMartin Saavedra Flores
- PCP_setupUploaded bymail2prb
- 110316Uploaded byRishi Jha
- php3.docxUploaded bysreedharantcr
- ddsdsddUploaded bysuhas
- LogUploaded byMohamed Awad
- My Apogee PaperUploaded bymaco_anshu