Skip to content

Experimental Support for Grouping Constraints over Common Patterns - #44

Open
pulsipher wants to merge 38 commits into
mainfrom
template_constraints
Open

Experimental Support for Grouping Constraints over Common Patterns#44
pulsipher wants to merge 38 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`

Support is limited to:

  • Constraints without measures
  • Constraints patterns with the same infinite parameters

These restrictions could be overcome in the future, but that would be in separate PR.

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 (beyond scope, requires variables with sparse indexing)
  • Removing recursion (beyond scope, ExaModels is not well-suited for deeply nested exprs)
  • Removing unnecessary asserts (keep for now just to be save)
  • Handling constraints with measures (beyond scope, measures deserve their own PR)
  • Investigating how this might apply to objective functions (future PR will extend this to objectives)
  • 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 97.42120% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.44%. Comparing base (782b4c3) to head (a39f5c8).

Files with missing lines Patch % Lines
src/transform.jl 97.52% 5 Missing ⚠️
src/grouped_constraints.jl 97.26% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #44      +/-   ##
==========================================
+ Coverage   85.99%   90.44%   +4.45%     
==========================================
  Files           6        7       +1     
  Lines         757     1026     +269     
==========================================
+ Hits          651      928     +277     
+ Misses        106       98       -8     

☔ 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