feat: Feature parity with ProblemReductions.jl#4
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR brings the Rust crate to feature parity with ProblemReductions.jl by introducing a typed reduction framework, runtime reduction path discovery, new topology and utility modules, and substantial new documentation and integration tests.
Changes:
- Added core reduction traits (
ReduceTo,ReductionResult) plus concrete reductions and a runtimeReductionGraphfor path discovery. - Introduced new topology/utilities (
HyperGraph,UnitDiskGraph,TruthTable, JSON I/O helpers) and exposed them via the crate API/prelude. - Added extensive integration tests and mdBook documentation, plus CI workflows and README/book updates.
Reviewed changes
Copilot reviewed 51 out of 53 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/reduction_tests.rs | New integration tests covering reduction correctness, chaining, topology, truth tables, and JSON roundtrips. |
| src/truth_table.rs | Adds TruthTable utility (bitvec-backed) with logic-gate constructors and serde support. |
| src/topology/unit_disk_graph.rs | Adds UnitDiskGraph topology type with derived edges + helpers. |
| src/topology/mod.rs | Exposes topology module APIs. |
| src/topology/hypergraph.rs | Adds HyperGraph topology type and helpers. |
| src/rules/vertexcovering_independentset.rs | Implements IndependentSet ↔ VertexCovering reductions. |
| src/rules/traits.rs | Introduces core reduction traits (ReduceTo, ReductionResult). |
| src/rules/spinglass_qubo.rs | Implements SpinGlass ↔ QUBO reductions. |
| src/rules/spinglass_maxcut.rs | Implements SpinGlass ↔ MaxCut reductions (ancilla for onsite fields). |
| src/rules/mod.rs | Wires up and re-exports rules modules. |
| src/rules/independentset_setpacking.rs | Implements IndependentSet ↔ SetPacking reductions. |
| src/rules/graph.rs | Adds runtime ReductionGraph with path discovery helpers. |
| src/models/set/set_packing.rs | Adds weights_ref accessor to support reductions without cloning via trait method. |
| src/models/graph/vertex_covering.rs | Adds weights_ref accessor. |
| src/models/graph/max_cut.rs | Adds with_weights constructor and edge_weights accessor. |
| src/models/graph/independent_set.rs | Adds weights_ref accessor. |
| src/lib.rs | Exposes new modules and exports reduction traits in the prelude. |
| src/io.rs | Adds JSON/string/file IO helpers and tests. |
| src/error.rs | Adds IO/serialization error variants. |
| docs/src/topology.md | Documents topology types and sample usage. |
| docs/src/solvers.md | Documents solver usage and configuration. |
| docs/src/reductions/using.md | Documents basic and chained reduction usage. |
| docs/src/reductions/index.md | Documents reduction overview and trait contracts. |
| docs/src/reductions/graph.md | Documents ReductionGraph usage and API. |
| docs/src/reductions/available.md | Documents available reductions and examples. |
| docs/src/problems/specialized.md | Documents specialized problems. |
| docs/src/problems/set.md | Documents set problems and SetPacking relationship. |
| docs/src/problems/satisfiability.md | Documents satisfiability problems. |
| docs/src/problems/optimization.md | Documents optimization problems. |
| docs/src/problems/index.md | Documents problem categories and core interface. |
| docs/src/problems/graph.md | Documents graph problems and relationships. |
| docs/src/io.md | Documents JSON I/O helpers. |
| docs/src/introduction.md | Adds mdBook introduction. |
| docs/src/getting-started.md | Adds mdBook getting started guide. |
| docs/src/contributing.md | Adds contributing guide. |
| docs/src/api.md | Adds mdBook API entry points and links. |
| docs/src/SUMMARY.md | Adds mdBook table of contents. |
| docs/plans/2025-01-25-feature-parity-implementation.md | Adds implementation plan documentation. |
| docs/plans/2025-01-25-feature-parity-design.md | Adds design documentation. |
| book.toml | Adds mdBook configuration. |
| README.md | Updates README with badges, overview, examples, and docs links. |
| Cargo.toml | Adds serde_json dependency. |
| Cargo.lock | Locks serde_json transitive updates. |
| .github/workflows/docs.yml | Adds GitHub Pages docs deployment (mdBook + rustdoc). |
| .github/workflows/ci.yml | Adds CI (test/fmt/clippy/coverage) workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Design for porting remaining features from ProblemReductions.jl: - Hybrid reduction framework (compile-time traits + runtime registry) - 14 reduction rules between problem types - Topology types (HyperGraph, UnitDiskGraph) - TruthTable utility - File I/O support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
13 tasks covering: - Core reduction traits and framework - 14 reduction rules with TDD approach - ReductionGraph for path finding - Topology types (HyperGraph, UnitDiskGraph) - TruthTable and File I/O utilities - Integration tests and coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- GitHub Actions CI workflow (test, clippy, fmt, coverage) - GitHub Actions docs workflow (mdBook to GitHub Pages) - Codecov integration - README badges (CI, coverage, crates.io, docs.rs) - mdBook structure with user guide chapters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds the ReductionResult and ReduceTo traits that form the foundation for problem reductions between NP-hard problems. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements bidirectional reductions between IS and VC problems. These are complementary problems - an IS complement is always a VC. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements bidirectional reductions between IS and SetPacking problems. IS maps to SP via edge-incident sets; SP maps to IS via intersection graph. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements bidirectional reductions between SpinGlass (Ising) and QUBO. Uses the transformation s = 2x - 1 to convert between spin and binary. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements bidirectional reductions between SpinGlass and MaxCut. MaxCut maps directly to SpinGlass; SpinGlass uses ancilla for onsite fields. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements a runtime graph of all registered reductions with path finding capabilities using petgraph's all_simple_paths algorithm. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements specialized graph topologies: - HyperGraph: edges can connect any number of vertices - UnitDiskGraph: vertices at 2D positions with distance-based edges 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements a truth table type with built-in support for common gates (AND, OR, NOT, XOR, NAND, NOR, XNOR, implies) and operations for combining and manipulating truth tables. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add src/io.rs with JSON serialization support - Add IoError and SerializationError variants to error types - Add serde_json dependency - Create comprehensive reduction tests (29 tests) - Add CI/CD workflows for testing and docs deployment - Add mdBook documentation with user guide - Add README with badges for CI, coverage, crates.io, docs.rs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove rustfmt CI job - Fix needless_range_loop warnings in matching, maximal_is, sat - Fix collapsible_if in vertex_covering - Fix doc_lazy_continuation in bmf - Allow should_implement_trait for BooleanExpr::not - Fix map_entry in paintshop using HashSet - Fix needless_range_loop in independentset_setpacking - Allow neg_cmp_op_on_partial_ord in brute_force 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Address PR review comment: compute_energy expects spins in {-1,+1},
but tests were casting 0/1 configs directly to i32. Now using
SpinGlass::config_to_spins for proper conversion.
Also fix clippy warning for useless_vec in matching.rs test.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
08cefd3 to
da3f6b7
Compare
This was referenced Feb 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements feature parity with ProblemReductions.jl, adding comprehensive reduction infrastructure, topology types, and utilities.
Changes
Core Reduction Framework
ReductionResultandReduceTotraits for type-safe problem reductionsReductionGraphfor discovering reduction paths between problem typesTopology Types
HyperGraph: Graphs with hyperedges connecting multiple verticesUnitDiskGraph: Geometric graphs based on distance thresholdsUtilities
TruthTable: Logic gadget generation (AND, OR, XOR, NAND, NOR, XNOR, IMPLIES, NOT)Testing & Documentation
Stats
Test plan
cargo test)mdbook build)🤖 Generated with Claude Code