Skip to content

Fix #330: Add MinMaxMulticenter (p-Center) model#630

Open
zazabap wants to merge 8 commits intomainfrom
issue-330-minmax-multicenter
Open

Fix #330: Add MinMaxMulticenter (p-Center) model#630
zazabap wants to merge 8 commits intomainfrom
issue-330-minmax-multicenter

Conversation

@zazabap
Copy link
Collaborator

@zazabap zazabap commented Mar 13, 2026

Summary

Adds the MinMaxMulticenter (vertex p-center) problem model as a satisfaction problem. Given a graph with vertex weights and edge lengths, K centers to place, and a distance bound B, determine whether K vertices can be chosen such that the maximum weighted shortest-path distance from any vertex to its nearest center is at most B.

Fixes #330

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 99.63504% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.94%. Comparing base (9a2b2b7) to head (4d47043).

Files with missing lines Patch % Lines
src/models/graph/min_max_multicenter.rs 99.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #630      +/-   ##
==========================================
+ Coverage   96.92%   96.94%   +0.01%     
==========================================
  Files         271      273       +2     
  Lines       36298    36572     +274     
==========================================
+ Hits        35182    35454     +272     
- Misses       1116     1118       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

GiggleLiu and others added 5 commits March 16, 2026 17:10
Implements the vertex-restricted p-center problem as a satisfaction problem:
given a graph with vertex weights, edge lengths, K centers, and distance
bound B, determine if K vertices can be chosen such that max{w(v)*d(v)} <= B.

Includes model, unit tests (15 tests), CLI creation support, canonical
example, and regenerated fixtures/schemas.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@GiggleLiu
Copy link
Contributor

Implementation Summary

Changes

  • src/models/graph/min_max_multicenter.rs — New satisfaction problem: MinMaxMulticenter (vertex p-center). Fields: graph, vertex_weights, edge_lengths, k, bound. Multi-source Dijkstra for shortest distances, evaluate returns bool.
  • src/models/graph/mod.rs — Registered module, re-export, doc comment, canonical example spec
  • src/models/mod.rs — Added MinMaxMulticenter to graph re-exports
  • src/lib.rs — Added MinMaxMulticenter to prelude
  • src/unit_tests/models/graph/min_max_multicenter.rs — 16 unit tests: basic, evaluate valid/invalid, serialization, brute-force solver, disconnected graph, weighted vertices, non-unit edge lengths, single vertex, all centers, panic assertions
  • src/unit_tests/trait_consistency.rs — Added MinMaxMulticenter entry
  • problemreductions-cli/src/cli.rs — Added help table entry
  • problemreductions-cli/src/commands/create.rs — Added pred create match arm
  • docs/paper/reductions.typ — Added display-name, problem-def with formal definition, background, and CeTZ example figure
  • src/example_db/fixtures/examples.json — Regenerated (33 model examples)
  • docs/src/reductions/problem_schemas.json — Regenerated
  • docs/src/reductions/reduction_graph.json — Regenerated

Deviations from Plan

  • None

Open Questions

  • DRY: MinMaxMulticenter and MinimumSumMulticenter share a nearly identical multi-source Dijkstra implementation. Could be extracted into a shared helper in a follow-up refactor.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new graph satisfaction model, MinMaxMulticenter (vertex p-center), integrating it into the model registry, CLI creation workflow, example DB, and generated docs/paper materials.

Changes:

  • Introduces MinMaxMulticenter<G, W> model with schema/variant registration and brute-force compatibility.
  • Adds unit tests, trait-consistency coverage, and example-db fixture entry for the new model.
  • Wires the model into exports/prelude, CLI pred create, and regenerates docs JSON + paper section.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/models/graph/min_max_multicenter.rs Implements the new MinMaxMulticenter satisfaction problem model, registers schema/variants, and provides example-db spec + tests module hook.
src/models/graph/mod.rs Registers the new graph model module and re-exports it; adds canonical example spec hook.
src/models/mod.rs Exposes MinMaxMulticenter at the top-level models module.
src/lib.rs Adds MinMaxMulticenter to the prelude exports.
src/unit_tests/models/graph/min_max_multicenter.rs Adds comprehensive unit tests for construction, evaluation, serialization, solver integration, and panics.
src/unit_tests/trait_consistency.rs Adds a trait-consistency smoke test instance for MinMaxMulticenter.
src/example_db/fixtures/examples.json Adds a canonical example instance and satisfying configurations for MinMaxMulticenter.
problemreductions-cli/src/commands/create.rs Adds pred create MinMaxMulticenter support and a help example string.
problemreductions-cli/src/cli.rs Documents MinMaxMulticenter-specific flags in CLI help text.
docs/src/reductions/problem_schemas.json Adds generated schema entry for MinMaxMulticenter.
docs/src/reductions/reduction_graph.json Adds generated reduction-graph node entry for MinMaxMulticenter and updates node indices accordingly.
docs/paper/reductions.typ Adds paper section + figure/example text for MinMaxMulticenter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +174 to +179
// Initialize centers
for (v, &selected) in config.iter().enumerate() {
if selected == 1 {
dist[v] = Some(W::Sum::zero());
}
}
Comment on lines +1013 to +1014
// Pick optimal[1] = {v1, v4} to match figure
let sol = x.optimal.at(1)
Comment on lines +966 to +971
let bound = args.bound.ok_or_else(|| {
anyhow::anyhow!(
"MinMaxMulticenter requires --bound (distance bound B)\n\n\
Usage: pred create MinMaxMulticenter --graph 0-1,1-2,2-3 --k 2 --bound 2"
)
})? as i32;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Model] MinMaxMulticenter

3 participants