@@ -26,8 +26,8 @@ make test clippy export-graph # Must pass before PR
2626- ` src/traits.rs ` - ` Problem ` , ` ConstraintSatisfactionProblem ` traits
2727- ` src/rules/traits.rs ` - ` ReduceTo<T> ` , ` ReductionResult ` traits
2828- ` src/registry/ ` - Compile-time reduction metadata collection
29- - ` src/unit_tests/ ` - Unit test files (extracted from inline ` mod tests ` blocks via ` #[path] ` )
30- - ` tests/main.rs ` - User-facing integration tests only (modules in ` tests/suites/ ` )
29+ - ` src/unit_tests/ ` - Unit test files (mirroring ` src/ ` structure, referenced via ` #[path] ` )
30+ - ` tests/main.rs ` - Integration tests (modules in ` tests/suites/ ` )
3131
3232### Trait Hierarchy
3333
@@ -56,80 +56,11 @@ ConstraintSatisfactionProblem : Problem (extension for CSPs)
5656└── ... (default methods: is_satisfied, compute_objective)
5757```
5858
59- ### Problem Implementations
60-
61- | Problem | ` Problem ` | ` ConstraintSatisfactionProblem ` |
62- | ---------| :---------:| :-------------------------------:|
63- | IndependentSet | ✓ | ✓ |
64- | VertexCovering | ✓ | ✓ |
65- | DominatingSet | ✓ | ✓ |
66- | Matching | ✓ | ✓ |
67- | MaxCut | ✓ | ✗ |
68- | Coloring | ✓ | ✓ |
69- | Satisfiability | ✓ | ✓ |
70- | KSatisfiability | ✓ | ✓ |
71- | SetPacking | ✓ | ✓ |
72- | SetCovering | ✓ | ✓ |
73- | SpinGlass | ✓ | ✗ |
74- | QUBO | ✓ | ✗ |
75- | ILP | ✓ | ✗ |
76- | CircuitSAT | ✓ | ✗ |
77- | Factoring | ✓ | ✗ |
78-
7959### Key Patterns
8060- Problems parameterized by weight type ` W ` and graph type ` G `
8161- ` ReductionResult ` provides ` target_problem() ` and ` extract_solution() `
8262- Graph types: SimpleGraph, GridGraph, UnitDiskGraph, Hypergraph
83-
84- ## Conventions
85-
86- ### File Naming
87- - Reduction files: ` src/rules/<source>_<target>.rs `
88- - Model files: ` src/models/<category>/<name>.rs `
89- - Test naming: ` test_<source>_to_<target>_closed_loop `
90-
91- ### Reduction Pattern (Recommended: Using Macro)
92- ``` rust
93- use problemreductions :: reduction;
94-
95- #[reduction(
96- overhead = { ReductionOverhead :: new(vec! [... ]) }
97- )]
98- impl ReduceTo <TargetProblem <Unweighted >> for SourceProblem <Unweighted > {
99- type Result = ReductionSourceToTarget ;
100- fn reduce_to (& self ) -> Self :: Result { ... }
101- }
102- ```
103-
104- The ` #[reduction] ` macro automatically:
105- - Extracts type names from the impl signature
106- - Detects weighted vs unweighted from type parameters (` Unweighted ` vs ` i32 ` /` f64 ` )
107- - Detects graph types from type parameters (e.g., ` GridGraph ` , ` SimpleGraph ` )
108- - Generates the ` inventory::submit! ` call
109-
110- Optional macro attributes:
111- - ` source_graph = "..." ` - Override detected source graph type
112- - ` target_graph = "..." ` - Override detected target graph type
113- - ` source_weighted = true/false ` - Override weighted detection
114- - ` target_weighted = true/false ` - Override weighted detection
115- - ` overhead = { ... } ` - Specify reduction overhead
116-
117- ### Manual Registration (Alternative)
118- ``` rust
119- inventory :: submit! {
120- ReductionEntry {
121- source_name : " SourceProblem" ,
122- target_name : " TargetProblem" ,
123- source_variant : & [(" graph" , " SimpleGraph" ), (" weight" , " Unweighted" )],
124- target_variant : & [(" graph" , " SimpleGraph" ), (" weight" , " Unweighted" )],
125- overhead_fn : || ReductionOverhead :: new (... ),
126- }
127- }
128- ```
129-
130- ### Weight Types
131- - ` Unweighted ` - Marker type for unweighted problems (all weights = 1)
132- - ` i32 ` , ` f64 ` , etc. - Concrete weight types for weighted problems
63+ - Weight types: ` Unweighted ` (marker), ` i32 ` , ` f64 `
13364
13465### Problem Variant IDs
13566Reduction graph nodes use variant IDs: ` ProblemName[/GraphType][/Weighted] `
@@ -138,55 +69,18 @@ Reduction graph nodes use variant IDs: `ProblemName[/GraphType][/Weighted]`
13869- Weighted variant: ` IndependentSet/Weighted `
13970- Both: ` IndependentSet/GridGraph/Weighted `
14071
141- ## Anti-patterns
142- - Don't create reductions without closed-loop tests
143- - Don't forget ` inventory::submit! ` registration (graph won't update)
144- - Don't hardcode weights - use generic ` W ` parameter
145- - Don't skip ` make clippy ` before PR
146-
147- ## Documentation Requirements
148-
149- The technical paper (` docs/paper/reductions.typ ` ) must include:
150-
151- 1 . ** Table of Contents** - Auto-generated outline of all sections
152- 2 . ** Problem Data Structures** - For each problem definition, include the Rust struct with fields in a code block
153- 3 . ** Reduction Examples** - For each reduction theorem, include a minimal working example showing:
154- - Creating the source problem
155- - Reducing to target problem
156- - Solving and extracting solution back
157- - Based on closed-loop tests from ` tests/reduction_tests.rs `
158-
159- ### Documentation Pattern
160- ``` typst
161- #definition("Problem Name")[
162- Mathematical definition...
163- ]
164-
165- // Rust data structure
166- ```rust
167- pub struct ProblemName<W = i32> {
168- field1: Type1,
169- field2: Type2,
170- }
171- `` `
172-
173- #theorem[
174- *(Source → Target)* Reduction description...
175- ]
72+ ## Conventions
17673
177- // Minimal working example
178- ```rust
179- let source = SourceProblem::new(...);
180- let reduction = ReduceTo::<TargetProblem>::reduce_to(&source);
181- let target = reduction.target_problem();
182- // ... solve and extract
183- `` `
184- ```
74+ ### File Naming
75+ - Reduction files: ` src/rules/<source>_<target>.rs `
76+ - Model files: ` src/models/<category>/<name>.rs `
77+ - Test naming: ` test_<source>_to_<target>_closed_loop `
18578
18679## Contributing
18780See ` .claude/rules/ ` for detailed guides:
18881- ` adding-reductions.md ` - How to add reduction rules
18982- ` adding-models.md ` - How to add problem types
19083- ` testing.md ` - Testing requirements and patterns
84+ - ` documentation.md ` - Paper documentation patterns
19185
19286Also see GitHub Issue #3 for coding rules.
0 commit comments