Could an expert help me speed up the following code? In particular,
-
Have I used the performance tips (https://jump.dev/JuMP.jl/stable/tutorials/Getting%20started/performance_tips/) correctly? That is only generate expressions inside macro.
-
Does it help to use sparse matrix?
-
Does multithreading the
for
loop with Threads.@threads help?
Note that computeMatrix
is not a bottleneck in my case, however the bottleneck could be with the fact that length(x)
is large.
Edit: I did a better benchmark this time and the slowdown is mainly due to computeMatrix
as caused by having large length(x)
so it seems this is not a JuMP problem.
for blk in blocks
if size(blk, 1) > 1
println("adding PSD constraint for block of size $(size(blk))")
@constraint(m, sum(x[i] .* computeMatrix(i, blk) for i in 1:length(x)) in PSDCone())
else
println("adding inequality constraint")
@constraint(m, sum(x[i] .* computeMatrix(i, blk) for i in 1:length(x)) .>= 0)
end
end