Content deleted Content added
Erel Segal (talk | contribs) |
MisterWeazel (talk | contribs) →Variants: added a factor 7 that was missing |
||
(15 intermediate revisions by 7 users not shown) | |||
Line 1:
{{Short description|Strongly NP-complete problem in computer science}}
The '''3-partition problem''' is a [[Strong NP-completeness|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:
* Input: a multiset ''S'' containing ''n'' positive integer elements.
* Conditions: ''S'' must be partitionable into ''m'' triplets, ''S''<sub>1</sub>, ''S''<sub>2</sub>,
* Output: whether or not there exists a partition of ''S'' such that, for all triplets, the sum of the elements in each triplet equals ''T''.
Line 23 ⟶ 24:
==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 ''S<sub>u</sub>'' of the unrestricted variant, construct a new instance of the restricted version {{math|''S<sub>r</sub>'' ≔ {s + 2{{hsp|''T''}} {{!}} s ∈ ''S<sub>u</sub>''}}}. Every solution of ''S<sub>u</sub>'' corresponds to a solution of ''S<sub>r</sub>'' but with a sum of 7{{hsp|''T''}} instead of ''T'', and every element of ''S<sub>r</sub>'' is in {{nowrap|[2{{hsp|''T''}}, 3{{hsp|''T''}}]}} which is contained in {{nowrap|{{pars|7{{hsp|''T''}}/4, 7{{hsp|''T''}}/2}}}}.
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.<ref>{{Cite journal|last1=Hulett|first1=Heather|last2=Will|first2=Todd G.|last3=Woeginger|first3=Gerhard J.|date=2008-09-01|title=Multigraph realizations of degree sequences: Maximization is easy, minimization is hard|url=http://www.sciencedirect.com/science/article/pii/S0167637708000552|journal=Operations Research Letters|language=en|volume=36|issue=5|pages=594–596|doi=10.1016/j.orl.2008.05.004|issn=0167-6377|url-access=subscription}}</ref>
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 ''S<sub>r</sub>'' of the restricted variant, with 3''m'' items summing up to ''mT'', construct a new instance of the unrestricted variant {{math|''S<sub>u</sub>'' ≔ {s + 2''T'' {{!}} s ∈ ''S<sub>r</sub>''}}}, with 3m items summing up to 7mT, and with target sum 7{{hsp|''T''}}. Every solution of ''S<sub>r</sub>'' naturally corresponds to a solution of ''S<sub>u</sub>''. Conversely, in every solution of ''S<sub>u</sub>'', since the target sum is 7{{hsp|''T''}} and each element is in {{nowrap|{{pars|7{{hsp|''T''}}/4, 7{{hsp|''T''}}/2}}}}, there must be exactly 3 elements per set, so it corresponds to a solution of ''S<sub>r</sub>''.
The '''
The '''4-partition problem''' is a variant in which ''S'' contains ''n'' = 4{{hsp|''m''}} integers, the sum of all integers is {{tmath|m T}}, 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-partition''' is a variant of 4-partition in which 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]].<ref>{{cite journal|author=[[Michael Garey|Garey, Michael R.]] and [[David S. Johnson]]|year=1975|title=Complexity
=== Reduction from 3d-matching to
We are given an instance of E of 3d-matching, containing some ''m'' triplets {w<sub>i</sub>,x<sub>j</sub>,y<sub>k</sub>}, where the vertices are w<sub>1</sub>,...,w<sub>q</sub> and x<sub>1</sub>,...,x<sub>q</sub> and y<sub>1</sub>,...,y<sub>q</sub>. We construct an instance
* For each triplet t = {w<sub>i</sub>,x<sub>j</sub>,y<sub>k</sub>} in E, the set A contains an element u<sub>t</sub> = 10r<sup>4</sup>-kr<sup>3</sup>-jr<sup>2</sup>-ir
* For each triplet t = {w<sub>i</sub>,x<sub>j</sub>,y<sub>k</sub>} in E,
** x<sub>j</sub>[1] = 10r<sup>4</sup>+jr<sup>2</sup>
** y<sub>k</sub>[1] = 10r<sup>4</sup>+kr<sup>3</sup>
* The sum of every three "real" elements or every three "dummy" elements is 30r<sup>4</sup>+ir+jr<sup>2</sup>+kr<sup>3</sup>
* The threshold for the
▲* For each triplet t = {w<sub>i</sub>,x<sub>j</sub>,y<sub>k</sub>} in E, A contains an element u<sub>t</sub> = 10r<sup>4</sup>-kr<sup>3</sup>-jr<sup>2</sup>-ir+8.
▲* For each triplet t = {w<sub>i</sub>,x<sub>j</sub>,y<sub>k</sub>} in E, A contains elements w<sub>it</sub>, x<sub>jt</sub>, y<sub>kt</sub>. So for each of w<sub>i</sub>, x<sub>j</sub>, y<sub>k</sub>, there may be many corresponding elements in A - one for each triplet in which they appear. We consider one of these elements (denoted by "1") as the "real" one, and the others as "dummy" ones. The element sizes are as follows:
▲** w<sub>i</sub>[1] = 10r<sup>4</sup>+ir+1; w<sub>i</sub>[2+] = 11r<sup>4</sup>+ir+1.
▲** x<sub>j</sub>[1] = 10r<sup>4</sup>+jr<sup>2</sup>+2; x<sub>j</sub>[2+] = 11r<sup>4</sup>+jr<sup>2</sup>+2.
▲** y<sub>k</sub>[1] = 10r<sup>4</sup>+kr<sup>3</sup>+4; y<sub>k</sub>[2+] = 8r<sup>4</sup>+kr<sup>3</sup>+4.
▲* The sum of every three "real" elements or every three "dummy" elements is 30r<sup>4</sup>+ir+jr<sup>2</sup>+kr<sup>3</sup>+7; and of the triplet element is added, the sum is 40r<sup>4</sup>+15.
▲* The threshold for the 4-partition instance is T=40r<sup>4</sup>+15. Note that the size of each element is in (T/3,T/5).
▲Given a perfect matching in ''E'', we construct a 4-partition of A as follows:
* For each triplet ''t='' {''w<sub>i</sub>,x<sub>j</sub>,y<sub>k</sub>''} in the matching, we construct a 4-set {u<sub>t</sub>, w<sub>i</sub>[1], x<sub>j</sub>[1], y<sub>k</sub>[1]}.
* For each triplet not in the matching, we construct a similar 4-set, but with the corresponding dummy elements.
In both cases, the sum of the 4-set is 40r<sup>4</sup> as needed.
Given a
Note that, in the above reduction, the size of each element is polynomial in the input size; hence, this reduction shows that
=== 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 4''m'' elements:
* For each element a in A, the corresponding element has size 16a+1;
* For each element b in B, the corresponding element has size 16b+2;
* For each element c in C, the corresponding element has size 16c+4;
* For each element d in D, the corresponding element has size 16d+8.
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.
▲Given a 4-partition of A, the sum of each 4-set is 40r<sup>4</sup>+15, and therefore it must contain elements whose size ends with +1, +2, +4, +8; that is, three vertex-elements and one triplet-element. Moreover, the terms with r, r<sup>2</sup> and r<sup>3</sup> must cancel out, and the terms with r<sup>4</sup> must sum up to 40r<sup>4</sup>; therefore, 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.
Using a similar reduction, ABC-partition can be reduced to 3-partition.
▲Note that, in the above reduction, the size of each element is polynomial in the input size; hence, this reduction shows that 4-partition is ''strongly'' NP-hard.
=== Reduction from 4-partition to 3-partition ===
Line 80 ⟶ 92:
== Applications ==
The NP-hardness of 3-partition was used to prove the NP-hardness [[rectangle packing]], as well as of [[Tetris#Computational complexity|Tetris]]<ref>{{Cite journal|date=2002-10-28|title=Tetris is hard, even to approximate|url=http://dx.doi.org/10.1038/news021021-9|journal=Nature|doi=10.1038/news021021-9|issn=0028-0836|url-access=subscription}}</ref><ref>{{Cite journal|last1=BREUKELAAR|first1=RON|last2=DEMAINE|first2=ERIK D.|last3=HOHENBERGER|first3=SUSAN|last4=HOOGEBOOM|first4=HENDRIK JAN|last5=KOSTERS|first5=WALTER A.|last6=LIBEN-NOWELL|first6=DAVID|title=Tetris is Hard, Even to Approximate|date=2004-04-01|url=http://dx.doi.org/10.1142/s0218195904001354|journal=International Journal of Computational Geometry & Applications|volume=14|issue=1n02|pages=41–68|doi=10.1142/s0218195904001354|issn=0218-1959|arxiv=cs/0210020|s2cid=1177 }}</ref> and some other puzzles,<ref>{{Cite journal|last1=Demaine|first1=Erik D.|last2=Demaine|first2=Martin L.|date=2007-06-01|title=Jigsaw Puzzles, Edge Matching, and Polyomino Packing: Connections and Complexity|url=http://dx.doi.org/10.1007/s00373-007-0713-4|journal=Graphs and Combinatorics|volume=23|issue=S1|pages=195–208|doi=10.1007/s00373-007-0713-4|s2cid=17190810 |issn=0911-0119|url-access=subscription}}</ref> and some [[Job scheduling|job scheduling problems]].<ref>{{Cite journal|last1=Bernstein|first1=D.|last2=Rodeh|first2=M.|last3=Gertner|first3=I.|date=1989|title=On the complexity of scheduling problems for parallel/pipelined machines|url=http://dx.doi.org/10.1109/12.29469|journal=IEEE Transactions on Computers|volume=38|issue=9|pages=1308–1313|doi=10.1109/12.29469|issn=0018-9340|url-access=subscription}}</ref>
==References==
|