Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #608 +/- ##
==========================================
+ Coverage 96.77% 96.79% +0.02%
==========================================
Files 228 230 +2
Lines 30048 30310 +262
==========================================
+ Hits 29079 29339 +260
- Misses 969 971 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add the Rural Postman Problem as a satisfaction problem: given a graph with edge lengths, a required subset of edges, and a bound B, determine if a circuit exists covering all required edges within the bound. - Model: src/models/graph/rural_postman.rs (SatisfactionProblem, Metric=bool) - 16 unit tests covering valid/invalid circuits, brute force, serialization - CLI: dispatch, alias (RPP), create handler with --required-edges/--bound - Paper: display-name + problem-def entry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds a new graph satisfaction model for the Rural Postman Problem (RPP) and wires it into the library exports, CLI instance creation/serialization, and documentation/schema generation.
Changes:
- Introduces
RuralPostmanmodel with registry schema entry, variants, and evaluation logic. - Adds unit tests for model behavior plus CLI dispatch +
pred createsupport and name/alias resolution. - Updates docs (problem schemas JSON and paper) to include the new problem.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/models/graph/rural_postman.rs |
New RuralPostman model, registry schema entry, evaluation logic, and variant declaration. |
src/unit_tests/models/graph/rural_postman.rs |
Unit tests covering construction, evaluation cases, brute-force satisfiability, serialization, and accessors. |
src/models/graph/mod.rs |
Registers the new graph model module and re-exports RuralPostman. |
src/models/mod.rs |
Re-exports RuralPostman from the top-level models module. |
src/lib.rs |
Exposes RuralPostman via the crate prelude. |
problemreductions-cli/src/problem_name.rs |
Adds RPP alias and resolves ruralpostman/rpp to RuralPostman. |
problemreductions-cli/src/dispatch.rs |
Enables CLI load/serialize dispatch for RuralPostman<SimpleGraph,i32>. |
problemreductions-cli/src/commands/create.rs |
Adds pred create RuralPostman ... support and usage examples. |
problemreductions-cli/src/cli.rs |
Adds --required-edges and --bound CLI flags and updates help text. |
docs/src/reductions/problem_schemas.json |
Adds the RuralPostman schema entry for docs/tooling. |
docs/paper/reductions.typ |
Adds a Rural Postman definition section for the paper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// # Representation | ||
| /// | ||
| /// Each edge is assigned a binary variable: | ||
| /// - 0: edge is not in the circuit | ||
| /// - 1: edge is in the circuit | ||
| /// | ||
| /// A valid circuit requires: | ||
| /// - All required edges are selected (config[i] == 1 for i in required_edges) | ||
| /// - All vertices with selected edges have even degree (Eulerian condition) | ||
| /// - The selected edges form a connected subgraph | ||
| /// - Total length ≤ bound | ||
| /// |
There was a problem hiding this comment.
The current model/evaluation encodes a connected Eulerian subgraph (binary select edges, even degrees, connected) and sums each selected edge length once. This is stricter than the Rural Postman definition in the PR/issue, where a circuit may traverse edges (especially non-required connectors) multiple times. As a result, instances that are feasible only by repeating edges will be incorrectly rejected. Consider changing the representation to allow per-edge traversal counts (dims > 2 derived from the bound / edge length) or otherwise updating the problem definition/description and docs to match the implemented (Eulerian-subgraph) problem.
| description: "Find a circuit covering required edges with total length at most B (Rural Postman Problem)", | ||
| fields: &[ | ||
| FieldInfo { name: "graph", type_name: "G", description: "The underlying graph G=(V,E)" }, | ||
| FieldInfo { name: "edge_lengths", type_name: "Vec<W>", description: "Edge lengths l(e) for each e in E" }, |
There was a problem hiding this comment.
ProblemSchemaEntry declares the flag/field name as edge_lengths, but the CLI pred create RuralPostman implementation parses --edge-weights (CreateArgs has edge_weights, not edge_lengths). Because schema-driven help prints flags from these field names, users will be told to pass --edge-lengths, which won't work. Please align naming (e.g., rename schema field to edge_weights and consider renaming the struct field/accessor for consistency with other graph models).
| FieldInfo { name: "edge_lengths", type_name: "Vec<W>", description: "Edge lengths l(e) for each e in E" }, | |
| FieldInfo { name: "edge_weights", type_name: "Vec<W>", description: "Edge lengths l(e) for each e in E" }, |
| #problem-def("RuralPostman")[ | ||
| Given an undirected graph $G = (V, E)$ with edge lengths $l: E -> ZZ_(gt.eq 0)$, a subset $E' subset.eq E$ of required edges, and a bound $B in ZZ^+$, determine whether there exists a circuit (closed walk) in $G$ that traverses every edge in $E'$ and has total length at most $B$. | ||
| ][ | ||
| The Rural Postman Problem (RPP) is a fundamental NP-complete arc-routing problem @lenstra1976 that generalizes the Chinese Postman Problem. When $E' = E$, the problem reduces to finding an Eulerian circuit with minimum augmentation (polynomial-time solvable via $T$-join matching). For general $E' subset E$, exact algorithms use dynamic programming over subsets of required edges in $O(n^2 dot 2^r)$ time, where $r = |E'|$ and $n = |V|$, analogous to the Held-Karp algorithm for TSP. The problem admits a $3 slash 2$-approximation for metric instances @frederickson1979. |
There was a problem hiding this comment.
The definition mixes subset symbols: it introduces
| The Rural Postman Problem (RPP) is a fundamental NP-complete arc-routing problem @lenstra1976 that generalizes the Chinese Postman Problem. When $E' = E$, the problem reduces to finding an Eulerian circuit with minimum augmentation (polynomial-time solvable via $T$-join matching). For general $E' subset E$, exact algorithms use dynamic programming over subsets of required edges in $O(n^2 dot 2^r)$ time, where $r = |E'|$ and $n = |V|$, analogous to the Held-Karp algorithm for TSP. The problem admits a $3 slash 2$-approximation for metric instances @frederickson1979. | |
| The Rural Postman Problem (RPP) is a fundamental NP-complete arc-routing problem @lenstra1976 that generalizes the Chinese Postman Problem. When $E' = E$, the problem reduces to finding an Eulerian circuit with minimum augmentation (polynomial-time solvable via $T$-join matching). For general $E' subset.eq E$, exact algorithms use dynamic programming over subsets of required edges in $O(n^2 dot 2^r)$ time, where $r = |E'|$ and $n = |V|$, analogous to the Held-Karp algorithm for TSP. The problem admits a $3 slash 2$-approximation for metric instances @frederickson1979. |
Resolve additive merge conflicts in imports, CLI args, problem_name aliases, and paper display-name/problem-def entries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. Rename schema field edge_lengths → edge_weights for CLI consistency
2. Fix subset symbol inconsistency in paper (subset → subset.eq)
3. Allow edge multiplicity {0,1,2} instead of binary selection to correctly
model circuits that traverse edges multiple times (RPP semantics)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review Pipeline Report
Copilot Fixes Applied
🤖 Generated by review-pipeline |
Resolve conflicts in registry files to include both RuralPostman (this branch) and PartitionIntoTriangles (from main). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve conflicts keeping both SubgraphIsomorphism (this branch) and RuralPostman (from main/PR #608) in all shared registry files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Add the Rural Postman Problem (RPP) as a satisfaction problem model. Given a graph G=(V,E) with edge lengths, a subset E' of required edges, and a bound B, determine if there exists a circuit covering all required edges with total length at most B.
Fixes #248