# Using operator relative entropy cone in Julia

**URL:** <https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [April 22, 2025, 8:49am UTC](https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285 "2025-04-22T08:49:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhouhh17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhouhh17/32/213139_2.png) [@zhouhh17](https://discourse.julialang.org/u/zhouhh17)\
**Post date:** [April 22, 2025, 8:49am UTC](https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285/1 "2025-04-22T08:49:44Z")

</div>

#### Question

Is it possible to optimize over the following _operator relative entropy cone_ natively in Julia:

\text{cl}\{(A, B, C)\in H^n\_+ \times H^n\_+ \times H^n: C \succeq - A^{1/2} \log(A^{-1/2} B A^{-1/2}) A^{1/2}\}

where cl stands for the closure, H^n is the space of n\times n Hermitian matrices, H^n\_+ is the space of n\times n PSD Hermitian matrices.

#### Context

- A [previous topic](https://discourse.julialang.org/t/optimizing-over-the-quantum-entropy-cone-natively-in-jump/59833) raised a similar question. I’m seeking the latest information on whether this can now be done directly in Julia.
- [Hypatia.jl](https://github.com/jump-dev/Hypatia.jl) implements [`EpiTrRelEntropyTri`](https://jump.dev/Hypatia.jl/v0.8/api/cones/#Hypatia.Cones.EpiTrRelEntropyTri), which seems to bound the **trace** of the matrix operator relative entropy of A and B, rather than directly constraining the three matrices A,B,C.
- In Python, this is supported by:
  - [PICOS](https://picos-api.gitlab.io/picos/) via the [Operator Relative Entropy](https://picos-api.gitlab.io/picos/api/picos.expressions.exp_oprelentr.html#picos.expressions.exp_oprelentr.OperatorRelativeEntropy)
  - [qics](https://qics.dev/introduction.html) via the [Operator Perspective Epigraph Cone](https://qics.dev/api/cones/OpPerspecEpi.html#qics.cones.OpPerspecEpi)

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:** [April 22, 2025, 9:48pm UTC](https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285/2 "2025-04-22T21:48:46Z")

</div>

Hi @zhouhh17, welcome to the forum 😄

I don’t think there has been any progress. You’re still limited to the trace. But I’m not an expert in this area, so someone might come along to correct me. Let me know if you need an example using the trace. You could use Hypatia via JuMP, or you could use Convex.jl.

---

<div class="post-metadata">

**Author:** ![zhouhh17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhouhh17/32/213139_2.png) [@zhouhh17](https://discourse.julialang.org/u/zhouhh17)\
**Post date:** [April 23, 2025, 6:42am UTC](https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285/4 "2025-04-23T06:42:08Z")

</div>

Hi odow. Thank you for the information.  
I’m new to this field and have only used frameworks and solvers as a user, never contributed code or developed one. Maybe I could try customizing this cone later.

- Is implementing this cone a good choice for a beginner? (I’m unfamiliar with the theory part and those self-concordant barrier function stuff, so I don’t know how hard it is.)
- Are there beginner examples for customizing a cone?

Thanks!

---

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [April 23, 2025, 11:46am UTC](https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285/5 "2025-04-23T11:46:26Z")

</div>

What do you mean by “customizing a cone”? Are you trying to develop a software kit?  
or you merely want to solve a convex conic optimization instance?

---

<div class="post-metadata">

**Author:** ![araujoms](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/araujoms/32/217734_2.png) [@araujoms](https://discourse.julialang.org/u/araujoms)\
**Post date:** [April 24, 2025, 7:29pm UTC](https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285/6 "2025-04-24T19:29:23Z")

</div>

In order to implement a cone you need to do five things:

1. Solve the central point equation to determine the starting point
2. Write a function to test whether a point belongs to the cone
3. Write functions to compute the gradient, Hessian, and third-order derivative of the barrier function

Now for this cone specifically the central point and the derivatives are already known, so you’d only need to implement them. Problem is, they are rather nasty. I’d say it’s straightforward but difficult. The best you to do it is get a similar cone, modify it function by function, and use ForwardDiff to test whether you are writing down the derivatives correctly.

As for beginner examples, I’m afraid all easy cones have been implemented already. You could as an exercise reimplement the second-order cone, for example.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [April 25, 2025, 12:12am UTC](https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285/7 "2025-04-25T00:12:21Z")

</div>

Convex.jl has `Convex.Constraint((T, X, Y), RelativeEntropyEpiConeSquare(size(X, 1), m, k, e))` but it looks a little different from your definition ([Supported Operations · Convex.jl](https://jump.dev/Convex.jl/stable/manual/operations/#Semidefinite-Program-Representable-Functions)). This uses an extended formulation ported from CVXQUAD rather than directly implementing the cone.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [April 25, 2025, 12:28am UTC](https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285/8 "2025-04-25T00:28:49Z")

</div>

Could we use Enzyme or something similar to write out the derivatives for us? Why do they have to be done manually?

---

<div class="post-metadata">

**Author:** ![araujoms](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/araujoms/32/217734_2.png) [@araujoms](https://discourse.julialang.org/u/araujoms)\
**Post date:** [April 25, 2025, 11:05am UTC](https://discourse.julialang.org/t/using-operator-relative-entropy-cone-in-julia/128285/9 "2025-04-25T11:05:37Z")

</div>

I tried Enzyme, no luck. ForwardDiff worked, but it was too slow and unstable to be useful.

It’s specially problematic when the functions have a restricted domain (like here), and the derivatives diverge in the boundary. When we’re close to the boundary (which always happens when solving a conic problem) ForwardDiff produces garbage.
