@@ -10,12 +10,17 @@ Return a tuple `(data, path)` where `data isa QPSReader.QPSData` is an object cr
1010- [`Dataset`](@ref)
1111"""
1212function 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
2025end
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
5560end
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). \n If 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
0 commit comments