-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Adding JuMPKey as elements of keys(::JuMPArray) and keys(::JuMPDict) #853
Conversation
@IssamT, use dependent indices or conditions, @variable(m, x[i=1:N,j=1:i])
@variable(m, x[i=1:N,j=1:N; j <= i]) |
Current coverage is 87.04% (diff: 93.75%)@@ master #853 diff @@
==========================================
Files 18 18
Lines 4494 4507 +13
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 3905 3923 +18
+ Misses 589 584 -5
Partials 0 0
|
Thanks for the example. I have a small question : why are some functions of |
No particular reason. The files are a bit disorganized, as the code has undergone a few serious rewrites in the past. Don't feel obligated to keep them structured as-is. |
This looks pretty good to me. Can you test to make sure there are no accidental performance penalties? Also, could you add some tests? |
I got some weird results on this test.
With JuMPArray: With JuMPDict:
I didn't understand the reason so I tried to check different versions. Using these:
There is no overhead at all, so I understood that the problem is in JuMPKey. Now using these:
The iteration is about 3 to 4 times FASTER compared to the commit before my patch (without JuMPKey). I don't understand why... maybe immutable types are more efficient when non parameterized? I would be glad if anyone can provide an explanation of this weird "julia" behavior... |
I have reproduced the issue with plain julia Dict. |
As mentioned in the issue you opened, adding the type parameter to immutable JuMPKey{T<:Tuple}
jk::T
end allows the compiler to reason about the concrete type of |
Just to be sure we speak about the same thing, what I find weird is that using this
is much slower than using this
I was expecting the opposite based on the same explanation @joehuchette has provided in his last comment. I believe this weird behavior is due to the fact we are not allowing the compiler to reason with concrete types everywhere since we have types declared with Any like
I am afraid this issue is not only related to |
Think of type JuMPKey
jk::Tuple{Int,Int}
end In your second definition, the type of the field |
I totally agree, but this
m̶u̶s̶t̶(Edit : should) be better than this (in term of performance)
am I wrong? |
Oh sorry, I had the two cases flipped in my mind. Yes, it is strange to me that the unparameterized version is faster... |
My guess is that julia's compiler isn't, yet, at the level of providing always improvements when you change some of your types from abstract to concrete, while keeping others abstract... |
This is stale, willing to consider new PRs |
I have added
JuMPKey
forJuMPArray
as suggested in #646 . And I would like to add it forJuMPDict
as well. Do you know how to make a small example returningJuMPDict
?