Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametrized container #3890

Closed
wants to merge 1 commit into from
Closed

Parametrized container #3890

wants to merge 1 commit into from

Conversation

blegat
Copy link
Member

@blegat blegat commented Nov 22, 2024

Still very much a draft. I'll add more details later.
When the user uses the container syntax to create constraints, MOI receives each constraint independently so ExaModels.jl has to recover the repeated structure. We discussed during the JuMP-dev hackathon of a way to communicate the repeated structure through MOI more explicitly and this PR is a POC the resulting design.
As a byproduct, this also gives a solution for #1654 since the constraint will be expanded at the MOI level with a bridge from IteratedFunction in Zeros to Scalar?Function in EqualTo (we need a way to know the scalar function type but that should be doable)
We can also recover the pretty printing of containers that we had in JuMP v0.18

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.58%. Comparing base (701251a) to head (d19658a).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3890   +/-   ##
=======================================
  Coverage   99.58%   99.58%           
=======================================
  Files          43       43           
  Lines        6031     6031           
=======================================
  Hits         6006     6006           
  Misses         25       25           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mlubin
Copy link
Member

mlubin commented Nov 24, 2024

Does this change the semantics of when and how often terms are evaluated?
What if you write something like:

@constraint(model, [i in [:a, :b]], x + d1[database_lookup(i)] >= d2[database_lookup(i)], container = ParametrizedArray)

@blegat
Copy link
Member Author

blegat commented Nov 26, 2024

Good question, this will not change the semantic, your subexpressions depending only on i but not any JuMP expressions could be any code (although this doesn't work yet but that's the idea). Once you start interacting with JuMP expressions, we record the value (so here the value of database_lookup(i)) obtained for each value of the iterator and this value has to be a Float64. At the MOI level, we pass the value obtained when we evaluated database_lookup(i) so MOI receives the Float64 value of each sub-expression depending on this iterator. I assume you don't have sub-expression depending on two iterators at the same time yet ^^

@blegat
Copy link
Member Author

blegat commented Nov 27, 2024

Moved to https://github.com/blegat/GeneratorOptInterface.jl as this is very experimental so it will be easier to experiment as a separate package

@blegat blegat closed this Nov 27, 2024
@odow odow deleted the bl/it branch November 28, 2024 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants