I encountered an issue which might be a bug (or not).
using JuMP
model = Model()
@variables(model, begin
x[1:2]
X[1:2, 1:2]
end)
@expression(model, Y, [cos(x[1]) 0 ; 0 x[2]])
@expression(model, XY, X*Y') # this returns an error
# @expression(model, YX, Y*X') # this is ok
ERROR: MethodError: promote_operation(::typeof(), ::Type{VariableRef}, ::Type{Union{}}) is ambiguous.
Candidates:
promote_operation(op::typeof(), ::Type{S}, A::Type{<:AbstractArray{T}}) where {S, T}
@ MutableArithmetics ~/.julia/packages/MutableArithmetics/xVyia/src/implementations/LinearAlgebra.jl:179
promote_operation(::Union{typeof(), typeof(+), typeof(-)}, V::Type{<:AbstractVariableRef}, C::Type{<:Union{Number, LinearAlgebra.UniformScaling}})
@ JuMP ~/.julia/packages/JuMP/glJ0u/src/mutable_arithmetics.jl:38
Possible fix, define
promote_operation(::typeof(), ::Type{S}, ::Type{Union{}}) where S<:AbstractVariableRef
Note that with a transpose it works well.
Actually, Y' is not defined:
Y'
2×2 adjoint(::Matrix{NonlinearExpr}) with eltype Union{}:
Error showing value of type LinearAlgebra.Adjoint{Union{}, Matrix{NonlinearExpr}}:
ERROR: MethodError: no method matching conj(::NonlinearExpr)
Hi,
I encountered an issue which might be a bug (or not).
Note that with a transpose it works well.
Actually, Y' is not defined:
I'm on julia v1.10.2 and JuMP v1.21.0