Skip to content

Commit a784239

Browse files
GiggleLiuclaude
andauthored
feat: batch implement reduction rules (phases 1-3) (#1017)
* Add CircuitSAT to Satisfiability reduction (#970) * Add Maximum2Satisfiability to MaxCut reduction * feat: add satisfiability to maximum2satisfiability reduction * feat: add KSAT to decision MVC reduction * feat: add 3sat to directed two-commodity flow * Add MonochromaticTriangle reductions * style: format ksatisfiability_directedtwocommodityintegralflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add proof-only mvc to mmm rule * feat: add MinimumCoveringByCliques to ILP * feat: add SubsetSum and IntegerKnapsack reductions * feat: add 3SAT to FeasibleRegisterAssignment + FRA to ILP reductions (#905) Implements Sethi's Reduction 3 / Theorem 5.11 with p/q/r/rbar clause gadgets, cyclic links, and shared-register variable leaf pairs. Also adds the companion FeasibleRegisterAssignment → ILP rule. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add paper entries for FRA reductions (#905) Add reduction-rule entries for KSatisfiability → FeasibleRegisterAssignment (Sethi Reduction 3) and FeasibleRegisterAssignment → ILP. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: gate ILPSolver imports behind ilp-solver feature Address Copilot review comments: ILPSolver and related imports in integration tests were unconditional but only used in feature-gated blocks. Gate them with #[cfg(feature = "ilp-solver")]. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fb9c608 commit a784239

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4268
-42
lines changed

docs/paper/reductions.typ

Lines changed: 497 additions & 3 deletions
Large diffs are not rendered by default.

src/models/graph/directed_two_commodity_integral_flow.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inventory::submit! {
3939
/// whether two integral flow functions f_1, f_2: A -> Z_0^+ exist such that:
4040
/// 1. Joint capacity: f_1(a) + f_2(a) <= c(a) for all a in A
4141
/// 2. Flow conservation: for each commodity i, flow is conserved at every
42-
/// vertex except the four terminals
42+
/// vertex except its own source and sink
4343
/// 3. Requirements: net flow into t_i under f_i is at least R_i
4444
///
4545
/// # Variables
@@ -191,8 +191,6 @@ impl DirectedTwoCommodityIntegralFlow {
191191
return false;
192192
}
193193
let arcs = self.graph.arcs();
194-
let terminals = [self.source_1, self.sink_1, self.source_2, self.sink_2];
195-
196194
// (1) Joint capacity constraint
197195
for a in 0..m {
198196
let f1 = config[a] as u64;
@@ -216,8 +214,18 @@ impl DirectedTwoCommodityIntegralFlow {
216214
}
217215

218216
for (commodity, commodity_balances) in balances.iter().enumerate() {
217+
let src = if commodity == 0 {
218+
self.source_1
219+
} else {
220+
self.source_2
221+
};
219222
for (v, &balance) in commodity_balances.iter().enumerate() {
220-
if !terminals.contains(&v) && balance != 0 {
223+
let snk = if commodity == 0 {
224+
self.sink_1
225+
} else {
226+
self.sink_2
227+
};
228+
if v != src && v != snk && balance != 0 {
221229
return false;
222230
}
223231
}

src/models/graph/monochromatic_triangle.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ impl<G: Graph> MonochromaticTriangle<G> {
125125
&self.triangles
126126
}
127127

128+
/// Get the number of triangles in the graph.
129+
pub fn num_triangles(&self) -> usize {
130+
self.triangles.len()
131+
}
132+
128133
/// Get the ordered edge list.
129134
pub fn edge_list(&self) -> &[(usize, usize)] {
130135
&self.edge_list

src/models/misc/feasible_register_assignment.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ impl FeasibleRegisterAssignment {
187187
self.num_registers
188188
}
189189

190+
/// Count unordered vertex pairs that share a register.
191+
pub fn num_same_register_pairs(&self) -> usize {
192+
let mut counts = vec![0usize; self.num_registers];
193+
for &register in &self.assignment {
194+
counts[register] += 1;
195+
}
196+
counts
197+
.into_iter()
198+
.map(|count| count.saturating_sub(1) * count / 2)
199+
.sum()
200+
}
201+
190202
/// Get the arcs.
191203
pub fn arcs(&self) -> &[(usize, usize)] {
192204
&self.arcs

0 commit comments

Comments
 (0)