Improved results for a memory allocation problem Rob van Stee University of Karlsruhe Germany Leah Epstein University of Haifa Israel WADS 2007 WAOA 2007.

Slides:



Advertisements
Similar presentations
Alexander Kononov Sobolev Institute of Mathematics Siberian Branch of Russian Academy of Science Novosibirsk, Russia.
Advertisements

Lindsey Bleimes Charlie Garrod Adam Meyerson
MATH 224 – Discrete Mathematics
Algorithm Design Techniques: Greedy Algorithms. Introduction Algorithm Design Techniques –Design of algorithms –Algorithms commonly used to solve problems.
QuickSort Average Case Analysis An Incompressibility Approach Brendan Lucier August 2, 2005.
Chapter 4: Trees Part II - AVL Tree
Approximation, Chance and Networks Lecture Notes BISS 2005, Bertinoro March Alessandro Panconesi University La Sapienza of Rome.
CS 484. Discrete Optimization Problems A discrete optimization problem can be expressed as (S, f) S is the set of all feasible solutions f is the cost.
UNIVERSITY OF JYVÄSKYLÄ Building NeuroSearch – Intelligent Evolutionary Search Algorithm For Peer-to-Peer Environment Master’s Thesis by Joni Töyrylä
Polynomial Time Approximation Schemes Presented By: Leonid Barenboim Roee Weisbert.
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
The number of edge-disjoint transitive triples in a tournament.
PTAS for Bin-Packing. Special Cases of Bin Packing 1. All item sizes smaller than Claim 1: Proof: If then So assume Therefore:
Approximating Maximum Edge Coloring in Multigraphs
Approximation Algorithms
Parameterized Approximation Scheme for the Multiple Knapsack Problem by Klaus Jansen (SODA’09) Speaker: Yue Wang 04/14/2009.
Approximation Algorithms
Chapter 3: The Efficiency of Algorithms Invitation to Computer Science, C++ Version, Fourth Edition.
B + -Trees (Part 1) Lecture 20 COMP171 Fall 2006.
B + -Trees (Part 1). Motivation AVL tree with N nodes is an excellent data structure for searching, indexing, etc. –The Big-Oh analysis shows most operations.
B + -Trees (Part 1) COMP171. Slide 2 Main and secondary memories  Secondary storage device is much, much slower than the main RAM  Pages and blocks.
Distributed Combinatorial Optimization
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
NP-complete and NP-hard problems. Decision problems vs. optimization problems The problems we are trying to solve are basically of two kinds. In decision.
Approximation Algorithms Motivation and Definitions TSP Vertex Cover Scheduling.
B + -Trees COMP171 Fall AVL Trees / Slide 2 Dictionary for Secondary storage * The AVL tree is an excellent dictionary structure when the entire.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Primal-Dual Meets Local Search: Approximating MST’s with Non-uniform Degree Bounds Author: Jochen Könemann R. Ravi From CMU CS 3150 Presentation by Dan.
Yossi Azar Tel Aviv University Joint work with Ilan Cohen Serving in the Dark 1.
Why is bin packing interesting?
Approximation schemes Bin packing problem. Bin Packing problem Given n items with sizes a 1,…,a n  (0,1]. Find a packing in unit-sized bins that minimizes.
1 Approximation Through Scaling Algorithms and Networks 2014/2015 Hans L. Bodlaender Johan M. M. van Rooij.
Design Techniques for Approximation Algorithms and Approximation Classes.
Approximating Minimum Bounded Degree Spanning Tree (MBDST) Mohit Singh and Lap Chi Lau “Approximating Minimum Bounded DegreeApproximating Minimum Bounded.
© 2009 IBM Corporation 1 Improving Consolidation of Virtual Machines with Risk-aware Bandwidth Oversubscription in Compute Clouds Amir Epstein Joint work.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 19: Searching and Sorting Algorithms.
Analysis of Algorithms
A Clustering Algorithm based on Graph Connectivity Balakrishna Thiagarajan Computer Science and Engineering State University of New York at Buffalo.
Approximation Algorithms for Knapsack Problems 1 Tsvi Kopelowitz Modified by Ariel Rosenfeld.
Order Statistics. Order statistics Given an input of n values and an integer i, we wish to find the i’th largest value. There are i-1 elements smaller.
Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)
The Selection Problem. 2 Median and Order Statistics In this section, we will study algorithms for finding the i th smallest element in a set of n elements.
1 Virtual Memory Chapter 9. 2 Resident Set Size n Fixed-allocation policy u Allocates a fixed number of frames that remains constant over time F The number.
Princeton University COS 423 Theory of Algorithms Spring 2001 Kevin Wayne Approximation Algorithms These lecture slides are adapted from CLRS.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
CSC 211 Data Structures Lecture 13
B + -Trees. Motivation An AVL tree with N nodes is an excellent data structure for searching, indexing, etc. The Big-Oh analysis shows that most operations.
Chapter 18: Searching and Sorting Algorithms. Objectives In this chapter, you will: Learn the various search algorithms Implement sequential and binary.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Approximation Algorithms Department of Mathematics and Computer Science Drexel University.
The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects.
1 Approximation algorithms Algorithms and Networks 2015/2016 Hans L. Bodlaender Johan M. M. van Rooij TexPoint fonts used in EMF. Read the TexPoint manual.
Page Buffering, I. Pages to be replaced are kept in main memory for a while to guard against poorly performing replacement algorithms such as FIFO Two.
The geometric GMST problem with grid clustering Presented by 楊劭文, 游岳齊, 吳郁君, 林信仲, 萬高維 Department of Computer Science and Information Engineering, National.
Feb 23, 2010 University of Liverpool Minimizing Total Busy Time in Parallel Scheduling with Application to Optical Networks Michele Flammini – University.
Clustering Data Streams A presentation by George Toderici.
Approximation Algorithms Department of Mathematics and Computer Science Drexel University.
Approximation Algorithms based on linear programming.
Sorting and Runtime Complexity CS255. Sorting Different ways to sort: –Bubble –Exchange –Insertion –Merge –Quick –more…
CSC 421: Algorithm Design & Analysis
CSC 421: Algorithm Design & Analysis
Time complexity Here we will consider elements of computational complexity theory – an investigation of the time (or other resources) required for solving.
CSC 421: Algorithm Design & Analysis
B+-Trees.
B+-Trees.
B+ Tree.
Chapter 3: The Efficiency of Algorithms
A new and improved algorithm for online bin packing
CSC 421: Algorithm Design & Analysis
Presentation transcript:

