Conic Optimization on Julia
Here I will describe a bit about conic programming on Julia based on
Juan Pablo Vielma’s JuliaCon 2020 talk and
JuMP devs Tutorials. We will begin by defining what is a cone and how to model them on JuMP
together with some simple examples, by the end we will solve an mixed - integer conic problem of avoiding obstacles by following a polynomial trajectory.
Why Conic Optimizacion?
- Linear- programming-like duality
- Faster and more stable algorithms
- Avoid non-differentiability issues, exploit primal-dual form, strong theory on barriers for interior point algorithms.
- Industry change in 2018:
- Knitro version 11.0 adds support for SOCP constraints.
- Mosek version 9.0 deprecates expression/function-based formulations and focuses on pure conic (linear, SOCP, rotated SOCP, SDP, exp & power)
Table of Contents
- What is a Cone?
- Conic Programming.
- Some type of Cones supported by JuMP and programming examples.
- Second Order - Cone
- Rotated Second Order - Cone
- Exponential Cone
- Positive Semidefinite Cone (PSD)
- Other Cones and Functions.
- Mixed Integer Conic example: Avoiding obstacles (Drone and Flappy bird)
- Continuous Conic programming on Julia?
What is a Cone?
A subset
A cone C is a convex cone if
Conic Programming
Conic programming problems are convex optimization problems in which a convex function is minimized over the intersection of an affine subspace and a convex cone. An example of a conic-form minimization problems, in the primal form is:
such that:
The corresponding dual problem is:
such that:
Where each
Some of the Types of Cones supported by JuMP
Second - Order Cone
The Second - Order Cone (or Lorentz Cone) of dimension
A Second - Order Cone rotated by
These cones are represented in JuMP
using MOI
sets SecondOrderCone
and RotatedSecondOrderCone
Example: Euclidean Projection on a hyperplane
For a given point
We can model the above problem as the following conic program:
If we transform this to the form we saw above,
Thus, we can obtain the dual problem as:
Let’s model this in Julia.
First we need to load some packages JuMP
is the modeling package, ECOS
is a solver, LinearAlgebra
and Random
are just to get some linear algebra operations and a fix seed for reproducibility respectively.
using JuMP
using ECOS
using LinearAlgebra
using Random
Random.seed!(2020);
Lets get some random values for the problem’s input:
u0 = rand(10)
p = rand(10)
q = rand();
Now we can write the model:
model = Model(optimizer_with_attributes(ECOS.Optimizer, "printlevel" => 0))
@variable(model, u[1:10])
@variable(model, t)
@objective(model, Min, t)
@constraint(model, [t, (u - u0)...] in SecondOrderCone())
@constraint(model, u' * p == q)
optimize!(model)

Then we can see the objective function value and variable value at the optimum by doing:
@show objective_value(model);
@show value.(u);
We get an objective value of :
e1 = [1.0, zeros(10)...]
dual_model = Model(optimizer_with_attributes(ECOS.Optimizer, "printlevel" => 0))
@variable(dual_model, y1 <= 0.0)
@variable(dual_model, y2[1:11])
@objective(dual_model, Max, q * y1 + dot(vcat(0.0, u0), y2))
@constraint(dual_model, e1 - [0.0, p...] .* y1 - y2 .== 0.0)
@constraint(dual_model, y2 in SecondOrderCone())
optimize!(dual_model)

@show objective_value(dual_model);
We get an objective value of :
We can also have an equivalent formulation using a Rotated Second - Order cone:
model = Model(optimizer_with_attributes(ECOS.Optimizer, "printlevel" => 0))
@variable(model, u[1:10])
@variable(model, t)
@objective(model, Min, t)
@constraint(model, [t, 0.5, (u - u0)...] in RotatedSecondOrderCone())
@constraint(model, u' * p == q)
optimize!(model)

We notice that the objective function values are different. There is a simple explanation to that behaviour. In the case of Second-Order Cone the objective function is
Exponential Cone
An exponential Cone is a set of the form:
It is represented in JuMP
using the MOI
set ExponentialCone
.
Example: Entropy Maximization
We want to maximize the entropy function
We just need to use the following transformation:
An example in Julia would be:
n = 15;
m = 10;
A = randn(m, n);
b = rand(m, 1);
model = Model(optimizer_with_attributes(ECOS.Optimizer, "printlevel" => 0))
@variable(model, t[1:n])
@variable(model, x[1:n])
@objective(model, Max, sum(t))
@constraint(model, sum(x) == 1.0)
@constraint(model, A * x .<= b )
# Cannot use the exponential cone directly in JuMP, hence we use MOI to specify the set.
@constraint(model, con[i = 1:n], [t[i], x[i], 1.0] in MOI.ExponentialCone())
optimize!(model);
Positive Semidefinite Cone
The set of Positive Semidefinite Matrices of dimension
A PSD cone is represented in JuMP using the MOI sets PositiveSemidefiniteConeTriangle
(for upper triangle of a PSD matrix) and PositiveSemidefiniteConeSquare
(for a complete PSD matrix). However, it is preferable to use the PSDCone
shortcut as illustrated below.
Example: Largest Eigenvalue of a Symmetrix Matrix
Suppose
using LinearAlgebra
using SCS
A = [3 2 4;
2 0 2;
4 2 3]
model = Model(optimizer_with_attributes(SCS.Optimizer, "verbose" => 0))
@variable(model, t)
@objective(model, Min, t)
@constraint(model, t .* Matrix{Float64}(I, 3, 3) - A in PSDCone())
optimize!(model)
Which give us
Other Cones and Functions
For other cones supported by JuMP, check out the MathOptInterface Manual. A good resource for learning more about functions which can be modelled using cones is the MOSEK Modeling Cookbook. Also Check this link to find out all the different solvers and their supported problem types
Mixed - Integer Conic example
Suppose we have a drone which we want to fly avoiding obstacles, how can we model and compute the optimal trajectory?

Let
- Step 1: Discretize time intro intervals
and then describe position by polynomials such that:
-
Step 2: “Safe polyhedrons”
such that:- Sum-of-Squares (SOS):
- Boyund degree of polynomials:
SDP
.
Using JuMP.jl
, PolyJuMP.jl
, SumOfSquares.jl
, MI-SDP Solver Pajarito.jl
for a 9 region, 8 time steps problem, we get optimal “smoothness” in 651 seconds as shown in the picture above.
While for 60 horizontal segments & obstacle every 5: Optimal “clicks” in 80 seconds.

Continuous solver?
- The
Hypatia.jl
solver: conic interior point algorithms and interfaces (Chris Coey, MIT)- A homogeneous interior-point solver for non - symmetric cones
- Versatility & performance = More Cones
- Two dozen predefined standard and exotic cones: e.g SDP, Sum-of-Squares and “Matrix” Sum-of-Squares for convexity/shape constraints.
- Customizable: “Bring your own barrier” = " Bring your own cone"
- Take advantage of Natural formulations.
- Take advantage of Julia: multi-precision arithmetic, abstract linear operators, etc.
- Modeling with new and nonsymmetric cones (Lea Kapelevich, MIT)
Tulip.jl
: An interior-point LP solver with abstract linear algebra (Mathieu Tanneau, Polytechnique Montréal)- Set Programming with JuMP (Benoît Legat, UC Louvain)
- JuliaMoments (Tillmann Weisser, Los Alamos National Laboratory) -Dual of Sum-of-Squares