Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/src/submodules/FileFormats/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ julia> model = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT_MPS)
A Mathematical Programming System (MPS) model
```

**The NL file format**

```jldoctest
julia> model = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT_NL)
An AMPL (.nl) model
```

**The SDPA file format**

```jldoctest
Expand Down
8 changes: 7 additions & 1 deletion src/FileFormats/FileFormats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include("CBF/CBF.jl")
include("LP/LP.jl")
include("MOF/MOF.jl")
include("MPS/MPS.jl")
include("NL/NL.jl")
include("SDPA/SDPA.jl")

"""
Expand All @@ -24,6 +25,7 @@ List of accepted export formats.
- `FORMAT_LP`: the LP file format
- `FORMAT_MOF`: the MathOptFormat file format
- `FORMAT_MPS`: the MPS file format
- `FORMAT_NL`: the AMPL .nl file format
- `FORMAT_SDPA`: the SemiDefinite Programming Algorithm format
"""
@enum(
Expand All @@ -33,6 +35,7 @@ List of accepted export formats.
FORMAT_LP,
FORMAT_MOF,
FORMAT_MPS,
FORMAT_NL,
FORMAT_SDPA,
)

Expand Down Expand Up @@ -64,6 +67,8 @@ function Model(;
return MOF.Model(; kwargs...)
elseif format == FORMAT_MPS
return MPS.Model(; kwargs...)
elseif format == FORMAT_NL
return NL.Model(; kwargs...)
elseif format == FORMAT_SDPA
return SDPA.Model(; kwargs...)
else
Expand All @@ -76,6 +81,7 @@ function Model(;
(".lp", LP.Model),
(".mof.json", MOF.Model),
(".mps", MPS.Model),
(".nl", NL.Model),
(".dat-s", SDPA.Model),
(".sdpa", SDPA.Model),
]
Expand All @@ -88,7 +94,7 @@ function Model(;
end

const MATH_OPT_FORMATS =
Union{CBF.Model,LP.Model,MOF.Model,MPS.Model,SDPA.Model}
Union{CBF.Model,LP.Model,MOF.Model,MPS.Model,NL.Model,SDPA.Model}

function MOI.write_to_file(model::MATH_OPT_FORMATS, filename::String)
compressed_open(filename, "w", AutomaticCompression()) do io
Expand Down
Loading