Open tkoolen opened 4 years ago
This might be related: We started a project to abstract all the code we have in JuMP/src/operator.jl to rewrite LinearAlgebra and SparseArrays code for JuMP expressions:
https://github.com/JuliaOpt/MutableArithmetics.jl/blob/master/src/linear_algebra.jl
The approach would be to create an abstract type so that if Parametron.Variable
is a subtype of this abstract type, the call is dispatched to MutableArithmetics instead of LinearAlgebra/SparseArrays. Then the multiplication will exploit the mutability of the expressions created and will compute the element type of the resulting array correctly (usually, what is used in SparseArrays doesn't work as it start by promoting the type of both array to a common type so it the product of an array of Int and an array of Variable gives quadratic expressions).
I just noticed that in
@expression
and in@constraint
sparse matrices are not accepted. For example,A=spzeros(n,m)
. If I useA_expr = @expression A
or@constraint(model, A * X ==0)
It gives me this error:Originally posted by @ssadat in https://github.com/tkoolen/Parametron.jl/issues/107#issuecomment-545127495