Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MOI.VersionNumber #41

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
odow marked this conversation as resolved.
Show resolved Hide resolved
@test version isa VersionNumber
@test version >= v"2.7.4"
return
end

end

TestMiniZinc.runtests()
Loading