-
Notifications
You must be signed in to change notification settings - Fork 16
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
Creating 'big' models is very slow #62
Comments
Can you provide a reproducible example in Julia? |
The following code shows the issue using JuMP struct Product struct Facility struct Customer struct Lane m = Model(HiGHS.Optimizer) customer_count = 1000 products = Set([Product()]) @variable(m, opened[facilities], Bin) @constraint(m, [p=products,c=customers], sum(sent[p, l] for l in lanes if l.customer == c) >= c.demand[p]) @objective(m, Min, sum(f.fixed_cost * opened[f] for f in facilities) + sum(l.unit_cost * sent[p, l] for l in lanes, p in products)) optimize!(m) |
I'll take a look, but a few things:
Once you've fixed those things, try the timing again and see if it improves things. Also: I don't know if HiGHS is ready for million variable integer problems yet (cc @jajhall and @lgottwald how big problems have you solved?) |
Its hard to say generally as models can behave very different in the solver but in principle HiGHS can already solve many big models. For both MIP and LP HiGHS can sometimes solve very large models very quickly but also its possible that you encounter performance bottlenecks that we still need to address. |
You could also try |
@lgottwald good to know. The problem is almost certainly on our side then. |
Thank you both for your comments. I understand that MIP are hard to solve and that it is difficult to predict up-front how long the solver will take to find a solution. My concern here was the time it took to create the model (before the actual solve). My (very crude) understanding is that the methods used to build the model (e.g., add rows) do quite a bit of work every time they are called. I was curious if there was a way to streamline them or maybe batch the column/row creations. I tried using a model without bridge constraints as suggested. The creation time is much faster. I had to change some of the variables (e.g., Binary variables produced an exception; I changed them to Integer variables between 0 and 1). Is there a way to know which constructs are supported without the bridge and which ones are not? |
What was the exception? This should work.
When you used |
Here is the stack trace when using Binary variables: ERROR: KeyError: key (MathOptInterface.SingleVariable, MathOptInterface.ZeroOne) not found |
Ah. I fixed that in #50 (along with some other things). I guess I forgot to add it back to |
The fix will be available as a new release once JuliaRegistries/General#42944 is merged. What are the timings with the typed structs, |
I changed the code to override == and hash as follows: struct Product struct Facility struct Customer struct Lane Base.:(==)(x::Product, y::Product) = x.name == y.name Base.:hash(x::Product) = hash(x.name) Base.:show(io::IOContext{IOBuffer}, x::Product) = print(io, "$(x.name)") with these changes the creation takes about 20s: @time create_model() |
Your definition of Base.hash(x::Product, h::UInt64) = hash(x.name, h) Your show definitions should also just be: Base.show(io::IO, x::Product) But pleased to see that it's not an issue with HiGHS. Can this issue be closed then? |
Yes; let's close the issue. Thank you for your help in speeding up the model construction (including my code...). |
Hello,
I am trying to build a large model (~100,000 variables and constraints) and the call to optimize! takes a long time (10+ min before the optimization even starts).
I have attached a partial trace (I stopped executing after a minute or so) and my understanding of it is that adding the rows and constraints is costly.
Is there a way to speed things in the Julia wrapper or is this an issue with HiGHS (or with my code...)?
Thank you.
trace.txt
The text was updated successfully, but these errors were encountered: