Skip to content

Design specs for #P/PP-complete problem support#750

Open
GiggleLiu wants to merge 1 commit intomainfrom
design/counting-and-aggregation
Open

Design specs for #P/PP-complete problem support#750
GiggleLiu wants to merge 1 commit intomainfrom
design/counting-and-aggregation

Conversation

@GiggleLiu
Copy link
Contributor

Summary

Two design specs for extending the trait hierarchy to support counting (#P-complete) and threshold (PP-complete) problems, which currently block 8 issues.

  • docs/plans/2026-03-22-counting-problem-trait-design.md — Minimal extension: adds CountingProblem as a third leaf trait with Weight<W>, CountingSolver, and ReduceToCount. Small diff, no changes to existing code.

  • docs/plans/2026-03-22-generalized-aggregation-design.md — Full unification: replaces all leaf traits (OptimizationProblem, SatisfactionProblem) with a single Aggregate monoid trait. Metric types (Max, Min, Sum, Or, And) encode the aggregation strategy directly. One Solver::solve method via fold. Supersedes design 1.

Blocked issues this unblocks

Models: #235 NetworkReliability, #237 NetworkSurvivability, #404 KthLargestSubset, #405 KthLargestMTuple

Rules: #256 SteinerTree → NetworkReliability, #257 VertexCover → NetworkSurvivability, #394 SubsetSum → KthLargestSubset, #395 SubsetSum → KthLargestMTuple

Related

Test plan

  • Review design 2 (generalized aggregation) for completeness
  • Confirm the monoid identity/combine semantics are correct for all 5 types
  • Verify migration path covers all ~80 model files
  • Check that ILP solver, test helpers, and SolveFn integration are addressed

🤖 Generated with Claude Code

Two alternative designs for extending the trait hierarchy to support
counting (#P) and threshold (PP-complete) problems:

1. CountingProblem trait (minimal extension) — adds a third leaf trait
   parallel to OptimizationProblem and SatisfactionProblem, with
   Weight<W> type, CountingSolver, and ReduceToCount.

2. Generalized aggregation (full unification) — replaces all leaf traits
   with a single Aggregate monoid trait. Metric types (Max, Min, Sum, Or,
   And) encode the aggregation strategy directly. One Solver::solve method
   via fold. Supersedes design 1.

Unblocks: #235, #237, #404, #405, #256, #257, #394, #395
Related: #737, #748

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

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.58%. Comparing base (d870c74) to head (5bbc97f).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #750   +/-   ##
=======================================
  Coverage   97.58%   97.58%           
=======================================
  Files         415      415           
  Lines       51632    51632           
=======================================
  Hits        50386    50386           
  Misses       1246     1246           

☔ 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.

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.

1 participant