-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Motivation
CONSECUTIVE ONES MATRIX AUGMENTATION (P164) from Garey & Johnson, A4 SR16. An NP-complete problem from the domain of storage and retrieval, asking whether a binary matrix can be made to have the consecutive ones property (C1P) by changing at most K zeros to ones. It arises in information retrieval, physical mapping of DNA, and sparse matrix compression. The C1P is testable in polynomial time using PQ-trees, but augmenting a matrix to achieve it is NP-complete.
Associated rules:
- R110: Optimal Linear Arrangement -> Consecutive Ones Matrix Augmentation (as target)
Definition
Name: ConsecutiveOnesMatrixAugmentation
Canonical name: CONSECUTIVE ONES MATRIX AUGMENTATION
Reference: Garey & Johnson, Computers and Intractability, A4 SR16
Mathematical definition:
INSTANCE: An m x n matrix A of 0's and 1's and a positive integer K.
QUESTION: Is there a matrix A', obtained from A by changing K or fewer 0 entries to 1's, such that A' has the consecutive ones property for columns? (That is, there exists a permutation of the columns of A' such that in each row the 1's appear consecutively.)
Variables
- Count: The decision variables are: (1) a column permutation (n! possibilities), and (2) which zero entries to flip to one (at most K of the m*n - nnz(A) zero entries).
- Per-variable domain: For the column permutation: each column maps to a position in {1, ..., n}. For the augmentation: each zero entry is either flipped (1) or not (0).
- Meaning: A satisfying assignment is a set S of zero-entries of A with |S| <= K, and a column permutation pi, such that after flipping S to ones and applying pi, every row has its ones in a contiguous block.
Schema (data type)
Type name: ConsecutiveOnesMatrixAugmentation
Variants: None
| Field | Type | Description |
|---|---|---|
matrix |
Vec<Vec<bool>> |
The m x n binary matrix A (row-major) |
bound |
i64 |
The positive integer K (max number of 0->1 flips allowed) |
Notes:
- This is a satisfaction (decision) problem:
Metric = bool, implementingSatisfactionProblem. - The consecutive ones property (C1P) for columns means there exists a column permutation such that in every row the 1-entries are contiguous.
- The variant asking for the circular ones property (1's wrap around) is also NP-complete per GJ.
Complexity
- Best known exact algorithm: O(n! · m · n) by enumerating all n! column permutations and for each computing the minimum 0→1 flips needed per row in O(m · n) time. For fixed K, the problem may admit FPT algorithms parameterized by K.
- Complexity string:
"factorial(num_cols) * num_rows * num_cols" - NP-completeness: NP-complete [Booth, 1975, Theorem 4.19], [Papadimitriou, 1976a]. Both independently observed that the k-augmented C1P problem is NP-complete, via reduction from Simple Optimal Linear Arrangement. G&J cites [Papadimitriou, 1976a] which is the bandwidth minimization paper; the NP-completeness observation for C1P augmentation appeared in the earlier technical report (TR-173, Princeton, December 1974).
- Related polynomial results: Testing whether a matrix already has the C1P (K=0) is solvable in linear time O(m + n + number of ones) using PQ-trees [Booth and Lueker, 1976].
- Approximation: Negative results are known: a large class of simple augmentation algorithms cannot find a near-optimum solution [Veldhorst, 1985].
- References:
- K. S. Booth (1975). "PQ Tree Algorithms." Ph.D. thesis, University of California, Berkeley.
- K. S. Booth and G. S. Lueker (1976). "Testing for the consecutive ones property, interval graphs, and graph planarity using PQ-tree algorithms." J. Computer and System Sciences, 13:335-379.
- C. H. Papadimitriou (1976). "The NP-completeness of the bandwidth minimization problem." Computing, 16:263-270.
- M. Veldhorst (1985). "Approximation of the consecutive ones matrix augmentation problem." SIAM Journal on Computing, 14(3):709-729.
Extra Remark
Full book text:
INSTANCE: An m x n matrix A of 0's and 1's and a positive integer K.
QUESTION: Is there a matrix A', obtained from A by changing K or fewer 0 entries to 1's, such that A' has the consecutive ones property?
Reference: [Booth, 1975], [Papadimitriou, 1976a]. Transformation from OPTIMAL LINEAR ARRANGEMENT.
Comment: Variant in which we ask instead that A' have the circular ones property is also NP-complete.
How to solve
- It can be solved by (existing) bruteforce -- enumerate all column permutations and for each, count the minimum number of 0->1 flips needed to make each row consecutive; check if total <= K.
- It can be solved by reducing to integer programming -- binary variables for column ordering and augmentation decisions, with C1P constraints linearized.
- Other: PQ-tree based approaches can enumerate valid orderings efficiently when the matrix is close to having C1P; branch-and-bound with C1P feasibility tests.
Example Instance
Instance 1 (YES instance):
This matrix is the vertex-edge incidence matrix of a graph on 4 vertices {0,1,2,3} with 5 edges: {0,1}, {1,2}, {2,3}, {0,3}, {0,2}. Rows correspond to vertices and columns to edges.
Matrix A (4 x 5):
Row 0: [1, 0, 0, 1, 1] (vertex 0: incident to e01, e03, e02)
Row 1: [1, 1, 0, 0, 0] (vertex 1: incident to e01, e12)
Row 2: [0, 1, 1, 0, 1] (vertex 2: incident to e12, e23, e02)
Row 3: [0, 0, 1, 1, 0] (vertex 3: incident to e23, e03)
K = 2
Column permutation: π = [0, 1, 4, 2, 3] (reorder columns as e01, e12, e02, e23, e03).
After applying π:
Row 0: [1, 0, 1, 0, 1] — 1's at positions 0, 2, 4 (gaps at 1 and 3)
Row 1: [1, 1, 0, 0, 0] — 1's at positions 0, 1 (consecutive, no flips needed)
Row 2: [0, 1, 1, 1, 0] — 1's at positions 1, 2, 3 (consecutive, no flips needed)
Row 3: [0, 0, 0, 1, 1] — 1's at positions 3, 4 (consecutive, no flips needed)
Only Row 0 needs augmentation: flip A[0][1] = 0→1 and A[0][2] = 0→1 (2 flips).
Augmented matrix A' after permutation π (C1P verified):
Row 0: [1, 1, 1, 1, 1] — consecutive ✓
Row 1: [1, 1, 0, 0, 0] — consecutive ✓
Row 2: [0, 1, 1, 1, 0] — consecutive ✓
Row 3: [0, 0, 0, 1, 1] — consecutive ✓
Total flips: 2 ≤ K = 2. Answer: YES.
Brute-force verification (120 total permutations): 8 permutations achieve 2 flips (optimal), 32 achieve 3, 40 achieve 4, 32 achieve 5, 8 achieve 6. No permutation achieves 0 or 1 flip, confirming K = 2 is tight.
Instance 2 (NO instance):
Matrix A (4 x 4):
Row 0: [1, 0, 1, 0]
Row 1: [0, 1, 0, 1]
Row 2: [1, 1, 0, 1]
Row 3: [0, 1, 1, 0]
K = 0
Brute-force verification: all 24 column permutations require at least 1 flip to achieve C1P. The best permutations need exactly 1 flip (4 permutations), while others need 2 (8 perms), 3 (8 perms), or 4 (4 perms). Since K = 0 and no permutation achieves C1P with 0 flips, the answer is NO.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status