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 #492: [Model] 3Partition
* Implement #492: [Model] 3Partition
* chore: remove plan file after implementation
* cargo fmt
* Adapt ThreePartition to current API: Value=Or, declare_variants!, find_witness
* Paper: derive 3-Partition example groups from optimal_config instead of hardcoded slices
* Hoist u128 bound conversion out of validation loop
---------
Co-authored-by: Xiwei Pan <xiwei.pan@connect.hkust-gz.edu.cn>
@@ -4587,6 +4588,43 @@ A classical NP-complete problem from Garey and Johnson @garey1979[Ch.~3, p.~76],
4587
4588
*Example.* Let $A = {5, 3, 8, 2, 7, 1}$ ($n = 6$) and $K = 3$ groups. The partition $A_1 = {8, 1}$, $A_2 = {5, 2}$, $A_3 = {3, 7}$ gives group sums $9, 7, 10$ and sum of squares $81 + 49 + 100 = 230$. The optimal partition has group sums ${9, 9, 8}$ yielding $81 + 81 + 64 = 226$.
4588
4589
]
4589
4590
4591
+
#{
4592
+
let x = load-model-example("ThreePartition")
4593
+
let sizes = x.instance.sizes
4594
+
let bound = x.instance.bound
4595
+
let config = x.optimal_config
4596
+
let m = int(sizes.len() / 3)
4597
+
// Group elements by their assignment in optimal_config
4598
+
let groups = range(m).map(g => {
4599
+
let indices = range(sizes.len()).filter(i => config.at(i) == g)
4600
+
indices.map(i => sizes.at(i))
4601
+
})
4602
+
[
4603
+
#problem-def("ThreePartition")[
4604
+
Given a set $A = {a_0, dots, a_(3m-1)}$ of $3m$ elements, a bound $B in ZZ^+$, and sizes $s(a) in ZZ^+$ such that $B/4 lt s(a) lt B/2$ for every $a in A$ and $sum_(a in A) s(a) = m B$, determine whether $A$ can be partitioned into $m$ disjoint triples $A_1, dots, A_m$ with $sum_(a in A_i) s(a) = B$ for every $i$.
4605
+
][
4606
+
3-Partition is Garey and Johnson's strongly NP-complete benchmark SP15 @garey1979. Unlike ordinary Partition, the strict size window forces every feasible block to contain exactly three elements, making the problem the canonical source for strong NP-completeness reductions to scheduling, packing, and layout models. The implementation in this repository uses one group-assignment variable per element, so the exported exact-search baseline is $O^*(3^n)$#footnote[This is the direct worst-case bound induced by the implementation's configuration space and matches the registered catalog expression `3^num_elements`; no sharper general exact bound was independently verified while preparing this entry.].
4607
+
4608
+
*Example.* Let $B = #bound$ and consider the #(sizes.len())-element instance with sizes $(#sizes.map(str).join(", "))$. The witness triples #groups.enumerate().map(((i, g)) => [$A_#(i+1) = {#g.map(str).join(", ")}$]).join([ and ]) both sum to $#bound$, so this instance is satisfiable.
0 commit comments