Improved results for a memory allocation problem Rob van Stee University of Karlsruhe Germany Leah Epstein University of Haifa Israel WADS 2007 WAOA 2007

Background Allocate memory to parallel processors Allocate memory to parallel processors Goals: Goals: –Each processor has sufficient memory –Not too much memory is wasted

Background Problem: memory requirement may vary over time Problem: memory requirement may vary over time If each processor can access only one memory, this is inefficient If each processor can access only one memory, this is inefficient If all processors share a single memory, there is heavy contention If all processors share a single memory, there is heavy contention

Suggested model Chung et al. [SPAA 2004] suggest a new architecture Chung et al. [SPAA 2004] suggest a new architecture Each memory may be accessed by at most two processors Each memory may be accessed by at most two processors This avoids the mentioned problems This avoids the mentioned problems

Bin packing They abstract this problem as a bin packing problem They abstract this problem as a bin packing problem Bins = memories Bins = memories Items = memory requirements of processors Items = memory requirements of processors Thus, items may be larger than 1 Thus, items may be larger than 1

Bin packing Items may be split and distributed among more than one bin Items may be split and distributed among more than one bin Condition: each bin contains at most two parts of items Condition: each bin contains at most two parts of items Corresponds to: each memory may be accessed by at most two processors Corresponds to: each memory may be accessed by at most two processors We also consider the model where each bin may contain k parts of items We also consider the model where each bin may contain k parts of items

Bin packing Processor Requirement Bins Assignment 1,2 3,4 2 3,4,5 1

Notes There may be many bins which are not full There may be many bins which are not full An item may be split more than once An item may be split more than once No upper bound on how often each item is split No upper bound on how often each item is split

Results Chung et al. [SPAA 2004]: Chung et al. [SPAA 2004]: –(k=2) NP-hardness –(k=2) 3/2-approximation Epstein & vS [WADS 2007]: Epstein & vS [WADS 2007]: –(k=2) 7/5-approximation –For general k: Next Fit is (2-1/k)-approximation Next Fit is (2-1/k)-approximation NP-hardness in the strong sense NP-hardness in the strong sense

