# Determinant constraints in JuMP

**URL:** <https://discourse.julialang.org/t/determinant-constraints-in-jump/126664>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, nonlinear\
**Created:** [March 7, 2025, 6:05am UTC](https://discourse.julialang.org/t/determinant-constraints-in-jump/126664 "2025-03-07T06:05:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@Rick](https://discourse.julialang.org/u/Rick)\
**Post date:** [March 7, 2025, 6:05am UTC](https://discourse.julialang.org/t/determinant-constraints-in-jump/126664/1 "2025-03-07T06:05:29Z")

</div>

Hi!

I have a question about using imposing determinant as a constraint in `JuMP`. Currently, I am trying to solve a problem that involve constraints of the form

\det(A) = c \det(B),

where c is a given scalar. A and B are matrices of the same size.

I am aware that there are functions like `RootDetConeSquare` that can impose constraints of the form \det(A)^{1/d} \geq t. But this is not what I need. So, I am wondering if there is a nice way to do it.

Besides, I also tried using `LinearAlgebra.det` directly, but it seems the solvers I tried (e.g., `KNITRO`, `Ipopt`) do not register the function properly (I suspect that I did not register the operator correctly). Here is a MWE of what I tried:

```julia
model = Model(Ipopt.Optimizer)
@variable(model, x[1:3, 1:3])
@variable(model, y[1:3, 1:3])

dett(x...) = LinearAlgebra.det(reshape(collect(x), 3, 3))
@operator(model, f1, 9, (x...) -> dett(collect(x))[1])

@constraint(model, f1(x...) .== .5 * f1(y...))
@objective(model, Max, 1)

optimize!(model)

```

Any thoughts on this are very much appreciated. Thank you!

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 7, 2025, 6:33pm UTC](https://discourse.julialang.org/t/determinant-constraints-in-jump/126664/2 "2025-03-07T18:33:10Z")

</div>

Here’s the code you’re tying to write:

```Julia
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.
