# Setting time limit through amplpy

**URL:** <https://discuss.ampl.com/t/setting-time-limit-through-amplpy/294>\
**Category:** Support\
**Created:** [December 29, 2022, 4:25am UTC](https://discuss.ampl.com/t/setting-time-limit-through-amplpy/294 "2022-12-29T04:25:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jessica\_Meng](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/jessica_meng/32/120_2.png) [@Jessica\_Meng](https://discuss.ampl.com/u/Jessica_Meng)\
**Post date:** [December 29, 2022, 4:25am UTC](https://discuss.ampl.com/t/setting-time-limit-through-amplpy/294/1 "2022-12-29T04:25:23Z")

</div>

Hi,

I’m solving a problem through amplpy. I wish to set a timelimit on the solver. However, I explored all ampl options and see no such option. How do I do that?

Sample code:  
ampl = AMPL(Environment(‘…’))  
#set solver  
ampl.setOption(‘solver’, ‘cbc’)

---

<div class="post-metadata">

**Author:** ![fdabrandao](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/fdabrandao/32/63_2.png) [@fdabrandao](https://discuss.ampl.com/u/fdabrandao)\
**Post date:** [December 29, 2022, 10:05am UTC](https://discuss.ampl.com/t/setting-time-limit-through-amplpy/294/2 "2022-12-29T10:05:35Z")

</div>

Hi Jessica,

The limit limit is a solver option. You can see all options for CBC at: [CBC Options — AMPL Resources](https://dev.ampl.com/solvers/cbc/options.html)

```auto
ampl.setOption('cbc_options', 'timelim=60')

```

BTW: this applies to the latest CBC driver released recently. You may need to download the latest version for CBC from the [AMPL Portal](https://portal.ampl.com/user/ampl/download/list)) in case you have an older installation.