Results Epstein & vS [WAOA 2007]: A polynomial time approximation scheme (PTAS) for every (constant) k A polynomial time approximation scheme (PTAS) for every (constant) k –For every constant  >0, a polynomial time algorithm that uses at most 1+  times the minimal number of bins –at most  OPT additional bins of size 1

Results Epstein & vS [WAOA 2007]: A dual approximation scheme for every (constant) k A dual approximation scheme for every (constant) k –For every constant  >0, a polynomial time algorithm that uses bins of size 1+  –Larger bins, but no additional bins

Next Fit in this context If current bin contains k parts of items or is fulll, open a new bin If current bin contains k parts of items or is fulll, open a new bin Put as much as possible of the current item in the current bin Put as much as possible of the current item in the current bin Open additional bin(s) if needed (for large items) Open additional bin(s) if needed (for large items)

Next Fit: lower bound One item of size Mk-1 One item of size Mk-1 –Next Fit uses Mk-1 bins M (k-1)k very small items M (k-1)k very small items –Next Fit puts k items in one bin, uses M (k-1) bins Mk -1 M (k -1)

Next Fit: lower bound Optimal solution needs only Mk bins Optimal solution needs only Mk bins Ratio: (M (2k-1)-1) /Mk 2 – 1/k Ratio: (M (2k-1)-1) /Mk 2 – 1/k Mk -1 M (k -1) Mk

Next Fit: upper bound Block = set of full bins, followed by a bin with k items Block = set of full bins, followed by a bin with k items Each bin >1 in a block was opened because the previous one was full Each bin >1 in a block was opened because the previous one was full

Weights Weight of item with size s =  s  /k Weight of item with size s =  s  /k There are at least  s  parts of item with size s in any packing There are at least  s  parts of item with size s in any packing OPT is at least the total weight of all the items OPT is at least the total weight of all the items

Next Fit: upper bound Consider last bin in a block (not the last block) Consider last bin in a block (not the last block) Has k items, so at least k -1 items of weight 1/k (these items are not split!) Has k items, so at least k -1 items of weight 1/k (these items are not split!) Block has 1 bin, then k such items Block has 1 bin, then k such items Else, consider all items in block except the k -1 last items Else, consider all items in block except the k -1 last items

Next Fit: upper bound S = all items in block except the k -1 last items S = all items in block except the k -1 last items How many items are in S ? Unknown! How many items are in S ? Unknown! What is the minimal weight of S ? What is the minimal weight of S ? Weight =, minimized for single item Weight =, minimized for single item

Next Fit: upper bound S = all items in block except the k -1 last items S = all items in block except the k -1 last items For block of size b, total size of items in S is strictly more than b -1 For block of size b, total size of items in S is strictly more than b -1 Total weight is then at least b /k Total weight is then at least b /k Weight in block at least b /k +(k -1)/k Weight in block at least b /k +(k -1)/k Note: also true for block of size 1 Note: also true for block of size 1

The last block Only one bin: weight at least 1/k (has at least one item) Only one bin: weight at least 1/k (has at least one item) b >1 bins: weight at least b /k b >1 bins: weight at least b /k Let size of block i be b i, then Next Fit uses bins Let size of block i be b i, then Next Fit uses bins We know that OPT is at least the total weight We know that OPT is at least the total weight

Next Fit: upper bound Let m be the amount of blocks Let m be the amount of blocks Also, OPT > NF – m (in each block, at most one bin is not completely full) Also, OPT > NF – m (in each block, at most one bin is not completely full)

Next Fit: upper bound Combining this we find

23 This talk We only discuss the algorithms for k=2 We only discuss the algorithms for k=2 General properties General properties PTAS PTAS Dual PTAS Dual PTAS

Representation of solutions A solution can be seen as a graph A solution can be seen as a graph Vertices = items Vertices = items An edge between two items = An edge between two items = Parts of these two items share a bin Parts of these two items share a bin – A loop means that a bin contains just one part of an item We can assume a forest (with loops) We can assume a forest (with loops) –Cycles can be easily removed without changing the cost (Chung et al.,2004).

Example Items:

Graph

Removal of cycle

Additional properties There exists an optimal packing forest where all items of size in (0,1/2] are leaves or singletons There exists an optimal packing forest where all items of size in (0,1/2] are leaves or singletons If the forest representation is minimal (no tree can be split) then a packing is implied from the tree If the forest representation is minimal (no tree can be split) then a packing is implied from the tree –Can be done iteratively –Singletons are packed into separate bins –A leaf is packed with a maximum amount of its neighbor, and removed from the forest

