Convex.jl Interface

Clarabel.jl implements support for MathOptInterface, and is therefore compatible with Convex.jl. This allows you to describe and modify your optimisation problem with Convex.jl and use Clarabel as the backend solver.

Setting Clarabel.jl Backend

You should construct your problem in the usual way in Convex.jl, and then solve using Clarabel.Optimizer, i.e. by calling solve! with

solve!(problem, Clarabel.Optimizer)

where problem is an object of type Convex.Problem.

Convex.jl or JuMP?

Clarabel.jl supports both Convex.jl and JuMP via MathOptInterface. Both packages are excellent and can make problem construction considerably easier than via the solver's native interface.

For problems with quadratic objective functions, JuMP is generally preferred when using Clarabel.jl since it will keep the quadratic function in the objective rather than reformulating the problem to a form with a linear cost and additional second-order cone constraints. Clarabel.jl natively supports quadratic objectives and solve times are generally faster if this reformulation is avoided.

Arbitrary Precision Arithmetic

Clarabel.jl supports arbitrary precision arithmetic for Convex.jl. Here is the Basic QP Example implemented using BigFloat types.

#hide setprecision(BigFloat,256)
using Clarabel, Convex

x = Variable(2)
objective = 3square(x[1]) + 2square(x[2]) - x[1] - 4x[2]
problem = minimize(objective; numeric_type = BigFloat)
problem.constraints = [x[1] == 2x[2]]
problem.constraints += [x >= -1; x <= 1]
solve!(problem, Clarabel.Optimizer{BigFloat}; silent_solver = false)
           Clarabel.jl v0.4.0  -  Clever Acronym
                   (c) Paul Goulart
                University of Oxford, 2022

  variables     = 5
  constraints   = 14
  nnz(P)        = 0
  nnz(A)        = 17
  cones (total) = 4
    : Clarabel.Zero = 1,  numel = 2
    : Clarabel.Nonnegative = 1,  numel = 6
    : Clarabel.SecondOrder = 2,  numel = (3,3)

  linear algebra: direct / qdldl, precision: BigFloat (128 bit)
  max iter = 200, time limit = Inf,  max step = 0.990
  tol_feas = 1.0e-08, tol_gap_abs = 1.0e-08, tol_gap_rel = 1.0e-08,
  static reg : on, ϵ1 = 1.0e-08, ϵ2 = 4.9e-32
  dynamic reg: on, ϵ = 1.0e-13, δ = 2.0e-07
  iter refine: on, reltol = 1.0e-13, abstol = 1.0e-12,
               max iter = 10, stop ratio = 5.0
  equilibrate: on, min_scale = 1.0e-04, max_scale = 1.0e+04
               max iter = 10

iter    pcost        dcost       gap       pres      dres      k/t        μ       step
  0  -3.5004e-41  -2.0528e+01  2.05e+01  7.03e-01  1.21e-01  1.00e+00  4.56e+00   ------
  1  -3.9929e-01  -6.6536e+00  6.25e+00  3.35e-01  3.94e-02  1.00e+00  1.53e+00  8.71e-01
  2  -1.0201e+00  -1.8936e+00  8.56e-01  4.93e-02  5.39e-03  1.48e-01  2.64e-01  8.87e-01
  3  -6.5281e-01  -6.8163e-01  2.88e-02  1.63e-03  1.75e-04  4.39e-03  8.90e-03  9.67e-01
  4  -6.4335e-01  -6.4589e-01  2.54e-03  1.45e-04  1.55e-05  3.88e-04  7.87e-04  9.14e-01
  5  -6.4289e-01  -6.4304e-01  1.54e-04  8.94e-06  9.48e-07  2.51e-05  4.81e-05  9.53e-01
  6  -6.4286e-01  -6.4286e-01  3.00e-06  1.75e-07  1.85e-08  4.89e-07  9.38e-07  9.81e-01
  7  -6.4286e-01  -6.4286e-01  8.34e-08  4.85e-09  5.14e-10  1.36e-08  2.61e-08  9.72e-01
  8  -6.4286e-01  -6.4286e-01  8.09e-09  1.98e-09  4.98e-11  1.32e-09  2.53e-09  9.04e-01
Terminated with status = solved
solve time = 5.75ms

This page was generated using Literate.jl.