diff --git a/docs/src/submodules/FileFormats/overview.md b/docs/src/submodules/FileFormats/overview.md index 9982fe3f88..46f6bc2863 100644 --- a/docs/src/submodules/FileFormats/overview.md +++ b/docs/src/submodules/FileFormats/overview.md @@ -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 @@ -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": [] @@ -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": [] diff --git a/src/FileFormats/MOF/MOF.jl b/src/FileFormats/MOF/MOF.jl index c16cbc635f..d7290faf8f 100644 --- a/src/FileFormats/MOF/MOF.jl +++ b/src/FileFormats/MOF/MOF.jl @@ -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", diff --git a/test/FileFormats/MOF/nlp.mof.json b/test/FileFormats/MOF/nlp.mof.json index e5df6fbaa1..79380257d0 100644 --- a/test/FileFormats/MOF/nlp.mof.json +++ b/test/FileFormats/MOF/nlp.mof.json @@ -2,7 +2,7 @@ "name": "MathOptFormat Model", "version": { "major": 1, - "minor": 7 + "minor": 9 }, "variables": [ { diff --git a/test/FileFormats/MOF/test_MOF.jl b/test/FileFormats/MOF/test_MOF.jl index e274faabcc..8bc10956fe 100644 --- a/test/FileFormats/MOF/test_MOF.jl +++ b/test/FileFormats/MOF/test_MOF.jl @@ -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()