You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that an inner product between two vectors is not identified as a scalar when parsed by JuMP.
using LinearAlgebra
using JuMP
u =ones(1)
v =ones(1)
m =Model()
@variable(m, x)
@constraint(m, (1.0+ u'v) * x ==0.0) # u, v are vectors so u'v is a scalar
raises the error
ERROR: MethodError: no method matching *(::Adjoint{Float64,Array{Float64,1}}, ::VariableRef)
Closest candidates are:*(::Any, ::Any, ::Any, ::Any...) at operators.jl:502*(::Adjoint{T,#s623}where#s623<:(AbstractArray{T,1} where T) where T, ::Adjoint{#s623,#s622} where #s622<:(Transpose{T,#s623} where #s623<:(AbstractArray{T,1} where T) where T) where #s623) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/adjtrans.jl:215*(::Adjoint{T,#s623}where#s623<:(AbstractArray{T,1} where T) where T, ::Adjoint{#s623,#s622} where #s622<:LinearAlgebra.AbstractTriangular where #s623) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/triangular.jl:1954
Note that the two following lines do not raise an error
@constraint(m, (1.0+dot(u, v)) * x ==0.0)
and
(1.0+ u'v) * x # returns 2 x
The text was updated successfully, but these errors were encountered:
m =Model()
@variable(m, x)
u = v =ones(1)
@constraint(m, u'* v * x ==0) # Works@constraint(m, (u'* v) * x ==0) # Doesn't work@constraint(m, x * (u'* v) ==0) # Doesn't work
Tidying up @macroexpand @constraint(m, (u' * v) * x == 0) shows that it gets parsed as
It seems that an inner product between two vectors is not identified as a scalar when parsed by JuMP.
raises the error
Note that the two following lines do not raise an error
and
The text was updated successfully, but these errors were encountered: