3-partition problem explained

The 3-partition problem is a strongly NP-complete problem in computer science. The problem is to decide whether a given multiset of integers can be partitioned into triplets that all have the same sum. More precisely:

The 3-partition problem remains strongly NP-complete under the restriction that every integer in S is strictly between T/4 and T/2.

Example

  1. The set

S=\{20,23,25,30,49,45,27,30,30,40,22,19\}

can be partitioned into the four sets

\{20,25,45\},\{23,27,40\},\{49,22,19\},\{30,30,30\}

, each of which sums to T = 90.
  1. The set

S=\{1,2,5,6,7,9\}

can be partitioned into the two sets

\{1,5,9\},\{2,6,7\}

each of which sum to T = 15.
  1. (every integer in S is strictly between T/4 and T/2):

S=\{4,5,5,5,5,6\}

, thus m=2, and T=15. There is feasible 3-partition

\{4,5,6\},\{5,5,5\}

.
  1. (every integer in S is strictly between T/4 and T/2):

S=\{4,4,4,6,6,6\}

, thus m=2, and T=15. There is no feasible solution.

Strong NP-completeness

The 3-partition problem remains NP-complete even when the integers in S are bounded above by a polynomial in n. In other words, the problem remains NP-complete even when representing the numbers in the input instance in unary. i.e., 3-partition is NP-complete in the strong sense or strongly NP-complete. This property, and 3-partition in general, is useful in many reductions where numbers are naturally represented in unary.

3-Partition vs Partition

The 3-partition problem is similar to the partition problem, in which the goal is to partition S into two subsets with equal sum, and the multiway number partitioning, in which the goal is to partition S into k subsets with equal sum, where k is a fixed parameter. In 3-Partition the goal is to partition S into m = n/3 subsets, not just a fixed number of subsets, with equal sum. Partition is "easier" than 3-Partition: while 3-Partition is strongly NP-hard, Partition is only weakly NP-hard - it is hard only when the numbers are encoded in non-unary system, and have value exponential in n. When the values are polynomial in n, Partition can be solved in polynomial time using the pseudopolynomial time number partitioning algorithm.

Variants

In the unrestricted-input variant, the inputs can be arbitrary integers; in the restricted-input variant, the inputs must be in (T/4, T/2). The restricted version is as hard as the unrestricted version: given an instance Su of the unrestricted variant, construct a new instance of the restricted version . Every solution of Su corresponds to a solution of Sr but with a sum of 7 instead of T, and every element of Sr is in which is contained in .

In the distinct-input variant, the inputs must be in (T/4, T/2), and in addition, they must all be distinct integers. It, too, is as hard as the unrestricted version.[1]

In the unrestricted-output variant, the m output subsets can be of arbitrary size - not necessarily 3 (but they still need to have the same sum T). The restricted-output variant can be reduced to the unrestricted-variant: given an instance Sr of the restricted variant, with 3m items summing up to mT, construct a new instance of the unrestricted variant, with 3m items summing up to 7mT, and with target sum 7. Every solution of Sr naturally corresponds to a solution of Su. Conversely, in every solution of Su, since the target sum is 7 and each element is in, there must be exactly 3 elements per set, so it corresponds to a solution of Sr.

The ABC-partition problem (also called numerical 3-d matching) is a variant in which, instead of a set S with 3 integers, there are three sets A, B, C with m integers in each. The sum of numbers in all sets is . The goal is to construct m triplets, each of which contains one element from A, one from B and one from C, such that the sum of each triplet is T.[2]

The 4-partition problem is a variant in which S contains n = 4 integers, the sum of all integers is, and the goal is to partition it into m quadruplets, all with a sum of T. It can be assumed that each integer is strictly between T/5 and T/3. Similarly, ABCD-parititon is a variant of 4-partition in which each there are 4 input sets and each quadruplet should contain one element from each set.

Proofs

Garey and Johnson (1975) originally proved 3-Partition to be NP-complete, by a reduction from 3-dimensional matching.[3] The classic reference by Garey and Johnson (1979) describes an NP-completeness proof, reducing from 3-dimensional matching to 4-partition to 3-partition.[4] Logically, the reduction can be partitioned into several steps.

