Multi - Way Number Partitioning

Slides:



Advertisements
Similar presentations
Types of Algorithms.
Advertisements

Quick Sort, Shell Sort, Counting Sort, Radix Sort AND Bucket Sort
Parallel Scheduling of Complex DAGs under Uncertainty Grzegorz Malewicz.
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Updated QuickSort Problem From a given set of n integers, find the missing integer from 0 to n using O(n) queries of type: “what is bit[j]
Lecture 7: Greedy Algorithms II Shang-Hua Teng. Greedy algorithms A greedy algorithm always makes the choice that looks best at the moment –My everyday.
1 Greedy Algorithms. 2 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
Quicksort.
This material in not in your text (except as exercises) Sequence Comparisons –Problems in molecular biology involve finding the minimum number of edit.
Lecture 7: Greedy Algorithms II
Scott Perryman Jordan Williams.  NP-completeness is a class of unsolved decision problems in Computer Science.  A decision problem is a YES or NO answer.
1 Chapter 24 Developing Efficient Algorithms. 2 Executing Time Suppose two algorithms perform the same task such as search (linear search vs. binary search)
Analysis of Algorithms
Fundamentals of Algorithms MCS - 2 Lecture # 7
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
CSC 211 Data Structures Lecture 13
Types of Algorithms. 2 Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification.
Dynamic Programming.  Decomposes a problem into a series of sub- problems  Builds up correct solutions to larger and larger sub- problems  Examples.
Data Structures and Algorithms Instructor: Tesfaye Guta [M.Sc.] Haramaya University.
A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding.
Greedy Algorithms Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Greedy Algorithms Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Recursion Powerful Tool
Algorithm Design Techniques, Greedy Method – Knapsack Problem, Job Sequencing, Divide and Conquer Method – Quick Sort, Finding Maximum and Minimum, Dynamic.
CSE15 Discrete Mathematics 03/06/17
Greedy Algorithms.
8.3.2 Constant Distance Approximations
TK3043 Analysis and Design of Algorithms
Analysis of Algorithms
Recitation 13 Searching and Sorting.
Weighted Interval Scheduling
Priority Queues and Heaps
Algorithm Analysis CSE 2011 Winter September 2018.
Types of Algorithms.
Greedy Algorithms / Interval Scheduling Yin Tat Lee
Quicksort 1.
Algorithm Design Methods
CS 2210 Discrete Structures Algorithms and Complexity
Binary Search Back in the days when phone numbers weren’t stored in cell phones, you might have actually had to look them up in a phonebook. How did you.
A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 13 (Reed) - Conditional.
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
Objective of This Course
Instructor: Shengyu Zhang
Unit-2 Divide and Conquer
Types of Algorithms.
Winter 2018 CISC101 12/2/2018 CISC101 Reminders
MURI Kickoff Meeting Randolph L. Moses November, 2008
CS 2210 Discrete Structures Algorithms and Complexity
Advanced Analysis of Algorithms
Sorting … and Insertion Sort.
Lecture No 6 Advance Analysis of Institute of Southern Punjab Multan
Discrete Mathematics CMP-101 Lecture 12 Sorting, Bubble Sort, Insertion Sort, Greedy Algorithms Abdul Hameed
Advanced Algorithms Analysis and Design
Graph Searching.
Matthew Renner, Trish Beeksma, Patch Kenny
Analysis of Algorithms
Quicksort.
Analysis of Algorithms
Sorting And Searching CSE116A,B 4/7/2019 B.Ramamurthy.
Types of Algorithms.
Divide & Conquer Sorting
Quicksort.
Analysis of Algorithms
Design and Analysis of Algorithms
A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 13 (Reed) - Conditional.
Divide and Conquer Merge sort and quick sort Binary search
Analysis of Algorithms
Algorithm Course Algorithms Lecture 3 Sorting Algorithm-1
Quicksort.
CS 2210 Discrete Structures Algorithms and Complexity
Presentation transcript:

Multi - Way Number Partitioning

Partition Problem Partition: Grouping a sets elements into non-empty subsets, with every element included in one and only one of the subsets Partition Problem: Is the task of deciding if a set of positive integers can be partitioned into two or more subsets of equal sum NP- Complete though there are dynamic programming solutions Dynamic Programming: Method that breaks down complex problems into simpler subproblems, solving the subproblems once and storing the solutions There are heuristics that can solve Heuristic: Any approach to problem solving that employs a practical method not guaranteed to be optimal or perfect, sufficient for immediate goals Called easiest NP-hard problem.

Problem Statement Let A represent a finite list of positive integers. A = {Z1, Z2, …, Zn-1, Zn} and let P be a family of any number of sets, P = {S1, S2, …, Sm-1, Sm} into which A can be partitioned. To be partitioned properly: Each integer, Zj, in list A must be a member of one of the nonempty subsets, Si. The subsets must be disjoint. If Si and Sj ε P the two sets Si and Sj are disjoint if Si ∩ Sj = Ø

