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

set multithread cbc solver in cvxpy problem #489

Open
Marie73 opened this issue Apr 5, 2022 · 10 comments
Open

set multithread cbc solver in cvxpy problem #489

Marie73 opened this issue Apr 5, 2022 · 10 comments

Comments

@Marie73
Copy link

Marie73 commented Apr 5, 2022

Hello,

I have an integer linear programming issue, which I managed to solve by formulating CVXPY problem with use of CBC solver. The task is to transport suitable boxes and units of products from source warehouse to more target warehouses according to minimal and maximal demand for product. Before rewriting to cvxpy, I reduce the problem dimension as much as possible and use sparse matrices.

I use this formula for finding solution:
problem.solve(verbose=True, solver='CBC', numberThreads = 1, allowablePercentageGap = 1)
It does not seem to take the numberThreads and allowablePercentageGap parameters into account. The solution time is almost the same for different parameter settings.

Can you help me set the CBC solver to run in parallel? Or do you have an idea how to solve ILP faster?
The small problem is solved in 2 minutes, the big one in 30-40 minutes. But we have to find a solution ideally within 15 minutes.

I posted this issue also in cvxpy lib : cvxpy/cvxpy#1741

Thank you

@rsemenoff
Copy link

rsemenoff commented Apr 5, 2022 via email

@Marie73
Copy link
Author

Marie73 commented Apr 6, 2022

Thank you for answer. I set maximal time of computation as:
problem.solve(verbose=True, solver='CBC', numberThreads = 1, allowablePercentageGap = 1, maximumSeconds = 13*60)
But the solution doesnt fit all constraints.

I can slit problem by target warehouses - calculate faster and less optimal, but still if there is some option to make it faster and right, I would like to try it.

@rsemenoff
Copy link

rsemenoff commented Apr 6, 2022 via email

@Marie73
Copy link
Author

Marie73 commented Apr 8, 2022

I tried SCIP and GLPK_MI with certain parameters. I didnt try CPLEX because it is commercial solver and I dont have a licence, the same with GUROBI and EXPRESS.

problem.solve(verbose=True, solver=cp.SCIP, scip_params = {'parallel/mode' : 1, 'lp/threads' : 6, 'parallel/minnthreads' : 6, 'limits/gap': 0.1})
problem.solve(verbose=True, solver='GLPK_MI', reltol = 0.1)

It will run as application in production, do you think that CBC is not reliable enough?

@jjhforrest
Copy link
Contributor

jjhforrest commented Apr 8, 2022 via email

@Martiniukas
Copy link

I have the same problem and have the same experiences as you Marie

@tkralphs
Copy link
Member

The documentation here is a bit optimistic :). The interface to Cbc is through CyLP and CyLP doesn't support setting arbitrary Cbc parameters. The way the interface is implemented, it seems to in fact be true that all the parameters are ignored :(. Changing this would require a change to CyLP, which is probably not very difficult.

For the record, I think it's pretty misleading to characterize Cbc as "not rigorously tested." It is quite robust in practice.

@Marie73
Copy link
Author

Marie73 commented Apr 11, 2022

Thank you for your response!

In other words, CyLP can compute cbc using multiple threads, but the problem is in parameter communication.
I found this two issues in /coin-or/CyLP:
coin-or/CyLP#133
coin-or/CyLP#1 .... can be helpful?

I'm new to python, so I can't make changes to packages myself yet, but I can report it as a bug / new feature in CyLP (?)

ps: Thank you for cbc support, I feel calmer now :)

@tkralphs
Copy link
Member

Yes, the main thing needed is the ability to pass parameters to Cbc, which #1 and #133 do both address for the case of setting the number of threads. Secondarily, the Cbc library that is used must also be built with support for multithreading. The current wheels made available are not built with this support, but this could also be changed. If you open an issue in CyLP about adding a method for setting arbitrary parameters, I will try to find some time to address it.

@Marie73
Copy link
Author

Marie73 commented Apr 13, 2022

Thank you! I opened the issue in CyLP.

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

No branches or pull requests

5 participants