Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
81c2e1b
Migrate workspace to Rust 2024 edition
isPANN Oct 14, 2026
16ee25f
Adopt the Rust 2024 rustfmt style edition
isPANN Oct 14, 2026
57ebb23
Declare rust-version 1.88 and fix leftover indentation
isPANN Oct 14, 2026
8368cca
Cover error paths touched by the let-chain rewrite
isPANN Oct 14, 2026
5a02d66
Add --format to pipeline_pr.py wait-ci
isPANN Oct 15, 2026
4152d3e
Update stale create_pr test for head-branch PR lookup
isPANN Oct 15, 2026
f5b370f
Merge reviewed graph and numeric cast changes into Rust 2024
GiggleLiu Oct 29, 2026
aee5a97
Merge reviewed polynomial LCS reduction into Rust 2024
GiggleLiu Oct 29, 2026
3e768b3
Merge reviewed NAE-SAT reduction into Rust 2024
GiggleLiu Oct 29, 2026
62da604
Record current main ancestry for Rust 2024 integration
GiggleLiu Oct 29, 2026
fcd7073
Test one-register instruction count overflow boundaries
GiggleLiu Oct 29, 2026
e638958
Merge remote-tracking branch 'origin/main' into HEAD
GiggleLiu Oct 29, 2026
41ff242
Integrate Rust 2024 across the reviewed safe stack
GiggleLiu Oct 29, 2026
1f75349
Apply Rust 2024 let-chain style to polynomial comparison
GiggleLiu Oct 29, 2026
d96e7c8
Carry verified comparison fixture into Rust 2024 integration
GiggleLiu Oct 29, 2026
7777479
Merge website verification fixes into Rust 2024 candidate
GiggleLiu Oct 29, 2026
4f57c65
Merge browser math and provenance test fixes into Rust 2024 candidate
GiggleLiu Oct 29, 2026
17dfcc1
Merge commit '37e381c41490a2908510901b63ef2c745dd24ba7' into HEAD
GiggleLiu Oct 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ members = [
[package]
name = "problemreductions"
version = "0.6.0"
edition = "2021"
edition = "2024"
rust-version = "1.88"
description = "A library for reducing NP-hard problems"
license = "MIT"
repository = "https://github.com/CodingThrust/problem-reductions"
Expand Down
2 changes: 1 addition & 1 deletion benches/solver_benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Benchmarks for the BruteForce solver on various problem types.

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use problemreductions::models::formula::*;
use problemreductions::models::graph::*;
use problemreductions::models::misc::*;
Expand Down
2 changes: 1 addition & 1 deletion examples/detect_isolated_problems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//!
//! Run with: `cargo run --example detect_isolated_problems`

use problemreductions::rules::analysis::check_connectivity;
use problemreductions::rules::ReductionGraph;
use problemreductions::rules::analysis::check_connectivity;

fn main() {
let graph = ReductionGraph::new();
Expand Down
2 changes: 1 addition & 1 deletion examples/detect_unreachable_from_3sat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//!
//! Run with: `cargo run --example detect_unreachable_from_3sat`

use problemreductions::rules::analysis::{check_reachability_from_3sat, UnreachableReason};
use problemreductions::rules::ReductionGraph;
use problemreductions::rules::analysis::{UnreachableReason, check_reachability_from_3sat};

fn main() {
let graph = ReductionGraph::new();
Expand Down
63 changes: 31 additions & 32 deletions examples/export_mapping_stages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

use problemreductions::rules::unitdiskmapping::{
_internal::{
create_copylines, mis_overhead_copyline, mis_overhead_copyline_triangular, CopyLine,
MappingGrid,
CopyLine, MappingGrid, create_copylines, mis_overhead_copyline,
mis_overhead_copyline_triangular,
},
ksg, triangular,
};
Expand Down Expand Up @@ -110,21 +110,21 @@ fn extract_grid_nodes(grid: &MappingGrid) -> Vec<GridNodeExport> {
let (rows, cols) = grid.size();
for r in 0..rows {
for c in 0..cols {
if let Some(cell) = grid.get(r, c) {
if !cell.is_empty() {
let state = match cell {
CellState::Occupied { .. } => "O",
CellState::Doubled { .. } => "D",
CellState::Connected { .. } => "C",
CellState::Empty => ".",
};
nodes.push(GridNodeExport {
row: r as i64, // 0-indexed - DO NOT change!
col: c as i64, // 0-indexed - DO NOT change!
weight: cell.weight(),
state: state.to_string(),
});
}
if let Some(cell) = grid.get(r, c)
&& !cell.is_empty()
{
let state = match cell {
CellState::Occupied { .. } => "O",
CellState::Doubled { .. } => "D",
CellState::Connected { .. } => "C",
CellState::Empty => ".",
};
nodes.push(GridNodeExport {
row: r as i64, // 0-indexed - DO NOT change!
col: c as i64, // 0-indexed - DO NOT change!
weight: cell.weight(),
state: state.to_string(),
});
}
}
}
Expand Down Expand Up @@ -159,21 +159,20 @@ fn crossat_triangular(

fn get_vertex_order_from_julia(graph_name: &str) -> Option<Vec<usize>> {
let path = format!("tests/data/{}_triangular_trace.json", graph_name);
if let Ok(content) = fs::read_to_string(&path) {
if let Ok(data) = serde_json::from_str::<serde_json::Value>(&content) {
if let Some(copy_lines) = data["copy_lines"].as_array() {
let mut lines: Vec<_> = copy_lines
.iter()
.filter_map(|cl| {
let vertex = cl["vertex"].as_u64()? as usize;
let vslot = cl["vslot"].as_u64()? as usize;
Some((vertex - 1, vslot)) // Convert to 0-indexed
})
.collect();
lines.sort_by_key(|(_, vslot)| *vslot);
return Some(lines.into_iter().map(|(v, _)| v).collect());
}
}
if let Ok(content) = fs::read_to_string(&path)
&& let Ok(data) = serde_json::from_str::<serde_json::Value>(&content)
&& let Some(copy_lines) = data["copy_lines"].as_array()
{
let mut lines: Vec<_> = copy_lines
.iter()
.filter_map(|cl| {
let vertex = cl["vertex"].as_u64()? as usize;
let vslot = cl["vslot"].as_u64()? as usize;
Some((vertex - 1, vslot)) // Convert to 0-indexed
})
.collect();
lines.sort_by_key(|(_, vslot)| *vslot);
return Some(lines.into_iter().map(|(v, _)| v).collect());
}
None
}
Expand Down
2 changes: 1 addition & 1 deletion examples/export_petersen_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
//! - `docs/paper/static/petersen_square_unweighted.json` - Unweighted King's subgraph
//! - `docs/paper/static/petersen_triangular.json` - Weighted triangular lattice

use problemreductions::rules::unitdiskmapping::{ksg, triangular, MappingResult};
use problemreductions::rules::unitdiskmapping::{MappingResult, ksg, triangular};
use serde::Serialize;
use std::fs;
use std::path::Path;
Expand Down
2 changes: 1 addition & 1 deletion examples/export_schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Run with: `cargo run --example export_schemas [output_path]`

use problemreductions::registry::{collect_schemas, ProblemSchemaEntry};
use problemreductions::registry::{ProblemSchemaEntry, collect_schemas};
use std::path::{Path, PathBuf};

pub fn run(output_path: &Path) {
Expand Down
2 changes: 1 addition & 1 deletion examples/polynomial_compare_audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! Each endpoint group is one generic batch, including every nonzero field certificate.
//!
//! cargo run --release --example polynomial_compare_audit
use problemreductions::poly_compare::{compare_all, Direction, Profile, Reason, Verdict};
use problemreductions::poly_compare::{Direction, Profile, Reason, Verdict, compare_all};
use problemreductions::rules::{ReductionGraph, ReductionPath, ReductionStep};
use std::collections::BTreeMap;
use std::time::Instant;
Expand Down
3 changes: 2 additions & 1 deletion problemreductions-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "problemreductions-cli"
version = "0.6.0"
edition = "2021"
edition = "2024"
rust-version = "1.88"
description = "CLI tool for exploring NP-hard problem reductions"
license = "MIT"
repository = "https://github.com/CodingThrust/problem-reductions"
Expand Down
2 changes: 1 addition & 1 deletion problemreductions-cli/src/bin/pred_sym.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::{Parser, Subcommand};
use problemreductions::{big_o_normal_form, evaluate_approximate, Expr, ProblemParameters};
use problemreductions::{Expr, ProblemParameters, big_o_normal_form, evaluate_approximate};

#[derive(Parser)]
#[command(
Expand Down
64 changes: 32 additions & 32 deletions problemreductions-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ pub fn print_subcommand_help_hint(error_msg: &str) {
let cmd = Cli::command();
for (pattern, name) in subcmds {
if first_line.contains(pattern) {
if let Some(sub) = cmd.find_subcommand(name) {
if let Some(help) = sub.get_after_help() {
eprintln!("\n{help}");
}
if let Some(sub) = cmd.find_subcommand(name)
&& let Some(help) = sub.get_after_help()
{
eprintln!("\n{help}");
}
return;
}
Expand Down Expand Up @@ -477,16 +477,18 @@ mod tests {
.kind(),
ErrorKind::UnknownArgument
);
assert!(Cli::try_parse_from([
"pred",
"create",
"ThreePartition",
"--sizes",
"1,1,1",
"--bound",
"9223372036854775808",
])
.is_err());
assert!(
Cli::try_parse_from([
"pred",
"create",
"ThreePartition",
"--sizes",
"1,1,1",
"--bound",
"9223372036854775808",
])
.is_err()
);
Cli::try_parse_from([
"pred",
"create",
Expand Down Expand Up @@ -573,25 +575,23 @@ mod tests {

#[test]
fn extract_requires_exactly_one_mapping_input() {
assert!(Cli::try_parse_from([
"pred",
"extract",
"bundle.json",
"--config",
"[true,false]"
])
.is_ok());
assert!(
Cli::try_parse_from(["pred", "extract", "bundle.json", "--config", "[true,false]"])
.is_ok()
);
assert!(Cli::try_parse_from(["pred", "extract", "bundle.json"]).is_err());
assert!(Cli::try_parse_from(["pred", "extract", "bundle.json", "--value", "2"]).is_ok());
assert!(Cli::try_parse_from([
"pred",
"extract",
"bundle.json",
"--config",
"[true,false]",
"--value",
"2"
])
.is_err());
assert!(
Cli::try_parse_from([
"pred",
"extract",
"bundle.json",
"--config",
"[true,false]",
"--value",
"2"
])
.is_err()
);
}
}
4 changes: 2 additions & 2 deletions problemreductions-cli/src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::dispatch::ProblemJsonOutput;
use crate::output::OutputConfig;
use crate::problem_name::{resolve_problem_ref, unknown_problem_error};
use crate::util;
use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};
use num_bigint::BigUint;
use problemreductions::export::{ModelExample, ProblemRef, ProblemSide, RuleExample};
use problemreductions::models::formula::Quantifier;
Expand All @@ -19,7 +19,7 @@ use std::collections::{BTreeMap, BTreeSet};
mod schema_support;
use self::schema_support::*;
pub(crate) use self::schema_support::{
create_inputs_for, resolve_schema_field_type, InputValueKind,
InputValueKind, create_inputs_for, resolve_schema_field_type,
};

fn all_data_flags_empty(args: &CreateArgs) -> bool {
Expand Down
43 changes: 25 additions & 18 deletions problemreductions-cli/src/commands/create/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,9 +1046,10 @@ fn test_create_generalized_hex_requires_sink() {
};

let err = create(&args, &out).unwrap_err();
assert!(err
.to_string()
.contains("missing required construction input(s): sink"));
assert!(
err.to_string()
.contains("missing required construction input(s): sink")
);
}

#[test]
Expand Down Expand Up @@ -1189,9 +1190,10 @@ fn test_create_production_planning_requires_all_period_vectors() {
};

let err = create(&args, &out).unwrap_err();
assert!(err
.to_string()
.contains("missing required construction input(s): production_costs"));
assert!(
err.to_string()
.contains("missing required construction input(s): production_costs")
);
}

#[test]
Expand Down Expand Up @@ -1228,9 +1230,10 @@ fn test_create_production_planning_rejects_mismatched_period_lengths() {
};

let err = create(&args, &out).unwrap_err();
assert!(err
.to_string()
.contains("all per-period vectors must have length num_periods"));
assert!(
err.to_string()
.contains("all per-period vectors must have length num_periods")
);
}

#[test]
Expand Down Expand Up @@ -1452,9 +1455,10 @@ fn test_create_longest_path_requires_edge_lengths() {
};

let err = create(&args, &out).unwrap_err();
assert!(err
.to_string()
.contains("missing required construction input(s): edge_lengths"));
assert!(
err.to_string()
.contains("missing required construction input(s): edge_lengths")
);
}

#[test]
Expand Down Expand Up @@ -1509,9 +1513,10 @@ fn test_create_undirected_flow_lower_bounds_requires_lower_bounds() {
};

let err = create(&args, &out).unwrap_err();
assert!(err
.to_string()
.contains("missing required construction input(s): lower_bounds"));
assert!(
err.to_string()
.contains("missing required construction input(s): lower_bounds")
);
}

fn empty_args() -> CreateArgs {
Expand Down Expand Up @@ -2130,9 +2135,11 @@ fn test_create_kclique() {
let problem: KClique<SimpleGraph> = serde_json::from_value(created.data).unwrap();
assert_eq!(problem.k(), 3);
assert_eq!(problem.num_vertices(), 5);
assert!(problem
.evaluate(&vec![false, false, true, true, true])
.unwrap());
assert!(
problem
.evaluate(&vec![false, false, true, true, true])
.unwrap()
);

let _ = std::fs::remove_file(output_path);
}
Expand Down
2 changes: 1 addition & 1 deletion problemreductions-cli/src/commands/evaluate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::dispatch::{load_problem, read_input, ProblemJson};
use crate::dispatch::{ProblemJson, load_problem, read_input};
use crate::output::OutputConfig;
use anyhow::{Context, Result};
use std::path::Path;
Expand Down
2 changes: 1 addition & 1 deletion problemreductions-cli/src/commands/extract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::cli::ExtractArgs;
use crate::dispatch::{extract_bundle_value, read_input, BundleReplay, ReductionBundle};
use crate::dispatch::{BundleReplay, ReductionBundle, extract_bundle_value, read_input};
use crate::output::OutputConfig;
use anyhow::{Context, Result};

Expand Down
Loading