Skip to content

Commit

Permalink
Add support for MOI.VersionNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Sep 19, 2023
1 parent 5984159 commit f17c7e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,14 @@ function test_highs_optimization_time_limit()
return
end

function test_version_number()
solver = MiniZinc.Optimizer{Float64}("highs")
version = MOI.get(model, MOI.SolverVersion())
@test version isa VersionNumber
@test version >= v"2.7.4"
return
end

end

TestMiniZinc.runtests()

0 comments on commit f17c7e5

Please sign in to comment.