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
12 changes: 3 additions & 9 deletions docs/src/submodules/FileFormats/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ MathOptInterface.Utilities.IndexMap with 1 entry:
julia> MOI.write_to_file(dest, "file.mof.json")

julia> print(read("file.mof.json", String))
{"name":"MathOptFormat Model","version":{"major":1,"minor":7},"variables":[{"name":"x1"}],"objective":{"sense":"feasibility"},"constraints":[]}
{"name":"MathOptFormat Model","version":{"major":1,"minor":9},"variables":[{"name":"x1"}],"objective":{"sense":"feasibility"},"constraints":[]}
```

## Read from file
Expand Down Expand Up @@ -244,10 +244,7 @@ Then, check if a model file is valid using `isvalid`:
```jldoctest schema_mof
julia> good_model = JSON.parse("""
{
"version": {
"major": 1,
"minor": 5
},
"version": {"major": 1, "minor": 9},
"variables": [{"name": "x"}],
"objective": {"sense": "feasibility"},
"constraints": []
Expand All @@ -263,10 +260,7 @@ validation fails:
```jldoctest schema_mof
julia> bad_model = JSON.parse("""
{
"version": {
"major": 1,
"minor": 5
},
"version": {"major": 1, "minor": 9},
"variables": [{"NaMe": "x"}],
"objective": {"sense": "feasibility"},
"constraints": []
Expand Down
2 changes: 2 additions & 0 deletions src/FileFormats/MOF/MOF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ MathOptInterface.
const SCHEMA_PATH = joinpath(@__DIR__, "mof.schema.json")

const _SUPPORTED_VERSIONS = (
v"1.9",
v"1.8",
v"1.7",
v"1.6",
v"1.5",
Expand Down
2 changes: 1 addition & 1 deletion test/FileFormats/MOF/nlp.mof.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "MathOptFormat Model",
"version": {
"major": 1,
"minor": 7
"minor": 9
},
"variables": [
{
Expand Down
42 changes: 42 additions & 0 deletions test/FileFormats/MOF/test_MOF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,48 @@ function test_unsupported_kwarg()
return
end

function test_v1_8()
io = IOBuffer(
"""
{
"version": {"major": 1, "minor": 8},
"variables": [{"name": "t"}, {"name": "x"}, {"name": "y"}],
"objective": {"sense": "feasibility"},
"constraints": [{
"function": {"type": "VectorOfVariables", "variables": ["t", "x", "y"]},
"set": {"type": "DualGeometricMeanCone", "dimension": 3}
}]
}
""",
)
model = MOI.FileFormats.MOF.Model()
read!(io, model)
ret = MOI.get(model, MOI.ListOfConstraintTypesPresent())
@test only(ret) == (MOI.VectorOfVariables, MOI.DualGeometricMeanCone)
return
end

function test_v1_9()
io = IOBuffer(
"""
{
"version": {"major": 1, "minor": 9},
"variables": [{"name": "u"}, {"name": "v"}, {"name": "w"}],
"objective": {"sense": "feasibility"},
"constraints": [{
"function": {"type": "VectorOfVariables", "variables": ["u", "v", "w"]},
"set": {"type": "DualRelativeEntropyCone", "dimension": 3}
}]
}
""",
)
model = MOI.FileFormats.MOF.Model()
read!(io, model)
ret = MOI.get(model, MOI.ListOfConstraintTypesPresent())
@test only(ret) == (MOI.VectorOfVariables, MOI.DualRelativeEntropyCone)
return
end

end

TestMOF.runtests()
Loading