diff --git a/src/Interfaces/MOI/attributes.jl b/src/Interfaces/MOI/attributes.jl index bd50f67..6a03747 100644 --- a/src/Interfaces/MOI/attributes.jl +++ b/src/Interfaces/MOI/attributes.jl @@ -58,10 +58,13 @@ end # # TimeLimitSec # -MOI.get(m::Optimizer, ::MOI.TimeLimitSec) = m.inner.params.IPM.TimeLimit +function MOI.get(m::Optimizer, ::MOI.TimeLimitSec) + value = m.inner.params.IPM.TimeLimit + return value == Inf ? nothing : value +end -function MOI.set(m::Optimizer, ::MOI.TimeLimitSec, t) - m.inner.params.IPM.TimeLimit = t +function MOI.set(m::Optimizer, ::MOI.TimeLimitSec, t::Union{Real,Nothing}) + m.inner.params.IPM.TimeLimit = convert(Float64, something(t, Inf)) return nothing end diff --git a/test/Interfaces/MOI_wrapper.jl b/test/Interfaces/MOI_wrapper.jl index 17154b4..6e0e91e 100644 --- a/test/Interfaces/MOI_wrapper.jl +++ b/test/Interfaces/MOI_wrapper.jl @@ -110,3 +110,15 @@ MOIU.@model(ModelData, "test_unbounded", ]) end + +@testset "test_attribute_TimeLimitSec" begin + model = Tulip.Optimizer() + @test MOI.supports(model, MOI.TimeLimitSec()) + @test MOI.get(model, MOI.TimeLimitSec()) === nothing + MOI.set(model, MOI.TimeLimitSec(), 0.0) + @test MOI.get(model, MOI.TimeLimitSec()) == 0.0 + MOI.set(model, MOI.TimeLimitSec(), nothing) + @test MOI.get(model, MOI.TimeLimitSec()) === nothing + MOI.set(model, MOI.TimeLimitSec(), 1.0) + @test MOI.get(model, MOI.TimeLimitSec()) == 1.0 +end