Syntax for specifying block diagonal constraints in Convex

It looks like there’s no good way to achieve this in Convex.jl. It uses an expression-graph representation of the problem, so it seems like it has some problems with using an arbitrary matrix type like BlockDiagonal.

Here’s how I’d write it in JuMP:

using JuMP, LinearAlgebra, BlockDiagonals, Hypatia
m, n = 4, 2
model = Model(Hypatia.Optimizer)
Σ = 0.5 * Matrix(I, m, m) + 0.5 * ones(m, m)
S = [0.5 * Matrix(I, n, n) + 0.5 * ones(n, n) for _ in 1:n]
@variable(model, 0 <= x[1:n] <= 1)
blocks = Matrix(BlockDiagonal([x[i] * S[i] for i in 1:n]))
@constraint(model, Symmetric(2 * Σ - blocks) in PSDCone())
1 Like