From fc80acd41caa57897c6595b89c420418cbf78510 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 29 Oct 2019 17:11:45 +0100 Subject: [PATCH 1/8] Implementations of writeLP and writeMPS that use MathOptFormat. --- Project.toml | 1 + src/JuMP.jl | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index bf486700f75..08900786e44 100644 --- a/Project.toml +++ b/Project.toml @@ -8,6 +8,7 @@ Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +MathOptFormat = "f3a3d49f-3211-5bb3-8051-36b1456cf382" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/src/JuMP.jl b/src/JuMP.jl index 010d911975f..6239f8e1e27 100644 --- a/src/JuMP.jl +++ b/src/JuMP.jl @@ -16,6 +16,7 @@ using SparseArrays import MathOptInterface const MOI = MathOptInterface const MOIU = MOI.Utilities +using MathOptFormat import Calculus import DataStructures.OrderedDict @@ -38,8 +39,8 @@ Base.@deprecate(setlowerbound, JuMP.set_lower_bound) Base.@deprecate(setupperbound, JuMP.set_upper_bound) Base.@deprecate(linearterms, JuMP.linear_terms) -writeLP(args...; kargs...) = error("writeLP has been removed from JuMP. Use `MathOptFormat.jl` instead.") -writeMPS(args...; kargs...) = error("writeMPS has been removed from JuMP. Use `MathOptFormat.jl` instead.") +writeLP(args...; kargs...) = error("writeLP has been renamed to write_LP and its arguments have changed.") +writeMPS(args...; kargs...) = error("writeMPS has been renamed to write_MPS and its arguments have changed.") include("utils.jl") From 323d1f0cb0e0d476a7c6eb06a76f9086f360d97d Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 29 Oct 2019 17:12:20 +0100 Subject: [PATCH 2/8] Propose a unified API. --- src/JuMP.jl | 5 ++-- src/export.jl | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 src/export.jl diff --git a/src/JuMP.jl b/src/JuMP.jl index 6239f8e1e27..cd375339cf5 100644 --- a/src/JuMP.jl +++ b/src/JuMP.jl @@ -39,8 +39,8 @@ Base.@deprecate(setlowerbound, JuMP.set_lower_bound) Base.@deprecate(setupperbound, JuMP.set_upper_bound) Base.@deprecate(linearterms, JuMP.linear_terms) -writeLP(args...; kargs...) = error("writeLP has been renamed to write_LP and its arguments have changed.") -writeMPS(args...; kargs...) = error("writeMPS has been renamed to write_MPS and its arguments have changed.") +writeLP(args...; kargs...) = error("writeLP has been merged into write_to_file and its arguments have changed.") +writeMPS(args...; kargs...) = error("writeMPS has been merged into write_to_file and its arguments have changed.") include("utils.jl") @@ -788,6 +788,7 @@ include("nlp.jl") include("print.jl") include("lp_sensitivity.jl") include("callbacks.jl") +include("export.jl") # JuMP exports everything except internal symbols, which are defined as those # whose name starts with an underscore. If you don't want all of these symbols diff --git a/src/export.jl b/src/export.jl new file mode 100644 index 00000000000..1fa8b623f8f --- /dev/null +++ b/src/export.jl @@ -0,0 +1,78 @@ +"List of accepted export formats. `Automatic` corresponds to a detection from the file name." +@enum(FileFormat, CBF, LP, MOF, MPS, Automatic) + +function _filename_to_format(filename::String) + return if endswith(filename, ".mof.json.gz") || endswith(filename, ".mof.json") + MOF + elseif endswith(filename, ".cbf.gz") || endswith(filename, ".cbf") + CBF + elseif endswith(filename, ".mps.gz") || endswith(filename, ".mps") + MPS + elseif endswith(filename, ".lp.gz") || endswith(filename, ".lp") + LP + else + error("File type of $(filename) not recognized by JuMP.") + end +end + +"List of accepted export compression formats. `Automatic` corresponds to a detection from the file name." +@enum(FileCompression, None, GZip, Automatic) + +function _filename_to_compression(filename::String) + return if endswith(filename, ".gz") + GZip + else + None + end +end + +function _open(f::Function, filename::String, mode::String; compression::FileCompression=Automatic) + if compression == Automatic + compression = _filename_to_compression(filename) + end + + open_f = if compression == GZip + GZip.open + else + open + end + return open_f(f, filename, mode) +end + +function write_to_file(model::Model, io::IO, format::FileFormat=MPS; kwargs...) + dest = if format == CBF + MathOptFormat.CBF.Model(; kwargs...) + elseif format == LP + MathOptFormat.LP.Model(; kwargs...) + elseif format == MOF + MathOptFormat.MOF.Model(; kwargs...) + elseif format == MPS + MathOptFormat.MPS.Model(; kwargs...) + else + error("When passing an IO object to write_to_file, the file format cannot be guessed from the file name.") + end + MOI.copy_to(dest, backend(model)) + MOI.write_to_file(dest, io) + return +end + +""" + write_to_file(model::Model, filename::String; format::FileFormat=Automatic, compression::FileCompression=Automatic, kwargs...) + +Write `model` to the file called `filename` using the format `format`. + +Valid formats are given by the enum [`FileFormat`](@ref). Valid compression algorithms +are given by the enum [`FileCompression`](@ref). + +For keyword options, see [MathOptFormat.jl](https://github.com/odow/MathOptFormat.jl). +""" +function write_to_file(model::Model, filename::String; format::FileFormat=Automatic, compression::FileCompression=Automatic, kwargs...) + if format == Automatic + format = _filename_to_format(filename) + end + + _open(filename, "w", compression) do io + write_to_file(model, io, format; kwargs...) + end + return +end From 6068992c823f6c0f14b5cf7ece9a7d34998a842a Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 29 Oct 2019 22:34:21 +0100 Subject: [PATCH 3/8] Respond to @odow's comments. --- Project.toml | 1 + src/JuMP.jl | 2 ++ src/{export.jl => file_formats.jl} | 42 ++++++++++++++++++------------ 3 files changed, 28 insertions(+), 17 deletions(-) rename src/{export.jl => file_formats.jl} (61%) diff --git a/Project.toml b/Project.toml index 08900786e44..8e08b7953b9 100644 --- a/Project.toml +++ b/Project.toml @@ -5,6 +5,7 @@ version = "0.20.0" [deps] Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" +CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/JuMP.jl b/src/JuMP.jl index cd375339cf5..3bc3684e698 100644 --- a/src/JuMP.jl +++ b/src/JuMP.jl @@ -17,6 +17,7 @@ import MathOptInterface const MOI = MathOptInterface const MOIU = MOI.Utilities using MathOptFormat +import CodecZlib import Calculus import DataStructures.OrderedDict @@ -789,6 +790,7 @@ include("print.jl") include("lp_sensitivity.jl") include("callbacks.jl") include("export.jl") +include("file_formats.jl") # JuMP exports everything except internal symbols, which are defined as those # whose name starts with an underscore. If you don't want all of these symbols diff --git a/src/export.jl b/src/file_formats.jl similarity index 61% rename from src/export.jl rename to src/file_formats.jl index 1fa8b623f8f..f269992a91b 100644 --- a/src/export.jl +++ b/src/file_formats.jl @@ -1,5 +1,8 @@ -"List of accepted export formats. `Automatic` corresponds to a detection from the file name." -@enum(FileFormat, CBF, LP, MOF, MPS, Automatic) +""" +List of accepted export formats. `AUTOMATIC_FILE_FORMAT` corresponds to +a detection from the file name. +""" +@enum(FileFormat, CBF, LP, MOF, MPS, AUTOMATIC_FILE_FORMAT) function _filename_to_format(filename::String) return if endswith(filename, ".mof.json.gz") || endswith(filename, ".mof.json") @@ -15,31 +18,34 @@ function _filename_to_format(filename::String) end end -"List of accepted export compression formats. `Automatic` corresponds to a detection from the file name." -@enum(FileCompression, None, GZip, Automatic) +""" +List of accepted export compression formats. `AUTOMATIC_FILE_COMPRESSION` +corresponds to a detection from the file name. +""" +@enum(FileCompression, NO_FILE_COMPRESSION, GZIP, AUTOMATIC_FILE_COMPRESSION) function _filename_to_compression(filename::String) return if endswith(filename, ".gz") - GZip + GZIP else - None + NO_FILE_COMPRESSION end end -function _open(f::Function, filename::String, mode::String; compression::FileCompression=Automatic) - if compression == Automatic +function _open(f::Function, filename::String, mode::String; compression::FileCompression=AUTOMATIC_FILE_COMPRESSION) + if compression == AUTOMATIC_FILE_COMPRESSION compression = _filename_to_compression(filename) end - open_f = if compression == GZip - GZip.open + if compression == GZIP + stream = (mode == "r") ? CodecZlib.GzipDecompressorStream : CodecZlib.GzipCompressorStream + return open(f, stream, filename, mode) else - open + return open(f, filename, mode) end - return open_f(f, filename, mode) end -function write_to_file(model::Model, io::IO, format::FileFormat=MPS; kwargs...) +function write_to_file(model::Model, io::IO, format::FileFormat; kwargs...) dest = if format == CBF MathOptFormat.CBF.Model(; kwargs...) elseif format == LP @@ -57,7 +63,7 @@ function write_to_file(model::Model, io::IO, format::FileFormat=MPS; kwargs...) end """ - write_to_file(model::Model, filename::String; format::FileFormat=Automatic, compression::FileCompression=Automatic, kwargs...) + write_to_file(model::Model, filename::String; format::FileFormat=AUTOMATIC_FILE_FORMAT, compression::FileCompression=AUTOMATIC_FILE_COMPRESSION, kwargs...) Write `model` to the file called `filename` using the format `format`. @@ -66,12 +72,14 @@ are given by the enum [`FileCompression`](@ref). For keyword options, see [MathOptFormat.jl](https://github.com/odow/MathOptFormat.jl). """ -function write_to_file(model::Model, filename::String; format::FileFormat=Automatic, compression::FileCompression=Automatic, kwargs...) - if format == Automatic +function write_to_file(model::Model, filename::String; format::FileFormat=AUTOMATIC_FILE_FORMAT, compression::FileCompression=AUTOMATIC_FILE_COMPRESSION, kwargs...) + if format == AUTOMATIC_FILE_FORMAT format = _filename_to_format(filename) end - _open(filename, "w", compression) do io + # println((filename, "w", compression)) + + _open(filename, "w", compression=compression) do io write_to_file(model, io, format; kwargs...) end return From 0c53815c026ee3aadca0d0ce497de30fca87bd5b Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 29 Oct 2019 22:56:49 +0100 Subject: [PATCH 4/8] Correct Project.toml. --- Project.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 8e08b7953b9..7c5967d887b 100644 --- a/Project.toml +++ b/Project.toml @@ -9,10 +9,11 @@ CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -MathOptFormat = "f3a3d49f-3211-5bb3-8051-36b1456cf382" +MathOptFormat = "f4570300-c277-12e8-125c-4912f86ce65d" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" @@ -20,6 +21,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Calculus = "0.5" DataStructures = "0.17" ForwardDiff = "~0.5.0, ~0.6, ~0.7, ~0.8, ~0.9, ~0.10" +MathOptFormat = "≥ 0.2" MathOptInterface = "~0.9.1" NaNMath = "0.3" OffsetArrays = "≥ 0.2.13" From b82f70cfeba2171f53746f198e581a7bb798b9bf Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 30 Oct 2019 01:24:11 +0100 Subject: [PATCH 5/8] Implement more compression formats. --- Project.toml | 3 ++- src/JuMP.jl | 2 ++ src/file_formats.jl | 20 ++++++++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index 7c5967d887b..5b7a6c3dfb5 100644 --- a/Project.toml +++ b/Project.toml @@ -5,6 +5,8 @@ version = "0.20.0" [deps] Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" +CodecBzip2 = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd" +CodecXz = "ba30903b-d9e8-5048-a5ec-d1f5b0d4b47b" CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" @@ -13,7 +15,6 @@ MathOptFormat = "f4570300-c277-12e8-125c-4912f86ce65d" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" diff --git a/src/JuMP.jl b/src/JuMP.jl index 3bc3684e698..37791357741 100644 --- a/src/JuMP.jl +++ b/src/JuMP.jl @@ -17,6 +17,8 @@ import MathOptInterface const MOI = MathOptInterface const MOIU = MOI.Utilities using MathOptFormat +import CodecBzip2 +import CodecXz import CodecZlib import Calculus diff --git a/src/file_formats.jl b/src/file_formats.jl index f269992a91b..afe54e09804 100644 --- a/src/file_formats.jl +++ b/src/file_formats.jl @@ -22,11 +22,15 @@ end List of accepted export compression formats. `AUTOMATIC_FILE_COMPRESSION` corresponds to a detection from the file name. """ -@enum(FileCompression, NO_FILE_COMPRESSION, GZIP, AUTOMATIC_FILE_COMPRESSION) +@enum(FileCompression, NO_FILE_COMPRESSION, BZIP2, GZIP, XZ, AUTOMATIC_FILE_COMPRESSION) function _filename_to_compression(filename::String) - return if endswith(filename, ".gz") + return if endswith(filename, ".bz2") + BZIP2 + elseif endswith(filename, ".gz") GZIP + elseif endswith(filename, ".xz") + XZ else NO_FILE_COMPRESSION end @@ -37,8 +41,14 @@ function _open(f::Function, filename::String, mode::String; compression::FileCom compression = _filename_to_compression(filename) end - if compression == GZIP - stream = (mode == "r") ? CodecZlib.GzipDecompressorStream : CodecZlib.GzipCompressorStream + if compression == BZIP2 || compression == GZIP || compression == XZ + stream = if compression == BZIP2 + (mode == "r") ? CodecBzip2.Bzip2DecompressorStream : CodecBzip2.Bzip2CompressorStream + elseif compression == GZIP + (mode == "r") ? CodecZlib.GzipDecompressorStream : CodecZlib.GzipCompressorStream + else # compression == XZ + (mode == "r") ? CodecXz.XzDecompressorStream : CodecXz.XzCompressorStream + end return open(f, stream, filename, mode) else return open(f, filename, mode) @@ -77,8 +87,6 @@ function write_to_file(model::Model, filename::String; format::FileFormat=AUTOMA format = _filename_to_format(filename) end - # println((filename, "w", compression)) - _open(filename, "w", compression=compression) do io write_to_file(model, io, format; kwargs...) end From 6991b86ee83b41e7703e7eb04c7ebffdf89c8f76 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 30 Oct 2019 02:31:02 +0100 Subject: [PATCH 6/8] Move most of the code to MathOptFormat. --- Project.toml | 3 -- src/JuMP.jl | 3 -- src/file_formats.jl | 79 +++++---------------------------------------- 3 files changed, 8 insertions(+), 77 deletions(-) diff --git a/Project.toml b/Project.toml index 5b7a6c3dfb5..8fed4af432e 100644 --- a/Project.toml +++ b/Project.toml @@ -5,9 +5,6 @@ version = "0.20.0" [deps] Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" -CodecBzip2 = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd" -CodecXz = "ba30903b-d9e8-5048-a5ec-d1f5b0d4b47b" -CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/JuMP.jl b/src/JuMP.jl index 37791357741..52852a9501c 100644 --- a/src/JuMP.jl +++ b/src/JuMP.jl @@ -17,9 +17,6 @@ import MathOptInterface const MOI = MathOptInterface const MOIU = MOI.Utilities using MathOptFormat -import CodecBzip2 -import CodecXz -import CodecZlib import Calculus import DataStructures.OrderedDict diff --git a/src/file_formats.jl b/src/file_formats.jl index afe54e09804..90197fbeb99 100644 --- a/src/file_formats.jl +++ b/src/file_formats.jl @@ -1,72 +1,6 @@ -""" -List of accepted export formats. `AUTOMATIC_FILE_FORMAT` corresponds to -a detection from the file name. -""" -@enum(FileFormat, CBF, LP, MOF, MPS, AUTOMATIC_FILE_FORMAT) - -function _filename_to_format(filename::String) - return if endswith(filename, ".mof.json.gz") || endswith(filename, ".mof.json") - MOF - elseif endswith(filename, ".cbf.gz") || endswith(filename, ".cbf") - CBF - elseif endswith(filename, ".mps.gz") || endswith(filename, ".mps") - MPS - elseif endswith(filename, ".lp.gz") || endswith(filename, ".lp") - LP - else - error("File type of $(filename) not recognized by JuMP.") - end -end - -""" -List of accepted export compression formats. `AUTOMATIC_FILE_COMPRESSION` -corresponds to a detection from the file name. -""" -@enum(FileCompression, NO_FILE_COMPRESSION, BZIP2, GZIP, XZ, AUTOMATIC_FILE_COMPRESSION) - -function _filename_to_compression(filename::String) - return if endswith(filename, ".bz2") - BZIP2 - elseif endswith(filename, ".gz") - GZIP - elseif endswith(filename, ".xz") - XZ - else - NO_FILE_COMPRESSION - end -end - -function _open(f::Function, filename::String, mode::String; compression::FileCompression=AUTOMATIC_FILE_COMPRESSION) - if compression == AUTOMATIC_FILE_COMPRESSION - compression = _filename_to_compression(filename) - end - - if compression == BZIP2 || compression == GZIP || compression == XZ - stream = if compression == BZIP2 - (mode == "r") ? CodecBzip2.Bzip2DecompressorStream : CodecBzip2.Bzip2CompressorStream - elseif compression == GZIP - (mode == "r") ? CodecZlib.GzipDecompressorStream : CodecZlib.GzipCompressorStream - else # compression == XZ - (mode == "r") ? CodecXz.XzDecompressorStream : CodecXz.XzCompressorStream - end - return open(f, stream, filename, mode) - else - return open(f, filename, mode) - end -end - -function write_to_file(model::Model, io::IO, format::FileFormat; kwargs...) - dest = if format == CBF - MathOptFormat.CBF.Model(; kwargs...) - elseif format == LP - MathOptFormat.LP.Model(; kwargs...) - elseif format == MOF - MathOptFormat.MOF.Model(; kwargs...) - elseif format == MPS - MathOptFormat.MPS.Model(; kwargs...) - else - error("When passing an IO object to write_to_file, the file format cannot be guessed from the file name.") - end +function write_to_file(model::Model, io::IO, format::MathOptFormat.FileFormat; kwargs...) + @assert format != AUTOMATIC_FILE_FORMAT + dest = MathOptFormat._file_formats[format]() MOI.copy_to(dest, backend(model)) MOI.write_to_file(dest, io) return @@ -82,12 +16,15 @@ are given by the enum [`FileCompression`](@ref). For keyword options, see [MathOptFormat.jl](https://github.com/odow/MathOptFormat.jl). """ -function write_to_file(model::Model, filename::String; format::FileFormat=AUTOMATIC_FILE_FORMAT, compression::FileCompression=AUTOMATIC_FILE_COMPRESSION, kwargs...) +function write_to_file(model::Model, filename::String; + format::MathOptFormat.FileFormat=MathOptFormat.AUTOMATIC_FILE_FORMAT, + compression::MathOptFormat.FileCompression=AUTOMATIC_FILE_COMPRESSION, + kwargs...) if format == AUTOMATIC_FILE_FORMAT format = _filename_to_format(filename) end - _open(filename, "w", compression=compression) do io + MathOptFormat.gzip_open(filename, "w", compression=compression) do io write_to_file(model, io, format; kwargs...) end return From 3e27c6ea9ecd09d928afd40ae1640d773767f134 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 26 Nov 2019 18:38:43 +0100 Subject: [PATCH 7/8] Update to MOF#master. --- src/file_formats.jl | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/file_formats.jl b/src/file_formats.jl index 90197fbeb99..6d070920b9e 100644 --- a/src/file_formats.jl +++ b/src/file_formats.jl @@ -1,31 +1,28 @@ function write_to_file(model::Model, io::IO, format::MathOptFormat.FileFormat; kwargs...) @assert format != AUTOMATIC_FILE_FORMAT - dest = MathOptFormat._file_formats[format]() + dest = MathOptFormat._file_formats[format][2]() MOI.copy_to(dest, backend(model)) MOI.write_to_file(dest, io) return end """ - write_to_file(model::Model, filename::String; format::FileFormat=AUTOMATIC_FILE_FORMAT, compression::FileCompression=AUTOMATIC_FILE_COMPRESSION, kwargs...) + write_to_file(model::Model, filename::String; format::FileFormat=AUTOMATIC_FILE_FORMAT, compression::MathOptFormat.AbstractCompressionScheme=MathOptFormat.AutomaticCompression(), kwargs...) Write `model` to the file called `filename` using the format `format`. Valid formats are given by the enum [`FileFormat`](@ref). Valid compression algorithms -are given by the enum [`FileCompression`](@ref). +are given by a concrete subtype of [`AbstractCompressionScheme`](@ref). For keyword options, see [MathOptFormat.jl](https://github.com/odow/MathOptFormat.jl). """ function write_to_file(model::Model, filename::String; format::MathOptFormat.FileFormat=MathOptFormat.AUTOMATIC_FILE_FORMAT, - compression::MathOptFormat.FileCompression=AUTOMATIC_FILE_COMPRESSION, + compression::MathOptFormat.AbstractCompressionScheme=MathOptFormat.AutomaticCompression(), kwargs...) if format == AUTOMATIC_FILE_FORMAT - format = _filename_to_format(filename) - end - - MathOptFormat.gzip_open(filename, "w", compression=compression) do io - write_to_file(model, io, format; kwargs...) + format = MathOptFormat._filename_to_format(filename) end + MOI.write_to_file(model, filename, compression=compression) return end From e1679eb173702cb869afc9fae18e55c2736ccd4c Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 26 Nov 2019 23:27:54 +0100 Subject: [PATCH 8/8] Rebasing mistake. --- src/JuMP.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/JuMP.jl b/src/JuMP.jl index 52852a9501c..f688a37e7d4 100644 --- a/src/JuMP.jl +++ b/src/JuMP.jl @@ -788,7 +788,6 @@ include("nlp.jl") include("print.jl") include("lp_sensitivity.jl") include("callbacks.jl") -include("export.jl") include("file_formats.jl") # JuMP exports everything except internal symbols, which are defined as those