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 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)
Problem statistics
  problem is DCP         : true
  number of variables    : 1 (2 scalar elements)
  number of constraints  : 3 (5 scalar elements)
  number of coefficients : 12
  number of atoms        : 23

Solution summary
  termination status : OPTIMAL
  primal status      : FEASIBLE_POINT
  dual status        : FEASIBLE_POINT
  objective value    : -0.6428999999999999999999999999999999999998

Expression graph
  minimize
   └─ + (convex; real)
      ├─ * (convex; positive)
      │  ├─ [3;;]
      │  └─ qol_elem (convex; positive)
      │     ├─ …
      │     └─ …
      ├─ * (convex; positive)
      │  ├─ [2;;]
      │  └─ qol_elem (convex; positive)
      │     ├─ …
      │     └─ …
      ├─ Convex.NegateAtom (affine; real)
      │  └─ index (affine; real)
      │     └─ …
      ⋮
  subject to
   ├─ == constraint (affine)
   │  └─ + (affine; real)
   │     ├─ index (affine; real)
   │     │  └─ …
   │     └─ Convex.NegateAtom (affine; real)
   │        └─ …
   ├─ ≥ constraint (affine)
   │  └─ + (affine; real)
   │     ├─ 2-element real variable (id: 124…864)
   │     └─ Convex.NegateAtom (constant; positive)
   │        └─ …
   └─ ≤ constraint (affine)
      └─ + (affine; real)
         ├─ 2-element real variable (id: 124…864)
         └─ Convex.NegateAtom (constant; negative)
            └─ …

This page was generated using Literate.jl.