I’m trying to solve an SDP problem on the form
with x being of size ~370 and the A matrices being sparse, using JuMP and Mosek. However, after about 20 minutes I get a Mosek.MosekError(1051, "Out of space.")
. Windows task manager also shows my RAM being maxed out (I have 16 GB) while it’s running. I tried doing this for a simpler problem:
using JuMP
using MosekTools
using LinearAlgebra
n = 150
model = Model(Mosek.Optimizer)
@variables model begin
P[1:n]
end
s = sum(P)
M = P |> Diagonal |> Matrix
@objective model Min s
@SDconstraint model M >= Matrix(I,n,n)
@time optimize!(model)
@show termination_status(model)
which is a very simple problem with the obvious solution that every decision variable is = 1. This is solvable until about n > 255, at which point I again get the memory error. The time taken to solve it also scales very quickly with n. I should note that using sparse
from the SparseMatrices package does nothing. On the other hand, I also tried using Mosek directly to solve the dual of the simple problem:
using Mosek
using Printf, SparseArrays, LinearAlgebra
printstream(msg::String) = print(msg)
n = 20
bkc = [ MSK_BK_FX for k in 1:n]
blc = [1.0 for k in 1:n]
buc = [1.0 for k in 1:n]
barci = [k for k in 1:n]
barcj = [k for k in 1:n]
barcval = [-1.0 for k in 1:n]
barai = Any[[k] for k in 1:n]
baraj = Any[[k] for k in 1:n]
baraval = Any[[1.0] for k in 1:n]
numcon = length(bkc)
barvardim = [n]
barvardims = [n for k in 1:n] |> Vector
nz = [1 for k in 1:n]
t = maketask() do task
putstreamfunc(task,MSK_STREAM_LOG,printstream)
appendcons(task,numcon)
appendbarvars(task,barvardim)
putconboundslice(task,1,numcon+1, bkc,blc,buc)
symc = appendsparsesymmat(task,barvardim[1],
barci,
barcj,
barcval)
idxs = []
for i in 1:n
idx = appendsparsesymmat(task,barvardim[1],
barai[i],
baraj[i],
baraval[i])
push!(idxs, idx)
end
putbarcj(task,1, [symc], [1.0])
for k in 1:n
putbaraij(task, k, 1, [idxs[k]], [1.0])
end
putobjsense(task,MSK_OBJECTIVE_SENSE_MINIMIZE)
optimize(task)
solutionsummary(task,MSK_STREAM_MSG)
end
which solves the problem very quickly even for large n. Given that in Mosek’s output when using JuMP, it lists n(n+1)/2 constraints (most of which are 0 = 0), it seems to me as if JuMP isn’t exploiting sparsity (or that information gets lost somewhere between JuMP and Mosek). Does anyone know what is going on here? Why is JuMP and Mosek taking so long and using so much memory to solve this simple problem? Can I do anything about this? I would prefer to avoid needing to construct the dual of my problem and solving that with Mosek directly.