Here’s the code you’re tying to write:
using JuMP, Ipopt, LinearAlgebra
function op_det_fn(x...)
xn = isqrt(length(x))
return LinearAlgebra.det(reshape(collect(x), xn, xn))
end
model = Model(Ipopt.Optimizer)
n = 3
@variable(model, x[1:n, 1:n])
@variable(model, y[1:n, 1:n])
@operator(model, op_det, n^2, op_det_fn)
@constraint(model, op_det(x...) == 0.5 * op_det(y...))
optimize!(model)
I don’t think it will really scale to larger n though.
I also don’t really know any good tricks for reformulating this constraint. But someone else might.