Problem Statement Cont.

Testing Greedy Karmarkar-Karp Set Differencing Experimental Algorithm performance is measured by comparing each partitions sum to the ‘ideal’ value and the time it takes to generate any number of partitions for any size starting set

All three algorithms run with randomly generated sets with various amounts of starting elements with Poisson and Uniform distribution

Greedy Algorithm Greedy approach includes making the locally optimal choice at each stage. With hope of finding a global optimum For this application the algorithm will iterate through the numbers in descending order, assigning them whichever subset has the smallest sum. Sort set to descending Place the first numbers While length of starting set != 0 Determine sums of partitioned sets Remove next number from starting set Insert removed number into smallest sumed subset

Greedy Algorithm O(nlogn) Does very well with small number of partitions no matter the size of the starting sets Even with increasing partitions results had a smaller imbalance Consistent through multiple distributions and moderately quick for the quality of results

Karmarkar-Karp Set Differencing A set is represented as a collection of subpartitions, each with k subset sums. The initial numbers are each represented by a subpartition with the number itself in one subset, and the remaining subsets empty Through combining and differencing, the subpartitions are completed and then the actual partitions are reconstructed.

Karmarkar-Kar Differencing For 3-way partition: (8, 7, 6, 5, 4) -> ((8, 0, 0), (7, 0, 0), (6, 0, 0), (5, 0, 0), (4, 0, 0)) ((8, 7, 0), (6, 0, 0), (5, 0, 0), (4, 0, 0)) -> ((8, 7, 6), (5, 0, 0), (4, 0, 0)) ((5, 0, 0), (4, 0, 0), (2, 1, 0)) -> ((5, 4, 0), (2, 1, 0)) Largest + smallest, medium + medium, smallest + largest Sum differences: ((5 + 0), (4 + 1), (0 + 2)) -> (5, 5, 2) -> (3, 3, 0) Partitions are formed when the subset sums are combined: 5 + 0(6) -> {5, 6}, 4 + 1(7) -> {4, 7}, 0 + 2(8) -> {8} Final partition: ({5, 6}, {4, 7}, {8}) with a final difference of 3

Experimental Brute-ish Force Algorithm Step by step cause and effect. Greedy in the sense it picks best case for set, but with ideal goal put in priority. We increment through starting set adding numbers to subsets closest to ideal value. The algorithm will not proceed until a value has been assigned so a higher and lower boundary of the ideal value is incremented up to insure the value will eventually be assigned. While != complete For j in start set Reset index Set assigned false While not assigned Else if the sum is still under ideal value - add to partitioned set Else increment index - keep index < number of partitions

Experimental Brute-ish Force O (N^2) Slower but accurate Accurate results with large and small number of partitions Results are accurate but not perfect A large trade for quality increase but increase in time

Results Results for a list of 100,000 integers placed into 20 subsets KK - Poisson (0.0467) Uniform(.062) The “Algorithm - Poission (43.646) Uniform(70.203) Greedy - Poission (17.353) Uniform(25.225)

KK The “Algorithm” Greedy

Questions 1. Clearly define the Partitioning Problem: The Partitioning Problem Is the task of deciding if a set of positive integers can be partitioned into two or more subsets of equal sum. 2. What is Dynamic Programming? - A Method that breaks down complex problems into simpler sub problems, solving the sub problems once and storing the solutions

3. What does Heuristic mean and how is it relevant to the Partitioning Problem? - A Heuristic approach is any approach to problem solving that employs a practical method not guaranteed to be optimal or perfect. A heuristic outcome can often be sufficient for immediate goals. - This relates to the Partitioning Problem in that a list of elements cannot always be partitioned into sets of equal sums. o Ex. 100 can be Partitioned three ways as 33, 33, 34; However, a perfect solution cannot be represented in whole numbers. o In this example the solution could be interpreted as being Heuristic, as a perfect solution does not exist. o Many algorithms used to solve the Partitioning problem give a Heuristic output that is not always in the form of perfect partitioning.

4. What is the difference between a Poisson and Uniform distribution? Poisson distribution is a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval of time and/or space if these events occur with a known average rate and independently of the time since the last event. In partitioning a Poisson curve can determine frequency of numbers that show up in your initial list. - Uniform distribution is a distribution with a constant probability that does not change over distance or time.

5. Why are brute force algorithms a terrible way to output a possible solution to n-way Partitioning? - Despite usually being able to find an optimal answer, Brute force and Exhaustive Search will eventually become impractical after a while due to the massive number of possibilities by which a set can be divided. - Take for example the number 100 which can be partitioned nearly 200 million different ways.