Features • Installation • License • Documentation
clarabel-gpu.jl is the GPU implementation of the Clarabel solver, which can solve conic problems of the following form:
with decision variables
- clarabel-gpu.jl can be added via the Julia package manager (type
]
):pkg> dev https://github.com/cvxgrp/clarabel-gpu.git
, (which will overwrite current use of Clarabel solver).
Modeling a conic optimization problem is the same as in the original Clarabel solver, except with the additional parameter direct_solve_method
. This can be set to :cudss
or :cudssmixed
. Here is a portfolio optimization problem modelled via JuMP:
using LinearAlgebra, SparseArrays, Random, JuMP
using Clarabel
## generate the data
rng = Random.MersenneTwister(1)
k = 5; # number of factors
n = k * 10; # number of assets
D = spdiagm(0 => rand(rng, n) .* sqrt(k))
F = sprandn(rng, n, k, 0.5); # factor loading matrix
μ = (3 .+ 9. * rand(rng, n)) / 100. # expected returns between 3% - 12%
γ = 1.0; # risk aversion parameter
d = 1 # we are starting from all cash
x0 = zeros(n);
a = 1e-3
b = 1e-1
γ = 1.0;
model = JuMP.Model(Clarabel.Optimizer)
set_optimizer_attribute(model, "direct_solve_method", :cudss)
@variable(model, x[1:n])
@variable(model, y[1:k])
@variable(model, s[1:n])
@variable(model, t[1:n])
@objective(model, Min, x' * D * x + y' * y - 1/γ * μ' * x);
@constraint(model, y .== F' * x);
@constraint(model, x .>= 0);
# transaction costs
@constraint(model, sum(x) + a * sum(s) == d + sum(x0) );
@constraint(model, [i = 1:n], x0[i] - x[i] == t[i])
@constraint(model, [i = 1:n], [s[i], t[i]] in MOI.SecondOrderCone(2));
JuMP.optimize!(model)
Coming out soon
This project is licensed under the Apache License 2.0 - see the LICENSE.md file for details.