# Do faster optimization with Cbc solver in JuMP

**URL:** https://discourse.julialang.org/t/do-faster-optimization-with-cbc-solver-in-jump/46276
**Category:** Optimization (Mathematical)
**Tags:** jump, multithreading, optimization, threads
**Created:** [September 8, 2020, 4:32pm UTC](https://discourse.julialang.org/t/do-faster-optimization-with-cbc-solver-in-jump/46276 "2020-09-08T16:32:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Luis\_Tormo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luis_tormo/32/16500_2.png) [@Luis\_Tormo](https://discourse.julialang.org/u/Luis_Tormo)
#### Post date: [September 8, 2020, 4:32pm UTC](https://discourse.julialang.org/t/do-faster-optimization-with-cbc-solver-in-jump/46276/1 "2020-09-08T16:32:16Z")

</div>

I am trying to do an optimization of a MILP problem with Cbc solver but it is too slow. I know that with CPLEX it is much faster but I need to use Cbc. Does anyone know of a resource to get it? Maybe multi-threading?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [September 8, 2020, 4:49pm UTC](https://discourse.julialang.org/t/do-faster-optimization-with-cbc-solver-in-jump/46276/2 "2020-09-08T16:49:05Z")

</div>

if you need to use use Cbc you’re using Cbc, unless you are talking about write a Julia Cbc?

---

<div class="post-metadata">

### Author: ![Luis\_Tormo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luis_tormo/32/16500_2.png) [@Luis\_Tormo](https://discourse.julialang.org/u/Luis_Tormo)
#### Post date: [September 8, 2020, 4:57pm UTC](https://discourse.julialang.org/t/do-faster-optimization-with-cbc-solver-in-jump/46276/3 "2020-09-08T16:57:54Z")

</div>

No. I am using JuMP and the Cbc solver for MILP optimization but it is too slow and I want to know if there is any way to make the optimization more faster.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [September 8, 2020, 5:03pm UTC](https://discourse.julialang.org/t/do-faster-optimization-with-cbc-solver-in-jump/46276/4 "2020-09-08T17:03:16Z")

</div>

but you still have to use Cbc optimizer, correct? if so, you’re asking how to make your JuMP code faster maybe (which was not clear, except maybe implied from the tag)

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [September 8, 2020, 6:40pm UTC](https://discourse.julialang.org/t/do-faster-optimization-with-cbc-solver-in-jump/46276/5 "2020-09-08T18:40:05Z")

</div>

Make sure you set the `threads` attribute:

```julia
using Cbc
using JuMP
n = # the number of threads available on your machine
model = Model(Cbc.Optimizer)
set_optimizer_attribute(model, "threads", n) 

```

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [September 8, 2020, 11:09pm UTC](https://discourse.julialang.org/t/do-faster-optimization-with-cbc-solver-in-jump/46276/6 "2020-09-08T23:09:11Z")

</div>

The answer is “it depends.”

Define “too slow.” To find a feasible solution? Or to prove optimality?

Most solvers will quickly find a good-enough solution, and then spend a long time proving it is near optimal. Just set a time-limit and return the good-enough solution.

Poor formulations, like large big-M constraints can also play a part. You could also try to provide a good starting point as a hint via [https://jump.dev/JuMP.jl/stable/variables/#Start-values-1](https://jump.dev/JuMP.jl/stable/variables/#Start-values-1)

You should also take a read of

> **[Documentation - Gurobi Optimization](https://www.gurobi.com/documentation/9.0/refman/num_grb_guidelines_for_num.html)**
>
> Est. reading time: 1 minute

---

<div class="post-metadata">

### Author: ![dburch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dburch/32/8741_2.png) [@dburch](https://discourse.julialang.org/u/dburch)
#### Post date: [September 23, 2021, 11:00pm UTC](https://discourse.julialang.org/t/do-faster-optimization-with-cbc-solver-in-jump/46276/7 "2021-09-23T23:00:44Z")

</div>

Another way to make Cbc faster is to shrink your search space with heuristics. Depending on how your problem is constructed, you might be able to apply to basic logic that will obviously reduce the area of search before it even gets to Cbc.

For instance, if you were trying to solve the Traveling Salesman Problem (TSP), then a natural heuristic would be to exclude options where the salesman travels to opposite sides of the geography.

Also, you might be including infeasible options in your search space. These options could waste time. If you find a way to exclude infeasible options from the get-go, then you’ll shrink the search space and Cbc will solve faster.
