Skip to content

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

Merged
GiggleLiu merged 11 commits intomainfrom
issue-330-minmax-multicenter
Mar 21, 2026
Merged

Fix #330: Add MinMaxMulticenter (p-Center) model#630
GiggleLiu merged 11 commits intomainfrom
issue-330-minmax-multicenter

Conversation

@zazabap
Copy link
Copy Markdown
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
Copy Markdown

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 99.63370% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.59%. Comparing base (1d7128b) to head (44674d0).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/models/graph/min_max_multicenter.rs 99.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #630      +/-   ##
==========================================
- Coverage   97.59%   97.59%   -0.01%     
==========================================
  Files         385      387       +2     
  Lines       47886    48159     +273     
==========================================
+ Hits        46736    47002     +266     
- Misses       1150     1157       +7     

☔ 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
Copy Markdown
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
Copy Markdown

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 thread docs/paper/reductions.typ Outdated
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;
GiggleLiu and others added 4 commits March 16, 2026 19:26
…icenter

# Conflicts:
#	docs/paper/reductions.typ
#	docs/src/cli.md
#	docs/src/reductions/problem_schemas.json
#	docs/src/reductions/reduction_graph.json
#	problemreductions-cli/src/cli.rs
#	problemreductions-cli/src/commands/create.rs
#	problemreductions-cli/src/commands/inspect.rs
#	problemreductions-cli/src/commands/solve.rs
#	problemreductions-cli/src/dispatch.rs
#	problemreductions-cli/tests/cli_tests.rs
#	src/example_db/fixtures/examples.json
#	src/lib.rs
#	src/models/graph/mod.rs
#	src/models/mod.rs
- Update canonical_model_example_specs to use new ModelExampleSpec
  struct fields (instance, optimal_config, optimal_value) instead of
  the old callback-based API
- Fix paper graph access: graph.edges instead of graph.inner.edges
- Fix paper optimal access: use optimal_config/optimal_value instead
  of old optimal array API
- Remove count of satisfying solutions (not available in new export)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@GiggleLiu GiggleLiu mentioned this pull request Mar 21, 2026
3 tasks
MinMaxMulticenter has no ILP reduction path, so it needs --solver
brute-force. Add it to the solve help text alongside
LengthBoundedDisjointPaths and StringToStringCorrection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@GiggleLiu GiggleLiu merged commit cb32085 into main Mar 21, 2026
5 checks passed
@GiggleLiu GiggleLiu deleted the issue-330-minmax-multicenter branch April 12, 2026 00:53
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