Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Performance improvements #69

Merged
merged 4 commits into from
Nov 8, 2018
Merged

Performance improvements #69

merged 4 commits into from
Nov 8, 2018

Conversation

odow
Copy link
Member

@odow odow commented Nov 5, 2018

This should really be two PR's, but the first two commits are related to #51. I can split into two, or I'll merge without squashing.

Closes #51

First commit: remove __check_conflicting_constraints__

using Gurobi, JuMP, BenchmarkTools
const MOI = Gurobi.MOI
function run_moi_direct(n)
  m = JuMP.direct_model(Gurobi.Optimizer(LogToConsole=false))
  @variable m x[i=1:n] <= i 
  # JuMP.optimize!(m)
end
@btime run_moi_direct(10^4)

Before: 1.528 s (243281 allocations: 12.74 MiB)
After commit 1: 690.032 ms (193304 allocations: 12.25 MiB)
After commit 2: 695.777 ms (233304 allocations: 15.76 MiB)

Second commit: add add_constraints

function run_moi_single(n)
  m = Gurobi.Optimizer()
  for i = 1:n
      index = MOI.add_variable(m)
      MOI.add_constraint(m, MOI.SingleVariable(index), MOI.LessThan(convert(Float64,i)))
  end
  return m
end
@btime run_moi_single(10^4);

Before: 1.504 s (143691allocations: 9.16 MiB)
After commit 1: 663.538 ms (53730 allocations: 5.56 MiB)
After commit 2: 652.206 ms (133714 allocations: 12.18 MiB)

function run_moi_vector(n)
  m = Gurobi.Optimizer()
  index = MOI.add_variables(m, n)
  MOI.add_constraints(m, MOI.SingleVariable.(index), MOI.LessThan.(convert.(Float64,1:n)))
  return m
end
@btime run_moi_vector(10^4);

Before: 1.240 s (103707 allocations: 6.05 MiB)
After commit 1: 438.617 ms (53730 allocations: 5.56 MiB)
After commit 2: 18.987 ms (13753 allocations: 2.93 MiB)

Commits 3 and 4

Coverage improvements.

@codecov-io
Copy link

codecov-io commented Nov 5, 2018

Codecov Report

Merging #69 into master will increase coverage by 2.18%.
The diff coverage is 91.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #69      +/-   ##
==========================================
+ Coverage   88.07%   90.25%   +2.18%     
==========================================
  Files          13       13              
  Lines        1291     1324      +33     
==========================================
+ Hits         1137     1195      +58     
+ Misses        154      129      -25
Impacted Files Coverage Δ
src/variables.jl 97.26% <100%> (+0.11%) ⬆️
src/mockoptimizer.jl 83.46% <100%> (+0.29%) ⬆️
src/LinQuadOptInterface.jl 100% <100%> (ø) ⬆️
src/constraints/singlevariable.jl 96.45% <90.38%> (+21.9%) ⬆️
src/solver_interface.jl 66.66% <0%> (+3.5%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dce0136...2ff3462. Read the comment docs.

@odow odow changed the title Replace check for conflicting constraints with an O(1) cache Performance improvements Nov 5, 2018
@odow odow requested a review from joaquimg November 6, 2018 17:21
@joaquimg
Copy link
Member

joaquimg commented Nov 6, 2018

muuuch better!

@odow odow merged commit 4c08533 into master Nov 8, 2018
@odow odow deleted the od/performance branch November 8, 2018 19:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants