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

similar(::JuMP.Containers.DenseAxisArray...) is ambiguous #2282

Closed
baggepinnen opened this issue Jul 15, 2020 · 1 comment
Closed

similar(::JuMP.Containers.DenseAxisArray...) is ambiguous #2282

baggepinnen opened this issue Jul 15, 2020 · 1 comment

Comments

@baggepinnen
Copy link
Contributor

The following snippet produces an ambiguity error from the last statement (JuMP v0.21.3, julia v1.5-rc1)

using JuMP, SCS
model = Model(SCS.Optimizer)
n = 10
V = randn(n,n)
@variable(model, G[n, n])
B = V*G*V'
MethodError: similar(::JuMP.Containers.DenseAxisArray{VariableRef,2,Tuple{Int64,Int64},Tuple{Dict{Int64,Int64},Dict{Int64,Int64}}}, ::Type{GenericAffExpr{Float64,VariableRef}}, ::Tuple{Int64,Int64}) is ambiguous. Candidates:
  similar(A::JuMP.Containers.DenseAxisArray{T,N,Ax,L} where L<:Tuple{Vararg{Dict,N}}, ::Type{S}, axes::Ax) where {T, N, Ax, S} in JuMP.Containers at /home/fredrikb/.julia/packages/JuMP/YXK4e/src/Containers/DenseAxisArray.jl:102
  similar(a::AbstractArray, ::Type{T}, dims::Tuple{Vararg{Int64,N}}) where {T, N} in Base at abstractarray.jl:636
Possible fix, define
  similar(::JuMP.Containers.DenseAxisArray{T,N,Ax,L} where L<:Tuple{Vararg{Dict,N}}, ::Type{T}, ::Ax) where {T, N, T, N, Ax<:Tuple{Vararg{Int64,N}}}
*(::Array{Float64,2}, ::JuMP.Containers.DenseAxisArray{VariableRef,2,Tuple{Int64,Int64},Tuple{Dict{Int64,Int64},Dict{Int64,Int64}}}) at matmul.jl:153
*(::Array{Float64,2}, ::JuMP.Containers.DenseAxisArray{VariableRef,2,Tuple{Int64,Int64},Tuple{Dict{Int64,Int64},Dict{Int64,Int64}}}, ::Adjoint{Float64,Array{Float64,2}}) at operators.jl:538
top-level scope at runtests.jl:316
include_string(::Function, ::Module, ::String, ::String) at loading.jl:1088
@baggepinnen
Copy link
Contributor Author

Sorr, my bad. I had the wrong syntax in creating the variable, it should be

@variable(model, G[1:n, 1:n])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant