Skip to content

Commit fbcdcd0

Browse files
authored
Merge pull request #10 from odow/patch-1
Update README to follow JuMP template
2 parents 784cd7c + b4dd9cc commit fbcdcd0

File tree

1 file changed

+57
-40
lines changed

1 file changed

+57
-40
lines changed

README.md

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,76 @@
33
[![CI](https://github.com/samuelsonric/MathOptChordalDecomposition.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/samuelsonric/MathOptChordalDecomposition.jl/actions/workflows/ci.yml)
44
[![codecov](https://codecov.io/gh/samuelsonric/MathOptChordalDecomposition.jl/graph/badge.svg?token=z67ISx3vkD)](https://codecov.io/gh/samuelsonric/MathOptChordalDecomposition.jl)
55

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

9-
## Basic Usage
9+
## Getting help
1010

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.
11+
If you need help, please ask a question on the [JuMP community forum](https://jump.dev/forum).
1212

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

16-
julia> import MosekTools, Mosek
15+
## License
1716

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

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-
```
20+
## Installation
3821

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)