# Setting Time Limits for JuMP (with CBC solver)

**URL:** <https://discourse.julialang.org/t/setting-time-limits-for-jump-with-cbc-solver/56303>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [March 2, 2021, 5:46am UTC](https://discourse.julialang.org/t/setting-time-limits-for-jump-with-cbc-solver/56303 "2021-03-02T05:46:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![acwkim](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@acwkim](https://discourse.julialang.org/u/acwkim)\
**Post date:** [March 2, 2021, 5:46am UTC](https://discourse.julialang.org/t/setting-time-limits-for-jump-with-cbc-solver/56303/1 "2021-03-02T05:46:00Z")

</div>

Hi all. Is there a way to set time limit for JuMP models using CBC solver?  
The “seconds” parameter only limits CPU seconds, which is different from Wallclock seconds.  
I need to set a limit for Wallclock second!  
Thanks

---

<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:** [March 2, 2021, 7:46am UTC](https://discourse.julialang.org/t/setting-time-limits-for-jump-with-cbc-solver/56303/2 "2021-03-02T07:46:48Z")

</div>

I don’t think so. Is the difference big?

Note that there is some time spent in JuMP setting up the problem that you will see in a call to `optimize!(model)` that is not captured by the time limit. Is that what you are observing?

---

<div class="post-metadata">

**Author:** ![acwkim](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@acwkim](https://discourse.julialang.org/u/acwkim)\
**Post date:** [March 3, 2021, 1:43am UTC](https://discourse.julialang.org/t/setting-time-limits-for-jump-with-cbc-solver/56303/3 "2021-03-03T01:43:54Z")

</div>

I don’t think so. Attached the screenshot of what’s happening.  
As you can see I set “seconds” to 120, but I think CPU seconds are counted.

 ![Screen Shot 2021-03-02 at 8.42.01 PM](https://global.discourse-cdn.com/julialang/original/3X/6/a/6a7f540c3f8b559c0debd79badbb1e2f242b5a3d.png)

---

<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:** [March 3, 2021, 2:03am UTC](https://discourse.julialang.org/t/setting-time-limits-for-jump-with-cbc-solver/56303/4 "2021-03-03T02:03:57Z")

</div>

I don’t know if there is a way make the time limit the wallclock.You could just increase the time limit to account for the multiple threads?

Note that even if you set a time limit, the solver will not stop immediately, but instead at the next available opportunity. (i.e., it stopped at 156 seconds, not 120).

What are you trying to achieve?

---

<div class="post-metadata">

**Author:** ![acwkim](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@acwkim](https://discourse.julialang.org/u/acwkim)\
**Post date:** [March 3, 2021, 2:11am UTC](https://discourse.julialang.org/t/setting-time-limits-for-jump-with-cbc-solver/56303/5 "2021-03-03T02:11:22Z")

</div>

I am doing some experiments on solving optimization problems when there is lack of resources, especially when there is time limit. I am trying to see how suboptimal the solutions are, depending on different time limits.

---

<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:** [March 3, 2021, 2:37am UTC](https://discourse.julialang.org/t/setting-time-limits-for-jump-with-cbc-solver/56303/6 "2021-03-03T02:37:55Z")

</div>

Note that there are plenty of issues to be aware of when trying to do this.

- Solvers might not respect time limits the same way.
- Insights are problem dependent.
- Solving the same model with the same solver and a longer time limit is not guaranteed to get a better answer.

See this slide deck for some of the pitfalls: [https://school.a4cp.org/summer2017/slidedecks/Consistency-in-Solvers.pdf](https://school.a4cp.org/summer2017/slidedecks/Consistency-in-Solvers.pdf)

---

<div class="post-metadata">

**Author:** ![acwkim](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@acwkim](https://discourse.julialang.org/u/acwkim)\
**Post date:** [March 3, 2021, 3:05am UTC](https://discourse.julialang.org/t/setting-time-limits-for-jump-with-cbc-solver/56303/7 "2021-03-03T03:05:19Z")

</div>

Wow did not know about these issues!  
Thank you so much for the tips!
