Skip to content

Experimental Support for Grouping Constraints over Common Patterns - #44

Open
pulsipher wants to merge 20 commits into
mainfrom
template_constraints
Open

Experimental Support for Grouping Constraints over Common Patterns#44
pulsipher wants to merge 20 commits into
mainfrom
template_constraints

Conversation

@pulsipher

@pulsipher pulsipher commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

This adds experimental support of detecting common constraint patterns, grouping them together, and adding each group as a single ExaModels.Constraint. Given model::InfiniteModel, the user syntax is simply:

em = ExaModel(model, group_repeated_constraint_patterns = true)

or

optimize!(model, group_repeated_constraint_patterns = true) # assumes backend is an `ExaTranscriptionBackend`

Initially support is limited to:

  • Constraints without measures

If this performs well, we should be able to relax these restriction(s).

Early testers can try this out via:

import Pkg
Pkg.add(url="https://github.com/infiniteopt/InfiniteExaModels.jl", rev = "template_constraints")

Possible improvements include:

  • Detecting repeated patterns across all constraints
  • Taking advantage of repeated patterns in derivative equations and collocation restrictions
  • Handing finite indexing with unregistered variables (e.g., derivatives)
  • Handling indexed infinite parameters
  • Removing recursion
  • Removing unnecessary asserts
  • Handling constraints with measures
  • Investigating how this might apply to objective functions
  • Improving the info printing, especially during this experimental phase

@pulsipher pulsipher added the enhancement New feature or request label Aug 14, 2026
@codecov-commenter

codecov-commenter commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.80488% with 204 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.30%. Comparing base (dac6f4c) to head (fdd7488).

Files with missing lines Patch % Lines
src/grouped_constraints.jl 0.00% 127 Missing ⚠️
src/transform.jl 61.30% 77 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #44       +/-   ##
===========================================
- Coverage   85.82%   69.30%   -16.53%     
===========================================
  Files           6        7        +1     
  Lines         748      997      +249     
===========================================
+ Hits          642      691       +49     
- Misses        106      306      +200     

☔ View full report in Codecov by Harness.
📢 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.

@pulsipher pulsipher changed the title Experimental Support for Aggregating Constraint Groups over Finite Indices Experimental Support for Grouping Constraints over Common Patterns Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants