Skip to content

[Model] 3Partition #492

@isPANN

Description

@isPANN

Motivation

3-PARTITION (P142) from Garey & Johnson, A3 SP15. A classical strongly NP-complete problem: given 3m positive integers with each between B/4 and B/2 and total sum mB, can they be partitioned into m triples each summing to B? Unlike the standard PARTITION problem (which is only weakly NP-hard), 3-PARTITION has no pseudo-polynomial-time algorithm unless P = NP. This makes it the canonical source for strong NP-completeness reductions, especially to scheduling and packing problems.

Associated rules (as source):

  • R66: 3-Partition -> Intersection Graph for Segments on a Grid
  • R67: 3-Partition -> Edge Embedding on a Grid
  • R80: 3DM -> 3-Partition (3-Partition as target)
  • R88: 3-Partition -> Dynamic Storage Allocation
  • R98: Partition / 3-Partition -> Expected Retrieval Cost
  • R131: 3-Partition -> Sequencing with Release Times and Deadlines
  • R135: 3-Partition -> Sequencing to Minimize Weighted Tardiness
  • R139: 3-Partition -> Resource Constrained Scheduling
  • R144: 3-Partition -> Flow-Shop Scheduling
  • R147: 3-Partition -> Job-Shop Scheduling
  • R232: 3-Partition -> Bandwidth
  • R233: 3-Partition -> Directed Bandwidth
  • R234: 3-Partition -> Weighted Diameter

Definition

Name: ThreePartition

Reference: Garey & Johnson, Computers and Intractability, A3 SP15

Mathematical definition:

INSTANCE: Set A of 3m elements, a bound B in Z^+, and a size s(a) in Z^+ for each a in A such that B/4 < s(a) < B/2 and such that sum_{a in A} s(a) = mB.
QUESTION: Can A be partitioned into m disjoint sets A_1,A_2,...,A_m such that, for 1 <= i <= m, sum_{a in A_i} s(a) = B (note that each A_i must therefore contain exactly three elements from A)?

Variables

  • Count: 3m (one variable per element, assigning it to a group)
  • Per-variable domain: {1, 2, ..., m} -- the group index to which the element is assigned
  • Meaning: g_i in {1,...,m} is the group for element a_i. The assignment is feasible iff each group contains exactly 3 elements and sum_{j: g_j = k} s(a_j) = B for all k in {1,...,m}.

Schema (data type)

Type name: ThreePartition
Variants: none (no type parameters; sizes and bound are plain positive integers)

Field Type Description
sizes Vec<u64> Positive integer size s(a) for each element a in A
bound u64 Target sum B for each triple

Note: The constraint B/4 < s(a) < B/2 and sum = mB are invariants that should be validated on construction. The number of groups m = sizes.len() / 3.

Complexity

  • Best known exact algorithm: 3-PARTITION is strongly NP-complete, meaning no pseudo-polynomial-time algorithm exists unless P = NP. The subset dynamic programming approach assigns each element to one of approximately 3 states, yielding a worst-case time complexity of O(3^n) where n = 3m is the number of elements. The brute-force approach enumerates all ways to partition 3m elements into m triples, which is O((3m)! / (3!)^m / m!) -- exponential. Because the problem is strongly NP-complete, no algorithm with running time polynomial in the input size (even when numbers are encoded in unary) is known. [Garey & Johnson, 1975; Garey & Johnson, Computers and Intractability, 1979.]
  • Concrete complexity expression: 3^num_elements

Extra Remark

Full book text:

INSTANCE: Set A of 3m elements, a bound B in Z^+, and a size s(a) in Z^+ for each a in A such that B/4 < s(a) < B/2 and such that sum_{a in A} s(a) = mB.
QUESTION: Can A be partitioned into m disjoint sets A_1,A_2,...,A_m such that, for 1 <= i <= m, sum_{a in A_i} s(a) = B (note that each A_i must therefore contain exactly three elements from A)?
Reference: [Garey and Johnson, 1975]. Transformation from 3DM (see Section 4.2).
Comment: NP-complete in the strong sense.

How to solve

  • It can be solved by (existing) bruteforce. (Enumerate all partitions of 3m elements into m triples; check if each triple sums to B.)
  • It can be solved by reducing to integer programming. (Binary ILP: x_{i,k} in {0,1}, sum_k x_{i,k} = 1 for each i, sum_i x_{i,k} = 3 for each k, sum_i x_{i,k} * s(a_i) = B for each k.)
  • Other: Dynamic programming over subset sums (pseudo-polynomial, O(n * B^(m-1))).

Example Instance

Input:
A = {a_1, ..., a_6} (3m = 6 elements, so m = 2)
B = 15
Sizes: s(a_1) = 4, s(a_2) = 5, s(a_3) = 6, s(a_4) = 4, s(a_5) = 6, s(a_6) = 5

  • All sizes satisfy B/4 = 3.75 < s(a_i) < B/2 = 7.5 (strict inequalities hold for all elements)
  • Total sum = 4 + 5 + 6 + 4 + 6 + 5 = 30 = 2 * 15 = mB

Feasible assignment:
A_1 = {a_1, a_2, a_3} = {4, 5, 6} (sum = 15 = B)
A_2 = {a_4, a_5, a_6} = {4, 6, 5} (sum = 15 = B)

Answer: YES -- a valid 3-partition exists.

Non-triviality: Of the 10 possible ways to partition 6 elements into 2 groups of 3, exactly 4 are valid 3-partitions (40%), while the remaining 6 are not -- providing a good mix for round-trip testing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoodAn issue passed all checks.modelA model problem to be implemented.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions