diff --git a/src/optimize.jl b/src/optimize.jl index 359a3d2..16f827e 100644 --- a/src/optimize.jl +++ b/src/optimize.jl @@ -94,6 +94,16 @@ function _run_minizinc(dest::Optimizer) return "" end +function MOI.get(model::Optimizer, ::MOI.SolverVersion) + output = sprint() do io + return _minizinc_exe() do exe + return run(pipeline(`$(exe) --version`; stdout = io)) + end + end + m = match(r"version (\d+.\d+.\d+)", output)::RegexMatch + return VersionNumber(m[1]) +end + # The MOI interface MOI.get(model::Optimizer, ::MOI.SolverName) = "MiniZinc" diff --git a/test/runtests.jl b/test/runtests.jl index 65e83d6..99d2c23 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1440,6 +1440,14 @@ function test_highs_optimization_time_limit() return end +function test_version_number() + solver = MiniZinc.Optimizer{Float64}("highs") + version = MOI.get(solver, MOI.SolverVersion()) + @test version isa VersionNumber + @test version >= v"2.7.4" + return +end + end TestMiniZinc.runtests()