Skip to content
51 changes: 49 additions & 2 deletions docs/paper/reductions.typ
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@
"SchedulingWithIndividualDeadlines": [Scheduling With Individual Deadlines],
"StaffScheduling": [Staff Scheduling],
"MinimumTardinessSequencing": [Minimum Tardiness Sequencing],
"SequencingToMinimizeWeightedTardiness": [Sequencing to Minimize Weighted Tardiness],
"SequencingToMinimizeMaximumCumulativeCost": [Sequencing to Minimize Maximum Cumulative Cost],
"ConsecutiveOnesSubmatrix": [Consecutive Ones Submatrix],
"SequencingToMinimizeMaximumCumulativeCost": [Sequencing to Minimize Maximum Cumulative Cost],
"SequencingToMinimizeWeightedTardiness": [Sequencing to Minimize Weighted Tardiness],
"SumOfSquaresPartition": [Sum of Squares Partition],
"TwoDimensionalConsecutiveSets": [2-Dimensional Consecutive Sets],
"SequencingWithinIntervals": [Sequencing Within Intervals],
"DirectedTwoCommodityIntegralFlow": [Directed Two-Commodity Integral Flow],
"ConjunctiveBooleanQuery": [Conjunctive Boolean Query],
Expand Down Expand Up @@ -1906,6 +1907,52 @@ A classical NP-complete problem from Garey and Johnson @garey1979[Ch.~3, p.~76],
]
}

#{
let x = load-model-example("TwoDimensionalConsecutiveSets")
let n = x.instance.alphabet_size
let subs = x.instance.subsets
let m = subs.len()
let sol = (config: x.optimal_config, metric: x.optimal_value)
let config = sol.config
// Build groups from config: groups.at(g) = list of symbols in group g
let groups = range(n).map(g => range(n).filter(s => config.at(s) == g))
// Only non-empty groups
let nonempty = groups.enumerate().filter(((_, g)) => g.len() > 0)
let k = nonempty.len()
let fmt-set(s) = "${" + s.map(e => str(e)).join(", ") + "}$"
[
#problem-def("TwoDimensionalConsecutiveSets")[
Given finite alphabet $Sigma = {0, 1, dots, n - 1}$ and collection $cal(C) = {Sigma_1, dots, Sigma_m}$ of subsets of $Sigma$, determine whether $Sigma$ can be partitioned into disjoint sets $X_1, X_2, dots, X_k$ such that each $X_i$ has at most one element in common with each $Sigma_j$, and for each $Sigma_j in cal(C)$ there is an index $l(j)$ with $Sigma_j subset.eq X_(l(j)) union X_(l(j)+1) union dots.c union X_(l(j)+|Sigma_j|-1)$.
][
This problem generalizes the Consecutive Sets problem (SR18) by requiring not just that each subset's elements appear consecutively in an ordering, but that they be spread across consecutive groups of a partition where each group contributes at most one element per subset. Shown NP-complete by Lipski @lipski1977fct via transformation from Graph 3-Colorability. The problem arises in information storage and retrieval where records must be organized in contiguous blocks. It remains NP-complete if all subsets have at most 5 elements, but is solvable in polynomial time if all subsets have at most 2 elements. The brute-force algorithm assigns each of $n$ symbols to one of up to $n$ groups, giving $O^*(n^n)$ time#footnote[No algorithm improving on brute-force enumeration is known for this problem.].

*Example.* Let $Sigma = {0, 1, dots, #(n - 1)}$ and $cal(C) = {#range(m).map(i => $Sigma_#(i + 1)$).join(", ")}$ with #subs.enumerate().map(((i, s)) => $Sigma_#(i + 1) = #fmt-set(s)$).join(", "). A valid partition uses $k = #k$ groups: #nonempty.map(((g, elems)) => $X_#(g + 1) = #fmt-set(elems)$).join(", "). Each group intersects every subset in at most one element, and each subset's elements span exactly $|Sigma_j|$ consecutive groups. For instance, $Sigma_1 = {0, 1, 2}$ maps to groups $X_1, X_2, X_3$ (consecutive), and $Sigma_5 = {0, 5}$ maps to groups $X_1, X_2$ (consecutive). Multiple valid partitions exist for this instance, differing only by unused or shifted group labels.

#figure(
canvas(length: 1cm, {
import draw: *
// Draw groups as labeled columns
let gw = 1.4
let gh = 0.45
for (col, (g, elems)) in nonempty.enumerate() {
let x0 = col * (gw + 0.3)
// Group header
content((x0 + gw / 2, 0.5), $X_#(g + 1)$, anchor: "south")
// Draw box for the group
rect((x0, -elems.len() * gh), (x0 + gw, 0),
stroke: 0.5pt + black, fill: rgb("#e8f0fe"))
// Elements inside
for (row, elem) in elems.enumerate() {
content((x0 + gw / 2, -row * gh - gh / 2), text(size: 9pt, str(elem)))
}
}
}),
caption: [2-Dimensional Consecutive Sets: partition of $Sigma = {0, dots, 5}$ into #k groups satisfying intersection and consecutiveness constraints for all #m subsets.],
) <fig:two-dim-consecutive-sets>
]
]
}

