Skip to content

Commit c7a7612

Browse files
isPANNclaude
andcommitted
Merge branch 'main' into fix/strong-connectivity-augmentation-example
Regenerate examples.json fixture after merge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 parents 41a2972 + 6bb3e9c commit c7a7612

24 files changed

Lines changed: 2604 additions & 490 deletions

docs/paper/reductions.typ

Lines changed: 214 additions & 13 deletions
Large diffs are not rendered by default.

docs/paper/references.bib

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
@inproceedings{wagner1975,
2+
author = {Robert A. Wagner},
3+
title = {On the Complexity of the Extended String-to-String Correction Problem},
4+
booktitle = {Proceedings of the 7th Annual ACM Symposium on Theory of Computing (STOC)},
5+
pages = {218--223},
6+
year = {1975},
7+
doi = {10.1145/800116.803771}
8+
}
9+
10+
@article{wagner1974,
11+
author = {Robert A. Wagner and Michael J. Fischer},
12+
title = {The String-to-String Correction Problem},
13+
journal = {Journal of the ACM},
14+
volume = {21},
15+
number = {1},
16+
pages = {168--173},
17+
year = {1974},
18+
doi = {10.1145/321796.321811}
19+
}
20+
121
@article{juttner2018,
222
author = {Alpár Jüttner and Péter Madarasi},
323
title = {VF2++ — An improved subgraph isomorphism algorithm},
@@ -577,6 +597,17 @@ @article{maier1978
577597
doi = {10.1145/322063.322075}
578598
}
579599

600+
@article{wagnerfischer1974,
601+
author = {Robert A. Wagner and Michael J. Fischer},
602+
title = {The String-to-String Correction Problem},
603+
journal = {Journal of the ACM},
604+
volume = {21},
605+
number = {1},
606+
pages = {168--173},
607+
year = {1974},
608+
doi = {10.1145/321796.321811}
609+
}
610+
580611
@article{blum2021,
581612
author = {Christian Blum and Maria J. Blesa and Borja Calvo},
582613
title = {{ILP}-based reduced variable neighborhood search for the longest common subsequence problem},
@@ -690,6 +721,17 @@ @article{lucchesi1978
690721
doi = {10.1112/jlms/s2-17.3.369}
691722
}
692723

724+
@article{lucchesi1978keys,
725+
author = {Cl\'audio L. Lucchesi and Sylvia L. Osborn},
726+
title = {Candidate Keys for Relations},
727+
journal = {Journal of Computer and System Sciences},
728+
volume = {17},
729+
number = {2},
730+
pages = {270--279},
731+
year = {1978},
732+
doi = {10.1016/0022-0000(78)90009-0}
733+
}
734+
693735
@article{lenstra1976,
694736
author = {Jan Karel Lenstra and Alexander H. G. Rinnooy Kan},
695737
title = {On General Routing Problems},
@@ -755,3 +797,25 @@ @article{papadimitriou1982
755797
year = {1982},
756798
doi = {10.1145/322307.322309}
757799
}
800+
801+
@article{kou1977,
802+
author = {Lawrence T. Kou},
803+
title = {Polynomial Complete Consecutive Information Retrieval Problems},
804+
journal = {SIAM Journal on Computing},
805+
volume = {6},
806+
number = {1},
807+
pages = {67--75},
808+
year = {1977},
809+
doi = {10.1137/0206005}
810+
}
811+
812+
@article{boothlueker1976,
813+
author = {Kellogg S. Booth and George S. Lueker},
814+
title = {Testing for the Consecutive Ones Property, Interval Graphs, and Graph Planarity Using {PQ}-Tree Algorithms},
815+
journal = {Journal of Computer and System Sciences},
816+
volume = {13},
817+
number = {3},
818+
pages = {335--379},
819+
year = {1976},
820+
doi = {10.1016/S0022-0000(76)80045-1}
821+
}

docs/src/cli.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ pred reduce problem.json --to QUBO -o reduced.json
8787
pred solve reduced.json --solver brute-force
8888

8989
# Pipe commands together (use - to read from stdin)
90-
pred create MIS --graph 0-1,1-2,2-3 | pred solve -
90+
pred create MIS --graph 0-1,1-2,2-3 | pred solve - # when an ILP reduction path exists
91+
pred create StringToStringCorrection --source-string "0,1,2,3,1,0" --target-string "0,1,3,2,1" --bound 2 | pred solve - --solver brute-force
9192
pred create MIS --graph 0-1,1-2,2-3 | pred reduce - --to QUBO | pred solve -
9293
```
9394

@@ -351,7 +352,9 @@ pred create LengthBoundedDisjointPaths --graph 0-1,1-6,0-2,2-3,3-6,0-4,4-5,5-6 -
351352
pred create Factoring --target 15 --bits-m 4 --bits-n 4 -o factoring.json
352353
pred create Factoring --target 21 --bits-m 3 --bits-n 3 -o factoring2.json
353354
pred create X3C --universe 9 --sets "0,1,2;0,2,4;3,4,5;3,5,7;6,7,8;1,4,6;2,5,8" -o x3c.json
355+
pred create MinimumCardinalityKey --num-attributes 6 --dependencies "0,1>2;0,2>3;1,3>4;2,4>5" --k 2 -o mck.json
354356
pred create MinimumTardinessSequencing --n 5 --deadlines 5,5,5,3,3 --precedence-pairs "0>3,1>3,1>4,2>4" -o mts.json
357+
pred create StringToStringCorrection --source-string "0,1,2,3,1,0" --target-string "0,1,3,2,1" --bound 2 | pred solve - --solver brute-force
355358
pred create StrongConnectivityAugmentation --arcs "0>1,1>2,2>0,3>4,4>3,2>3,4>5,5>3" --candidate-arcs "3>0:5,3>1:3,3>2:4,4>0:6,4>1:2,4>2:7,5>0:4,5>1:3,5>2:1,0>3:8,0>4:3,0>5:2,1>3:6,1>4:4,1>5:5,2>4:3,2>5:7,1>0:2" --bound 1 -o sca.json
356359
```
357360
@@ -375,7 +378,8 @@ pred create MaxCut --random --num-vertices 20 --edge-prob 0.5 -o maxcut.json
375378
Without `-o`, the problem JSON is printed to stdout, which can be piped to other commands:
376379
377380
```bash
378-
pred create MIS --graph 0-1,1-2,2-3 | pred solve -
381+
pred create MIS --graph 0-1,1-2,2-3 | pred solve - # when an ILP reduction path exists
382+
pred create StringToStringCorrection --source-string "0,1,2,3,1,0" --target-string "0,1,3,2,1" --bound 2 | pred solve - --solver brute-force
379383
pred create MIS --random --num-vertices 10 | pred inspect -
380384
```
381385
@@ -516,10 +520,17 @@ Source evaluation: Valid(2)
516520
517521
> **Note:** The ILP solver requires a reduction path from the target problem to ILP.
518522
> Some problems do not currently have one. Examples include BoundedComponentSpanningForest,
519-
> LengthBoundedDisjointPaths, QUBO, SpinGlass, MaxCut, CircuitSAT, and MultiprocessorScheduling.
523+
> LengthBoundedDisjointPaths, MinimumCardinalityKey, QUBO, SpinGlass, MaxCut, CircuitSAT, and MultiprocessorScheduling.
520524
> Use `pred solve <file> --solver brute-force` for these, or reduce to a problem that supports ILP first.
521525
> For other problems, use `pred path <PROBLEM> ILP` to check whether an ILP reduction path exists.
522526
527+
For example, the canonical Minimum Cardinality Key instance can be created and solved with:
528+
529+
```bash
530+
pred create MinimumCardinalityKey --num-attributes 6 --dependencies "0,1>2;0,2>3;1,3>4;2,4>5" --k 2 -o mck.json
531+
pred solve mck.json --solver brute-force
532+
```
533+
523534
## Shell Completions
524535
525536
Enable tab completion by adding one line to your shell config:

problemreductions-cli/src/cli.rs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Typical workflow:
1313
pred evaluate problem.json --config 1,0,1,0
1414
1515
Piping (use - to read from stdin):
16-
pred create MIS --graph 0-1,1-2 | pred solve -
16+
pred create MIS --graph 0-1,1-2 | pred solve - # when an ILP reduction path exists
17+
pred create StringToStringCorrection --source-string \"0,1,2,3,1,0\" --target-string \"0,1,3,2,1\" --bound 2 | pred solve - --solver brute-force
1718
pred create MIS --graph 0-1,1-2 | pred evaluate - --config 1,0,1
1819
pred create MIS --graph 0-1,1-2 | pred reduce - --to QUBO
1920
@@ -237,6 +238,7 @@ Flags by problem type:
237238
ComparativeContainment --universe, --r-sets, --s-sets [--r-weights] [--s-weights]
238239
X3C (ExactCoverBy3Sets) --universe, --sets (3 elements each)
239240
SetBasis --universe, --sets, --k
241+
MinimumCardinalityKey --num-attributes, --dependencies, --k
240242
BicliqueCover --left, --right, --biedges, --k
241243
BalancedCompleteBipartiteSubgraph --left, --right, --biedges, --k
242244
BiconnectivityAugmentation --graph, --potential-edges, --budget [--num-vertices]
@@ -249,14 +251,15 @@ Flags by problem type:
249251
RuralPostman (RPP) --graph, --edge-weights, --required-edges, --bound
250252
MultipleChoiceBranching --arcs [--weights] --partition --bound [--num-vertices]
251253
SubgraphIsomorphism --graph (host), --pattern (pattern)
252-
LCS --strings
254+
LCS --strings, --bound [--alphabet-size]
253255
FAS --arcs [--weights] [--num-vertices]
254256
FVS --arcs [--weights] [--num-vertices]
255257
StrongConnectivityAugmentation --arcs, --candidate-arcs, --bound [--num-vertices]
256258
FlowShopScheduling --task-lengths, --deadline [--num-processors]
257259
StaffScheduling --schedules, --requirements, --num-workers, --k
258260
MinimumTardinessSequencing --n, --deadlines [--precedence-pairs]
259261
SCS --strings, --bound [--alphabet-size]
262+
StringToStringCorrection --source-string, --target-string, --bound [--alphabet-size]
260263
D2CIF --arcs, --capacities, --source-1, --sink-1, --source-2, --sink-2, --requirement-1, --requirement-2
261264
ILP, CircuitSAT (via reduction only)
262265
@@ -275,6 +278,7 @@ Examples:
275278
pred create SAT --num-vars 3 --clauses \"1,2;-1,3\"
276279
pred create QUBO --matrix \"1,0.5;0.5,2\"
277280
pred create MultipleChoiceBranching/i32 --arcs \"0>1,0>2,1>3,2>3,1>4,3>5,4>5,2>4\" --weights 3,2,4,1,2,3,1,3 --partition \"0,1;2,3;4,7;5,6\" --bound 10
281+
pred create StringToStringCorrection --source-string \"0,1,2,3,1,0\" --target-string \"0,1,3,2,1\" --bound 2 | pred solve - --solver brute-force
278282
pred create MIS/KingsSubgraph --positions \"0,0;1,0;1,1;0,1\"
279283
pred create MIS/UnitDiskGraph --positions \"0,0;1,0;0.5,0.8\" --radius 1.5
280284
pred create MIS --random --num-vertices 10 --edge-prob 0.3
@@ -283,7 +287,8 @@ Examples:
283287
pred create FVS --arcs \"0>1,1>2,2>0\" --weights 1,1,1
284288
pred create UndirectedTwoCommodityIntegralFlow --graph 0-2,1-2,2-3 --capacities 1,1,2 --source-1 0 --sink-1 3 --source-2 1 --sink-2 3 --requirement-1 1 --requirement-2 1
285289
pred create X3C --universe 9 --sets \"0,1,2;0,2,4;3,4,5;3,5,7;6,7,8;1,4,6;2,5,8\"
286-
pred create SetBasis --universe 4 --sets \"0,1;1,2;0,2;0,1,2\" --k 3")]
290+
pred create SetBasis --universe 4 --sets \"0,1;1,2;0,2;0,1,2\" --k 3
291+
pred create MinimumCardinalityKey --num-attributes 6 --dependencies \"0,1>2;0,2>3;1,3>4;2,4>5\" --k 2")]
287292
pub struct CreateArgs {
288293
/// Problem type (e.g., MIS, QUBO, SAT). Omit when using --example.
289294
#[arg(value_parser = crate::problem_name::ProblemNameParser)]
@@ -447,13 +452,13 @@ pub struct CreateArgs {
447452
/// Required edge indices for RuralPostman (comma-separated, e.g., "0,2,4")
448453
#[arg(long)]
449454
pub required_edges: Option<String>,
450-
/// Upper bound or length bound (for BoundedComponentSpanningForest, LengthBoundedDisjointPaths, MultipleChoiceBranching, OptimalLinearArrangement, RuralPostman, or SCS)
455+
/// Upper bound or length bound (for BoundedComponentSpanningForest, LengthBoundedDisjointPaths, LongestCommonSubsequence, MultipleChoiceBranching, OptimalLinearArrangement, RuralPostman, ShortestCommonSupersequence, or StringToStringCorrection)
451456
#[arg(long, allow_hyphen_values = true)]
452457
pub bound: Option<i64>,
453458
/// Pattern graph edge list for SubgraphIsomorphism (e.g., 0-1,1-2,2-0)
454459
#[arg(long)]
455460
pub pattern: Option<String>,
456-
/// Input strings for LCS (e.g., "ABAC;BACA") or SCS (e.g., "0,1,2;1,2,0")
461+
/// Input strings for LCS (e.g., "ABAC;BACA" or "0,1,0;1,0,1") or SCS (e.g., "0,1,2;1,2,0")
457462
#[arg(long)]
458463
pub strings: Option<String>,
459464
/// Directed arcs for directed graph problems (e.g., 0>1,1>2,2>0)
@@ -468,7 +473,7 @@ pub struct CreateArgs {
468473
/// Candidate weighted arcs for StrongConnectivityAugmentation (e.g., 2>0:1,2>1:3)
469474
#[arg(long)]
470475
pub candidate_arcs: Option<String>,
471-
/// Deadlines for MinimumTardinessSequencing (comma-separated, e.g., "5,5,5,3,3")
476+
/// Deadlines for scheduling problems (comma-separated, e.g., "5,5,5,3,3")
472477
#[arg(long)]
473478
pub deadlines: Option<String>,
474479
/// Precedence pairs for MinimumTardinessSequencing (e.g., "0>3,1>3,1>4,2>4")
@@ -492,9 +497,21 @@ pub struct CreateArgs {
492497
/// Number of available workers for StaffScheduling
493498
#[arg(long)]
494499
pub num_workers: Option<u64>,
495-
/// Alphabet size for SCS (optional; inferred from max symbol + 1 if omitted)
500+
/// Alphabet size for LCS, SCS, or StringToStringCorrection (optional; inferred from the input strings if omitted)
496501
#[arg(long)]
497502
pub alphabet_size: Option<usize>,
503+
/// Functional dependencies for MinimumCardinalityKey (semicolon-separated "lhs>rhs" pairs, e.g., "0,1>2;0,2>3")
504+
#[arg(long)]
505+
pub dependencies: Option<String>,
506+
/// Number of attributes for MinimumCardinalityKey
507+
#[arg(long)]
508+
pub num_attributes: Option<usize>,
509+
/// Source string for StringToStringCorrection (comma-separated symbol indices, e.g., "0,1,2,3")
510+
#[arg(long)]
511+
pub source_string: Option<String>,
512+
/// Target string for StringToStringCorrection (comma-separated symbol indices, e.g., "0,1,3,2")
513+
#[arg(long)]
514+
pub target_string: Option<String>,
498515
}
499516

500517
#[derive(clap::Args)]
@@ -504,7 +521,8 @@ Examples:
504521
pred solve problem.json --solver brute-force # brute-force (exhaustive search)
505522
pred solve reduced.json # solve a reduction bundle
506523
pred solve reduced.json -o solution.json # save result to file
507-
pred create MIS --graph 0-1,1-2 | pred solve - # read from stdin
524+
pred create MIS --graph 0-1,1-2 | pred solve - # read from stdin when an ILP path exists
525+
pred create StringToStringCorrection --source-string \"0,1,2,3,1,0\" --target-string \"0,1,3,2,1\" --bound 2 | pred solve - --solver brute-force
508526
pred solve problem.json --timeout 10 # abort after 10 seconds
509527
510528
Typical workflow:
@@ -518,6 +536,8 @@ Solve via explicit reduction:
518536
Input: a problem JSON from `pred create`, or a reduction bundle from `pred reduce`.
519537
When given a bundle, the target is solved and the solution is mapped back to the source.
520538
The ILP solver auto-reduces non-ILP problems before solving.
539+
Problems without an ILP reduction path, such as `LengthBoundedDisjointPaths` and
540+
`StringToStringCorrection`, currently need `--solver brute-force`.
521541
522542
ILP backend (default: HiGHS). To use a different backend:
523543
cargo install problemreductions-cli --features coin-cbc

0 commit comments

Comments
 (0)