Fix #548: [Model] CosineProductIntegration#684
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #684 +/- ##
========================================
Coverage 97.86% 97.87%
========================================
Files 627 631 +4
Lines 68842 69046 +204
========================================
+ Hits 67374 67577 +203
- Misses 1468 1469 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Implemented Summary:
Verification:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new CosineProductIntegration model implementing the Cosine Product Integration decision problem (Garey & Johnson A7 AN14). The problem asks whether ∫₀²π ∏ᵢcos(aᵢθ)dθ ≠ 0, which is equivalent to checking whether a balanced sign assignment exists for the given integer coefficients. The implementation uses a pseudo-polynomial DP approach for the has_balanced_sign_assignment helper and brute-force sign enumeration for the core evaluate method.
Changes:
- Added
CosineProductIntegrationmodel with schema, Problem/SatisfactionProblem trait implementations, signed-sum evaluation, DP-based balanced-sum check, and declare_variants complexity annotation - Added CLI
pred createsupport with--coefficientsflag and comprehensive unit tests - Added mathematical documentation in the paper and a canonical example in the example DB
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/models/misc/cosine_product_integration.rs | Core model: struct, schema, signed_sum, has_balanced_sign_assignment DP, Problem/SatisfactionProblem impls, variants, example spec |
| src/unit_tests/models/misc/cosine_product_integration.rs | Tests covering creation, signed sum, evaluate, solver, empty/zero/negative cases, serialization |
| src/models/misc/mod.rs | Register new module, re-export, add to canonical example specs |
| src/models/mod.rs | Re-export CosineProductIntegration |
| src/lib.rs | Add to prelude |
| problemreductions-cli/src/commands/create.rs | CLI create handler for CosineProductIntegration, import, flag check, format hint cleanup |
| problemreductions-cli/src/cli.rs | Add --coefficients flag, help text, and example |
| docs/paper/reductions.typ | Mathematical definition and explanation in the paper |
| src/example_db/fixtures/examples.json | Canonical example instance and updated existing example solutions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review Pipeline Report
Remaining issues for final review
🤖 Generated by review-pipeline |
|
On Hold: The reduction from Partition is completely trivial. The problem is essentially Partition in disguise, so it doesn't add meaningful value to the reduction graph. |
Add CosineProductIntegration (Garey & Johnson A7/AN14) as an independent model with a Partition → CosineProductIntegration reduction. The problem asks whether a balanced sign assignment exists for a sequence of integer frequencies, which is equivalent to Partition for positive integers but generalizes to arbitrary signed coefficients. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b4ef3f4 to
b74600d
Compare
Summary
CosineProductIntegrationFixes #548