feat: One weight IS↔SP variants, fix complexity metadata, enrich paper#106
feat: One weight IS↔SP variants, fix complexity metadata, enrich paper#106
Conversation
- Add One weight variant for MaximumIndependentSet ↔ MaximumSetPacking reductions using local macros to keep impls DRY - Register MaximumSetPacking<One> variant and add One→i32 weight cast - Remove ConfigIterator (superseded by DimsIterator) - Remove unused testing module (macros never adopted) - Make LinearConstraint::new() pub(crate) (only le/ge/eq delegate to it) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #106 +/- ##
==========================================
- Coverage 96.89% 96.88% -0.02%
==========================================
Files 198 196 -2
Lines 26904 26747 -157
==========================================
- Hits 26068 25913 -155
+ Misses 836 834 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
… paper Variant complexity fixes: - MaximumMatching: 2^n → n^3 (polynomial by Edmonds' blossom) - KColoring<K2>: 2^n → n+m (polynomial bipartiteness test) - KColoring<K3>: 3^n → 1.3289^n (Beigel-Eppstein) - KColoring<K4>: 4^n → 1.7159^n (Wu et al.) - KColoring<K5>: 5^n → 2^n (Zamir) - KColoring<KN>: k^n → 2^n (Björklund et al.) - KSatisfiability<K2>: 2^n → n+m (Aspvall-Plass-Tarjan SCC) Reduction overhead fixes: - IS→SP: universe_size num_vertices → num_edges (sets contain edge indices) - SP→IS: num_edges num_sets → num_sets^2 (intersection graph) - SAT→kSAT: tighter clause/variable bounds for short-clause padding - Factoring→CircuitSAT: 6 assignments + I/O vars per multiplier cell Paper: remove standalone complexity table (Section 2.6), add render-complexity inline in problem-def, enrich all 21 definitions with algorithm context, limitations, and citations verified via web search. Fix MaxClique bound (1.1892→1.1996 via MIS complement). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR extends the reduction/variant metadata system by adding a unit-weight (One) variant for the MaximumIndependentSet ↔ MaximumSetPacking reductions, correcting complexity/overhead metadata used to generate the reduction graph and paper, and removing unused/dead testing/config APIs.
Changes:
- Add
Oneweight variants for MIS ↔ Set Packing reductions and variant-cast support for MaximumSetPacking. - Fix/refresh complexity + reduction-overhead metadata and regenerate
reduction_graph.json; render complexity inline in the paper. - Remove dead APIs and test utilities (
testingmodule,ConfigIterator) and update unit tests accordingly.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/unit_tests/testing/mod.rs | Removes tests for the deleted testing utilities module. |
| src/unit_tests/testing/macros.rs | Removes macro tests for deleted testing macros. |
| src/unit_tests/rules/maximumindependentset_maximumsetpacking.rs | Adds closed-loop tests for One-weighted MIS ↔ SP reductions. |
| src/unit_tests/config.rs | Removes tests tied to deleted ConfigIterator; keeps conversion + dims iterator tests. |
| src/testing/mod.rs | Deletes the public testing utilities module (macros + test-case structs). |
| src/testing/macros.rs | Deletes exported testing macros (graph_problem_tests!, complement_test!, quick_problem_test!). |
| src/rules/sat_ksat.rs | Updates #[reduction(overhead)] formulas for SAT → 3-SAT transformation. |
| src/rules/maximumsetpacking_casts.rs | Adds variant-cast reduction MaximumSetPacking<One> => MaximumSetPacking<i32>. |
| src/rules/maximumindependentset_maximumsetpacking.rs | Generalizes MIS ↔ SP reductions to support both i32 and One; fixes overhead field mapping. |
| src/rules/factoring_circuit.rs | Updates reduction overhead metadata for Factoring → CircuitSAT. |
| src/models/set/maximum_set_packing.rs | Declares MaximumSetPacking<One> variant complexity. |
| src/models/satisfiability/ksat.rs | Fixes K2 (2-SAT) declared complexity to polynomial time. |
| src/models/optimization/ilp.rs | Makes LinearConstraint::new crate-private. |
| src/models/graph/maximum_matching.rs | Fixes declared complexity to polynomial time (n^3). |
| src/models/graph/kcoloring.rs | Updates declared complexities for K-coloring variants. |
| src/lib.rs | Removes pub mod testing export. |
| src/config.rs | Removes ConfigIterator and tightens module docs around DimsIterator. |
| docs/src/reductions/reduction_graph.json | Regenerates graph JSON with updated complexities, nodes/edges, and overhead formulas. |
| docs/paper/references.bib | Adds citations supporting updated complexity claims. |
| docs/paper/reductions.typ | Renders complexity inline from graph JSON; enriches problem definitions with algorithm context. |
| .claude/CLAUDE.md | Documents how to verify declare_variants! complexity and #[reduction(overhead)] formulas. |
Comments suppressed due to low confidence (1)
src/config.rs:6
ConfigIteratorhas been removed from the publicconfigAPI. Even if it was unused internally, this is a breaking change for downstream users who relied on it for uniform-dimension iteration. If intentional, consider documenting the replacement (e.g.,DimsIterator::new(vec![num_flavors; num_variables])) and accounting for the API break in versioning/release notes.
//! Configuration utilities for problem solving.
/// Convert a configuration index to a configuration vector.
///
/// The index is treated as a number in base `num_flavors`.
pub fn index_to_config(index: usize, num_variables: usize, num_flavors: usize) -> Vec<usize> {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/models/graph/kcoloring.rs
Outdated
| KColoring<K2, SimpleGraph> => "num_vertices + num_edges", | ||
| KColoring<K3, SimpleGraph> => "1.3289^num_vertices", | ||
| KColoring<K4, SimpleGraph> => "1.7159^num_vertices", | ||
| KColoring<K5, SimpleGraph> => "2^num_vertices", |
There was a problem hiding this comment.
KColoring<K5, SimpleGraph> is declared with complexity 2^num_vertices, but the paper text in docs/paper/reductions.typ states 5-coloring has an algorithm that breaks the 2^n barrier (Zamir 2021). To keep the rendered complexity (from declare_variants!) consistent with the paper and with the “best known algorithm” convention, update this complexity string (or adjust the paper text if you intentionally want an upper bound).
| KColoring<K5, SimpleGraph> => "2^num_vertices", | |
| KColoring<K5, SimpleGraph> => "<2^num_vertices", |
|
|
||
| #problem-def("KColoring")[ | ||
| Given $G = (V, E)$ and $k$ colors, find $c: V -> {1, ..., k}$ minimizing $|{(u, v) in E : c(u) = c(v)}|$. | ||
| Deciding $k$-colorability is NP-complete for $k >= 3$ @garey1979. Best known: $O(n+m)$ for $k=2$ (equivalent to bipartiteness testing by BFS); $O^*(1.3289^n)$ for $k=3$ @beigel2005; $O^*(1.7159^n)$ for $k=4$ @wu2024; $O^*((2-epsilon)^n)$ for $k=5$, the first to break the $2^n$ barrier @zamir2021; $O^*(2^n)$ in general via inclusion-exclusion over independent sets @bjorklund2009. |
There was a problem hiding this comment.
This section claims 5-coloring runs in reduction_graph.json / declare_variants! (currently KColoring<K5> is 2^num_vertices). Align the complexity metadata with this claim (or soften the claim) so the paper doesn’t present conflicting complexities.
| Deciding $k$-colorability is NP-complete for $k >= 3$ @garey1979. Best known: $O(n+m)$ for $k=2$ (equivalent to bipartiteness testing by BFS); $O^*(1.3289^n)$ for $k=3$ @beigel2005; $O^*(1.7159^n)$ for $k=4$ @wu2024; $O^*((2-epsilon)^n)$ for $k=5$, the first to break the $2^n$ barrier @zamir2021; $O^*(2^n)$ in general via inclusion-exclusion over independent sets @bjorklund2009. | |
| Deciding $k$-colorability is NP-complete for $k >= 3$ @garey1979. Best known upper bounds for deciding $k$-colorability include: $O(n+m)$ for $k=2$ (equivalent to bipartiteness testing by BFS); $O^*(1.3289^n)$ for $k=3$ @beigel2005; $O^*(1.7159^n)$ for $k=4$ @wu2024; $O^*(2^n)$ for $k >= 5$ via inclusion-exclusion over independent sets @bjorklund2009; and faster sub-$2^n$ algorithms are known for $k=5$ @zamir2021. |
| pub mod config; | ||
| pub mod error; | ||
| pub mod export; | ||
| pub(crate) mod expr; | ||
| pub mod io; | ||
| pub mod models; | ||
| pub mod registry; | ||
| pub mod rules; | ||
| pub mod solvers; | ||
| pub mod testing; | ||
| pub mod topology; | ||
| pub mod traits; |
There was a problem hiding this comment.
Removing pub mod testing; is a breaking public API change (downstream users can no longer import problemreductions::testing / its macros). If this is intentional, consider documenting it in release notes and ensuring the versioning strategy accounts for the break.
| impl LinearConstraint { | ||
| /// Create a new linear constraint. | ||
| pub fn new(terms: Vec<(usize, f64)>, cmp: Comparison, rhs: f64) -> Self { | ||
| pub(crate) fn new(terms: Vec<(usize, f64)>, cmp: Comparison, rhs: f64) -> Self { |
There was a problem hiding this comment.
Changing LinearConstraint::new from pub to pub(crate) is a breaking change for external users that constructed constraints via new. If the intent is to force callers onto le/ge/eq, consider noting this in release notes and (optionally) adding a doc comment/deprecation path to guide downstream migration.
| pub(crate) fn new(terms: Vec<(usize, f64)>, cmp: Comparison, rhs: f64) -> Self { | |
| pub fn new(terms: Vec<(usize, f64)>, cmp: Comparison, rhs: f64) -> Self { |
src/rules/factoring_circuit.rs
Outdated
| num_variables = "num_bits_first * num_bits_second", | ||
| num_assignments = "num_bits_first * num_bits_second", | ||
| num_variables = "6 * num_bits_first * num_bits_second + num_bits_first + num_bits_second", | ||
| num_assignments = "6 * num_bits_first * num_bits_second", |
There was a problem hiding this comment.
The num_assignments overhead doesn’t match what reduce_to() constructs. The reduction adds 6 assignments per multiplier cell plus one additional assignment per output bit constraint (loop over m_vars), i.e. num_bits_first + num_bits_second extra assignments. Update the overhead formula accordingly and regenerate docs/src/reductions/reduction_graph.json so the exported graph matches the code.
| num_assignments = "6 * num_bits_first * num_bits_second", | |
| num_assignments = "6 * num_bits_first * num_bits_second + num_bits_first + num_bits_second", |
- Fix KColoring K5 complexity: "2^num_vertices" -> "(2-epsilon)^num_vertices" (Zamir 2021) - Fix Factoring->CircuitSAT num_assignments overhead to include output bit constraints - Add tests for MaximumSetPacking variant cast reductions (One->i32, i32->f64) - Regenerate reduction_graph.json with corrected metadata Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Oneweight variant forMaximumIndependentSet ↔ MaximumSetPackingreductionsConfigIterator, unusedtestingmodule,LinearConstraint::new()publicitydeclare_variants!complexity strings (poly-time problems had exponential bounds)#[reduction(overhead)]formulas (universe mismatch, quadratic edges, cell counts)reduction_graph.jsonwith corrected datarender-complexityTest plan
cargo test)typst compile)🤖 Generated with Claude Code