Skip to content

Commit 85ecaf3

Browse files
committed
Add Mittelmann benchmark
1 parent 9cdbcf8 commit 85ecaf3

File tree

11 files changed

+268
-70
lines changed

11 files changed

+268
-70
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ authors = ["Guillaume Dalle"]
77
projects = ["test"]
88

99
[deps]
10+
CodecBzip2 = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd"
1011
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
1112
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
1213
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1314
QPSReader = "10f199a5-22af-520b-b891-7ce84a7b1bd0"
1415

1516
[compat]
17+
CodecBzip2 = "0.8.5"
1618
DataDeps = "0.7.13"
1719
GZip = "0.6.2"
1820
Logging = "1.10.0"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Supported datasets:
88

99
- [x] [Netlib](https://www.netlib.org/lp/data/index.html)
1010
- [x] [MIPLIB 2017](https://miplib.zib.de/index.html)
11-
- [ ] [Mittelman benchmark](https://plato.asu.edu/ftp/lptestset/)
11+
- [ ] [Mittelmann benchmark](https://plato.asu.edu/ftp/lptestset/)
1212

1313
The source files are downloaded automatically thanks to [DataDeps.jl](https://github.com/oxinabox/DataDeps.jl).
1414
The returned problem format is `QPSData` from [QPSReader.jl](https://github.com/JuliaSmoothOptimizers/QPSReader.jl).

src/MathProgBenchmarks.jl

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,19 @@
11
module MathProgBenchmarks
22

3+
import CodecBzip2
34
using DataDeps
4-
using GZip
5+
import GZip
56
using Logging
67
using QPSReader
78

89
include("datasets.jl")
910
include("instances.jl")
1011
include("lists.jl")
12+
include("mittelmann.jl")
13+
include("init.jl")
1114

12-
export Dataset, MIPLIB2017, MIPLIB2017Benchmark, Netlib
15+
export Dataset, MIPLIB2017, Netlib, MittelmannLP
1316
export read_instance
1417
export list_instances
1518

16-
function __init__()
17-
register(
18-
DataDep(
19-
"miplib2017-collection",
20-
"""
21-
All instances in the MIPLIB 2017 collection set (size: 3.5 GB).
22-
Source: https://miplib.zib.de/index.html.""",
23-
"https://miplib.zib.de/downloads/collection.zip",
24-
post_fetch_method = unpack,
25-
),
26-
)
27-
register(
28-
DataDep(
29-
"miplib2017-benchmark",
30-
"""
31-
All instances in the MIPLIB 2017 benchmark set (size: 317 MB).
32-
Source: https://miplib.zib.de/index.html.""",
33-
"https://miplib.zib.de/downloads/benchmark.zip",
34-
post_fetch_method = unpack,
35-
"c756eefd544d83b31809306b45d3549a1a5b9378e6aa78b68738b1a3b6a418fa"
36-
),
37-
)
38-
register(
39-
DataDep(
40-
"miplib2017-collection-list",
41-
"""
42-
List of instances in the MIPLIB 2017 collection.
43-
Source: https://miplib.zib.de/index.html.""",
44-
"https://miplib.zib.de/downloads/collection-v1.test",
45-
"c416f857083e2b7ec6edad87acc80437e2ea4be65debdbe7c4f3072881981c3f"
46-
),
47-
)
48-
register(
49-
DataDep(
50-
"miplib2017-benchmark-list",
51-
"""
52-
List of instances in the MIPLIB 2017 benchmark.
53-
Source: https://miplib.zib.de/index.html.""",
54-
"https://miplib.zib.de/downloads/benchmark-v2.test",
55-
"0ee9758dba64bb1689cc121c794ee547992a046bcabe1cce9ea79158375dabd5"
56-
),
57-
)
58-
return nothing
59-
end
60-
6119
end # module MathProgBenchmarks

src/datasets.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,35 @@ Enum type for mathematical programming datasets.
55
66
Possible values:
77
8-
- [`MIPLIB2017`](@ref), [`MIPLIB2017Benchmark`](@ref)
8+
- [`MIPLIB2017`](@ref)
99
- [`Netlib`](@ref)
10+
- [`MittelmannLP`](@ref)
1011
"""
11-
@enum Dataset MIPLIB2017 MIPLIB2017Benchmark Netlib
12+
@enum Dataset MIPLIB2017 Netlib MittelmannLP
1213

1314
"""
1415
MIPLIB2017
1516
1617
Mixed Integer Linear Programs from the MIPLIB2017 collection dataset.
1718
18-
Source: <https://miplib.zib.de/>.
19+
Source: <https://miplib.zib.de/tag_collection.html>.
1920
"""
2021
MIPLIB2017
2122

2223
"""
23-
MIPLIB2017Benchmark
24+
Netlib
2425
25-
Mixed Integer Linear Programs from the MIPLIB2017 benchmark dataset (much smaller than the collection dataset).
26+
Linear Programs from the Netlib dataset.
2627
27-
Source: <https://miplib.zib.de/>.
28+
Source: <https://www.netlib.org/lp/data/index.html>.
2829
"""
29-
MIPLIB2017Benchmark
30+
Netlib
3031

3132
"""
32-
Netlib
33+
MittelmannLP
3334
34-
Linear Programs from the Netlib dataset.
35+
Linear Programs from the Mittelmann benchmark dataset.
3536
36-
Source: <https://www.netlib.org/lp/data/index.html>.
37+
Source: <https://plato.asu.edu/ftp/lptestset/>.
3738
"""
38-
Netlib
39+
MittelmannLP

src/init.jl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
function __init__()
2+
# MIPLIB 2017
3+
register(
4+
DataDep(
5+
"miplib2017-collection",
6+
"""
7+
All instances in the MIPLIB 2017 collection set (size: 3.5 GB).
8+
Source: https://miplib.zib.de/index.html.""",
9+
"https://miplib.zib.de/downloads/collection.zip",
10+
post_fetch_method = unpack,
11+
),
12+
)
13+
register(
14+
DataDep(
15+
"miplib2017-benchmark",
16+
"""
17+
All instances in the MIPLIB 2017 benchmark set (size: 317 MB).
18+
Source: https://miplib.zib.de/index.html.""",
19+
"https://miplib.zib.de/downloads/benchmark.zip",
20+
post_fetch_method = unpack,
21+
"c756eefd544d83b31809306b45d3549a1a5b9378e6aa78b68738b1a3b6a418fa"
22+
),
23+
)
24+
register(
25+
DataDep(
26+
"miplib2017-collection-list",
27+
"""
28+
List of instances in the MIPLIB 2017 collection.
29+
Source: https://miplib.zib.de/index.html.""",
30+
"https://miplib.zib.de/downloads/collection-v1.test",
31+
"c416f857083e2b7ec6edad87acc80437e2ea4be65debdbe7c4f3072881981c3f"
32+
),
33+
)
34+
register(
35+
DataDep(
36+
"miplib2017-benchmark-list",
37+
"""
38+
List of instances in the MIPLIB 2017 benchmark.
39+
Source: https://miplib.zib.de/index.html.""",
40+
"https://miplib.zib.de/downloads/benchmark-v2.test",
41+
"0ee9758dba64bb1689cc121c794ee547992a046bcabe1cce9ea79158375dabd5"
42+
),
43+
)
44+
# Mittelmann
45+
for (folder, names) in pairs(MITTELMANN_LP_INSTANCES)
46+
for name in names
47+
@info "$folder / $name"
48+
datadep_name = "mittelmann-lp-$name"
49+
# TODO: some paths are just .bz2, following no visible pattern
50+
if isnothing(folder)
51+
datadep_msg = """
52+
Instance $name from the Mittelmann LP benchmark set.
53+
Source: https://plato.asu.edu/ftp/lptestset/."""
54+
datadep_url = "https://plato.asu.edu/ftp/lptestset/$name.mps.bz2"
55+
else
56+
datadep_msg = """
57+
Instance $name from the Mittelmann LP benchmark set (folder $folder).
58+
Source: https://plato.asu.edu/ftp/lptestset/."""
59+
datadep_url = "https://plato.asu.edu/ftp/lptestset/$folder/$name.mps.bz2"
60+
end
61+
register(
62+
DataDep(datadep_name, datadep_msg, datadep_url)
63+
)
64+
end
65+
end
66+
return nothing
67+
end

src/instances.jl

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ Read the instance identified by `name` from a given `dataset` and return a `QPSR
88
- [`Dataset`](@ref)
99
"""
1010
function read_instance(dataset::Dataset, name::String)
11-
if dataset == MIPLIB2017 || dataset == MIPLIB2017Benchmark
12-
return read_miplib2017_instance(dataset, name)
11+
if dataset == MIPLIB2017
12+
return read_miplib2017_instance(name)
1313
elseif dataset == Netlib
1414
return read_netlib_instance(name)
15+
elseif dataset == MittelmannLP
16+
return read_mittelmann_lp_instance(name)
1517
end
1618
end
1719

18-
function read_miplib2017_instance(dataset::Dataset, name::String)
19-
folder = if dataset == MIPLIB2017Benchmark
20+
function read_miplib2017_instance(name::String)
21+
folder = if name in list_miplib2017_instances(; benchmark_only = true)
2022
datadep"miplib2017-benchmark"
2123
else
2224
datadep"miplib2017-collection"
@@ -39,6 +41,17 @@ function read_netlib_instance(name::String)
3941
return read_mps(sif_path; mpsformat)
4042
end
4143

44+
function read_mittelmann_lp_instance(name::String)
45+
folder_path = @datadep_str("mittelmann-lp-$name")
46+
path1 = joinpath(folder_path, "$name.mps.bz2")
47+
path2 = joinpath(folder_path, "$name.bz2")
48+
if ispath(path1)
49+
return read_mps(path1)
50+
else
51+
return read_mps(path2)
52+
end
53+
end
54+
4255
function read_mps(path::String; mpsformat::Symbol = :free)
4356
if endswith(path, ".mps.gz")
4457
contents = GZip.open(path, "r") do f
@@ -48,6 +61,13 @@ function read_mps(path::String; mpsformat::Symbol = :free)
4861
open(mps_path, "w") do f
4962
write(f, contents)
5063
end
64+
elseif endswith(path, ".bz2") || endswith(path, ".mps.bz2")
65+
compressed = CodecBzip2.read(path)
66+
contents = String(CodecBzip2.transcode(CodecBzip2.Bzip2Decompressor, compressed))
67+
mps_path = string(tempname(), ".mps")
68+
open(mps_path, "w") do f
69+
write(f, contents)
70+
end
5171
else
5272
@assert endswith(path, ".mps") || endswith(path, ".SIF")
5373
mps_path = path

src/lists.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ Return the names of all available instances in a given `dataset`.
88
- [`Dataset`](@ref)
99
"""
1010
function list_instances(dataset::Dataset)
11-
if dataset == MIPLIB2017 || dataset == MIPLIB2017Benchmark
12-
return list_miplib2017_instances(dataset)
11+
if dataset == MIPLIB2017
12+
return list_miplib2017_instances()
1313
elseif dataset == Netlib
1414
return list_netlib_instances()
15+
elseif dataset == MittelmannLP
16+
return list_mittelmann_lp_instances()
1517
end
1618
end
1719

18-
function list_miplib2017_instances(dataset::Dataset)
19-
list_path = if dataset == MIPLIB2017Benchmark
20+
function list_miplib2017_instances(; benchmark_only::Bool = false)
21+
list_path = if benchmark_only
2022
joinpath(datadep"miplib2017-benchmark-list", "benchmark-v2.test")
2123
else
2224
joinpath(datadep"miplib2017-collection-list", "collection-v1.test")
@@ -32,3 +34,7 @@ function list_netlib_instances()
3234
valid_instances = filter(n -> endswith(n, ".SIF"), readdir(netlib_path))
3335
return map(n -> lowercase(chopsuffix(n, ".SIF")), valid_instances)
3436
end
37+
38+
function list_mittelmann_lp_instances()
39+
return reduce(vcat, values(MITTELMANN_LP_INSTANCES))
40+
end

0 commit comments

Comments
 (0)