Skip to content

Commit 0bd470b

Browse files
authored
Add RootDetAtom (#605)
1 parent faf7fa7 commit 0bd470b

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

docs/src/manual/operations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ solver (including SCS and Mosek).
113113
| `opnorm(x, 2)` (`operatornorm(x)`)| max of singular values of $x$ | convex | not monotonic | |
114114
| `eigmax(x)` | max eigenvalue of $x$ | convex | not monotonic | |
115115
| `eigmin(x)` | min eigenvalue of $x$ | concave | not monotonic | |
116+
| `rootdet(X)` | n-th root-determinant of the $n$-by-$n$ matrix X, that is $det(X)^{1/n}$ | concave | not monotonic | |
116117
| `matrixfrac(x, P)` | $x^TP^{-1}x$ | convex | not monotonic | IC: P is positive semidefinite |
117118
| `sumlargesteigs(x, k)` | sum of top $k$ eigenvalues of $x$ | convex | not monotonic | IC: P symmetric |
118119
| `T in GeomMeanHypoCone(A, B, t)` | $T \preceq A \#_t B = A^{1/2} (A^{-1/2} B A^{-1/2})^t A^{1/2}$ | concave | increasing | IC: $A \succeq 0$, $B \succeq 0$, $t \in [0,1]$ |

src/Convex.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export conv,
5252
trace_logm,
5353
trace_mpower,
5454
lieb_ando,
55+
rootdet,
5556
# Constraints
5657
Constraint,
5758
,

src/atoms/sdp_cone/RootDetAtom.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
mutable struct RootDetAtom <: AbstractExpr
2+
children::Tuple{AbstractExpr}
3+
size::Tuple{Int,Int}
4+
5+
RootDetAtom(x::AbstractExpr) = new((x,), (1, 1))
6+
end
7+
8+
head(io::IO, ::RootDetAtom) = print(io, "rootdet")
9+
10+
Base.sign(::RootDetAtom) = NoSign()
11+
12+
monotonicity(::RootDetAtom) = (NoMonotonicity(),)
13+
14+
curvature(::RootDetAtom) = ConcaveVexity()
15+
16+
function evaluate(x::RootDetAtom)
17+
n = size(only(AbstractTrees.children(x)), 1)
18+
return LinearAlgebra.det(evaluate(x.children[1]))^(1 / n)
19+
end
20+
21+
function new_conic_form!(context::Context{T}, x::RootDetAtom) where {T}
22+
t = conic_form!(context, Variable())
23+
A = only(AbstractTrees.children(x))
24+
f = operate(vcat, T, sign(x), t, conic_form!(context, A))
25+
MOI_add_constraint(context.model, f, MOI.RootDetConeSquare(size(A, 1)))
26+
return t
27+
end
28+
29+
rootdet(x::AbstractExpr) = RootDetAtom(x)

test/test_atoms.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,24 @@ end
14391439

14401440
# TODO
14411441

1442+
### sdp_cone/RootDetAtom
1443+
1444+
function test_RootDetAtom()
1445+
target = """
1446+
variables: t, x11, x12, x21, x22
1447+
minobjective: 1.0 * t + 0.0
1448+
[1.0*t, 1.0*x11, 1.0 *x12, 1.0*x21, 1.0*x22] in RootDetConeSquare(2)
1449+
"""
1450+
_test_atom(target) do context
1451+
return rootdet(Variable(2, 2))
1452+
end
1453+
x = Variable(2, 2)
1454+
x.value = [2.0 -1.5; -1.5 3.0]
1455+
atom = rootdet(x)
1456+
@test evaluate(atom) LinearAlgebra.det(x.value)^(1 / 2)
1457+
return
1458+
end
1459+
14421460
### second_order_cone/EuclideanNormAtom
14431461

14441462
function test_EuclideanNormAtom()

0 commit comments

Comments
 (0)