Commit f81fef3
feat: Implement set-theoretic reduction path finding (#12)
* docs: Add set-theoretic reduction path finding design
Design document addressing issues #10 and #11:
- Parametric problem modeling with graph type + weight type
- Set-theoretic path validation (A ⊆ C, D ⊆ B)
- Automatic registration via inventory crate
- Polynomial overhead model for output size
- Customizable cost functions for path optimization
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: Add implementation plan for set-theoretic reductions
Detailed step-by-step plan with 25+ bite-sized tasks across 7 phases:
1. Foundation types (graph markers, NumericWeight, Polynomial)
2. Reduction registration (inventory, ReductionEntry, overhead)
3. Update Problem trait (NAME, GraphType, Weight parameters)
4. Update problem implementations (all 14+ problem types)
5. Rewrite ReductionGraph (set-theoretic validation, Dijkstra)
6. Update reduction implementations (add registration)
7. Integration tests
Each task includes exact file paths, complete code, and commit points.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* deps: Add inventory and ordered-float crates
* feat: Add graph marker traits for parametric problems
* feat: Add inventory-based graph subtype registration
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: Add NumericWeight marker trait
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: Add Polynomial type for reduction overhead
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: Add reduction registration with inventory
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: Add PathCostFn trait and built-in cost functions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: Add NAME, GraphType, Weight to Problem trait
Add three new associated items to the Problem trait for parametric
problem modeling and registration:
- const NAME: Base name of the problem type (e.g., "IndependentSet")
- type GraphType: The graph type marker this problem operates on
- type Weight: The numeric weight type for this problem
Update test problem types (SimpleWeightedProblem, SimpleCsp,
MultiFlavorProblem) to implement the new requirements.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor: Add NAME, GraphType, Weight to all Problem implementations
- Add const NAME, type GraphType, and type Weight to all Problem trait
implementations across graph, set, satisfiability, optimization, and
specialized problem types
- Update CSP implementations to use 'static bounds for compatibility
- Add blanket implementation for NumericWeight trait to support generic
weight types that satisfy the required bounds
- Update all reduction rules with 'static lifetime bounds
- Update test problems in brute_force.rs and traits.rs
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor: Implement set-theoretic path finding with cost functions
- Add ReductionEdge struct to store graph type info and overhead on edges
- Build graph hierarchy from GraphSubtypeEntry via inventory
- Implement transitive closure for graph type subtyping
- Add is_graph_subtype() and rule_applicable() for set-theoretic validation
- Add find_cheapest_path() using Dijkstra with custom cost functions
- Auto-discover reductions from inventory::iter::<ReductionEntry>
- Export ReductionEdge from rules module
- Keep backward compatibility with manual reduction registration
- Add comprehensive tests for new functionality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: Register all reductions with inventory for auto-discovery
Add inventory::submit! blocks to all reduction files to enable automatic
registration with the ReductionGraph. This allows the graph to discover
all available reductions at runtime without manual registration.
Changes:
- Modified ReductionEntry to use overhead_fn (function pointer) instead
of overhead field to avoid static allocation issues with Vec/Polynomial
- Added inventory::submit! to 12 reduction files with proper overhead
polynomials:
- vertexcovering_independentset.rs (2 reductions)
- independentset_setpacking.rs (2 reductions)
- matching_setpacking.rs (1 reduction)
- vertexcovering_setcovering.rs (1 reduction)
- spinglass_maxcut.rs (2 reductions)
- spinglass_qubo.rs (2 reductions)
- sat_independentset.rs (1 reduction)
- sat_coloring.rs (1 reduction)
- sat_dominatingset.rs (1 reduction)
- sat_ksat.rs (2 reductions)
- factoring_circuit.rs (1 reduction)
- circuit_spinglass.rs (1 reduction)
- Updated graph.rs to use overhead() method instead of field access
- Fixed test_find_cheapest_path_multi_step to use compatible graph types
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test: Add integration tests for set-theoretic reduction system
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test: Improve coverage for new modules
Add additional tests to improve test coverage for:
- graph_types.rs: declared subtype relationships, Default/Clone/Copy traits, BipartiteGraph and UnitDiskGraph entries
- cost.rs: CustomCost function, Minimize with missing field, MinimizeMax with empty vector
- registry.rs: ReductionEntry overhead evaluation, debug formatting, registered entries verification
- polynomial.rs: zero polynomial, constant polynomial, monomial scale, polynomial scale, multi-variable monomial
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: Address PR review comments
- Remove redundant clone() on Copy type (clippy fix)
- Add comment explaining why explicit subtype declarations are needed
- Remove extra blank line in polynomial.rs
- Document round() usage in registry.rs
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent a4ff2df commit f81fef3
47 files changed
Lines changed: 3786 additions & 72 deletions
File tree
- docs/plans
- src
- models
- graph
- optimization
- satisfiability
- set
- specialized
- rules
- solvers
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
0 commit comments