Commit cc35756
feat: add problem_size() to Problem trait with validation (#76)
* feat: add problem_size() to Problem trait (compile-breaking)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: implement problem_size() for all graph problems
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: implement problem_size() for SAT problems
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: implement problem_size() for set problems
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: implement problem_size() for optimization problems
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: implement problem_size() for specialized problems
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: validate overhead variable names against problem_size in find_cheapest_path
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add problem_size() unit tests for all 21 problem types
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add find_cheapest_path integration test with problem_size
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: update test ProblemSize variable names to match problem_size() components
Existing tests used arbitrary variable names like "n" and "m" that don't
match the overhead polynomial variable names. Updated to use correct names
(num_vertices, num_edges) or empty ProblemSize to pass the new validation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: format
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: split ProblemSize into type-level names + instance-level values
Split the `Problem::problem_size()` method into two parts:
- `problem_size_names() -> &'static [&'static str]` (type-level, static)
- `problem_size_values(&self) -> Vec<usize>` (instance-level)
A free function `problem_size()` combines them into a `ProblemSize`.
This enables compile-time overhead validation: `ReductionGraph::new()`
now asserts that each reduction's overhead input variables are a subset
of the source's `problem_size_names`, and output fields are a subset of
the target's. This caught and fixed several latent bugs:
- `num_elements` → `universe_size` in SetPacking/SetCovering overheads
- `num_gates` → `num_variables`/`num_assignments` in Factoring→CircuitSAT
- `num_variables` → `num_vars` in SAT→CircuitSAT input
- `num_colors` removed from KColoring size (k is a type parameter)
- KColoring→ILP/QUBO overheads updated to not reference num_colors
Also includes earlier work from this branch:
- BicliqueCover refactored to use BipartiteGraph as input
- Polynomial composition (mul, pow, substitute) for symbolic overhead
- evaluate_path_overhead + compose_path_overhead on ReductionGraph
- 3-SAT→MIS triangular overhead test with numeric and symbolic asserts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: extract validate_overhead_variables and use ILP for factoring test
- Extract overhead validation logic from ReductionGraph::new() and
find_cheapest_path() into standalone validate_overhead_variables()
- Add 5 unit tests for the validation function
- Replace brute-force SpinGlass solve with ILP solver in
test_jl_parity_factoring_to_spinglass_path (>60s → <1s)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: assert_eq in ProblemSize + correct SAT→KColoring edge overhead
- Use assert_eq! instead of debug_assert_eq! in from_names_values()
so length mismatches are caught in release builds
- Fix SAT→KColoring num_edges polynomial: 3*num_vars + 11*num_literals
- 9*num_clauses + 3 (was incorrectly copied from num_vertices)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: add reduction overhead section to getting-started
Show evaluate_path_overhead and compose_path_overhead in the chained
reduction example. The getting-started guide now explains how to inspect
problem size growth along a reduction path.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 776e855 commit cc35756
102 files changed
Lines changed: 2592 additions & 485 deletions
File tree
- benches
- docs
- paper
- plans
- src
- examples
- problemreductions-macros/src
- src
- models
- graph
- optimization
- satisfiability
- set
- specialized
- rules
- unit_tests
- models
- graph
- specialized
- rules
- solvers
- testing
- unitdiskmapping_algorithms
- tests/suites
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
| |||
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
231 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
232 | 237 | | |
233 | 238 | | |
234 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| |||
0 commit comments