# Convex Semi-definite Problem

**URL:** <https://discourse.julialang.org/t/convex-semi-definite-problem/113656>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, optimization, convex\
**Created:** [April 30, 2024, 3:03pm UTC](https://discourse.julialang.org/t/convex-semi-definite-problem/113656 "2024-04-30T15:03:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julian\_Villaquira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/julian_villaquira/32/203772_2.png) [@Julian\_Villaquira](https://discourse.julialang.org/u/Julian_Villaquira)\
**Post date:** [April 30, 2024, 3:03pm UTC](https://discourse.julialang.org/t/convex-semi-definite-problem/113656/1 "2024-04-30T15:03:31Z")

</div>

I am trying to solve a convex semi-definite optimization problem, and I don’t know what would be the right approach to implement it in Julia. The problem is the following:

`min c'x`

where `c` and `x` are vectors in `R^n` subject to

`F(x) <= Y`

where `F(x)` is a symmetric `m * m` matrix for any `x`, and `Y` is a fixed matrix. The main problem is that `F` is a highly non-linear convex function, and each evaluation requires a lot of computations which are not implemented in Julia (I have them in FreeFEM++). To solve the problem, each evaluation of `F` would require to run an external script.

Do you have any recommendations of where can I start? I was thinking of using Mosek and JuMP . . . but I don’t really know if it would be feasible to implement in Julia.

Any help would be appreciated, thanks!

---

<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:** [May 1, 2024, 2:13am UTC](https://discourse.julialang.org/t/convex-semi-definite-problem/113656/2 "2024-05-01T02:13:10Z")

</div>

What do you mean by `F(x) <= Y`? Do you want them to be element wise inequality, or do you mean `Y - F(x)` is positive-semidefinite?

You cannot use Mosek (or really, any conic SDP solver) for this because they don’t support external functions.

Depending on what you mean by `<=`, a second question is: can you differentiate `F(x)`?

---

<div class="post-metadata">

**Author:** ![Julian\_Villaquira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/julian_villaquira/32/203772_2.png) [@Julian\_Villaquira](https://discourse.julialang.org/u/Julian_Villaquira)\
**Post date:** [May 1, 2024, 2:23am UTC](https://discourse.julialang.org/t/convex-semi-definite-problem/113656/3 "2024-05-01T02:23:21Z")

</div>

I mean that the difference is positive-semidefinite.

And yes, `F` is Frechet-differentiable. I would have to compute its derivative with a finite difference scheme though.

---

<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:** [May 1, 2024, 2:42am UTC](https://discourse.julialang.org/t/convex-semi-definite-problem/113656/4 "2024-05-01T02:42:46Z")

</div>

This is a pretty tricky problem, and I don’t have an immediate suggestions for you. What is the dimension of `x`? Finite differencing sounds expensive.

One approach might be to use a nonlinear optimizer with

`g(x) = LinearAlgebra.eigmin(Y - F(x))` and the constraint `g(x) >= 0`.

but you’d still need some way of supplying derivatives.

I’ll note that you probably shouldn’t use JuMP for this. See:

- [Should you use JuMP? · JuMP](https://jump.dev/JuMP.jl/stable/should_i_use/#You-want-to-optimize-a-complicated-Julia-function)
- [Should you use JuMP? · JuMP](https://jump.dev/JuMP.jl/stable/should_i_use/#Black-box,-derivative-free,-or-unconstrained-optimization)

Other readers on this forum will probably chime in with some clever ideas that presently escape me.

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [May 1, 2024, 6:03am UTC](https://discourse.julialang.org/t/convex-semi-definite-problem/113656/5 "2024-05-01T06:03:39Z")

</div>

When the solver is not in Julia but you know exactly what it does, maybe ImplicitDifferentiation.jl can help to get derivatives of `F` wrt `x`?

---

<div class="post-metadata">

**Author:** ![Julian\_Villaquira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/julian_villaquira/32/203772_2.png) [@Julian\_Villaquira](https://discourse.julialang.org/u/Julian_Villaquira)\
**Post date:** [May 2, 2024, 1:32am UTC](https://discourse.julialang.org/t/convex-semi-definite-problem/113656/6 "2024-05-02T01:32:12Z")

</div>

Thanks to both of you. Surely I shouldn’t use JuMP for this problem, and I will look into ImplicitDifferentiation.jl.

I will read about interior-point methods usually used for SDP problems, and see if I can take any ideas from there. Any recommendations?

On the other hand, I know for a fact that `F` is a decreasing function (`x` with the component-wise partial order and `F(x)` with the semi-definite one). Can I use this information somehow when implementing some method?
