AssertionError when deleting and updating constraint in JuMP using Mosek solver

Dear team,

I would like to sequentially solve a problem by updating a constraint, the way I do it is to delete and restate the constraint inside a loop. Once the problem is solved and I try to delete the constraint I get the following error “AssertionError: (m.x_sd[ref2id(vi)]).matrix == -1”. I got the error only if I use Mosek as a solver (with SCS everything is ok).

Here is a simple example to replicate the error :

using JuMP
using MosekTools
function error_delete()
    m   =   Model(Mosek.Optimizer)
    @variable   m   x[1:4,1:4]
    A   =   rand(4,4)
    #@constraint m c1    A*x*A' in JuMP.PSDCone()
    c1  =   @constraint(m,  A*x*A' in JuMP.PSDCone())
    @objective  m   Min sum(x[i,i] for i=1:4)
    for i = 1: 10
        B   =   rand(4,4)
        #@constraint m c1    B*x*B' in JuMP.PSDCone()
        c1  =   @constraint(m,B*x*B' in JuMP.PSDCone())


Am I doing something the wrong way?

1 Like

Hi @bobo, welcome to the forum.

I don’t have a Mosek license so I can’t test this, but this looks like a bug in MosekTools.jl.

Mosek has a few quirks on how it handles PSD cones, so @blegat is the person to ask about what’s going on here.

1 Like

Thanks for reporting. This is because Mosek does not support deleting matrix variables. The error should be improved in Better error message for deletion of matrix variable by blegat · Pull Request #121 · jump-dev/MosekTools.jl · GitHub

1 Like