Skip to content

Commit 6f7358b

Browse files
GiggleLiuclaude
andcommitted
Design: recategorize problem models by input structure
Current categorization mixes input structure (graph, set) with problem type (optimization, satisfaction). Reorganize into orthogonal categories based solely on input structure: graph/, formula/, set/, algebraic/, misc/. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 88c1635 commit 6f7358b

2 files changed

Lines changed: 91 additions & 2 deletions

File tree

.claude/CLAUDE.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ make release V=x.y.z # Tag and push a new release (CI publishes to crates.io)
4949
## Architecture
5050

5151
### Core Modules
52-
- `src/models/` - Problem implementations (SAT, Graph, Set, Optimization)
52+
- `src/models/` - Problem implementations organized by input structure:
53+
- `graph/` - Problems on graphs (MIS, MaxClique, MaxCut, MinVC, MinDS, MaxMatching, MaximalIS, KColoring, TSP, SpinGlass, BicliqueCover)
54+
- `formula/` - Logical formulas and circuits (SAT, k-SAT, CircuitSAT)
55+
- `set/` - Set systems (MinSetCovering, MaxSetPacking)
56+
- `algebraic/` - Matrices, linear systems, lattices (QUBO, ILP, CVP, BMF)
57+
- `misc/` - Unique input structures (BinPacking, PaintShop, Factoring)
5358
- `src/rules/` - Reduction rules + inventory registration
5459
- `src/solvers/` - BruteForce solver, ILP solver (feature-gated)
5560
- `src/traits.rs` - `Problem`, `OptimizationProblem`, `SatisfactionProblem` traits
@@ -140,7 +145,7 @@ Reduction graph nodes use variant key-value pairs from `Problem::variant()`:
140145

141146
### File Naming
142147
- Reduction files: `src/rules/<source>_<target>.rs` (e.g., `maximumindependentset_qubo.rs`)
143-
- Model files: `src/models/<category>/<name>.rs` (e.g., `maximum_independent_set.rs`)
148+
- Model files: `src/models/<category>/<name>.rs` — category is by input structure: `graph/` (graph input), `formula/` (boolean formula/circuit), `set/` (universe + subsets), `algebraic/` (matrix/linear system/lattice), `misc/` (other)
144149
- Example files: `examples/reduction_<source>_to_<target>.rs` (must have `pub fn run()` + `fn main() { run() }`)
145150
- Test naming: `test_<source>_to_<target>_closed_loop`
146151

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Problem Categorization Redesign
2+
3+
## Problem
4+
5+
The current categorization mixes two axes:
6+
- **Input structure** (graph, set system, formula)
7+
- **Problem type** (optimization vs satisfaction)
8+
9+
This creates ambiguity: MIS is both a graph problem and an optimization problem. QUBO is on a matrix but lives in `optimization/`. CircuitSAT is a satisfiability problem but lives in `specialized/`. The `specialized/` folder is a catch-all with no unifying principle.
10+
11+
## Design
12+
13+
**Single axis: primary input structure** — "what data type does the problem operate on?"
14+
15+
The optimization/satisfaction distinction is already captured by the trait hierarchy (`OptimizationProblem` vs `SatisfactionProblem`), so folders should not duplicate it.
16+
17+
### New folder structure
18+
19+
```
20+
src/models/
21+
├── graph/ # Input: a graph (optionally weighted)
22+
│ ├── maximum_independent_set.rs
23+
│ ├── maximum_clique.rs
24+
│ ├── max_cut.rs
25+
│ ├── maximum_matching.rs
26+
│ ├── minimum_vertex_cover.rs
27+
│ ├── minimum_dominating_set.rs
28+
│ ├── maximal_is.rs
29+
│ ├── kcoloring.rs
30+
│ ├── traveling_salesman.rs
31+
│ ├── spin_glass.rs ← from optimization/
32+
│ └── biclique_cover.rs ← from specialized/
33+
34+
├── formula/ # Input: a logical formula or circuit
35+
│ ├── sat.rs
36+
│ ├── ksat.rs
37+
│ └── circuit.rs ← from specialized/
38+
39+
├── set/ # Input: universe + collection of subsets
40+
│ ├── minimum_set_covering.rs
41+
│ └── maximum_set_packing.rs
42+
43+
├── algebraic/ # Input: matrix, linear system, or lattice
44+
│ ├── qubo.rs ← from optimization/
45+
│ ├── ilp.rs ← from optimization/
46+
│ ├── closest_vector_problem.rs ← from optimization/
47+
│ └── bmf.rs ← from specialized/
48+
49+
└── misc/ # Problems with unique input structures
50+
├── bin_packing.rs ← from optimization/
51+
├── paintshop.rs ← from specialized/
52+
└── factoring.rs ← from specialized/
53+
```
54+
55+
### Decision rule for new problems
56+
57+
> "What is the primary data structure in the struct definition?"
58+
> - Graph → `graph/`
59+
> - Boolean formula or circuit → `formula/`
60+
> - Universe + subsets → `set/`
61+
> - Matrix, linear system, or lattice → `algebraic/`
62+
> - None of the above → `misc/`
63+
64+
### What moves
65+
66+
| Problem | From | To | Reason |
67+
|---|---|---|---|
68+
| SpinGlass | optimization/ | graph/ | Parameterized by G, operates on graph edges |
69+
| BicliqueCover | specialized/ | graph/ | Input is a BipartiteGraph |
70+
| CircuitSAT | specialized/ | formula/ | Input is a boolean circuit |
71+
| QUBO | optimization/ | algebraic/ | Input is a Q matrix (no graph param) |
72+
| ILP | optimization/ | algebraic/ | Input is constraint matrix + objective |
73+
| CVP | optimization/ | algebraic/ | Input is lattice basis matrix |
74+
| BMF | specialized/ | algebraic/ | Input is a boolean matrix |
75+
| BinPacking | optimization/ | misc/ | Input is items + capacity |
76+
| PaintShop | specialized/ | misc/ | Input is a car sequence |
77+
| Factoring | specialized/ | misc/ | Input is an integer |
78+
79+
### What doesn't change
80+
81+
- Trait hierarchy (`OptimizationProblem`, `SatisfactionProblem`)
82+
- All public API, type names, re-exports
83+
- Only `mod.rs` files, `use` paths, and `#[path]` test references change
84+
- The `optimization/` and `specialized/` folders are eliminated

0 commit comments

Comments
 (0)