Skip to content

Commit aaa92ae

Browse files
committed
update
1 parent b0fd4e3 commit aaa92ae

4 files changed

Lines changed: 26 additions & 12 deletions

File tree

.github/workflows/docs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ jobs:
3737
run: |
3838
cargo run --example export_graph
3939
cargo run --example export_schemas
40-
cp docs/paper/reduction_graph.json docs/src/reductions/
4140
4241
- name: Build mdBook
4342
run: mdbook build

docs/paper/reductions.typ

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@
234234
#align(center)[
235235
#text(size: 16pt, weight: "bold")[Problem Reductions: Models and Transformations]
236236
#v(0.5em)
237-
#text(size: 11pt)[Technical Documentation]
237+
#text(size: 11pt)[Jin-Guo Liu#super[1] #h(1em) Xi-Wei Pan#super[1]]
238+
#v(0.3em)
239+
#text(size: 9pt)[#super[1]Hong Kong University of Science and Technology (Guangzhou)]
238240
#v(0.3em)
239241
#text(size: 10pt, style: "italic")[github.com/CodingThrust/problem-reductions]
240242
#v(1em)
@@ -398,7 +400,7 @@ Each reduction is presented as a *Rule* (with linked problem names and overhead
398400
#let mvc_mis_sol = mvc_mis_r.solutions.at(0)
399401
#reduction-rule("MinimumVertexCover", "MaximumIndependentSet",
400402
example: true,
401-
example-caption: [Path graph $P_4$: VC $arrow.l.r$ IS],
403+
example-caption: [Petersen graph ($n = 10$): VC $arrow.l.r$ IS],
402404
extra: [
403405
Source VC: $C = {#mvc_mis_sol.source_config.enumerate().filter(((i, x)) => x == 1).map(((i, x)) => str(i)).join(", ")}$ (size #mvc_mis_sol.source_config.filter(x => x == 1).len()) #h(1em)
404406
Target IS: $S = {#mvc_mis_sol.target_config.enumerate().filter(((i, x)) => x == 1).map(((i, x)) => str(i)).join(", ")}$ (size #mvc_mis_sol.target_config.filter(x => x == 1).len()) \
@@ -446,9 +448,17 @@ Each reduction is presented as a *Rule* (with linked problem names and overhead
446448
Expanding $sum_(i,j) Q_(i j) (s_i+1)(s_j+1)/4$ gives $J_(i j) = -Q_(i j)/4$, $h_i = -(Q_(i i) + sum_j Q_(i j))/2$. _Solution extraction:_ $x_i = (s_i + 1)/2$.
447449
]
448450

451+
#let sg_qubo = load-example("spinglass_to_qubo")
452+
#let sg_qubo_r = load-results("spinglass_to_qubo")
453+
#let sg_qubo_sol = sg_qubo_r.solutions.at(0)
449454
#reduction-rule("SpinGlass", "QUBO",
450455
example: true,
451-
example-caption: [2-spin system with coupling $J_(01) = -1$, fields $h = (0.5, -0.5)$],
456+
example-caption: [10-spin Ising model on Petersen graph],
457+
extra: [
458+
Source: $n = #sg_qubo.source.instance.num_spins$ spins, $h_i = 0$, couplings $J_(i j) in {plus.minus 1}$ \
459+
Mapping: $s_i = 2x_i - 1$ converts spins ${-1, +1}$ to binary ${0, 1}$ \
460+
Ground state ($#sg_qubo_r.solutions.len()$-fold degenerate): $bold(x) = (#sg_qubo_sol.target_config.map(str).join(", "))$ #sym.checkmark
461+
],
452462
)[
453463
The substitution $s_i = 2x_i - 1$ yields $H_"SG"(bold(s)) = H_"QUBO"(bold(x)) + "const"$.
454464
][
@@ -465,7 +475,7 @@ where $P$ is a penalty weight large enough that any constraint violation costs m
465475
#let mis_qubo_r = load-results("maximumindependentset_to_qubo")
466476
#reduction-rule("MaximumIndependentSet", "QUBO",
467477
example: true,
468-
example-caption: [IS on path $P_4$ to QUBO],
478+
example-caption: [IS on the Petersen graph ($n = 10$) to QUBO],
469479
extra: [
470480
*Source edges:* $= {#mis_qubo.source.instance.edges.map(e => $(#e.at(0), #e.at(1))$).join(", ")}$ \
471481
*QUBO matrix* ($Q in RR^(#mis_qubo.target.instance.num_vars times #mis_qubo.target.instance.num_vars)$):
@@ -569,10 +579,11 @@ where $P$ is a penalty weight large enough that any constraint violation costs m
569579
#let sat_mis_sol = sat_mis_r.solutions.at(0)
570580
#reduction-rule("Satisfiability", "MaximumIndependentSet",
571581
example: true,
572-
example-caption: [$phi = (x_1 or x_2) and (not x_1 or x_3) and (x_2 or not x_3)$],
582+
example-caption: [3-SAT with 5 variables and 7 clauses],
573583
extra: [
574-
SAT assignment: $x_1=#sat_mis_sol.source_config.at(0), x_2=#sat_mis_sol.source_config.at(1), x_3=#sat_mis_sol.source_config.at(2)$ #h(1em)
575-
IS graph: #sat_mis.target.instance.num_vertices vertices, #sat_mis.target.instance.num_edges edges (one vertex per literal occurrence)
584+
SAT assignment: $(x_1, ..., x_5) = (#sat_mis_sol.source_config.map(str).join(", "))$ \
585+
IS graph: #sat_mis.target.instance.num_vertices vertices ($= 3 times #sat_mis.source.instance.num_clauses$ literals), #sat_mis.target.instance.num_edges edges \
586+
IS of size #sat_mis.source.instance.num_clauses $= m$: one vertex per clause $arrow.r$ satisfying assignment #sym.checkmark
576587
],
577588
)[
578589
@karp1972 Given CNF $phi$ with $m$ clauses, construct graph $G$ such that $phi$ is satisfiable iff $G$ has an IS of size $m$.

docs/src/arch.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ impl ReduceTo<B> for A { /* ... */ }
147147
Regenerate exports:
148148

149149
```bash
150-
cargo run --example export_graph # docs/src/reductions/reduction_graph.json
150+
cargo run --example export_graph # docs/src/reductions/reduction_graph.json (default)
151+
cargo run --example export_graph -- output.json # custom output path
151152
cargo run --example export_schemas # docs/src/reductions/problem_schemas.json
152153
```
153154

examples/export_graph.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Export the reduction graph to a JSON file.
22
//!
3-
//! Run with: `cargo run --example export_graph`
3+
//! Run with: `cargo run --example export_graph [output_path]`
44
55
use problemreductions::rules::ReductionGraph;
6-
use std::path::Path;
6+
use std::path::PathBuf;
77

88
fn main() {
99
let graph = ReductionGraph::new();
@@ -14,7 +14,10 @@ fn main() {
1414
println!(" Reductions: {}", graph.num_reductions());
1515

1616
// Export to JSON (single source for both mdBook and paper)
17-
let output_path = Path::new("docs/src/reductions/reduction_graph.json");
17+
let output_path = std::env::args()
18+
.nth(1)
19+
.map(PathBuf::from)
20+
.unwrap_or_else(|| PathBuf::from("docs/src/reductions/reduction_graph.json"));
1821

1922
// Create parent directories if needed
2023
if let Some(parent) = output_path.parent() {

0 commit comments

Comments
 (0)