Convex.jl currently supports the following functions. These functions may be composed according to the DCP composition rules to form new convex, concave, or affine expressions. Convex.jl transforms each problem into an equivalent conic program in order to pass the problem to a specialized solver. Depending on the types of functions used in the problem, the conic constraints may include linear, second-order, exponential, or semidefinite constraints, as well as any binary or integer constraints placed on the variables. Below, we list each function available in Convex.jl organized by the (most complex) type of cone used to represent that function, and indicate which solvers may be used to solve problems with those cones. Problems mixing many different conic constraints can be solved by any solver that supports every kind of cone present in the problem.
In the notes column in the tables below, we denote implicit constraints imposed on the arguments to the function by IC, and parameter restrictions that the arguments must obey by PR. (Convex.jl will automatically impose ICs; the user must make sure to satisfy PRs.) Elementwise means that the function operates elementwise on vector arguments, returning a vector of the same size.
An optimization problem using only these functions can be solved by any LP solver.
operation | description | vexity | slope | notes |
---|---|---|---|---|
x+y or x.+y
|
addition | affine | increasing | none |
x-y or x.-y
|
subtraction | affine | increasing in |
none none |
x*y |
multiplication | affine | increasing if constant term |
PR: one argument is constant |
x/y |
division | affine | increasing | PR: |
dot(*)(x, y) |
elementwise multiplication | affine | increasing | PR: one argument is constant |
dot(/)(x, y) |
elementwise division | affine | increasing | PR: one argument is constant |
x[1:4, 2:3] |
indexing and slicing | affine | increasing | none |
diag(x, k) |
|
affine | increasing | none |
diagm(x) |
construct diagonal matrix | affine | increasing | PR: |
x' |
transpose | affine | increasing | none |
vec(x) |
vector representation | affine | increasing | none |
dot(x,y) |
affine | increasing | PR: one argument is constant | |
kron(x,y) |
Kronecker product | affine | increasing | PR: one argument is constant |
vecdot(x,y) |
dot(vec(x),vec(y)) |
affine | increasing | PR: one argument is constant |
sum(x) |
affine | increasing | none | |
sum(x, k) |
sum elements across dimension |
affine | increasing | none |
sumlargest(x, k) |
sum of |
convex | increasing | none |
sumsmallest(x, k) |
sum of |
concave | increasing | none |
dotsort(a, b) |
dot(sort(a),sort(b)) |
convex | increasing | PR: one argument is constant |
reshape(x, m, n) |
reshape into |
affine | increasing | none |
minimum(x) |
concave | increasing | none | |
maximum(x) |
convex | increasing | none | |
[x y] or [x; y] hcat(x, y) or vcat(x, y)
|
stacking | affine | increasing | none |
tr(x) |
affine | increasing | none | |
partialtrace(x,sys,dims) |
Partial trace | affine | increasing | none |
partialtranspose(x,sys,dims) |
Partial transpose | affine | increasing | none |
conv(h,x) |
|
affine | increasing if |
PR: |
min(x,y) |
concave | increasing | none | |
max(x,y) |
convex | increasing | none | |
pos(x) |
convex | increasing | none | |
neg(x) |
convex | decreasing | none | |
invpos(x) |
convex | decreasing | IC: |
|
abs(x) |
convex | increasing on |
none | |
opnorm(x, 1) |
maximum absolute column sum: |
convex | increasing on |
|
opnorm(x, Inf) |
maximum absolute row sum: |
convex | increasing on |
An optimization problem using these functions can be solved by any SOCP solver (including ECOS, SCS, Mosek, Gurobi, and CPLEX). Of course, if an optimization problem has both LP and SOCP representable functions, then any solver that can solve both LPs and SOCPs can solve the problem.
operation | description | vexity | slope | notes |
---|---|---|---|---|
norm(x, p) |
convex | increasing on |
PR: p >= 1
|
|
quadform(x, P; assume_psd=false) |
convex in |
increasing on |
PR: either assume_psd=true to skip checking if P is positive semidefinite. |
|
quadoverlin(x, y) |
convex | increasing on |
IC: |
|
sumsquares(x) |
convex | increasing on |
none | |
sqrt(x) |
concave | decreasing | IC: |
|
square(x), x^2 |
convex | increasing on |
PR : |
|
dot(^)(x,2) |
convex | increasing on |
elementwise | |
geomean(x, y) |
concave | increasing | IC: |
|
huber(x, M=1) |
$\begin{cases} x^2 &|x| \leq M \ 2M|x| - M^2 &|x| > M \end{cases}$ | convex | increasing on |
PR: |
Note that for p=1
and p=Inf
, the function norm(x,p)
is a linear-program representable, and does not need a SOCP solver, and for a matrix x
, norm(x,p)
is defined as norm(vec(x), p)
.
An optimization problem using these functions can be solved by any exponential cone solver (SCS).
operation | description | vexity | slope | notes |
---|---|---|---|---|
logsumexp(x) |
convex | increasing | none | |
exp(x) |
convex | increasing | none | |
log(x) |
concave | increasing | IC: |
|
entropy(x) |
concave | not monotonic | IC: |
|
logisticloss(x) |
convex | increasing | none |
An optimization problem using these functions can be solved by any SDP solver (including SCS and Mosek).
operation | description | vexity | slope | notes |
---|---|---|---|---|
nuclearnorm(x) |
sum of singular values of |
convex | not monotonic | none |
opnorm(x, 2) (operatornorm(x) ) |
max of singular values of |
convex | not monotonic | none |
eigmax(x) |
max eigenvalue of |
convex | not monotonic | none |
eigmin(x) |
min eigenvalue of |
concave | not monotonic | none |
matrixfrac(x, P) |
convex | not monotonic | IC: P is positive semidefinite | |
sumlargesteigs(x, k) |
sum of top |
convex | not monotonic | IC: P symmetric |
T in GeomMeanHypoCone(A, B, t) |
concave | increasing | IC: |
|
T in GeomMeanEpiCone(A, B, t) |
convex | not monotonic | IC: |
|
quantum_entropy(X) |
concave | not monotonic | IC: |
|
quantum_relative_entropy(A, B) |
convex | not monotonic | IC: |
|
trace_logm(X, C) |
concave in X | not monotonic | IC: |
|
trace_mpower(A, t, C) |
concave in A for |
not monotonic | IC: |
|
lieb_ando(A, B, K, t) |
concave in A,B for |
not monotonic | IC: |
|
T in RelativeEntropyEpiCone(X, Y, m, k, e) |
convex | not monotonic | IC: |
An optimization problem using these functions can be solved by any solver that supports exponential constraints and semidefinite constraints simultaneously (SCS).
operation | description | vexity | slope | notes |
---|---|---|---|---|
logdet(x) |
log of determinant of |
concave | increasing | IC: x is positive semidefinite |
When an atom or constraint is applied to a scalar and a higher
dimensional variable, the scalars are promoted. For example, we can do
max(x, 0)
gives an expression with the shape of x
whose elements are
the maximum of the corresponding element of x
and 0
.