Skip to content

Commit f81fef3

Browse files
GiggleLiuclaude
andauthored
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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ serde_json = "1.0"
2020
thiserror = "1.0"
2121
num-traits = "0.2"
2222
good_lp = { version = "1.8", default-features = false, features = ["highs"], optional = true }
23+
inventory = "0.3"
24+
ordered-float = "5.0"
2325

2426
[dev-dependencies]
2527
rand = "0.8"

0 commit comments

Comments
 (0)