Operations¶
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 cone 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, secondorder, 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.)
Linear Program Representable Functions¶
An optimization problem using only these functions can be solved by any LP solver.
SecondOrder Cone Representable Functions¶
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) 
\((\sum x_i^p)^{1/p}\)  convex  increasing on \(x \ge 0\) decreasing on \(x \le 0\) 
PR: p >= 1 
vecnorm(x, p) 
\((\sum x_{ij}^p)^{1/p}\)  convex  increasing on \(x \ge 0\) decreasing on \(x \le 0\) 
PR: p >= 1 
quad_form(x, P) 
\(x^T P x\)  convex in \(x\) affine in \(P\) 
increasing on \(x \ge 0\) decreasing on \(x \le 0\) increasing in \(P\) 
PR: either \(x\) or \(P\) must be constant; if \(x\) is not constant, then \(P\) must be symmetric and positive semidefinite 
quad_over_lin(x, y) 
\(x^T x/y\)  convex  increasing on \(x \ge 0\) decreasing on \(x \le 0\) decreasing in \(y\) 
IC: \(y > 0\) 
sum_squares(x) 
\(\sum x_i^2\)  convex  increasing on \(x \ge 0\) decreasing on \(x \le 0\) 
none 
sqrt(x) 
\(\sqrt{x}\)  convex  decreasing  IC: \(x>0\) 
square(x), x^2 
\(x^2\)  convex  increasing on \(x \ge 0\) decreasing on \(x \le 0\) 
none 
geo_mean(x, y) 
\(\sqrt{xy}\)  concave  increasing  IC: \(x\ge0\), \(y\ge0\) 

\(\begin{cases} x^2 &x \leq M \\ 2Mx  M^2 &x > M \end{cases}\)  convex  increasing on \(x \ge 0\) decreasing on \(x \le 0\) 
PR: \(M>=1\) 
Exponential Cone Representable Functions¶
An optimization problem using these functions can be solved by any exponential cone solver (SCS).
operation  description  vexity  slope  notes 

logsumexp(x) 
\(\log(\sum_i \exp(x_i))\)  convex  increasing  none 
exp(x) 
\(\exp(x)\)  convex  increasing  none 
log(x) 
\(\log(x)\)  concave  increasing  IC: \(x>0\) 
entropy(x) 
\(\sum_{ij} x_{ij} \log (x_{ij})\)  concave  not monotonic  IC: \(x>0\) 
logistic_loss(x) 
\(\log(1 + \exp(x_i))\)  convex  increasing  none 
Semidefinite Program Representable Functions¶
An optimization problem using these functions can be solved by any SDP solver (including SCS and Mosek).
Exponential + SDP representable Functions¶
An optimization problem using these functions can be solved by any solver that supports exponential constraints and semidefinite constraints simultaneously (SCS).
Promotions¶
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
.