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

Sum identity and matrix of variables #1989

Closed
blegat opened this issue Jun 19, 2019 · 1 comment · Fixed by #1993
Closed

Sum identity and matrix of variables #1989

blegat opened this issue Jun 19, 2019 · 1 comment · Fixed by #1993

Comments

@blegat
Copy link
Member

blegat commented Jun 19, 2019

julia> model = Model()
@vA JuMP Model
Feasibility problem with:
Variables: 0
ariModel mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> @variable(model, Q[1:2, 1:2], PSD)
2×2 LinearAlgebra.Symmetric{VariableRef,Array{VariableRef,2}}:
 Q[1,1]  Q[1,2]
 Q[1,2]  Q[2,2]

julia> using LinearAlgebra
Q 
julia> Q + I
ERROR: MethodError: Union{}(::VariableRef) is ambiguous. Candidates:
  (::Type{SA})(x...) where SA<:StaticArrays.StaticArray in StaticArrays at /home/blegat/.julia/packages/StaticArrays/VyRz3/src/convert.jl:4
  (::Type{T})(itr) where T<:Tuple in Base at tuple.jl:246
Possible fix, define
  Union{}(::Any)
Stacktrace:
 [1] convert(::Type{Union{}}, ::VariableRef) at ./sysimg.jl:71
 [2] setindex!(::Array{Union{},2}, ::VariableRef, ::Int64) at ./array.jl:767
 [3] copyto! at ./abstractarray.jl:753 [inlined]
 [4] copyto! at ./abstractarray.jl:745 [inlined]
 [5] AbstractArray{Union{},2}(::Array{VariableRef,2}) at ./array.jl:483
 [6] convert at ./abstractarray.jl:16 [inlined]
 [7] AbstractArray{Union{},2}(::Symmetric{VariableRef,Array{VariableRef,2}}) at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/symmetric.jl:256
 [8] convert(::Type{AbstractArray{Union{},2}}, ::Symmetric{VariableRef,Array{VariableRef,2}}) at ./abstractarray.jl:16
 [9] copy_oftype(::Symmetric{VariableRef,Array{VariableRef,2}}, ::Type{Union{}}) at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/LinearAlgebra.jl:341
 [10] +(::Symmetric{VariableRef,Array{VariableRef,2}}, ::UniformScaling{Bool}) at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/uniformscaling.jl:117
 [11] top-level scope at none:0

(v1.1) pkg> st JuMP
    Status `~/.julia/environments/v1.1/Project.toml`
  [4076af6c] JuMP v0.19.0
  [b8f27783] MathOptInterface v0.8.4
@blegat
Copy link
Member Author

blegat commented Jun 19, 2019

Apparently, we need to define the sum between an affine expression and a UniformScaling, so this should work too

julia> @variable(model, x)
x

julia> x + I
ERROR: MethodError: no method matching +(::VariableRef, ::UniformScaling{Bool})
Closest candidates are:
  +(::Any, ::Any, ::Any, ::Any...) at operators.jl:502
  +(::BitArray{2}, ::UniformScaling) at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/uniformscaling.jl:90
  +(::UnitUpperTriangular, ::UniformScaling) at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/uniformscaling.jl:106
  ...
Stacktrace:
 [1] top-level scope at none:0

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

Successfully merging a pull request may close this issue.

1 participant