You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Replace repeated trait/solver/naming details with cross-references
- Remove duplicate example test rules and "Before PR" section
- Fix CircuitSAT listed under both satisfiability/ and specialized/
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .claude/CLAUDE.md
+5-53Lines changed: 5 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -185,32 +185,17 @@ cargo run --example export_graph
185
185
186
186
### Trait Implementations
187
187
188
-
Every problem must implement `Problem` (see `src/traits.rs`). Key points:
189
-
190
-
-**`type Metric`** — `SolutionSize<W>` for optimization, `bool` for satisfaction
191
-
-**`fn dims()`** — configuration space dimensions (e.g., `vec![2; n]` for n binary variables)
192
-
-**`fn evaluate()`** — return `SolutionSize::Valid(value)` / `SolutionSize::Invalid` for optimization, or `bool` for satisfaction
193
-
-**`fn variant()`** — graph and weight type metadata for the reduction registry
194
-
195
-
Optimization problems additionally implement `OptimizationProblem` (see `src/traits.rs`):
196
-
-**`type Value`** — the inner objective type (e.g., `i32`, `f64`, `W`)
197
-
-**`fn direction()`** — `Direction::Maximize` or `Direction::Minimize`
198
-
199
-
The supertrait `Problem<Metric = SolutionSize<Self::Value>>` ensures the solver can call `metric.is_valid()` and `metric.is_better()` directly — no per-problem customization needed.
200
-
201
-
Weight management (`weights()`, `set_weights()`, `is_weighted()`) goes on inherent `impl` blocks, not traits. See the reference implementation for the pattern.
188
+
See Trait Hierarchy above for `Problem` and `OptimizationProblem` members. Weight management (`weights()`, `set_weights()`, `is_weighted()`) goes on inherent `impl` blocks, not traits. See the reference implementation for the pattern.
Use explicit optimization prefixes: `Maximum` for maximization, `Minimum` for minimization (e.g., `MaximumIndependentSet`, `MinimumVertexCover`).
198
+
Naming convention: see Problem Names above.
214
199
215
200
## Testing Requirements
216
201
@@ -232,44 +217,11 @@ New code must have >95% test coverage. Run `make coverage` to check.
232
217
233
218
### Key Testing Patterns
234
219
235
-
Follow the reference files above for exact API usage. Summary:
236
-
237
-
-`solver.find_best(&problem)` → `Option<Vec<usize>>` — one optimal solution for optimization problems
238
-
-`solver.find_satisfying(&problem)` → `Option<Vec<usize>>` — one satisfying assignment
239
-
-`solver.find_all_best(&problem)` → `Vec<Vec<usize>>` — all optimal solutions (BruteForce only)
240
-
-`solver.find_all_satisfying(&problem)` → `Vec<Vec<usize>>` — all satisfying assignments (BruteForce only)
241
-
-`problem.evaluate(&config)` — returns `SolutionSize::Valid(value)` / `SolutionSize::Invalid` for optimization, `bool` for satisfaction
220
+
See Key Patterns above for solver API signatures. Follow the reference files for exact usage.
242
221
243
222
### File Organization
244
223
245
-
Unit tests live in `src/unit_tests/`, mirroring `src/` structure. Source files reference them via `#[path]`:
246
-
247
-
```rust
248
-
// In src/rules/foo_bar.rs:
249
-
#[cfg(test)]
250
-
#[path ="../unit_tests/rules/foo_bar.rs"]
251
-
modtests;
252
-
```
253
-
254
-
Integration tests are in `tests/suites/`, consolidated through `tests/main.rs`.
255
-
256
-
### Example Tests
257
-
258
-
**Reference:**`tests/suites/examples.rs` — macro-based test harness
259
-
260
-
Example programs (`examples/reduction_*.rs`) are tested via `include!` in `tests/suites/examples.rs` — each example is compiled directly into the test binary (no subprocess overhead). Each example must expose a `pub fn run()` entry point. See any existing example (e.g., `examples/reduction_minimumvertexcover_to_maximumindependentset.rs`) for the pattern:
- Regular comments (`//`) not inner doc comments (`//!`)
264
-
- Hardcoded example name, not `env!("CARGO_BIN_NAME")`
265
-
266
-
The test harness auto-registers each example as a separate `#[test]`, so `cargo test` runs them in parallel.
267
-
268
-
### Before PR
269
-
270
-
```bash
271
-
make test clippy
272
-
```
224
+
Unit tests in `src/unit_tests/` linked via `#[path]` (see Core Modules above). Integration tests in `tests/suites/`, consolidated through `tests/main.rs`. Example tests in `tests/suites/examples.rs` (see Example Program in Adding a Reduction above).
0 commit comments