Skip to content

Commit

Permalink
Merge pull request #126 from JuliaOpt/bl/solve_time
Browse files Browse the repository at this point in the history
Implement MOI.SolveTime
  • Loading branch information
blegat committed Nov 28, 2018
2 parents 35ee9a5 + 75e75db commit 4faada9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/MOIWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ mutable struct MOISolution
dual::Vector{Float64}
slack::Vector{Float64}
objval::Float64
solve_time::Float64
end
MOISolution() = MOISolution(0, # SCS_UNFINISHED
Float64[], Float64[], Float64[], NaN)
Float64[], Float64[], Float64[], NaN, 0.0)

# Used to build the data with allocate-load during `copy_to`.
# When `optimize!` is called, a the data is passed to SCS
Expand Down Expand Up @@ -338,17 +339,23 @@ function MOI.optimize!(optimizer::Optimizer)

linear_solver, options = sanatize_SCS_options(optimizer.options)

sol = SCS_solve(linear_solver, m, n, A, b, c,
t = time()
sol = SCS_solve(linear_solver, m, n, A, b, c,
cone.f, cone.l, cone.qa, cone.sa, cone.ep, cone.ed, cone.p,
optimizer.sol.primal, optimizer.sol.dual,
optimizer.sol.slack; options...)
solve_time = time() - t

ret_val = sol.ret_val
primal = sol.x
dual = sol.y
slack = sol.s
objval = (optimizer.maxsense ? -1 : 1) * dot(c, primal) + objconstant
optimizer.sol = MOISolution(ret_val, primal, dual, slack, objval)
optimizer.sol = MOISolution(ret_val, primal, dual, slack, objval, solve_time)
end

function MOI.get(optimizer::Optimizer, ::MOI.SolveTime)
return optimizer.sol.solve_time
end

# Implements getter for result value and statuses
Expand Down

0 comments on commit 4faada9

Please sign in to comment.