Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ enum Direction { Maximize, Minimize }
### Key Patterns
- Problems parameterized by weight type `W` and graph type `G`
- `ReductionResult` provides `target_problem()` and `extract_solution()`
- `Solver::find_best()` for optimization problems, `Solver::find_satisfying()` for `Metric = bool`
- `Solver::find_best()` → `Option<Vec<usize>>` for optimization problems; `Solver::find_satisfying()` → `Option<Vec<usize>>` for `Metric = bool`
- `BruteForce::find_all_best()` / `find_all_satisfying()` return `Vec<Vec<usize>>` for all optimal/satisfying solutions
- Graph types: SimpleGraph, GridGraph, UnitDiskGraph, Hypergraph
- Weight types: `Unweighted` (marker), `i32`, `f64`
- Weight management via inherent methods (`weights()`, `set_weights()`, `is_weighted()`), not traits
Expand Down
6 changes: 4 additions & 2 deletions .claude/rules/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ New code must have >95% test coverage. Run `make coverage` to check.

Follow the reference files above for exact API usage. Summary:

- `solver.find_best(&problem)` — for optimization problems (`OptimizationProblem`, `Metric = SolutionSize<W>`)
- `solver.find_satisfying(&problem)` — for satisfaction problems (`Metric = bool`)
- `solver.find_best(&problem)` → `Option<Vec<usize>>` — one optimal solution for optimization problems
- `solver.find_satisfying(&problem)` → `Option<Vec<usize>>` — one satisfying assignment
- `solver.find_all_best(&problem)` → `Vec<Vec<usize>>` — all optimal solutions (BruteForce only)
- `solver.find_all_satisfying(&problem)` → `Vec<Vec<usize>>` — all satisfying assignments (BruteForce only)
- `problem.evaluate(&config)` — returns `SolutionSize::Valid(value)` / `SolutionSize::Invalid` for optimization, `bool` for satisfaction

## File Organization
Expand Down
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for problemreductions

.PHONY: help build test fmt clippy doc mdbook paper examples clean coverage rust-export compare qubo-testdata export-schemas release run-plan
.PHONY: help build test fmt clippy doc mdbook paper examples clean coverage rust-export compare qubo-testdata export-schemas release run-plan diagrams

# Default target
help:
Expand All @@ -11,6 +11,7 @@ help:
@echo " fmt-check - Check code formatting"
@echo " clippy - Run clippy lints"
@echo " doc - Build mdBook documentation"
@echo " diagrams - Generate SVG diagrams from Typst (light + dark)"
@echo " mdbook - Build and serve mdBook (with live reload)"
@echo " paper - Build Typst paper (requires typst)"
@echo " coverage - Generate coverage report (requires cargo-llvm-cov)"
Expand Down Expand Up @@ -47,16 +48,26 @@ clippy:
# Build mdBook documentation
doc:
cargo run --example export_graph
cp docs/paper/reduction_graph.json docs/src/reductions/
cargo run --example export_schemas
mdbook build docs
RUSTDOCFLAGS="--default-theme=dark" cargo doc --all-features --no-deps
rm -rf docs/book/api
cp -r target/doc docs/book/api

# Generate SVG diagrams from Typst sources (light + dark themes)
TYPST_DIAGRAMS := $(wildcard docs/src/static/*.typ)
diagrams:
@for src in $(TYPST_DIAGRAMS); do \
base=$$(basename $$src .typ); \
echo "Compiling $$base..."; \
typst compile $$src --input dark=false docs/src/static/$$base.svg; \
typst compile $$src --input dark=true docs/src/static/$$base-dark.svg; \
done

# Build and serve mdBook with API docs
mdbook:
cargo run --example export_graph
cp docs/paper/reduction_graph.json docs/src/reductions/
cargo run --example export_schemas
RUSTDOCFLAGS="--default-theme=dark" cargo doc --all-features --no-deps
mdbook build
rm -rf book/api
Expand Down Expand Up @@ -84,7 +95,7 @@ export-schemas:
paper: examples
cargo run --example export_graph
cargo run --example export_schemas
cd docs/paper && typst compile reductions.typ reductions.pdf
cd docs/paper && typst compile --root .. reductions.typ reductions.pdf

# Generate coverage report (requires: cargo install cargo-llvm-cov)
coverage:
Expand Down
Loading