You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add plan for #416: [Model] SparseMatrixCompression
* Implement #416: [Model] SparseMatrixCompression
* chore: remove plan file after implementation
* fix: cargo fmt after merge with main
* fix: reject --bound 0 in CLI instead of panicking
SparseMatrixCompression::new() asserts bound_k > 0, but the CLI's
parse_nonnegative_usize_bound() accepted 0 and passed it through,
causing a panic. Add an explicit check before construction.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: remove unreachable second pass in storage_vector()
After the first pass succeeds without collisions, the biconditional
a_{ij}=1 iff b[slot]=i is already guaranteed: row labels are unique
and each row only writes to its 1-entry slots. The second pass was
dead code (the codecov-uncovered line).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Xiwei Pan <xiwei.pan@connect.hkust-gz.edu.cn>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
"DirectedTwoCommodityIntegralFlow": [Directed Two-Commodity Integral Flow],
141
142
"IntegralFlowHomologousArcs": [Integral Flow with Homologous Arcs],
142
143
"IntegralFlowWithMultipliers": [Integral Flow With Multipliers],
@@ -6117,6 +6118,110 @@ A classical NP-complete problem from Garey and Johnson @garey1979[Ch.~3, p.~76],
6117
6118
]
6118
6119
}
6119
6120
6121
+
#{
6122
+
let x = load-model-example("SparseMatrixCompression")
6123
+
let A = x.instance.matrix
6124
+
let m = A.len()
6125
+
let n = if m > 0 { A.at(0).len() } else { 0 }
6126
+
let K = x.instance.bound_k
6127
+
let cfg = x.optimal_config
6128
+
let shifts = cfg.map(v => v + 1)
6129
+
let storage = (4, 1, 2, 3, 1, 0)
6130
+
let A-int = A.map(row => row.map(v => if v { 1 } else { 0 }))
6131
+
let row-colors = (
6132
+
graph-colors.at(0),
6133
+
rgb("#f28e2b"),
6134
+
rgb("#76b7b2"),
6135
+
rgb("#e15759"),
6136
+
)
6137
+
[
6138
+
#problem-def("SparseMatrixCompression")[
6139
+
Given an $m times n$ binary matrix $A$ and a positive integer $K$, determine whether there exist a shift function $s: \{1, dots, m\} -> \{1, dots, K\}$ and a storage vector $b in \{0, 1, dots, m\}^{n + K}$ such that, for every row $i$ and column $j$, $A_(i j) = 1$ if and only if $b_(s(i) + j - 1) = i$.
6140
+
][
6141
+
Sparse Matrix Compression appears as problem SR13 in Garey and Johnson @garey1979. It models row-overlay compression for sparse lookup tables: rows may share storage positions only when their shifted 1-entries never demand different row labels from the same slot. The implementation in this crate searches over row shifts only, then reconstructs the implied storage vector internally. This yields the direct exact bound $O(K^m dot m dot n)$ for $m$ rows and $n$ columns.#footnote[The storage vector is not enumerated as part of the configuration space. Once the shifts are fixed, every occupied slot is forced by the 1-entries of the shifted rows.]
6142
+
6143
+
*Example.* Let $A = mat(#A-int.map(row => row.map(v => str(v)).join(", ")).join("; "))$ and $K = #K$. The stored config $(#cfg.map(str).join(", "))$ encodes the one-based shifts $s = (#shifts.map(str).join(", "))$. These shifts place the four row supports at positions $\{2, 5\}$, $\{3\}$, $\{4\}$, and $\{1\}$ respectively, so the supports are pairwise disjoint. The implied overlay vector is therefore $b = (#storage.map(str).join(", "))$, and this is the unique satisfying shift assignment among the $2^4 = 16$ configs in the canonical fixture.
caption: [Canonical Sparse Matrix Compression YES instance. Row-colored 1-entries on the left are shifted into the overlay vector on the right, producing $b = (4, 1, 2, 3, 1, 0)$.],
6220
+
) <fig:sparse-matrix-compression>
6221
+
]
6222
+
]
6223
+
}
6224
+
6120
6225
// Completeness check: warn about problem types in JSON but missing from paper
0 commit comments