Comments (4)
I did not know about the multi-argument eachindex
:
I think you're hitting these errors because, fundamentally, JuMP and Distances have no contract for the interface API that they expect each other to implement. There's also no way for us to know, and the problem with Julia is that it has a bunch of default fallbacks that may or may not work depending on the assumptions made by Base
.
We can fix these case by case, but I can guess that it must be frustrating to keep on finding them (I'm also frustrated with this).
from jump.jl.
SparseAxisArray
also doesn't quite work, either:
julia> @variable(model, u[i = 1:2, j = i:3])
JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Int64}} with 5 entries:
[1, 1] = u[1,1]
[1, 2] = u[1,2]
[1, 3] = u[1,3]
[2, 2] = u[2,2]
[2, 3] = u[2,3]
julia> @variable(model, w[i = 1:2, j = i:3])
JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Int64}} with 5 entries:
[1, 1] = w[1,1]
[1, 2] = w[1,2]
[1, 3] = w[1,3]
[2, 2] = w[2,2]
[2, 3] = w[2,3]
julia> [(I for I in eachindex(e,f)]^C
julia> Euclidean()(u, w)
ERROR: `Base.size` is not implemented for `SparseAxisArray` because although it is a subtype of `AbstractArray`, it is conceptually closer to a dictionary with `N`-dimensional keys. If you encounter this error and you didn't call `size` explicitly, it is because you called a method that is unsupported for `SparseAxisArray`s. Consult the JuMP documentation for a list of supported operations.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] size(#unused#::JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Int64}})
@ JuMP.Containers ~/.julia/packages/JuMP/0X8Yo/src/Containers/SparseAxisArray.jl:58
[3] axes(A::JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Int64}})
@ Base ./abstractarray.jl:98
[4] _evaluate(d::Euclidean, a::JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Int64}}, b::JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Int64}}, #unused#::Nothing)
@ Distances ~/.julia/packages/Distances/PvoXa/src/metrics.jl:251
[5] (::Euclidean)(a::JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Int64}}, b::JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Int64}})
@ Distances ~/.julia/packages/Distances/PvoXa/src/metrics.jl:328
[6] top-level scope
@ REPL[72]:1
from jump.jl.
This is the same problem. DenseAxisArray
and SparseAxisArray
are not first-class AbstractArray
s.
You should really consider using a different array type if you are going to be using Distances
.
from jump.jl.
@odow thank you.
from jump.jl.
Related Issues (20)
- jump.dev is down HOT 1
- Model printing is rather verbose HOT 5
- Diagnostics request: using variable in variable container bounds HOT 4
- && and || do not short-circuit in macros HOT 3
- Add support for MOI.ScalarQuadraticCoefficientChange
- Tools to test JuMP models
- NumFOCUS: GSoC 2024 Update HOT 1
- Error vcat(::NonlinearExpr, ::VariableRef, ::Float64) HOT 5
- Increase performance of SOC constraints HOT 4
- Iterating SparseAxisArray does not preserve order HOT 4
- How to improve the speed to build a complex model? HOT 2
- Coefficients of complex variables created with a GenericModel are always Float64
- LinearAlgebra.hermitian is incorrect
- *(::Real, ::Hermitian) is not hermitian HOT 5
- Cannot `convert` an object of type Float64 to an object of type JuMP.NonlinearExpr HOT 3
- Documentation Request: List whether a solver supports Indicator Constraints HOT 4
- Bullet point alignment in bibliography HOT 9
- Multiplication of matrix expression and variables leads to stack overflow and matmul error HOT 4
- Multiple Ranges for variables HOT 3
- Y' when Y is of type ::Matrix{NonlinearExpr} HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jump.jl.