-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
Add vector of scalar variables with in
syntax
#2657
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2657 +/- ##
==========================================
+ Coverage 93.84% 93.85% +0.01%
==========================================
Files 44 44
Lines 5524 5534 +10
==========================================
+ Hits 5184 5194 +10
Misses 340 340
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just my style pet-peeves. JuliaFormatter doesn't have an option for this yet.
Latest version allows SparseAxisArray @variable(model, b[i=1:2, j=1:2; i+j==3] in MOI.GreaterThan(3.0))
# and
@variable(model, a[i=1:2, j=1:2; i+j==3] in
JuMP.Containers.SparseAxisArray(
Dict(
(1,2) => MOI.GreaterThan(3.0),
(2,1) => MOI.GreaterThan(3.0),
))) But DenseAxisArray like: @variable(model, z1[1:2, 2:4] in MOI.GreaterThan(3.0)) fails with:
Any ideas? |
Hmm. I'm guessing I did something wrong here: #2533. Broadcasting over multiple DenseAxisArrays is hard. |
We probably need to modify this somehow JuMP.jl/src/Containers/DenseAxisArray.jl Lines 190 to 206 in 2a87c29
|
@joaquimg I pushed a fix for the broadcasting |
Co-authored-by: Oscar Dowson <odow@users.noreply.github.com>
function Base.BroadcastStyle(::Type{T}) where {T<:DenseAxisArray} | ||
return Broadcast.ArrayStyle{T}() | ||
function Base.BroadcastStyle(::Type{<:DenseAxisArray}) | ||
return Broadcast.ArrayStyle{DenseAxisArray}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was subtle
Partially solves: #2148
this enables both:
and
.in
does not parse in julia, so@variable(model, x[1:2] .in MOI.GreaterThan.([3, 2]))
is not an option.Also added protection to other cases.
This would be a great replacement for jump-dev/ParametricOptInterface.jl#40
cc @guilhermebodin