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

Cannot multiply array of polynomials and array of JuMP variables #1990

Closed
blegat opened this issue Jun 19, 2019 · 0 comments · Fixed by #1995
Closed

Cannot multiply array of polynomials and array of JuMP variables #1990

blegat opened this issue Jun 19, 2019 · 0 comments · Fixed by #1995

Comments

@blegat
Copy link
Member

blegat commented Jun 19, 2019

julia> using JuMP

julia> using DynamicPolynomials

julia> @polyvar x
(x,)

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

julia> @variable(model, a)
a

julia> (a .* ones(2, 2)) * (x .* ones(2, 2))
ERROR: MethodError: no method matching _A_mul_B!(::Array{Polynomial{true,GenericAffExpr{Float64,VariableRef}},2}, ::Array{GenericAffExpr{Float64,VariableRef},2}, ::Array{Term{true,Float64},2})
Closest candidates are:
  _A_mul_B!(::AbstractArray{T<:Union{AbstractJuMPScalar, NonlinearExpression},N} where N, ::Any, ::Any) where T<:Union{AbstractJuMPScalar, NonlinearExpression} at /home/blegat/.julia/packages/JuMP/jnmGG/src/operators.jl:371
  _A_mul_B!(::AbstractArray{#s1040,N} where N where #s1040<:Union{GenericAffExpr, GenericQuadExpr}, ::SparseArrays.SparseMatrixCSC, ::Any) at /home/blegat/.julia/packages/JuMP/jnmGG/src/operators.jl:382
  _A_mul_B!(::AbstractArray{#s1040,N} where N where #s1040<:Union{GenericAffExpr, GenericQuadExpr}, ::AbstractArray{T,2} where T, ::SparseArrays.SparseMatrixCSC) at /home/blegat/.julia/packages/JuMP/jnmGG/src/operators.jl:395
Stacktrace:
 [1] _A_mul_B(::Array{GenericAffExpr{Float64,VariableRef},2}, ::Array{Term{true,Float64},2}) at /home/blegat/.julia/packages/JuMP/jnmGG/src/operators.jl:418
 [2] *(::Array{GenericAffExpr{Float64,VariableRef},2}, ::Array{Term{true,Float64},2}) at /home/blegat/.julia/packages/JuMP/jnmGG/src/operators.jl:512
 [3] top-level scope at none:0

This would probably be resolved if we used Base.mul! instead of a custom _A_mul_B so that the fallback could be used in cased the result type is not a JuMP scalar function.

blegat added a commit that referenced this issue Jun 23, 2019
dourouc05 pushed a commit to dourouc05/JuMP.jl that referenced this issue Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant