# Amplpy solve time Job shop scheduling

**URL:** <https://discuss.ampl.com/t/amplpy-solve-time-job-shop-scheduling/1020>\
**Category:** Support\
**Tags:** displays-results\
**Created:** [March 25, 2024, 6:25pm UTC](https://discuss.ampl.com/t/amplpy-solve-time-job-shop-scheduling/1020 "2024-03-25T18:25:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![icey](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/icey/32/527_2.png) [@icey](https://discuss.ampl.com/u/icey)\
**Post date:** [March 25, 2024, 6:25pm UTC](https://discuss.ampl.com/t/amplpy-solve-time-job-shop-scheduling/1020/1 "2024-03-25T18:25:54Z")

</div>

Hello,

I am modeling a job shop scheduling problem and want to evaluate the performance of different models in AMPL / AMPLPY.

The AMPL solver finds the solution pretty quickly, but unless i set a time limit, it will try and find another optimal solution for hours.

In amplpy, is there any way i can get the time of when ampl found the last optimal solution?

heres a small example :  
10 machines, 5 jobs.

cmax 926 was found after 1 sec, but it will continue to find other 926 solutions for 30+min. It makes comparison between solve time metrics pretty useless.

Or, is there a way to make ampl stop if no better solution are found after x amount of time ?  
Any ideas will help.

Thanks in advance.

---

<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:** [March 25, 2024, 8:14pm UTC](https://discuss.ampl.com/t/amplpy-solve-time-job-shop-scheduling/1020/2 "2024-03-25T20:14:27Z")

</div>

Hi @icey,

Which solver are you using? In order to implement a custom stopping criteria like that you would need to use a callback via our solver interface with callbacks ([ampls:: Python solver libraries — ampl::ampls-api 0.1 documentation](https://ampls.ampl.com/en/latest/python/index.html)) available for Gurobi, CPLEX, XPRESS, and COPT. There is an example with Gurobi at [ampls-api/python/examples/callbacks\_stopping.py at master · ampl/ampls-api · GitHub](https://github.com/ampl/ampls-api/blob/master/python/examples/callbacks_stopping.py)

---

<div class="post-metadata">

**Author:** ![icey](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/icey/32/527_2.png) [@icey](https://discuss.ampl.com/u/icey)\
**Post date:** [March 26, 2024, 4:15pm UTC](https://discuss.ampl.com/t/amplpy-solve-time-job-shop-scheduling/1020/3 "2024-03-26T16:15:34Z")

</div>

Hello,

thank you so much, ive just tested it with gurobi and it works perfectly.  
Having the cplex option will allow me to even compare performance between solvers.

Have a good day,
