Skip to content

Fix #410: [Model] MultipleCopyFileAllocation#665

Merged
isPANN merged 15 commits intomainfrom
issue-410-multiple-copy-file-allocation
Mar 20, 2026
Merged

Fix #410: [Model] MultipleCopyFileAllocation#665
isPANN merged 15 commits intomainfrom
issue-410-multiple-copy-file-allocation

Conversation

@GiggleLiu
Copy link
Contributor

Summary

Add the execution plan for the MultipleCopyFileAllocation model.

Fixes #410

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.47%. Comparing base (1bafa02) to head (25493a5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #665      +/-   ##
==========================================
+ Coverage   97.46%   97.47%   +0.01%     
==========================================
  Files         353      355       +2     
  Lines       45097    45294     +197     
==========================================
+ Hits        43954    44151     +197     
  Misses       1143     1143              

☔ 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
Copy link
Contributor Author

Implementation Summary

Changes

  • Added the MultipleCopyFileAllocation satisfaction model, schema metadata, registry/prelude wiring, canonical example, and unit/trait-consistency coverage.
  • Added pred create MultipleCopyFileAllocation support with --graph, --usage, --storage, and --bound, plus CLI coverage for happy-path output and length-mismatch failures.
  • Added the paper problem-def entry and regenerated reduction exports for the new model.

Deviations from Plan

  • None.

Open Questions

  • None.

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 first-class support for the MultipleCopyFileAllocation graph satisfaction model across the library, CLI, tests, and generated docs/fixtures (fixes #410).

Changes:

  • Introduces MultipleCopyFileAllocation model implementation (schema registration, variants, example-db spec, and evaluation/cost logic).
  • Adds CLI pred create MultipleCopyFileAllocation support (+ new flags --usage / --storage) and corresponding CLI tests.
  • Updates example-db fixtures and generated docs JSON, plus adds unit tests and paper documentation section.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/models/graph/multiple_copy_file_allocation.rs New model implementation, schema registration, variants, and example-db spec
src/models/graph/mod.rs Registers the new model module, re-export, and example-db hook
src/models/mod.rs Re-exports MultipleCopyFileAllocation from the graph module
src/lib.rs Exposes MultipleCopyFileAllocation via the crate prelude
src/unit_tests/models/graph/multiple_copy_file_allocation.rs New unit tests covering creation, cost/validity, solver behavior, and serde
src/unit_tests/trait_consistency.rs Ensures the model satisfies basic Problem trait expectations
problemreductions-cli/src/cli.rs Adds --usage and --storage flags and updates help listing
problemreductions-cli/src/commands/create.rs Adds create match arm + parsing helper for MCFA vertex vectors
problemreductions-cli/tests/cli_tests.rs Adds CLI tests for create flow + validation errors
src/example_db/fixtures/examples.json Adds MCFA canonical example and updates regenerated fixtures
docs/src/reductions/problem_schemas.json Generated schema entry for MCFA
docs/src/reductions/reduction_graph.json Generated reduction graph node entry for MCFA (and re-indexing)
docs/paper/reductions.typ Adds paper section + figure/example for MCFA

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

{"source":{"problem":"KColoring","variant":{"graph":"SimpleGraph","k":"KN"},"instance":{"graph":{"inner":{"edge_property":"undirected","edges":[[0,1,null],[0,2,null],[1,3,null],[2,3,null],[2,4,null],[3,4,null]],"node_holes":[],"nodes":[null,null,null,null,null]}},"num_colors":3}},"target":{"problem":"QUBO","variant":{"weight":"f64"},"instance":{"matrix":[[-6.0,12.0,12.0,3.0,0.0,0.0,3.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,-6.0,12.0,0.0,3.0,0.0,0.0,3.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,-6.0,0.0,0.0,3.0,0.0,0.0,3.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,-6.0,12.0,12.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,-6.0,12.0,0.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,-6.0,0.0,0.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,-6.0,12.0,12.0,3.0,0.0,0.0,3.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,-6.0,12.0,0.0,3.0,0.0,0.0,3.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-6.0,0.0,0.0,3.0,0.0,0.0,3.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-6.0,12.0,12.0,3.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-6.0,12.0,0.0,3.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-6.0,0.0,0.0,3.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-6.0,12.0,12.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-6.0,12.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-6.0]],"num_vars":15}},"solutions":[{"source_config":[1,2,2,1,0],"target_config":[0,1,0,0,0,1,0,0,1,0,1,0,1,0,0]}]},
{"source":{"problem":"KSatisfiability","variant":{"k":"K2"},"instance":{"clauses":[{"literals":[1,2]},{"literals":[-1,3]},{"literals":[-2,4]},{"literals":[-3,-4]}],"num_vars":4}},"target":{"problem":"QUBO","variant":{"weight":"f64"},"instance":{"matrix":[[0.0,1.0,-1.0,0.0],[0.0,0.0,0.0,-1.0],[0.0,0.0,0.0,1.0],[0.0,0.0,0.0,0.0]],"num_vars":4}},"solutions":[{"source_config":[0,1,0,1],"target_config":[0,1,0,1]}]},
{"source":{"problem":"KSatisfiability","variant":{"k":"K3"},"instance":{"clauses":[{"literals":[1,2,-3]},{"literals":[-1,3,4]},{"literals":[2,-4,5]},{"literals":[-2,3,-5]},{"literals":[1,-3,5]},{"literals":[-1,-2,4]},{"literals":[3,-4,-5]}],"num_vars":5}},"target":{"problem":"QUBO","variant":{"weight":"f64"},"instance":{"matrix":[[0.0,4.0,-4.0,0.0,0.0,4.0,-4.0,0.0,0.0,4.0,-4.0,0.0],[0.0,0.0,-2.0,-2.0,0.0,4.0,0.0,4.0,-4.0,0.0,-4.0,0.0],[0.0,0.0,2.0,-2.0,0.0,1.0,4.0,0.0,4.0,-4.0,0.0,4.0],[0.0,0.0,0.0,4.0,0.0,0.0,-1.0,-4.0,0.0,0.0,-1.0,-4.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,1.0,-1.0,0.0,1.0],[0.0,0.0,0.0,0.0,0.0,-2.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,3.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,7.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2.0]],"num_vars":12}},"solutions":[{"source_config":[0,0,0,0,0],"target_config":[0,0,0,0,0,1,0,0,0,0,0,0]}]},
{"source":{"problem":"KSatisfiability","variant":{"k":"K3"},"instance":{"clauses":[{"literals":[1,2,-3]},{"literals":[-1,3,4]},{"literals":[2,-4,5]},{"literals":[-2,3,-5]},{"literals":[1,-3,5]},{"literals":[-1,-2,4]},{"literals":[3,-4,-5]}],"num_vars":5}},"target":{"problem":"QUBO","variant":{"weight":"f64"},"instance":{"matrix":[[0.0,4.0,-4.0,0.0,0.0,4.0,-4.0,0.0,0.0,4.0,-4.0,0.0],[0.0,0.0,-2.0,-2.0,0.0,4.0,0.0,4.0,-4.0,0.0,-4.0,0.0],[0.0,0.0,2.0,-2.0,0.0,1.0,4.0,0.0,4.0,-4.0,0.0,4.0],[0.0,0.0,0.0,4.0,0.0,0.0,-1.0,-4.0,0.0,0.0,-1.0,-4.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,1.0,-1.0,0.0,1.0],[0.0,0.0,0.0,0.0,0.0,-2.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,3.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,7.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2.0]],"num_vars":12}},"solutions":[{"source_config":[1,1,1,1,1],"target_config":[1,1,1,1,1,0,0,0,0,0,1,0]}]},
@GiggleLiu
Copy link
Contributor Author

Agentic Review Report

Structural Check

# Check Status
1 Model file exists (src/models/graph/multiple_copy_file_allocation.rs) PASS
2 inventory::submit! present PASS
3 #[derive(...Serialize, Deserialize)] on struct PASS
4 Problem trait impl PASS
5 SatisfactionProblem impl PASS
6 #[cfg(test)] + #[path = "..."] test link PASS
7 Test file exists PASS
8 Test file has >= 3 test functions PASS (9 tests)
9 Registered in graph/mod.rs PASS
10 Re-exported in models/mod.rs PASS
11 declare_variants! entry PASS
12 CLI alias resolution PASS
13 CLI create support PASS
14 Canonical model example registered PASS
15 Paper display-name entry PASS
16 Paper problem-def block PASS

Build: make test PASS, make clippy PASS

Issue compliance: 8/8 checks passed. Problem name, mathematical definition, satisfaction type, configuration space, feasibility checks, and objective function all match issue #410.

Whitelist: FAIL — expected for model PRs needing new CLI flags. The solver-default refactor (dispatch.rs, solve.rs, inspect.rs, mcp/tools.rs, main.rs) is a bundled cross-cutting change directly motivated by the new model's lack of ILP reachability. Acceptable to merge as-is.

Semantic correctness:

  • evaluate() correctly computes total cost = storage cost + usage-weighted BFS distances, compared against bound K
  • Multi-source BFS is standard textbook approach, correctly handles multiple sources, unreachable vertices, and disconnected graphs
  • Edge cases covered: empty V', non-binary configs, disconnected components, cost exactly above bound

Issues:

  • [Suggestion] Missing positivity validation in constructor — usage and storage values should be strictly positive per the mathematical definition (Z+). Compare with MinimumSumMulticenter::new() which validates k > 0.
  • [Important] Bundled solver-default refactor — significant CLI behavior change (dynamic solver selection based on ILP reachability) is bundled alongside the model. Well-implemented and well-motivated, but represents scope expansion beyond a pure model PR.

Quality Check

Design Principles:

  • DRY: OK for the model itself. Pre-existing solver resolution duplication between solve.rs and mcp/tools.rs is extended but not introduced by this PR.
  • KISS: OK — clean BFS implementation, well-factored helpers (selected_vertices, shortest_distances, total_cost).
  • HC/LC: OK — model struct, trait impl, and CLI wiring are well-separated.

HCI (CLI/MCP):

  • Error messages are actionable with full usage hints
  • pred create MultipleCopyFileAllocation without flags shows help with required parameters
  • Flag naming (--graph, --usage, --storage, --bound) follows established conventions
  • Solver auto-selection (ILP when reachable, brute-force otherwise) is a good UX improvement

Test Quality:

  • 9 unit tests with concrete value assertions (not just type/shape checks)
  • Instance diversity: cycle, path, heterogeneous weights, disconnected graph, yes/no instances
  • Adversarial cases: empty config, non-binary values, all-zero config, unreachable components, cost exactly above bound
  • Solver test validates both YES and NO instances
  • Brute-force exhaustiveness: find_all_satisfying asserts exact count (36 configurations)
  • Round-trip serialization test
  • 7 CLI integration tests covering creation, inspection, error cases, and solver selection

Issues:

  • [Important] Complexity string "2^num_vertices" — this is the naive brute-force bound. Per project guidelines, should verify whether a better exact algorithm exists in the literature.
  • [Important] Test helper cycle_no_instance is misleadingly named — the graph is a path (6 vertices, 5 edges, missing edge 5-0), not a cycle. Should be path_no_instance.
  • [Minor] Paper figure uses hardcoded vertex positions instead of computed circular layout.

Agentic Feature Tests

# Test Command Status
1 Catalog listing pred list PASSED
2 Detail display pred show MultipleCopyFileAllocation PASSED
3 Example creation pred create --example MultipleCopyFileAllocation PASSED
4 Brute-force solve pred solve <instance> PASSED
5 Manual creation pred create MultipleCopyFileAllocation --graph ... PASSED
6 Unit tests (9/9) cargo test multiple_copy_file_allocation PASSED
7 Full regression (2080/2080) cargo test --lib PASSED
8 Example-DB integration (3/3) cargo test example_db PASSED

Confirmed bugs: 0

All CLI features work correctly. Solutions were manually verified against the mathematical definition. Edge cases (unreachable vertices, no-solution instances, invalid configs) handled properly. No regressions detected.


Generated by review-pipeline

@isPANN isPANN self-assigned this Mar 20, 2026
isPANN and others added 6 commits March 20, 2026 13:20
- Update canonical_model_example_specs to use new ModelExampleSpec fields
  (instance, optimal_config, optimal_value) instead of removed `build` field
- Fix paper Typst: remove `.inner` from graph access, use optimal_config
  instead of removed .optimal/.samples accessors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove supports_ilp(), available_solvers(), default_solver() from DynProblem.
Revert solve/inspect/MCP to main's hardcoded ILP default. Update MCFA CLI
test to use explicit --solver brute-force.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rtion

- graph uses edges/num_vertices (no inner/nodes wrapper)
- inspect solver list is dynamic on main (brute-force only for MCFA)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@isPANN isPANN merged commit 7906394 into main Mar 20, 2026
5 checks passed
@isPANN
Copy link
Collaborator

isPANN commented Mar 20, 2026

Please kindly check the following items (PR #665):

  • Paper (PDF): check definition, proof sketch, and example figure
  • CLI demo (build from source: cargo install --path problemreductions-cli):
    pred show MultipleCopyFileAllocation
    pred create --example MultipleCopyFileAllocation -o instance.json
    pred solve instance.json --solver brute-force
  • Implementation (Optional): spot-check the source files changed in this PR for correctness

@isPANN isPANN mentioned this pull request Mar 20, 2026
3 tasks
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] MultipleCopyFileAllocation

3 participants