== Optimization Problems

#{
Expand Down
160 changes: 86 additions & 74 deletions docs/paper/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -944,20 +944,25 @@ @article{papadimitriou1982
doi = {10.1145/322307.322309}
}

@book{papadimitriou-steiglitz1982,
author = {Christos H. Papadimitriou and Kenneth Steiglitz},
title = {Combinatorial Optimization: Algorithms and Complexity},
publisher = {Prentice-Hall},
address = {Englewood Cliffs, NJ},
year = {1982}
@article{booth1976,
author = {Booth, Kellogg S. and Lueker, George S.},
title = {Testing for the consecutive ones property, interval graphs, and graph planarity using {PQ}-tree algorithms},
journal = {Journal of Computer and System Sciences},
volume = {13},
number = {3},
pages = {335--379},
year = {1976}
}

@techreport{Heidari2022,
author = {Heidari, Shahrokh and Dinneen, Michael J. and Delmas, Patrice},
title = {An Equivalent {QUBO} Model to the Minimum Multi-Way Cut Problem},
institution = {Centre for Discrete Mathematics and Theoretical Computer Science, University of Auckland},
year = {2022},
number = {CDMTCS-565}
@article{boothlueker1976,
author = {Kellogg S. Booth and George S. Lueker},
title = {Testing for the Consecutive Ones Property, Interval Graphs, and Graph Planarity Using {PQ}-Tree Algorithms},
journal = {Journal of Computer and System Sciences},
volume = {13},
number = {3},
pages = {335--379},
year = {1976},
doi = {10.1016/S0022-0000(76)80045-1}
}

@phdthesis{booth1975,
Expand All @@ -967,25 +972,25 @@ @phdthesis{booth1975
year = {1975}
}

@article{booth1976,
author = {Booth, Kellogg S. and Lueker, George S.},
title = {Testing for the consecutive ones property, interval graphs, and graph planarity using {PQ}-tree algorithms},
journal = {Journal of Computer and System Sciences},
volume = {13},
number = {3},
pages = {335--379},
year = {1976}
@article{chopra1996,
author = {Sunil Chopra and Jonathan H. Owen},
title = {Extended formulations for the A-cut problem},
journal = {Mathematical Programming},
volume = {73},
pages = {7--30},
year = {1996},
doi = {10.1007/BF02592096}
}

@article{lawler1972,
author = {Eugene L. Lawler},
title = {A Procedure for Computing the $K$ Best Solutions to Discrete Optimization Problems and Its Application to the Shortest Path Problem},
journal = {Management Science},
volume = {18},
number = {7},
pages = {401--405},
@article{coffman1972,
author = {Edward G. Coffman and Ronald L. Graham},
title = {Optimal Scheduling for Two-Processor Systems},
journal = {Acta Informatica},
volume = {1},
number = {3},
pages = {200--213},
year = {1972},
doi = {10.1287/mnsc.18.7.401}
doi = {10.1007/BF00288685}
}

@article{eppstein1992,
Expand All @@ -999,14 +1004,23 @@ @article{eppstein1992
doi = {10.1007/BF01994880}
}

@article{chopra1996,
author = {Sunil Chopra and Jonathan H. Owen},
title = {Extended formulations for the A-cut problem},
journal = {Mathematical Programming},
volume = {73},
pages = {7--30},
year = {1996},
doi = {10.1007/BF02592096}
@techreport{Heidari2022,
author = {Heidari, Shahrokh and Dinneen, Michael J. and Delmas, Patrice},
title = {An Equivalent {QUBO} Model to the Minimum Multi-Way Cut Problem},
institution = {Centre for Discrete Mathematics and Theoretical Computer Science, University of Auckland},
year = {2022},
number = {CDMTCS-565}
}

@article{hu1961,
author = {Te Chiang Hu},
title = {Parallel Sequencing and Assembly Line Problems},
journal = {Operations Research},
volume = {9},
number = {6},
pages = {841--848},
year = {1961},
doi = {10.1287/opre.9.6.841}
}

@article{kou1977,
Expand All @@ -1020,26 +1034,15 @@ @article{kou1977
doi = {10.1137/0206005}
}

@article{boothlueker1976,
author = {Kellogg S. Booth and George S. Lueker},
title = {Testing for the Consecutive Ones Property, Interval Graphs, and Graph Planarity Using {PQ}-Tree Algorithms},
journal = {Journal of Computer and System Sciences},
volume = {13},
number = {3},
pages = {335--379},
year = {1976},
doi = {10.1016/S0022-0000(76)80045-1}
}

@article{ullman1975,
author = {Jeffrey D. Ullman},
title = {NP-Complete Scheduling Problems},
journal = {Journal of Computer and System Sciences},
volume = {10},
number = {3},
pages = {384--393},
year = {1975},
doi = {10.1016/S0022-0000(75)80008-0}
@article{lawler1972,
author = {Eugene L. Lawler},
title = {A Procedure for Computing the $K$ Best Solutions to Discrete Optimization Problems and Its Application to the Shortest Path Problem},
journal = {Management Science},
volume = {18},
number = {7},
pages = {401--405},
year = {1972},
doi = {10.1287/mnsc.18.7.401}
}

@article{lenstra1978,
Expand All @@ -1053,26 +1056,24 @@ @article{lenstra1978
doi = {10.1287/opre.26.1.22}
}

@article{coffman1972,
author = {Edward G. Coffman and Ronald L. Graham},
title = {Optimal Scheduling for Two-Processor Systems},
journal = {Acta Informatica},
volume = {1},
number = {3},
pages = {200--213},
year = {1972},
doi = {10.1007/BF00288685}
@inproceedings{lipski1977fct,
author = {Witold Lipski Jr.},
title = {Two {NP}-Complete Problems Related to Information Retrieval},
booktitle = {Fundamentals of Computation Theory (FCT 1977)},
series = {Lecture Notes in Computer Science},
volume = {56},
pages = {452--458},
publisher = {Springer},
year = {1977},
doi = {10.1007/3-540-08442-8_115}
}

@article{hu1961,
author = {Te Chiang Hu},
title = {Parallel Sequencing and Assembly Line Problems},
journal = {Operations Research},
volume = {9},
number = {6},
pages = {841--848},
year = {1961},
doi = {10.1287/opre.9.6.841}
@book{papadimitriou-steiglitz1982,
author = {Christos H. Papadimitriou and Kenneth Steiglitz},
title = {Combinatorial Optimization: Algorithms and Complexity},
publisher = {Prentice-Hall},
address = {Englewood Cliffs, NJ},
year = {1982}
}

@inproceedings{papadimitriou1979,
Expand All @@ -1083,3 +1084,14 @@ @inproceedings{papadimitriou1979
year = {1979},
doi = {10.1145/800135.804393}
}

@article{ullman1975,
author = {Jeffrey D. Ullman},
title = {NP-Complete Scheduling Problems},
journal = {Journal of Computer and System Sciences},
volume = {10},
number = {3},
pages = {384--393},
year = {1975},
doi = {10.1016/S0022-0000(75)80008-0}
}
1 change: 1 addition & 0 deletions docs/src/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ Stdin is supported with `-`:
```bash
pred create MIS --graph 0-1,1-2,2-3 | pred solve -
pred create MIS --graph 0-1,1-2,2-3 | pred solve - --solver brute-force
pred create TwoDimensionalConsecutiveSets --alphabet-size 6 --sets "0,1,2;3,4,5;1,3;2,4;0,5" | pred solve - --solver brute-force
```

When the problem is not ILP, the solver automatically reduces it to ILP, solves, and maps the solution back. The auto-reduction is shown in the output:
Expand Down
9 changes: 6 additions & 3 deletions problemreductions-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ Flags by problem type:
ComparativeContainment --universe, --r-sets, --s-sets [--r-weights] [--s-weights]
X3C (ExactCoverBy3Sets) --universe, --sets (3 elements each)
SetBasis --universe, --sets, --k
PrimeAttributeName --universe, --deps, --query
MinimumCardinalityKey --num-attributes, --dependencies, --k
PrimeAttributeName --universe, --deps, --query
TwoDimensionalConsecutiveSets --alphabet-size, --sets
BicliqueCover --left, --right, --biedges, --k
BalancedCompleteBipartiteSubgraph --left, --right, --biedges, --k
BiconnectivityAugmentation --graph, --potential-edges, --budget [--num-vertices]
Expand Down Expand Up @@ -307,8 +308,9 @@ Examples:
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
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\"
pred create SetBasis --universe 4 --sets \"0,1;1,2;0,2;0,1,2\" --k 3
pred create MinimumCardinalityKey --num-attributes 6 --dependencies \"0,1>2;0,2>3;1,3>4;2,4>5\" --k 2
pred create PrimeAttributeName --universe 6 --deps \"0,1>2,3,4,5;2,3>0,1,4,5\" --query 3
pred create MinimumCardinalityKey --num-attributes 6 --dependencies \"0,1>2;0,2>3;1,3>4;2,4>5\" --k 2")]
pred create TwoDimensionalConsecutiveSets --alphabet-size 6 --sets \"0,1,2;3,4,5;1,3;2,4;0,5\"")]
pub struct CreateArgs {
/// Problem type (e.g., MIS, QUBO, SAT). Omit when using --example.
#[arg(value_parser = crate::problem_name::ProblemNameParser)]
Expand Down Expand Up @@ -547,7 +549,7 @@ pub struct CreateArgs {
/// Number of available workers for StaffScheduling
#[arg(long)]
pub num_workers: Option<u64>,
/// Alphabet size for LCS, SCS, or StringToStringCorrection (optional; inferred from the input strings if omitted)
/// Alphabet size for LCS, SCS, StringToStringCorrection, or TwoDimensionalConsecutiveSets (optional; inferred from the input strings if omitted)
#[arg(long)]
pub alphabet_size: Option<usize>,
/// Number of attributes for AdditionalKey or MinimumCardinalityKey
Expand Down Expand Up @@ -597,6 +599,7 @@ Examples:
pred solve reduced.json -o solution.json # save result to file
pred create MIS --graph 0-1,1-2 | pred solve - # read from stdin when an ILP path exists
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
pred create TwoDimensionalConsecutiveSets --alphabet-size 6 --sets \"0,1,2;3,4,5;1,3;2,4;0,5\" | pred solve - --solver brute-force
pred solve problem.json --timeout 10 # abort after 10 seconds

Typical workflow:
Expand Down
30 changes: 27 additions & 3 deletions problemreductions-cli/src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,18 @@ fn example_for(canonical: &str, graph_type: Option<&str>) -> &'static str {
"--universe 4 --r-sets \"0,1,2,3;0,1\" --s-sets \"0,1,2,3;2,3\" --r-weights 2,5 --s-weights 3,6"
}
"SetBasis" => "--universe 4 --sets \"0,1;1,2;0,2;0,1,2\" --k 3",
"PrimeAttributeName" => {
"--universe 6 --deps \"0,1>2,3,4,5;2,3>0,1,4,5\" --query 3"
}
"LongestCommonSubsequence" => {
"--strings \"010110;100101;001011\" --bound 3 --alphabet-size 2"
}
"MinimumCardinalityKey" => {
"--num-attributes 6 --dependencies \"0,1>2;0,2>3;1,3>4;2,4>5\" --k 2"
}
"PrimeAttributeName" => {
"--universe 6 --deps \"0,1>2,3,4,5;2,3>0,1,4,5\" --query 3"
}
"TwoDimensionalConsecutiveSets" => {
"--alphabet-size 6 --sets \"0,1,2;3,4,5;1,3;2,4;0,5\""
}
"ShortestCommonSupersequence" => "--strings \"0,1,2;1,2,0\" --bound 4",
"SequencingToMinimizeMaximumCumulativeCost" => {
"--costs 2,-1,3,-2,1,-3 --precedence-pairs \"0>2,1>2,1>3,2>4,3>5,4>5\" --bound 4"
Expand Down Expand Up @@ -1794,6 +1797,27 @@ pub fn create(args: &CreateArgs, out: &OutputConfig) -> Result<()> {
)
}

// TwoDimensionalConsecutiveSets
"TwoDimensionalConsecutiveSets" => {
let alphabet_size = args.alphabet_size.or(args.universe).ok_or_else(|| {
anyhow::anyhow!(
"TwoDimensionalConsecutiveSets requires --alphabet-size (or --universe) and --sets\n\n\
Usage: pred create TwoDimensionalConsecutiveSets --alphabet-size 6 --sets \"0,1,2;3,4,5;1,3;2,4;0,5\""
)
})?;
let sets = parse_sets(args)?;
(
ser(
problemreductions::models::set::TwoDimensionalConsecutiveSets::try_new(
alphabet_size,
sets,
)
.map_err(anyhow::Error::msg)?,
)?,
resolved_variant.clone(),
)
}

// BicliqueCover
"BicliqueCover" => {
let usage = "pred create BicliqueCover --left 2 --right 2 --biedges 0-0,0-1,1-1 --k 2";
Expand Down
Loading
Loading