An efficient Algorithm to partition a Sequence of Integers into Subsets with equal Sums
Alexander B\"uchel, Ulrich Gille{\ss}en, Kurt-Ulrich Witt

TL;DR
This paper introduces an efficient algorithm for partitioning a sequence of integers into subsets with equal sums, addressing a specific NP-hard problem in a more practical context.
Contribution
The paper presents a novel efficient algorithm for the homogeneous subset sum partition problem, improving upon existing methods for this NP-hard challenge.
Findings
Algorithm efficiently partitions sequences into equal-sum subsets
Significant reduction in computational complexity for the homogeneous case
Potential applications in resource allocation and load balancing
Abstract
To partition a sequence of n integers into subsets with prescribed sums is an NP-hard problem in general. In this paper we present an efficient solution for the homogeneous version of this problem; i.e. where the elements in each subset add up to the same sum.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLimits and Structures in Graph Theory · Graph Labeling and Dimension Problems · Advanced Graph Theory Research
**An efficient Algorithm to partition a Sequence of Integers into Subsets with equal Sums **
Alexander Büchel1,2, Ulrich Gilleßen2, Kurt-Ulrich Witt1,2
Bonn-Rhein-Sieg University of Applied Sciences
Department of Computer Science
1b-it Applied Science Institute
2Research Group Discrete Mathematics and Optimization (ADIMO)
Sankt Augustin, Germany
[email protected], [email protected] [email protected]
February 20, 2018
Abstract
Let and be non-negative integers such that and . In this paper we present an efficient algorithm which partitions the elements of into mutually disjoint subsets such that and for each . The algorithm runs in time.
Key words: Set partition problem, Cutting sticks problem
1 Introduction
For let , , and . We call a collection of mutually disjoint subsets a -partition of if
- (i)
for ,
- (ii)
and
- (iii)
.
Given the set and the non-negative integers , , with the related decision problem is to decide, whether there exists a -partition of . Fu und Hu, (1992) show, that for with and a -partition of exists. Chen et al., (2005) prove, that a -partition of exists, if and for and hold. In Büchel et al., (2016) we present a [math]/-linear program to solve partition problems.
In the special case, where we call a -partition of . Given with and the decision problem reduces to the question, whether a partition of exists. Straight and Schillo, (1979) show that for all with and a partition of exists. Ando et al., (1990) withdraw the condition and prove that can be partitioned into disjoint subsets with if and only if .
Where as the cited papers study for which -tuples -partitions of exist, we are interested in efficient algorithms to determine partitions. In this paper we consider problem instances with and . In chapter 3 we introduce the recursive algorithm which efficiently determines a partition for each instance . Before, in chapter 2 we present the so called meander algorithm which solves problem instances , where is even and is a divisor of or where is odd and divides , respectively. The reason is, that can be stopped, when one of these conditions is reached, and the remaining partition can be determined directly by means of the meander algorithm. In chapter 4 we analyze the run time complexity of . Chapter 5 summarizes the paper and mentiones some ideas to improve .
2 Meander Algorithm
For and we denote if is a divisor of . Given the problem instance the meander algorithm applies if ist even and or if is odd an , respectively. The algorithm distributes the elements of the set into the subsets such that
[TABLE]
2.1 Case: even and
Figure 1 shows the part of the meander algorithm which solves problem instances when even and divides .
To prove that the algorithm determines a correct -partition of we have to show (i) that the set of elements assigned to the subsets in (1) and (2) is equal to and (ii) that the resulting partition fulfills condition (2.1). We will verify (i) in Lemma 2.1 and (ii) in Lemma 2.2. Let
[TABLE]
be the sets of elements of which are distributed in assignment (1) or assignment (2), respectively.
Lemma 2.1
Let be a problem instance such that even and , then .
Proof* For each there exist unambiguously such that*
[TABLE]
We consider the two following sets of remainders : and . Since , if , it follows and . Thus with respect to (2.4) we get either
[TABLE]
or
[TABLE]
It follows . Hence we have shown .
If , then , and if then . Thus, if , we have , hence and thereby .
Lemma 2.2
Let be a problem instance with even and , then the output , , of fulfills condition (2.1).
Proof* For each we have*
[TABLE]
Qed.
Theorem 2.1
**
a)* determines a correct partition of for all problem instances with even and , and*
b)* runs in time.*
Proof* a) follows immediately from Lemma 2.1 and 2.2, and b) is obvious.*
2.2 Case: odd and
To solve problem instances with odd and we adapt slightly the --algorithm (see Fig. 2). The correctness of the -algorithm can be shown analogously to the proof of the correctnes of the -algorithm. At this point we define the sets of elements asssigned due to labels (1) and (2) in the -algorithm as
[TABLE]
Lemma 2.3
Let be a problem instance such that odd and , then .
Proof* For each there exist unambiguously such that*
[TABLE]
We consider the sets of remainders : and . Since , if , it follows and . Thus with respect to (2.7) we get
[TABLE]
or
[TABLE]
respectively. It follows . Hence we have shown .
If , then , and if then . Thus, if , we have , hence and thereby .
Lemma 2.4
Let be a problem instance with odd and , then the output , , of fullfills condition (2.1).
Proof* For each we have*
[TABLE]
Qed.
Theorem 2.2
**
a)* determines a correct partition of for all problem instances with odd and , and*
b)* runs in time.*
Proof* a) follows from Lemma 2.3 and 2.4, and b) is obvious.*
3 The Algorithm
In this section we present the different cases which the -algorithm distinguishes. The input to the algorithm is the set and integers with and . The output is a partition , , which fullfills condition (2.1).
3.1 Case:
In this case the algorithm makes a distinction between the cases even and odd.
3.1.1 Case: even
The algorithm starts with filling sets as follows:
[TABLE]
Obviously these sets are disjoint and fullfill condition (2.1). The union of these sets is the set . Thus the elements of the set and the element remain, these have to be distributed into the empty sets. To do this, each of these sets is split into two subsets:
[TABLE]
The total number of these subsets is . The set is filled with the element :
[TABLE]
Thus it remains to distribute the elements of into the sets and , , , i.e. it remains to solve the problem instance where
[TABLE]
We have to verify that this instance fulfills the input conditions
[TABLE]
and
[TABLE]
Using (3.4) – (3.6) we get on one side
[TABLE]
and on the other side
[TABLE]
Since for our initial problem the condition holds, the verification of (3.7) follows immediately from (3.9) and (3.10).
From and even it follows and from this we get . Using (3.4) and (3.6) condition (3.8) is verified, too.
Thus the algorithm can recursively continue to solve the initial problem by determining a solution for the instance .
3.1.2 Case: odd
In this case the algorithm initially fills sets as follows:
[TABLE]
Obviously these sets are disjoint and fullfill condition (2.1). The union of these sets builds the set . Thus the elements of the set remain, these have to be distributed into the empty sets. Thus the instance has to be solved, where
[TABLE]
To proof that this instance is feasible we have to verify, that the input conditions (3.7) and (3.8) are fulfilled in this case as well. Using (3.12) – (3.14) we get on one side
[TABLE]
and on the other side
[TABLE]
Since the verification of (3.7) follows immediately from (3.16) and (3.10).
From it follows . From this we get by means of the input condition and the definitions (3.12) and (3.14): , i.e. condition (3.8) is fulfilled.
3.2 Case:
In this case each set is split into two disjoint subsets: , . The sets will be filled as follows:
[TABLE]
Thereby the elements are already disributed, and the two elements in each of these sets add up to
[TABLE]
It remains to partition the elements of into the sets such that the sum of elements in each equals . Thus it remains to solve the problem instance with
[TABLE]
As well as in the former cases we have to assure, that the input conditions (3.7) and (3.8) are fulfilled. On the one side we have
[TABLE]
and on the other side
[TABLE]
(3.7) follows immediately from (3.22) and (3.23).
From it follows . By subtraction we get and from this and definitions (3.19) and (3.21) , i.e. condition (3.8) is verified.
The considerations so far lead to the algorithm shown in figure 3, and we proved that it works correctly in all cases.
4 Complexity
In this section we analyse the worst case run time complexity of the -Algorithm. The algorithm consists of four subalgorithms related to the cases we distinguish: (1) or , (2) , (3) and even, (4) and odd. We abbreviate these cases by (meander), (smaller), (greater even), and (greater odd), respectively. Then the run can be represented by a sequence .
Example 4.1
a)* Let . The list of runs for all partitions of is:*
[TABLE]
b)* Let , then we have*
[TABLE]
Let be a non empty sequence over , then is the first and the last symbol of , and is the sequence without the last symbol. is the number of occurrences of symbol in the sequence .
Obviously we have
Lemma 4.1
Let be a problem instance, then and is not a member of .
Thus, we may neglect the last symbol of and denote . As well we do not need the alphabet , because . We denote this alphabet by .
Next we show, that the last call before the recursion stops with the -case cannot be .
Lemma 4.2
Let be a problem instance. If , then .
Proof* We assume . Let be the problem instance before the last -call. Then by (3.19) and (3.20) after the -call we have and . Since the next call is it has to be or , i.e. or . It follows or . Hence the instance would have been solved by an -call, a contradiction to our assumption .*
Corollary 4.1
Let be a problem instance. If , then .
4.1 Case: and odd
From we can conclude . Using (3.12) and (3.14) we get . This leads to
Lemma 4.3
Let be a problem instance with , odd and , , , then
a)* , if ,*
b)* , if .*
Thus, after the case the recursion ends by call of the meander algorithm or the recursion continues with the case either.
Corollary 4.2
Let be a problem instance with and odd, then .
4.2 Case: and even
From (3.6) it follows immediately
[TABLE]
4.3 Case:
In this case if the algorithm performs the instance , then the next instance to solve may be with and (cf. subsection 3.2, equations (3.19) and (3.21), respectively). By and we denote the value of and in the recursion call in the case . Thus we have , and , , for example. By induction we get
[TABLE]
Now we determine the order of the maximum value of guaranteeing the condition . Using (4.2) and (4.3) we get
[TABLE]
To determine we solve the quadratic equation
[TABLE]
which has the solutions
[TABLE]
i.e.
[TABLE]
Finally we get
[TABLE]
Thus, we have just proven
Lemma 4.4
Let be a problem instance. If with , then .
Corollary 4.2, inequality (4.1) and Lemma 4.4 lead to
Theorem 4.1
Let be a problem instance.
a)* Then the recursion depth of is .*
b)* Since the complexity of operations the algorithm performs in each recursion call (assigning elements of to some set , arithmetic comparisons and oprerations) is it follows that the worst case run time complexity of is*
[TABLE]
.
5 Conclusion
In section 3 we present the recursive algorithm which solves following subset partition problems: Given and with and , then the algorithm partitions the integers from [math] to into mutually disjoint sets such that the elements in each set add up to . The recursion can be stopped, if ist even and is a divisor or if is odd and is a divisor of , respectively, because in these cases the meander algorithms presented in section 2 can be applied, which directly determines a partition.
We prove that the algorithm works correctly and runs in
[TABLE]
time for each problem instance .
In Jagadish, (2015) an approximation algorithm for the cutting sticks-problem is presented. Because the cutting sticks-problem can be transformed into an equivalent partitioning problem our algorithms can be applied to the corresponding cutting sticks-problems.
Further research may investigate whether ideas from the previous chapters and cited papers can be used to improve the efficiency of the -algorithm. In Büchel et al., (2016), Büchel et al., 2017a and Büchel et al., 2017b we present efficient solutions for problem instances , where , odd; , ; , ; , ; ; and , where is the set of prime numbers. Thus we may augment the -algorithm by related conditions to stop further recursion calls.
Acknowledgement: We would like to thank Arkadiusz Zarychta who created a tool by means of which we are able to test the algorithm and to analyse experimentally its performance.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1Ando et al., (1990) Ando, K., Gervacio, S., Kano, M.: Disjoint Subsets of Integers having a constant Sum, Discrete Mathematics 82, 1990, 7 - 11
- 2Büchel et al., (2016) Büchel, A., Gilleßen, U., Witt, K.-U.: Betrachtungen zum Cutting sticks-Problem (in German), Technical Report 01-2016, Department of Computer Science, Bonn-Rhein-Sieg University of Applied Sciences, 2016
- 3(3) Büchel, A., Gilleßen, U., Witt, K.-U.: Ansätze für effiziente Lösungen von Cutting sticks-Problemen und deren Charakterisierung (in German), Technical Report in preparation, Department of Computer Science, Bonn-Rhein-Sieg University of Applied Sciences, 2017 a
- 4(4) Büchel, A., Gilleßen, U., Witt, K.-U.: Effiziente Lösungen von Spezialfällen des Cutting sticks-Problems (in German), Technical Report in preparation, Department of Computer Science, Bonn-Rhein-Sieg University of Applied Sciences, 2017 b
- 5Chen et al., (2005) Chen, F.-L., Fu, H.-L., Wang, Y., Zhou, J.: Partition of a Set of Integers into Subsets with prescribed Sums, Taiwanese Journal of Mathematics 9, 2005, 629 - 638
- 6Fu und Hu, (1992) Fu, H.-L., Hu, W.-H.: A Special Partition of the Set I n subscript 𝐼 𝑛 I_{n} , Bulletin of the Institute of Combinatorics and its Applications 6, 1992, 57 - 60
- 7Jagadish, (2015) Jagadish, M.: An Approximation Algorithm for the Cutting-Sticks Problem, Information Processing Letters 115, 2015, 170 - 174
- 8Straight and Schillo, (1979) Straight, H. J., Schillo, P.: On the Problem of Partitioning { 1 , … , n } 1 … 𝑛 \left\{1,\ldots,n\right\} into Subsets having equal Sums, Proceedings of the American Mathematical Society 74(2), 1979, 229 - 231