Reduction from 3d-matching to ABCD-partition

We are given an instance of E of 3d-matching, containing some m triplets, where the vertices are w1,...,wq and x1,...,xq and y1,...,yq. We construct an instance of ABCD-partition with 4*m elements, as follows (where r := 32q):

Given a perfect matching in E, we construct a 4-partition of ABCD as follows:

In both cases, the sum of the 4-set is 40r4 as needed.

Given a partition of ABCD, the sum of each 4-set is 40r4. Therefore, the terms with r, r2 and r3 must cancel out, and the terms with r4 must sum up to 40r4; so the 4-set must contain a triplet and 3 matching "real" elements, or a triplet and 3 matching "dummy" elements. From the triplets with the 3 matching "real" elements, we construct a valid perfect matching in E.

Note that, in the above reduction, the size of each element is polynomial in the input size; hence, this reduction shows that ABCD-partition is strongly NP-hard.

Reduction from ABCD-partition to 4-partition

Given an instance of ABCD-partition with m elements per set, threshold T, and sum mT, we construct an instance of 4-partition with 4m elements:

All in all, the sum is 16mT+15m, and the new threshold is 16T+15.

Every ABCD-partition corresponds naturally to a 4-partition. Conversely, in every 4-partition, the sum modulo 16 is 15, and therefore it must contain exactly one item with size modulo 16 = 1, 2, 4, 8; this corresponds to exactly one item from A, B, C, D, from which we can construct an ABCD-partition.

Using a similar reduction, ABC-partition can be reduced to 3-partition.

Reduction from 4-partition to 3-partition

We are given an instance A of 4-partition: 4m integers, a1,...,a4m, each of which in the range (T/3,T/5), summing up to mT. We construct an instance B of 3-partition as follows:

Given a 4-partition of A, we construct a 3-partition for B as follows:

Conversely, given a 3-partition of B, the sum of each 3-set is a multiple of 4, so it must contain either two regular items and one pairing item, or two pairing items and one filler item:

Applications

The NP-hardness of 3-partition was used to prove the NP-hardness rectangle packing, as well as of Tetris[5] [6] and some other puzzles,[7] and some job scheduling problems.[8]

Notes and References

  1. Hulett. Heather. Will. Todd G.. Woeginger. Gerhard J.. 2008-09-01. Multigraph realizations of degree sequences: Maximization is easy, minimization is hard. Operations Research Letters. en. 36. 5. 594–596. 10.1016/j.orl.2008.05.004. 0167-6377.
  2. Web site: Demaine. Erik. 2015. MIT OpenCourseWare - Hardness made Easy 2 - 3-Partition I. https://ghostarchive.org/varchive/youtube/20211214/ZaSMm2xvatw . 2021-12-14 . live. Youtube.
  3. Garey, Michael R. and David S. Johnson. 1975. Complexity results for multiprocessor scheduling under resource constraints. SIAM Journal on Computing. 4. 4. 397–411. 10.1137/0204035.
  4. [Michael Garey|Garey, Michael R.]
  5. 2002-10-28. Tetris is hard, even to approximate. Nature. 10.1038/news021021-9. 0028-0836.
  6. BREUKELAAR. RON. DEMAINE. ERIK D.. HOHENBERGER. SUSAN. HOOGEBOOM. HENDRIK JAN. KOSTERS. WALTER A.. LIBEN-NOWELL. DAVID. Tetris is Hard, Even to Approximate. 2004-04-01. International Journal of Computational Geometry & Applications. 14. 1n02. 41–68. 10.1142/s0218195904001354. 0218-1959. cs/0210020. 1177 .
  7. Demaine. Erik D.. Demaine. Martin L.. 2007-06-01. Jigsaw Puzzles, Edge Matching, and Polyomino Packing: Connections and Complexity. Graphs and Combinatorics. 23. S1. 195–208. 10.1007/s00373-007-0713-4. 17190810 . 0911-0119.
  8. Bernstein. D.. Rodeh. M.. Gertner. I.. 1989. On the complexity of scheduling problems for parallel/pipelined machines. IEEE Transactions on Computers. 38. 9. 1308–1313. 10.1109/12.29469. 0018-9340.