Dual to PSD Constraint in JuMP

Hi @lopenguin, welcome to the forum :smile:

You鈥檙e correct that we don鈥檛 have a good way to get the constraint associated with a variable set.

I鈥檝e opened an issue Constraint associated with a variable set 路 Issue #3951 路 jump-dev/JuMP.jl 路 GitHub

A work-around for now is to construct the constraint separately:

julia> import LinearAlgebra, SCS

julia> using JuMP

julia> begin
           a = [[2.0, 2.0], [2.5, 2.1], [7.0, 7.0], [2.2, 2.3], [6.8, 7.0], [7.2, 7.5]]
           m = length(a)
           num_clusters = 2
           W = zeros(m, m)
           for i in 1:m, j in i+1:m
               W[i, j] = W[j, i] = exp(-LinearAlgebra.norm(a[i] - a[j]) / 1.0)
           end
           model = Model(SCS.Optimizer)
           set_silent(model)
           @variable(model, Z[1:m, 1:m] >= 0, Symmetric)
           @constraint(model, Z_ref, Z in PSDCone())
           @objective(model, Min, LinearAlgebra.tr(W * (LinearAlgebra.I - Z)))
           @constraint(model, [i = 1:m], sum(Z[i, :]) .== 1)
           @constraint(model, LinearAlgebra.tr(Z) == num_clusters)
           optimize!(model)
           assert_is_solved_and_feasible(model)
           Z_val = value.(Z)
           Z_dual = dual(Z_ref)
       end
6脳6 LinearAlgebra.Symmetric{Float64, Matrix{Float64}}:
  0.436055     -0.185689      0.000335814  -0.250273      0.000107101  -0.000536029
 -0.185689      0.436056      0.000324706  -0.250272      6.26428e-5   -0.000482078
  0.000335814   0.000324706   0.520101     -0.000435283  -0.338518     -0.181809
 -0.250273     -0.250272     -0.000435283   0.500357     -0.000335969   0.000958925
  0.000107101   6.26428e-5   -0.338518     -0.000335969   0.482705     -0.144021
 -0.000536029  -0.000482078  -0.181809      0.000958925  -0.144021      0.325889

julia> Z_dual' * Z_val
6脳6 Matrix{Float64}:
  1.13355e-5   9.63657e-6  -1.00692e-5   9.24534e-6  -1.00654e-5  -1.00675e-5
  9.81162e-6   1.15108e-5  -1.02443e-5   9.42015e-6  -1.02406e-5  -1.02421e-5
  2.43498e-5   2.43496e-5  -2.25635e-5   2.43565e-5  -2.57207e-5  -2.48098e-5
 -2.11285e-5  -2.11288e-5   2.0296e-5   -1.86478e-5   2.0287e-5    2.02912e-5
 -1.79189e-5  -1.79191e-5   1.65731e-5  -1.79273e-5   1.95066e-5   1.77142e-5
 -6.44951e-6  -6.4492e-6    6.00798e-6  -6.44691e-6   6.23308e-6   7.11415e-6
2 Likes