Skip to content

Commit 0fba181

Browse files
authored
Update README to follow JuMP template
1 parent 784cd7c commit 0fba181

File tree

1 file changed

+58
-42
lines changed

1 file changed

+58
-42
lines changed

README.md

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,77 @@
11
# MathOptChordalDecomposition.jl
22

3-
[![CI](https://github.com/samuelsonric/MathOptChordalDecomposition.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/samuelsonric/MathOptChordalDecomposition.jl/actions/workflows/ci.yml)
4-
[![codecov](https://codecov.io/gh/samuelsonric/MathOptChordalDecomposition.jl/graph/badge.svg?token=z67ISx3vkD)](https://codecov.io/gh/samuelsonric/MathOptChordalDecomposition.jl)
3+
[![Build Status](https://github.com/samuelsonric/MathOptChordalDecomposition.jl/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/samuelsonric/MathOptChordalDecomposition.jl/actions?query=workflow%3ACI)
54

6-
MathOptChordalDecomposition.jl is a [MathOptInterface.jl](https://github.com/jump-dev/MathOptInterface.jl) layer that implements chordal decomposition of
7-
sparse semidefinite constraints.
5+
MathOptChordalDecomposition.jl is a [MathOptInterface.jl](https://github.com/jump-dev/MathOptInterface.jl)
6+
layer that implements chordal decomposition of sparse semidefinite constraints.
87

9-
## Basic Usage
8+
## Getting help
109

11-
The `sdplib` directory contains four semidefinite programming problems from the [SDPLIB library](https://github.com/vsdp/SDPLIB). The function `construct_model`, defined below, reads one of the problems and constructs a [JuMP.jl](https://github.com/jump-dev/JuMP.jl) model.
10+
If you need help, please ask a question on the [JuMP community forum](https://jump.dev/forum).
1211

13-
```julia-repl
14-
julia> using FileIO, LinearAlgebra, JuMP
12+
If you have a reproducible example of a bug, please [open a GitHub issue](https://github.com/samuelsonric/MathOptChordalDecomposition.jl/issues/new).
1513

16-
julia> import MosekTools, Mosek
14+
## License
1715

18-
julia> import MathOptChordalDecomposition as MOCD
16+
`MathOptChordalDecomposition.jl` is licensed under the
17+
[MIT License](https://github.com/samuelsonric/MathOptChordalDecomposition.jl/blob/master/LICENSE).
1918

20-
julia> function construct_model(f, name::String)
21-
# load data
22-
data = load("./sdplib/$name.jld2");
23-
F = data["F"]
24-
c = data["c"]
25-
m = data["m"]
26-
n = data["n"]
27-
28-
# construct model
29-
model = JuMP.Model(f)
30-
set_silent(model)
31-
@variable(model, x[1:m])
32-
@objective(model, Min, c' * x)
33-
@constraint(model, con, Symmetric(-Matrix(F[1]) + sum(Matrix(F[k + 1]) .* x[k] for k in 1:m)) in JuMP.PSDCone())
34-
return model, con
35-
end
36-
construct_model (generic function with 1 method)
37-
```
19+
## Installation
3820

39-
Solve the problem using the [Mosek.jl](https://github.com/MOSEK/Mosek.jl) optimizer.
21+
Install MathOptChordalDecomposition as follows:
22+
```julia
23+
import Pkg
24+
Pkg.add("MathOptChordalDecomposition")
25+
```
4026

41-
```julia-repl
42-
julia> model, con = construct_model(Mosek.Optimizer, "mcp124-1");
27+
## Use with JuMP
4328

44-
julia> @time JuMP.optimize!(model)
45-
6.005076 seconds (2.53 k allocations: 515.859 KiB)
29+
To use MathOptChordalDecomposition with JuMP, use `MathOptChordalDecomposition.Optimizer`:
4630

47-
julia> objective_value(model)
48-
141.9904770422396
31+
```julia
32+
using JuMP, MathOptChordalDecomposition, SCS
33+
model = Model(() -> MathOptChordalDecomposition.Optimizer(SCS.Optimizer))
4934
```
35+
Change `SCS` for any other conic solver that supports semidefinite constraints.
36+
37+
## Basic Usage
5038

51-
Solve the problem using [Mosek.jl](https://github.com/MOSEK/Mosek.jl) and MathOptChordalDecomposition.jl.
39+
The `sdplib` directory contains four semidefinite programming problems from the
40+
[SDPLIB library](https://github.com/vsdp/SDPLIB).
5241

53-
```julia-repl
54-
julia> model, con = construct_model(() -> MOCD.Optimizer(Mosek.Optimizer), "mcp124-1");
42+
The function `construct_model`, defined below, reads one of the problems and
43+
constructs a [JuMP.jl](https://github.com/jump-dev/JuMP.jl) model.
44+
45+
For this example, it is significantly faster to solve the problem with
46+
MathOptChordalDecomposition than to use SCS by itself:
47+
48+
```julia
49+
julia> using FileIO, JLD2, JuMP, LinearAlgebra, SCS
50+
51+
julia> import MathOptChordalDecomposition as MOCD
52+
53+
julia> function main(optimizer, name::String)
54+
data = FileIO.load("./sdplib/$name.jld2");
55+
F, c, m, n = data["F"], data["c"], data["m"], data["n"]
56+
model = Model(optimizer)
57+
set_silent(model)
58+
@variable(model, x[1:m])
59+
@objective(model, Min, c' * x)
60+
@constraint(
61+
model,
62+
con,
63+
LinearAlgebra.Symmetric(-F[1] + x' * F[2:end]) in PSDCone(),
64+
)
65+
optimize!(model)
66+
return objective_value(model)
67+
end
68+
main (generic function with 1 method)
5569

56-
julia> @time JuMP.optimize!(model)
57-
0.041175 seconds (230.72 k allocations: 11.800 MiB)
70+
julia> @time main(SCS.Optimizer, "mcp124-1")
71+
9.447474 seconds (154.70 k allocations: 12.313 MiB)
72+
141.96561765120785
5873

59-
julia> objective_value(model)
60-
141.99047611570586
74+
julia> @time main(() -> MOCD.Optimizer(SCS.Optimizer), "mcp124-1")
75+
0.245992 seconds (170.72 k allocations: 15.103 MiB, 1.85% compilation time)
76+
141.9887372030578
6177
```

0 commit comments

Comments
 (0)