I want to create PSD constraints with a sparse matrix of AffExpr as in the snippet below (rawdata is a Vector of tuples of the form (I, J, Va, Vs) containing row-col-values information)
model = let
println("Constructing SDP model...")
model = JuMP.Model()
numvars = maximum([maximum(m[3]) for m in rawdata])
println("Number of variables = $numvars")
x = @variable(model, x[1:numvars])
for m in rawdata
mat = sparse(m[1], m[2], m[4].*x[m[3]])
@constraint(model, mat >=0, PSDCone())
end
model
end
Is this error expected?
MethodError: no method matching -(::SparseMatrixCSC{AffExpr, Int64}, ::Int64)
Closest candidates are:
-(!Matched::T, ::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at int.jl:86
-(!Matched::Union{MathOptInterface.ScalarAffineFunction{T}, MathOptInterface.ScalarQuadraticFunction{T}}, ::T) where T at C:\Users\******\.julia\packages\MathOptInterface\YDdD3\src\Utilities\functions.jl:1725
-(!Matched::LinearAlgebra.UniformScaling, ::Number) at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\uniformscaling.jl:147
...
sub_mul(a::SparseMatrixCSC{AffExpr, Int64}, b::Int64) at MutableArithmetics.jl:33
operate(::typeof(MutableArithmetics.sub_mul), ::SparseMatrixCSC{AffExpr, Int64}, ::Int64) at interface.jl:131
operate_fallback!(::MutableArithmetics.NotMutable, ::Function, ::SparseMatrixCSC{AffExpr, Int64}, ::Int64) at interface.jl:428
operate!(op::typeof(MutableArithmetics.sub_mul), x::SparseMatrixCSC{AffExpr, Int64}, args::Int64) at rewrite.jl:83
macro expansion at rewrite.jl:279 [inlined]
macro expansion at macros.jl:676 [inlined]
top-level scope at readDavid.jl:25
eval at boot.jl:360 [inlined]