diff --git a/src/MathOptLazy.jl b/src/MathOptLazy.jl index c48e128..509f3d7 100644 --- a/src/MathOptLazy.jl +++ b/src/MathOptLazy.jl @@ -23,6 +23,13 @@ function MOI.Utilities.shift_constant(set::LazyScalarSet, constant) return LazyScalarSet(MOI.Utilities.shift_constant(set.set, constant)) end +function MOI.FileFormats.MOF.moi_to_object( + set::LazyScalarSet, + x::Dict{MOI.VariableIndex,String}, +) + return MOI.FileFormats.MOF.moi_to_object(set.set, x) +end + """ Lazy(; lazy::Bool = true) diff --git a/test/runtests.jl b/test/runtests.jl index d9e4fd8..bc406d1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -162,6 +162,18 @@ function test_basic_scalaraffinefunction_lessthan() return end +function test_writing_mof_file() + src = MathOptLazy.Optimizer(HiGHS.Optimizer) + x = MOI.add_variable(src) + c = MOI.add_constraint(src, x, MathOptLazy.LazyScalarSet(MOI.ZeroOne())) + dest = MOI.FileFormats.MOF.Model() + _ = MOI.copy_to(dest, src) + contents = sprint(write, dest) + @test occursin("ZeroOne", contents) + @test !occursin("LazyScalarSet", contents) + return +end + end # TestMathOptLazy TestMathOptLazy.runtests()