Skip to content

Commit ceb03aa

Browse files
committed
Add Maros-Meszaros dataset
1 parent 4e8137d commit ceb03aa

File tree

9 files changed

+117
-11
lines changed

9 files changed

+117
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Please read and abide by the license of the dataset you plan to use.
1717

1818
### QP
1919

20+
- [x] [Maros-Meszaros](https://www.doc.ic.ac.uk/~im/#DATA)
2021
- [ ] [QPLIB](https://qplib.zib.de/)
21-
- [ ] [Maros-Meszaros](https://www.doc.ic.ac.uk/~im/#DATA)
2222

2323
## Getting started
2424

src/MathOptBenchmarkInstances.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include("lists.jl")
1313
include("mittelmann.jl")
1414
include("init.jl")
1515

16-
export Dataset, MIPLIB2017, Netlib, MittelmannLP
16+
export Dataset, MIPLIB2017, Netlib, MittelmannLP, MarosMeszaros
1717
export read_instance
1818
export list_instances
1919

src/datasets.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Possible values:
88
- [`MIPLIB2017`](@ref)
99
- [`Netlib`](@ref)
1010
- [`MittelmannLP`](@ref)
11+
- [`MarosMeszaros`](@ref)
1112
"""
12-
@enum Dataset MIPLIB2017 Netlib MittelmannLP
13+
@enum Dataset MIPLIB2017 Netlib MittelmannLP MarosMeszaros
1314

1415
"""
1516
MIPLIB2017
@@ -37,3 +38,12 @@ Linear Programs from the Mittelmann benchmark dataset.
3738
Source: <https://plato.asu.edu/ftp/lptestset/>.
3839
"""
3940
MittelmannLP
41+
42+
"""
43+
MarosMeszaros
44+
45+
Quadratic Programs from the Maros-Meszaros benchmark dataset.
46+
47+
Source: <https://www.doc.ic.ac.uk/~im/#DATA>.
48+
"""
49+
MarosMeszaros

src/init.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,22 @@ function __init__()
6363
),
6464
)
6565
)
66+
# Maros-Meszaros
67+
register(
68+
DataDep(
69+
"marosmeszaros",
70+
"""
71+
All instances in the Maros-Meszaros QP benchmark set.
72+
Source: https://www.doc.ic.ac.uk/~im/#DATA.
73+
Compressed download size: 28.1 MB.
74+
Decompressed size: ??""",
75+
[
76+
"http://www.doc.ic.ac.uk/%7Eim/QPDATA1.ZIP",
77+
"http://www.doc.ic.ac.uk/%7Eim/QPDATA2.ZIP",
78+
"http://www.doc.ic.ac.uk/%7Eim/QPDATA3.ZIP",
79+
];
80+
post_fetch_method = [unpack, unpack, unpack]
81+
)
82+
)
6683
return nothing
6784
end

src/instances.jl

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ Return a tuple `(data, path)` where `data isa QPSReader.QPSData` is an object cr
1010
- [`Dataset`](@ref)
1111
"""
1212
function read_instance(dataset::Dataset, name::String)
13+
if !(name in list_instances(dataset))
14+
throw(ArgumentError("Instance $name is not available in dataset $dataset: please use `list_instances` to find valid instance names."))
15+
end
1316
if dataset == MIPLIB2017
1417
return read_miplib2017_instance(name)
1518
elseif dataset == Netlib
1619
return read_netlib_instance(name)
1720
elseif dataset == MittelmannLP
1821
return read_mittelmann_lp_instance(name)
22+
elseif dataset == MarosMeszaros
23+
return read_marosmeszaros_instance(name)
1924
end
2025
end
2126

@@ -49,14 +54,24 @@ function read_mittelmann_lp_instance(name::String)
4954
mps_bz2_path2 = joinpath(folder_path, "$name.bz2")
5055
if ispath(mps_bz2_path1)
5156
return read_mps(mps_bz2_path1; scratch_subfolder = "mittelman-lp")
52-
else
57+
elseif ispath(mps_bz2_path2)
5358
return read_mps(mps_bz2_path2; scratch_subfolder = "mittelman-lp")
5459
end
5560
end
5661

57-
function read_mps(path::String; scratch_subfolder::String, mpsformat::Symbol = :free)
62+
function read_marosmeszaros_instance(name::String)
63+
folder_path = datadep"marosmeszaros"
64+
qps_path = joinpath(folder_path, "$name.QPS")
65+
return read_mps(qps_path)
66+
end
67+
68+
function read_mps(
69+
path::String;
70+
scratch_subfolder::Union{String, Nothing} = nothing,
71+
mpsformat::Symbol = :free
72+
)
5873
name = splitext(splitext(splitpath(path)[end])[1])[1]
59-
if !isdir(joinpath(MPS_SCRATCH, scratch_subfolder))
74+
if !isnothing(scratch_subfolder) && !isdir(joinpath(MPS_SCRATCH, scratch_subfolder))
6075
mkdir(joinpath(MPS_SCRATCH, scratch_subfolder))
6176
end
6277
if endswith(path, ".gz") || endswith(path, ".bz2")
@@ -70,15 +85,18 @@ function read_mps(path::String; scratch_subfolder::String, mpsformat::Symbol = :
7085
compressed = CodecBzip2.read(path)
7186
contents = String(CodecBzip2.transcode(CodecBzip2.Bzip2Decompressor, compressed))
7287
elseif endswith(path, ".bz2")
73-
throw(ArgumentError("File at $path not supported"))
88+
throw(ArgumentError("File at $path not supported (not a compressed MPS file).\nIf you know how to handle these files, please open an issue at <https://github.com/JuliaDecisionFocusedLearning/MathOptBenchmarkInstances.jl/issues>."))
7489
end
7590
open(mps_path, "w") do f
7691
write(f, contents)
7792
end
7893
end
79-
else
80-
@assert endswith(path, ".mps") || endswith(path, ".SIF")
94+
elseif endswith(lowercase(path), ".mps") ||
95+
endswith(lowercase(path), ".qps") ||
96+
endswith(lowercase(path), ".sif")
8197
mps_path = path
98+
else
99+
throw(ArgumentError("Invalid file extension for $(splitpath(path)[end])"))
82100
end
83101

84102
qps_data = with_logger(NullLogger()) do

src/lists.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function list_instances(dataset::Dataset)
1414
return list_netlib_instances()
1515
elseif dataset == MittelmannLP
1616
return list_mittelmann_lp_instances()
17+
elseif dataset == MarosMeszaros
18+
return list_marosmeszaros_instances()
1719
end
1820
end
1921

@@ -39,3 +41,7 @@ function list_mittelmann_lp_instances()
3941
all_names = reduce(vcat, MITTELMANN_LP_INSTANCES)
4042
return map(n -> string(chopsuffix(split(n, "/")[end], ".mps")), all_names)
4143
end
44+
45+
function list_marosmeszaros_instances()
46+
return map(n -> string(chopsuffix(n, ".QPS")), readdir(datadep"marosmeszaros"))
47+
end

test/marosmeszaros.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using MathOptBenchmarkInstances
2+
using Test
3+
4+
maros_list = list_instances(MarosMeszaros)
5+
@test length(maros_list) == 138
6+
7+
for name in maros_list
8+
if name in ["EXDATA", "QFORPLAN", "QGFRDXPN", "VALUES"]
9+
@test_broken read_instance(MarosMeszaros, name) isa Tuple{QPSData, String}
10+
else
11+
@test read_instance(MarosMeszaros, name) isa Tuple{QPSData, String}
12+
end
13+
end

test/mittelmann.jl

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,47 @@ using Test
55
mittelmann_list = list_instances(MittelmannLP)
66
@test length(mittelmann_list) == 116
77

8-
mittelmann_small = [n for n in mittelmann_list if startswith(n, "qap")]
8+
# only instances under 10M, most from the main list and one or two from each subfolder
9+
# files that are .bz2 (as opposed to .mps.bz2) don't work for now
10+
11+
mittelmann_small = [
12+
# "Linf_520c",
13+
# "bdry2",
14+
"brazil3",
15+
"chromaticindex1024-7",
16+
"datt256_lp",
17+
"ex10",
18+
"bal8x12",
19+
"n370a",
20+
# "fome11",
21+
# "fome13",
22+
"graph40-40",
23+
"irish-electricity",
24+
# "cont1",
25+
# "neos",
26+
# "ns1687037",
27+
# "sgpf5y6",
28+
# "watson_1",
29+
"neos-5052403-cygnet",
30+
"neos-5251015",
31+
"16_n14",
32+
"lo10",
33+
# "nug08-3rd",
34+
# "pds-20",
35+
"physiciansched3-3",
36+
"qap15",
37+
# "rail507",
38+
"rmine15",
39+
"s100",
40+
"s250r10",
41+
"savsched1",
42+
"supportcase10",
43+
"woodlands09",
44+
]
945

1046
for name in mittelmann_small
47+
@test name in mittelmann_list
1148
@test read_instance(MittelmannLP, name) isa Tuple{QPSData, String}
1249
end
50+
51+
@test_throws ArgumentError read_instance(MittelmannLP, "bdry2")

test/runtests.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ ENV["DATADEPS_ALWAYS_ACCEPT"] = true
1414
@testset "MIPLIB 2017" begin
1515
include("miplib2017.jl")
1616
end
17-
@testset "Mittelmann" begin
17+
@testset "Mittelmann LP" begin
1818
include("mittelmann.jl")
1919
end
20+
@testset "Maros-Meszaros" begin
21+
include("marosmeszaros.jl")
22+
end
2023
end

0 commit comments

Comments
 (0)