(Different) example

Packing process

PTAS for k=2 We would like to use standard methods such as We would like to use standard methods such as –Linear grouping and rounding –Enumeration of patterns But But –Patterns are trees –Items sizes are not bounded from above

New tricks Optimal packing is adapted in order to make it possible to imitate it Optimal packing is adapted in order to make it possible to imitate it Trees are “truncated” Trees are “truncated” –Partitioned into smaller trees Large items are truncated Large items are truncated –Partitioned into several items that are still large, but bounded The last two adaptations increase the number of bins by a factor of 1+  The last two adaptations increase the number of bins by a factor of 1+ 

Trying all trees Type of a tree is (j,E) Type of a tree is (j,E) –j is number of edges –E is set of j-1 edges (so that it is a tree) Pattern = type plus vector of length j Pattern = type plus vector of length j –Element i in the vector indicates group of node i Constant number of patterns Constant number of patterns Only question: how many of each? Only question: how many of each?

Dual PTAS for k=2 (briefly) We use an integer parameter K, based on . We use an integer parameter K, based on . Items can be rounded down to a sizes of the form i/K Items can be rounded down to a sizes of the form i/K We round some non-zero sizes into zero! We round some non-zero sizes into zero! By scaling, we get items of integer sizes, and a bin size K By scaling, we get items of integer sizes, and a bin size K

Cutting There is no reason to cut items at non-integer point There is no reason to cut items at non-integer point For each item size (at most K), we define cutting patterns For each item size (at most K), we define cutting patterns We “guess” how to cut the input items We “guess” how to cut the input items –Using enumeration

Finding a solution We use a layered graph to find an optimal packing for each option We use a layered graph to find an optimal packing for each option –If the cutting was applied, the problem becomes much easier –However, we did not cut items larger than the bin size –We cut a piece off each one of them, but do not decide on all cutting points The best (smallest number of bins) option is chosen The best (smallest number of bins) option is chosen Increasing items back to original sizes increases bins slightly Increasing items back to original sizes increases bins slightly

Open problems PTAS, dual PTAS for non-constant k PTAS, dual PTAS for non-constant k (FPTAS or dual FPTAS are most likely impossible since the problem is strongly NP-hard for every constant value of k) (FPTAS or dual FPTAS are most likely impossible since the problem is strongly NP-hard for every constant value of k) Generalize 7/5-approximation for larger k Generalize 7/5-approximation for larger k

7/5-approximation We show an approximation algorithm for k=2 (at most two parts of items per bin allowed) We show an approximation algorithm for k=2 (at most two parts of items per bin allowed) First it sorts the items First it sorts the items Then it packs them, starting with the most difficult ones: size between ½ and 1 Then it packs them, starting with the most difficult ones: size between ½ and 1 We use Next Fit as a subroutine We use Next Fit as a subroutine

Step 1: Sorting Items of size at most ½ are small Items of size at most ½ are small –Sort them in order of increasing size Items larger than 1 are large Items larger than 1 are large –Sort them in order of decreasing size Other items are medium-sized Other items are medium-sized –Sort them in order of decreasing size –We pack these items first

Step 2: medium-sized items Pack medium-sized items one by one: Pack medium-sized items one by one: –If current item fits in one bin with the smallest unpacked small item, pack them together –Else, pack current item together with two largest unpacked small items in two bins

Step 3: all small items are packed We do this until we run out of either the medium-sized or the small items We do this until we run out of either the medium-sized or the small items If all small items are packed, use Next Fit on rest, start with medium-sized items If all small items are packed, use Next Fit on rest, start with medium-sized items

Step 4: some small items remain Pack each small item in its own bin Pack each small item in its own bin Pack large items into these bins using Next Fit Pack large items into these bins using Next Fit Still use ordering from before: Still use ordering from before: –Largest large items first –Smallest small items first

Step 5: small items left We have now run out of either the large or the small items We have now run out of either the large or the small items If bins with small items remain, repack these items two per bin If bins with small items remain, repack these items two per bin

Step 6: large items left Pack remaining large items using Next Fit Pack remaining large items using Next Fit

