Skip to content

Commit

Permalink
Allow querying SolutionTime attribute (#146)
Browse files Browse the repository at this point in the history
> SolutionTime	Float64	Solution time, in seconds
  • Loading branch information
pratyai authored Feb 19, 2024
1 parent 2edf525 commit 8a3cce9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Interfaces/tulip_julia_api.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QPSReader
using TimerOutputs: tottime

# TODO: user-facing API in Julia
# Other APIs should wrap this one
Expand Down Expand Up @@ -60,6 +61,20 @@ function get_attribute(m::Model, ::Status)
return m.status
end

"""
get_attribute(model::Model, ::SolutionTime)
Query the `SolutionTime` attribute from `model`
"""
function get_attribute(m::Model, ::SolutionTime)
if isnothing(m.solver)
return 0
else
local ns = tottime(m.solver.timer)
return ns * 1e-9
end
end

"""
get_attribute(model::Model, ::BarrierIterations)
Expand Down

0 comments on commit 8a3cce9

Please sign in to comment.