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

performance issue #115

Closed
1991jhf opened this issue Apr 28, 2022 · 6 comments
Closed

performance issue #115

1991jhf opened this issue Apr 28, 2022 · 6 comments

Comments

@1991jhf
Copy link

1991jhf commented Apr 28, 2022

Hi,
I noticed adding variables for HiGHS solver is very slow compare to cplex solver. It seems there is a lot of allocations going on. Below is the code:

using HiGHS
using CPLEX
import MathOptInterface as MOI

highs_model=HiGHS.Optimizer()
cplex_model=CPLEX.Optimizer()

@time MOI.add_variables(highs_model,100000)
1.811086 seconds (100.01 k allocations: 8.694 MiB, 7.26% gc time)

@time MOI.add_variables(cplex_model,100000)
0.011854 seconds (400.01 k allocations: 15.561 MiB)

@odow
Copy link
Member

odow commented Apr 28, 2022

It actually seems like there are less allocations in HiGHS?

Is adding variables a bottleneck in a real use-case?

@odow
Copy link
Member

odow commented Apr 28, 2022

This isn't overhead in HiGHS.jl, it's the cost in the underlying solver:

julia> import HiGHS

julia> const MOI = HiGHS.MOI
MathOptInterface

julia> function main(N)
           highs = HiGHS.Optimizer()
           MOI.add_variables(highs, N)
           return highs
       end
main (generic function with 1 method)

julia> @time main(10_000)
  0.026619 seconds (10.04 k allocations: 962.594 KiB)
A HiGHS model with 10000 columns and 0 rows.

julia> @time main(100_000)
  1.644493 seconds (100.05 k allocations: 8.870 MiB)
A HiGHS model with 100000 columns and 0 rows.

julia> function bar(N)
           highs = HiGHS.Highs_create()
           for _ in 1:N
               HiGHS.Highs_addCol(highs, 0.0, -Inf, Inf, 0, C_NULL, C_NULL)
           end
           HiGHS.Highs_destroy(highs)
           return
       end
bar (generic function with 1 method)

julia> @time bar(10_000)
  0.023322 seconds

julia> @time bar(100_000)
  1.671258 seconds

@1991jhf
Copy link
Author

1991jhf commented Apr 29, 2022

Thank you for digging into the issue.
It is common in my use case to add millions of variables and constraints.
It is quiet fast in 1.0.0. I will report to HiGHS team.

@odow
Copy link
Member

odow commented Apr 29, 2022

It is quiet fast in 1.0.0

In HiGHS.jl v1.0.0 or HiGHS the solver?

@odow
Copy link
Member

odow commented Apr 29, 2022

I will report to HiGHS team.

I can do it. I'm just testing some different things

@odow
Copy link
Member

odow commented Apr 29, 2022

Closing in favor of ERGO-Code/HiGHS#830

@odow odow closed this as completed Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants