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

Lh/extension refactor #25

Merged
merged 10 commits into from
Oct 1, 2022
Merged

Lh/extension refactor #25

merged 10 commits into from
Oct 1, 2022

Conversation

hellemo
Copy link
Member

@hellemo hellemo commented Sep 25, 2022

Support extending standards JuMP macros (#19):

m = Model()
@variable(m, x[i = 1:3, j = 100:102] >= 0, container = IndexedVarArray)

Should also fix #22 for IndexedVarArray

This PR includes changes from PR #24, can separate later if we don't want those changes, but is using e.g. nnz here.

@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2022

Codecov Report

Base: 83.94% // Head: 84.26% // Increases project coverage by +0.32% 🎉

Coverage data is based on head (6c7e0e1) compared to base (5269ddd).
Patch coverage: 92.85% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
+ Coverage   83.94%   84.26%   +0.32%     
==========================================
  Files           8        8              
  Lines         436      445       +9     
==========================================
+ Hits          366      375       +9     
  Misses         70       70              
Impacted Files Coverage Δ
src/sparsearray.jl 52.08% <50.00%> (ø)
src/indexedarray.jl 91.07% <100.00%> (+0.78%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@trulsf
Copy link
Member

trulsf commented Sep 25, 2022

Nice solution to get integration with JuMP macros.

A question regarding the index sets. Currently, these are not copied upon construction so they can be modified during the lifetime of the variable. E.g. the following example will throw an exception

F = ["A", "B"]
G = [1,2,3]

@variable(m, x[F,G] >= 0, container = IndexedVarArray)

G = []
insertvar!(x, "A", 1)

Should it be an option to fix the index sets upon construction? I.e. let the index_names tuple have copies of the original index sets. I guess it is not that easy to provide an option to the @variable macro, so maybe a parametric type with the behaviour as parameter?

src/indexedarray.jl Outdated Show resolved Hide resolved
@hellemo
Copy link
Member Author

hellemo commented Sep 28, 2022

Waiting for a decision on order of arguments (see jump-dev/JuMP.jl#3088) before merging.

@trulsf
Copy link
Member

trulsf commented Sep 29, 2022

I think there is a problem with the linear indexing when integers are used for the index sets

@variable(m, x[10:20]; container=IndexedVarArray)
x[1]

will lead to an infinite loop.

@trulsf
Copy link
Member

trulsf commented Sep 29, 2022

I also have some problems with sum(x) and collect(x) where x is an IndexedVarArray

@trulsf
Copy link
Member

trulsf commented Sep 29, 2022

I am leaning towards looking more to SparseAxisArray and not so much to SparseArrays for how to implement length() and exclude size().

@hellemo
Copy link
Member Author

hellemo commented Sep 29, 2022

Allright, I'll have a look, maybe revert the AbstractArray stuff if it only causes problems.

@hellemo hellemo merged commit 65473ed into main Oct 1, 2022
@hellemo hellemo deleted the lh/extension-refactor branch October 1, 2022 07:26
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.

Error if trying to register existing variable name for model
3 participants