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

Fix performance issue #180

Merged
merged 2 commits into from
Nov 4, 2021
Merged

Fix performance issue #180

merged 2 commits into from
Nov 4, 2021

Conversation

odow
Copy link
Member

@odow odow commented Nov 4, 2021

Closes #172
Closes #173

Before

julia> bench();
Optimal - objective value 4.50015e+08
Optimal objective 450015000 - 0 iterations time 0.002
  4.113598 seconds (60.00 k allocations: 2.976 MiB)

After

julia> bench();
Optimal - objective value 4.50015e+08
Optimal objective 450015000 - 0 iterations time 0.002
  0.000598 seconds (4 allocations: 234.547 KiB)

Script

using Cbc
const MOI = Cbc.MOI

function bench(N = 30_000)
    cbc = Cbc.Optimizer()
    model = MOI.Utilities.CachingOptimizer(MOI.Utilities.Model{Float64}(), cbc)
    x = MOI.add_variables(model, N);
    MOI.add_constraints(model, x, MOI.GreaterThan.(1.0:N));
    MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE);
    f = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(1.0, x), 0.0);
    MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f);
    MOI.optimize!(model)
    @time MOI.get.(model, MOI.VariablePrimal(), x)
end
bench()

@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #180 (1a263fe) into master (33bcd1b) will increase coverage by 0.67%.
The diff coverage is 95.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #180      +/-   ##
==========================================
+ Coverage   53.93%   54.61%   +0.67%     
==========================================
  Files           3        3              
  Lines         534      542       +8     
==========================================
+ Hits          288      296       +8     
  Misses        246      246              
Impacted Files Coverage Δ
src/MOI_wrapper/MOI_wrapper.jl 80.83% <95.00%> (+0.47%) ⬆️

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 33bcd1b...1a263fe. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

MOI is slow querying solution information again
2 participants