Lower bound for this algorithm 4N small items of size 2/N 4N small items of size 2/N 2N medium-sized items of size 1-1/N 2N medium-sized items of size 1-1/N 3N medium-sized items of size 1-2/N 3N medium-sized items of size 1-2/N Algorithm starts with largest medium- sized items Algorithm starts with largest medium- sized items

Lower bound for this algorithm Step 2: pack medium-sized items one by one: –If current item fits in one bin with the smallest unpacked small item, pack them together –Else, pack current item together with two largest unpacked small items in two bins

Lower bound for this algorithm 4N small items of size 2/N 4N small items of size 2/N 2N medium-sized items of size 1-1/N 2N medium-sized items of size 1-1/N 3N medium-sized items of size 1-2/N 3N medium-sized items of size 1-2/N Algorithm creates 4N bins with half an item of size 1-1/N and one small item Algorithm creates 4N bins with half an item of size 1-1/N and one small item Rest is packed using Next Fit Rest is packed using Next Fit 3N(1-2/N) = 3N-6 bins for other items 3N(1-2/N) = 3N-6 bins for other items

The optimal solution 3N small items in separate bins 3N small items in separate bins –In these bins, the items of size 1-2/N can be packed N small items split into two bins N small items split into two bins –Here the items of size 1-1/N can be packed Requires 5N bins for all items Requires 5N bins for all items Ratio 7/5 for large N Ratio 7/5 for large N

Upper bound We use the same weight definition as before: weight of item with size s is We use the same weight definition as before: weight of item with size s is We know that OPT is at least the total weight We know that OPT is at least the total weight How much weight do we pack in a bin? How much weight do we pack in a bin?

Amount of weight packed Step 2: Pack medium-sized items one by one: Pack medium-sized items one by one: –If current item fits in one bin with the smallest unpacked small item, pack them together. Weight ½+½ = 1 –Else, pack current item together with two largest unpacked small items in two bins. Three items of weight ½ in two bins: ¾

Amount of weight packed Step 3: If all small items are packed, use Next Fit on rest, start with medium-sized items If all small items are packed, use Next Fit on rest, start with medium-sized items We assume many small items exist We assume many small items exist Then, this step does not occur Then, this step does not occur

Amount of weight packed Step 4: Pack each small item in its own bin Pack each small item in its own bin Pack large items into these bins using Next Fit Pack large items into these bins using Next Fit Still use ordering from before: Still use ordering from before: –Largest large items first –Smallest small items first

Amount of weight packed Consider a large item which is packed into g bins Consider a large item which is packed into g bins It is packed together with g small items (total weight g /2) It is packed together with g small items (total weight g /2) The large item has size strictly more than (g -1)/2, so weight at least g /4 The large item has size strictly more than (g -1)/2, so weight at least g /4 Average weight per bin = 3/4 Average weight per bin = 3/4

Amount of weight packed Step 5: We have now run out of either the large or the small items We have now run out of either the large or the small items If bins with small items remain, repack these items two per bin If bins with small items remain, repack these items two per bin Weight: ½ + ½ = 1 Weight: ½ + ½ = 1

Packed weight: summary Step 2: ½+½=1, or 3 times ½ in two bins, average ¾ Step 2: ½+½=1, or 3 times ½ in two bins, average ¾ Step 4: average ¾ Step 4: average ¾ Step 5: ½+½=1 Step 5: ½+½=1 Gives upper bound of 4/3! (Since OPT is at least total weight)

However… There may be only one small item left at the end of Step 5 There may be only one small item left at the end of Step 5 –„If bins with small items remain, repack these items two per bin“ We may run out of small items in Step 2, so that Step 3 is executed We may run out of small items in Step 2, so that Step 3 is executed We may run out of small items in Step 4, so that Step 6 is executed We may run out of small items in Step 4, so that Step 6 is executed

Upper bound It turns out that these cases are the most difficult It turns out that these cases are the most difficult Proof is a number of pages Proof is a number of pages Eventually we find an upper bound of 7/5 in all cases Eventually we find an upper bound of 7/5 in all cases

Open questions Improve this approximation ratio Improve this approximation ratio –We can give a PTAS, but this is much less efficient already for epsilon = 2/5 Generalize this algorithm for larger k Generalize this algorithm for larger k –We have the upper bound of Next Fit, which is 2-1/k, and a PTAS –Can we improve on Next Fit efficiently?

Thank you!