-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add problem variants, documentation improvements, and reduction macro #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
57ed2b9
update
GiggleLiu 2b769a7
feat: Add problem variants, documentation improvements, and reduction…
GiggleLiu 3e7a953
docs: Add variant trait design document
GiggleLiu 0b2f7a1
docs: Add variant trait implementation plan
GiggleLiu 116c35d
feat: add variant helper module with short_type_name
GiggleLiu 0a9b359
feat: replace GraphType/Weight with variant() in Problem trait
GiggleLiu 0b4ee2d
feat: update graph models to use variant()
GiggleLiu ab535a6
feat: update satisfiability models to use variant()
GiggleLiu 103fb74
feat: update set models to use variant()
GiggleLiu b1dcf77
feat: update optimization models to use variant()
GiggleLiu 28184f7
feat: update specialized models to use variant()
GiggleLiu 02785e2
feat: update GraphProblem template to use variant()
GiggleLiu 102688f
feat: update solver test problems to use variant()
GiggleLiu 6174b9d
feat: update ReductionEntry to use variant slices
GiggleLiu 84a3baf
feat: update graph JSON export to structured variant format
GiggleLiu 61f7256
feat: update reduction macro for variant slices
GiggleLiu db1fbcb
feat: update all reduction registrations to variant format
GiggleLiu a7cc68a
feat: remove NAME from GraphMarker trait
GiggleLiu d5c43ce
chore: regenerate reduction graph with new variant format
GiggleLiu 235338c
docs: update reductions.typ for variant() trait design
GiggleLiu a9fd802
test: add coverage for variant() methods
GiggleLiu be1c420
test: Add variant() coverage tests for remaining Problem impls
GiggleLiu 7f878ba
test: Add variant() tests for test problems in traits.rs
GiggleLiu 2bf7f49
chore: Add codecov config excluding proc-macro crate
GiggleLiu afd0c9b
test: Add more is_base_reduction test cases for coverage
GiggleLiu dda31b5
fix: Update diagram to show edges by base problem names
GiggleLiu 6bf2286
fix: Address PR review comments
GiggleLiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Codecov configuration for problem-reductions | ||
| # https://docs.codecov.com/docs/codecov-yaml | ||
|
|
||
| coverage: | ||
| precision: 2 | ||
| round: down | ||
| range: "90...100" | ||
|
|
||
| status: | ||
| project: | ||
| default: | ||
| target: 95% | ||
| threshold: 2% | ||
| patch: | ||
| default: | ||
| target: 95% | ||
| threshold: 2% | ||
|
|
||
| # Exclude proc-macro crate from coverage since it runs at compile time | ||
| # and traditional runtime coverage tools cannot measure it | ||
| ignore: | ||
| - "problemreductions-macros/**/*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| #import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge | ||
| #import "@preview/cetz:0.4.2": canvas, draw | ||
|
|
||
| #let graph-data = json("reduction_graph.json") | ||
|
|
||
| #let category-colors = ( | ||
| "graph": rgb("#e0ffe0"), | ||
| "set": rgb("#ffe0e0"), | ||
| "optimization": rgb("#ffffd0"), | ||
| "satisfiability": rgb("#e0e0ff"), | ||
| "specialized": rgb("#ffe0f0"), | ||
| "other": rgb("#f0f0f0"), | ||
| ) | ||
|
|
||
| #let get-color(category) = { | ||
| category-colors.at(category, default: rgb("#f0f0f0")) | ||
| } | ||
|
|
||
| // Build node ID from name + variant (new JSON format) | ||
| // Format: "Name" for base, "Name/graph/weight" for variants | ||
| #let build-node-id(n) = { | ||
| if n.variant == (:) or n.variant.keys().len() == 0 { | ||
| n.name | ||
| } else { | ||
| let parts = (n.name,) | ||
| if "graph" in n.variant and n.variant.graph != "" and n.variant.graph != "SimpleGraph" { | ||
| parts.push(n.variant.graph) | ||
| } | ||
| if "weight" in n.variant and n.variant.weight != "" and n.variant.weight != "Unweighted" { | ||
| parts.push(n.variant.weight) | ||
| } | ||
| parts.join("/") | ||
| } | ||
| } | ||
|
|
||
| // Build display label from name + variant | ||
| #let build-node-label(n) = { | ||
| if n.variant == (:) or n.variant.keys().len() == 0 { | ||
| n.name | ||
| } else { | ||
| // For variants, show abbreviated form | ||
| let suffix = () | ||
| if "graph" in n.variant and n.variant.graph != "" and n.variant.graph != "SimpleGraph" { | ||
| suffix.push(n.variant.graph) | ||
| } | ||
| // Filter out Unweighted and single-letter generic type params (W, K, T, etc.) | ||
| if "weight" in n.variant and n.variant.weight != "" and n.variant.weight != "Unweighted" and n.variant.weight.len() != 1 { | ||
| suffix.push(n.variant.weight) | ||
| } | ||
| if suffix.len() > 0 { | ||
| n.name + "/" + suffix.join("/") | ||
| } else { | ||
| n.name | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Check if node is a base problem (empty variant) | ||
| #let is-base-problem(n) = { | ||
| n.variant == (:) or n.variant.keys().len() == 0 | ||
| } | ||
|
|
||
| // Base problem positions | ||
| #let base-positions = ( | ||
| // Row 0: Root nodes | ||
| "Satisfiability": (-1.5, 0), | ||
| "Factoring": (2.5, 0), | ||
| // Row 1: Direct children of roots | ||
| "KSatisfiability": (-2.5, 1), | ||
| "IndependentSet": (-0.5, 1), | ||
| "Coloring": (0.5, 1), | ||
| "DominatingSet": (-1.5, 1), | ||
| "CircuitSAT": (2.5, 1), | ||
| // Row 2: Next level | ||
| "VertexCovering": (-0.5, 2), | ||
| "Matching": (-2, 2), | ||
| "SpinGlass": (2.5, 2), | ||
| "ILP": (3.5, 1), | ||
| // Row 3: Leaf nodes | ||
| "SetPacking": (-1.5, 3), | ||
| "SetCovering": (0.5, 3), | ||
| "MaxCut": (1.5, 3), | ||
| "QUBO": (3.5, 3), | ||
| "GridGraph": (0.5, 2), | ||
| ) | ||
|
|
||
| // Get position for a node | ||
| #let get-node-position(n) = { | ||
| if is-base-problem(n) { | ||
| // Base problem - use manual position | ||
| base-positions.at(n.name, default: (0, 0)) | ||
| } else { | ||
| // Variant - position below parent with horizontal offset | ||
| let parent-pos = base-positions.at(n.name, default: (0, 0)) | ||
| // Find variant index among siblings with same base name | ||
| let siblings = graph-data.nodes.filter(x => x.name == n.name and not is-base-problem(x)) | ||
| let idx = siblings.position(x => build-node-id(x) == build-node-id(n)) | ||
| let offset = if idx == none { 0 } else { idx * 0.4 } | ||
| (parent-pos.at(0) + offset, parent-pos.at(1) + 0.5) | ||
| } | ||
| } | ||
|
|
||
| // Filter to show only base problems in the main diagram | ||
| #let base-nodes = graph-data.nodes.filter(n => is-base-problem(n)) | ||
|
|
||
| // Collect unique base problem names | ||
| #let base-names = base-nodes.map(n => n.name) | ||
|
|
||
| // Filter edges to only those between base problem names (ignoring variants) | ||
| // This allows us to show the high-level structure even though edges connect variant nodes | ||
| #let base-edges = graph-data.edges.filter(e => { | ||
| base-names.contains(e.source.name) and base-names.contains(e.target.name) | ||
| }) | ||
|
|
||
| // Deduplicate edges by (source-name, target-name) pair, keeping bidirectionality | ||
| #let edge-key(e) = if e.source.name < e.target.name { | ||
| (e.source.name, e.target.name) | ||
| } else { | ||
| (e.target.name, e.source.name) | ||
| } | ||
|
|
||
| // Group edges by their base names and merge bidirectionality | ||
| #let edge-map = (:) | ||
| #for e in base-edges { | ||
| let key = e.source.name + "->" + e.target.name | ||
| let rev-key = e.target.name + "->" + e.source.name | ||
| if rev-key in edge-map { | ||
| // Reverse edge exists, mark as bidirectional | ||
| edge-map.at(rev-key).bidirectional = true | ||
| } else if key not in edge-map { | ||
| edge-map.insert(key, (source: e.source.name, target: e.target.name, bidirectional: e.bidirectional)) | ||
| } | ||
| } | ||
|
|
||
| #let deduped-edges = edge-map.values() | ||
|
|
||
| #let reduction-graph(width: 18mm, height: 14mm) = diagram( | ||
| spacing: (width, height), | ||
| node-stroke: 0.6pt, | ||
| edge-stroke: 0.6pt, | ||
| node-corner-radius: 2pt, | ||
| node-inset: 3pt, | ||
| ..base-nodes.map(n => { | ||
| let color = get-color(n.category) | ||
| let pos = get-node-position(n) | ||
| let node-label = build-node-label(n) | ||
| let node-id = build-node-id(n) | ||
| node(pos, text(size: 7pt)[#node-label], fill: color, name: label(node-id)) | ||
| }), | ||
| ..deduped-edges.map(e => { | ||
| let arrow = if e.bidirectional { "<|-|>" } else { "-|>" } | ||
| // Use simple name as node ID since we're showing base problems | ||
| edge(label(e.source), label(e.target), arrow) | ||
| }), | ||
| ) | ||
|
|
||
| #reduction-graph() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLAUDE.md documentation shows an outdated manual registration example that uses the old field names:
But the actual ReductionEntry structure now uses:
This example should be updated to match the current API to avoid confusing developers who reference this documentation.