Download presentation
Presentation is loading. Please wait.
1
Multi - Way Number Partitioning
2
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.
3
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 = Ø
4
Problem Statement Cont.
5
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
6
All three algorithms run with randomly generated sets with various amounts of starting elements with Poisson and Uniform distribution
7
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
8
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
9
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.
10
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
11
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
12
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
13
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)
14
KK The “Algorithm” Greedy
15
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
16
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.
17
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.
18
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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.