Skip to content

Fix #548: [Model] CosineProductIntegration#684

Open
GiggleLiu wants to merge 4 commits intomainfrom
issue-548-cosine-product-integration
Open

Fix #548: [Model] CosineProductIntegration#684
GiggleLiu wants to merge 4 commits intomainfrom
issue-548-cosine-product-integration

Conversation

@GiggleLiu
Copy link
Contributor

Summary

  • add an implementation plan for CosineProductIntegration
  • document the witness-free evaluation approach and follow-up implementation batches

Fixes #548

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.05%. Comparing base (dfcc313) to head (5cc24ce).

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #684    +/-   ##
========================================
  Coverage   97.04%   97.05%            
========================================
  Files         284      286     +2     
  Lines       38037    38174   +137     
========================================
+ Hits        36914    37050   +136     
- Misses       1123     1124     +1     

☔ 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

Implemented CosineProductIntegration in this PR.

Summary:

  • added the new misc model, registry exports, CLI pred create support, paper entry, tests, and canonical example-db fixture
  • model configs are explicit sign assignments (0 => +a_i, 1 => -a_i), so a satisfying config witnesses sum_i epsilon_i a_i = 0
  • during implementation I corrected the ticket's predicate after review and a literature cross-check: the witness-bearing NP-complete form is the integral != 0 decision / balanced-sign-assignment existence. The original = 0 phrasing is the complement problem and does not fit the repo's closed-loop witness semantics

Verification:

  • cargo test cosine_product_integration --lib
  • cargo test --features "ilp-highs example-db" verify_model_fixtures_match_computed --lib
  • cargo run -p problemreductions-cli --bin pred -- create CosineProductIntegration --coefficients 2,3,5
  • make paper
  • make clippy
  • make test

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

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 CosineProductIntegration model with schema, Problem/SatisfactionProblem trait implementations, signed-sum evaluation, DP-based balanced-sum check, and declare_variants complexity annotation
  • Added CLI pred create support with --coefficients flag 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.

@GiggleLiu
Copy link
Contributor Author

Review Pipeline Report

Check Result
Copilot comments 0 fixed
Issue/human comments 1 checked, 0 fixed
Structural review 16/16 passed
CI green
Agentic test passed
Needs human decision none
Board Review pool -> Under review -> Final review

Remaining issues for final review

  • None.

🤖 Generated by review-pipeline

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] CosineProductIntegration

2 participants