Julia API Reference
Solver and main API
Clarabel.Solver
— TypeSolver{T <: AbstractFloat}()
Initializes an empty Clarabel solver that can be filled with problem data using:
setup!(solver, P, q, A, b, cones, [settings]).
Clarabel.setup!
— Functionsetup!(solver, P, q, A, b, cones, [settings])
Populates a Solver
with a cost function defined by P
and q
, and one or more conic constraints defined by A
, b
and a description of a conic constraint composed of cones whose types and dimensions are specified by cones.
The solver will be configured to solve the following optimization problem:
min 1/2 x'Px + q'x
s.t. Ax + s = b, s ∈ K
All data matrices must be sparse. The matrix P
is assumed to be symmetric and positive semidefinite, and only the upper triangular part is used.
The cone K
is a composite cone. To define the cone the user should provide a vector of cone specifications along with the appropriate dimensional information. For example, to generate a cone in the nonnegative orthant followed by a second order cone, use:
cones = [Clarabel.NonnegativeConeT(dim_1),
Clarabel.SecondOrderConeT(dim_2)]
If the argument 'cones' is constructed incrementally, the should should initialize it as an empty array of the supertype for all allowable cones, e.g.
cones = Clarabel.SupportedCone[]
push!(cones,Clarabel.NonnegativeConeT(dim_1))
...
The optional argument settings
can be used to pass custom solver settings:
settings = Clarabel.Settings(verbose = true)
setup!(model, P, q, A, b, cones, settings)
To solve the problem, you must make a subsequent call to solve!
Clarabel.solve!
— Functionsolve!(solver)
Computes the solution to the problem in a Clarabel.Solver
previously defined in setup!
.
Clarabel.save_to_file
— Functionsave_to_file(solver, filename)
Write the problem data in a Clarabel.Solver
to filename
in JSON format. The data is written in a format that can be read back into a Clarabel.Solver
using load_from_file
. The problem data will be written in unscaled form, but in the internal format used by the solver after applying chordal decomposition and presolve. It is not necessary to solve the problem before writing it to a file.
Clarabel.load_from_file
— Functionload_from_file(filename)
Create a Clarabel.Solver
object from data in filename
previously written by save_to_file
.
SupportedCone
Clarabel.SupportedCone
— TypeSupportedCone
An abstract type use by the Clarabel API used when passing cone specifications to the solver setup!
. The currently supported concrete types are:
ZeroConeT
: The zero cone. Used to define equalities.NonnegativeConeT
: The nonnegative orthant.SecondOrderConeT
: The second order / Lorentz / ice-cream cone.ExponentialConeT
: The exponential cone (in R^3)PowerConeT
: The power cone with power α (in R^3)GenPowerConeT
: The generalized power conePSDTriangleConeT
: The positive semidefinite cone (triangular format).
Solver Status
Clarabel.SolverStatus
— TypeSolverStatus
An Enum of of possible conditions set by solve!
.
If no call has been made to solve!
, then the SolverStatus
is:
UNSOLVED
: The algorithm has not started.
Otherwise:
SOLVED
: Solver terminated with a solution.PRIMAL_INFEASIBLE
: Problem is primal infeasible. Solution returned is a certificate of primal infeasibility.DUAL_INFEASIBLE
: Problem is dual infeasible. Solution returned is a certificate of dual infeasibility.ALMOST_SOLVED
: Solver terminated with a solution (reduced accuracy).ALMOST_PRIMAL_INFEASIBLE
: Problem is primal infeasible. Solution returned is a certificate of primal infeasibility (reduced accuracy).ALMOST_DUAL_INFEASIBLE
: Problem is dual infeasible. Solution returned is a certificate of dual infeasibility (reduced accuracy).MAX_ITERATIONS
: Iteration limit reached before solution or infeasibility certificate found.MAX_TIME
: Time limit reached before solution or infeasibility certificate found.NUMERICAL_ERROR
: Solver terminated with a numerical error.INSUFFICIENT_PROGRESS
: Solver terminated due to lack of progress.