**COSMO.jl** is a Julia implementation of the *Conic Operator Splitting Method*. The underlying ADMM-algorithm is well-suited for large convex conic problems. COSMO solves the following problem:

with decision variables $x \in \mathbb{R}^n$, $s \in \mathbb{R}^m$ and data matrices $P=P^\top \succeq 0$, $q \in \mathbb{R}^n$, $A \in \mathbb{R}^{m \times n}$, and $b \in \mathbb{R}^m$. The convex set $\mathcal{K}$ is a composition of convex sets and cones.

## Features

**Versatile**: COSMO solves linear programs, quadratic programs, second-order cone programs, semidefinite programs and problems involving exponential and power cones**Quad SDPs**: Positive semidefinite programs with quadratic objective functions are natively supported**Infeasibility detection**: Infeasible problems are detected without a homogeneous self-dual embedding of the problem**JuMP support**: COSMO supports MathOptInterface and JuMP, which allows you to model your problem in JuMP**Chordal decomposition**: COSMO tries to decompose large structured PSD constraints into multiple smaller PSD constraints using chordal decomposition techniques. This often results in a significant speedup compared to solving the original problem.**Smart clique merging**: After an initial decomposition of a structured SDP, COSMO recombines overlapping cliques/blocks to speed up the algorithm.**Warm starting**: COSMO supports warm starting of the decision variables**Open Source**: Our code is available on GitHub and distributed under the Apache 2.0 Licence

## Installation

COSMO can be installed using the Julia package manager for Julia `v1.0`

and higher. Inside the Julia REPL, type `]`

to enter the Pkg REPL mode then run

`pkg> add COSMO`

If you want to install the latest version from master run

`pkg> add COSMO#master`

## Quick Example

Consider the following 2x2 semidefinite program with decision variable `X`

:

with problem data `A`

, `b`

and `C`

:

where `tr`

denotes the trace of a matrix. We can solve this problem either using COSMO's interface:

```
using COSMO, LinearAlgebra
C = [1. 2; 0 2]
A = [1. 0; 5 2]
b = 4;
model = COSMO.Model();
# define the cost function
P = zeros(4, 4)
q = vec(C)
# define the constraints
# A x = b
cs1 = COSMO.Constraint(vec(A)', -b, COSMO.ZeroSet)
# X in PSD cone
cs2 = COSMO.Constraint(Matrix(1.0I, 4, 4), zeros(4), COSMO.PsdCone)
constraints = [cs1; cs2]
# assemble and solve the model
assemble!(model, P, q, constraints)
result = COSMO.optimize!(model);
X_sol = reshape(result.x, 2, 2)
obj_value = result.obj_val
```

or we can describe the problem using `JuMP`

and use COSMO as the backend solver:

```
using COSMO, JuMP, LinearAlgebra
C = [1 2; 0 2]
A = [1 0; 5 2]
b = 4;
m = Model(with_optimizer(COSMO.Optimizer));
@variable(m, X[1:2, 1:2], PSD)
@objective(m, Min, tr(C * X));
@constraint(m, tr(A * X) == b);
JuMP.optimize!(m);
status = JuMP.termination_status(m)
X_sol = JuMP.value.(X)
obj_value = JuMP.objective_value(m)
```

## Presentation Video

A video of the presentation at JuMP-dev is available here:

## Credits

The following people are involved in the development of COSMO:

- Michael Garstka (main development)
- Nikitas Rontsis (algorithm performance)
- Paul Goulart (code architecture, maths and algorithms)
- Mark Cannon (maths and algorithms)

*all contributors are affiliated with the University of Oxford.

If this project is useful for your work please consider

- Citing the relevant papers
- Leaving a star on the GitHub repository

## Licence

COSMO.jl is licensed under the Apache License 2.0. For more details click here.