Giter Club home page Giter Club logo

Comments (4)

odow avatar odow commented on June 11, 2024

I did not know about the multi-argument eachindex:

image

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.

LebedevRI avatar LebedevRI commented on June 11, 2024

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.

odow avatar odow commented on June 11, 2024

This is the same problem. DenseAxisArray and SparseAxisArray are not first-class AbstractArrays.

You should really consider using a different array type if you are going to be using Distances.

from jump.jl.

LebedevRI avatar LebedevRI commented on June 11, 2024

@odow thank you.

from jump.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.