# Re: \[AMPL 25019\] Inquiry Regarding Discrepancy in Solve Time Metrics

**URL:** <https://discuss.ampl.com/t/re-ampl-25019-inquiry-regarding-discrepancy-in-solve-time-metrics/1037>\
**Category:** Google Group Mirror\
**Created:** [April 6, 2024, 9:04pm UTC](https://discuss.ampl.com/t/re-ampl-25019-inquiry-regarding-discrepancy-in-solve-time-metrics/1037 "2024-04-06T21:04:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AMPL\_Google\_Group1](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@AMPL\_Google\_Group1](https://discuss.ampl.com/u/AMPL_Google_Group1)\
**Post date:** [April 6, 2024, 9:04pm UTC](https://discuss.ampl.com/t/re-ampl-25019-inquiry-regarding-discrepancy-in-solve-time-metrics/1037/1 "2024-04-06T21:04:00Z")

</div>

Those times are determined as follows:

- \_ampl\_elapsed\_time is the elapsed time in the current AMPL session, not including time that AMPL was paused waiting for solver processes to finish.
- \_solve\_elapsed\_time is the elapsed time in the most recent solver process of the current AMPL session.
- \_total\_solve\_elapsed\_time is the total elapsed time in all solver processes since the beginning of the current AMPL session.  
Thus in particular, if there has been only one solve in the current AMPL session, \_solve\_elapsed\_time and \_total\_solve\_elapsed\_time are equal. (The “current AMPL session” begins with the last “reset;”, or with the start of the AMPL process if there has been no “reset;” yet;)

---

<div class="post-metadata">

**Author:** ![dmorill](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/dmorill/32/901_2.png) [@dmorill](https://discuss.ampl.com/u/dmorill)\
**Post date:** [April 6, 2024, 11:32pm UTC](https://discuss.ampl.com/t/re-ampl-25019-inquiry-regarding-discrepancy-in-solve-time-metrics/1037/2 "2024-04-06T23:32:42Z")

</div>

Thank you, but with this information, is there a variable that stores the time for loading the model into RAM?

Regards,

---

<div class="post-metadata">

**Author:** ![AMPL\_Google\_Group1](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@AMPL\_Google\_Group1](https://discuss.ampl.com/u/AMPL_Google_Group1)\
**Post date:** [April 8, 2024, 10:47am UTC](https://discuss.ampl.com/t/re-ampl-25019-inquiry-regarding-discrepancy-in-solve-time-metrics/1037/3 "2024-04-08T10:47:47Z")

</div>

AMPL only has builtin params for overall measures of solve time and AMPL time. However, some solvers have an option to provide a listing that gives more detailed times, such as the time to read in the AMPL problem file. If you’re interested in more details about that, let us know which solver(s) you are using.

---

<div class="post-metadata">

**Author:** ![dmorill](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/dmorill/32/901_2.png) [@dmorill](https://discuss.ampl.com/u/dmorill)\
**Post date:** [April 8, 2024, 2:54pm UTC](https://discuss.ampl.com/t/re-ampl-25019-inquiry-regarding-discrepancy-in-solve-time-metrics/1037/4 "2024-04-08T14:54:55Z")

</div>

Sure, I usually use Cplex and Gurobi for solving these linear models.

---

<div class="post-metadata">

**Author:** ![AMPL\_Google\_Group1](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@AMPL\_Google\_Group1](https://discuss.ampl.com/u/AMPL_Google_Group1)\
**Post date:** [April 10, 2024, 3:37pm UTC](https://discuss.ampl.com/t/re-ampl-25019-inquiry-regarding-discrepancy-in-solve-time-metrics/1037/5 "2024-04-10T15:37:28Z")

</div>

If you add **timing=1** to your cplex\_options or gurobi\_options string\*, you will get a listing of timings like this:

```auto
ampl: solve;
Gurobi 11.0.1: tech:timing = 1

NL model read time = 0.017579s
NL model conversion time = 0.005686s
Setup time = 0.026512s
Solution time = 0.116632s
Output time = 0.004045s

Gurobi 11.0.1: optimal solution; objective 235625
186 simplex iterations
12 branching nodes

```

NL model read time is for loading the optimization problem into the AMPL-Gurobi interface, NL model conversion time is for transforming to the formulation required by Gurobi, and setup time is for those plus loading the optimization problem into the Gurobi solver. These timings are not returned to AMPL, however, so you have to extract them from the listing.

Our most recent builds of CPLEX\*\* and Gurobi also recognize **reporttimes=1** in the cplex\_options or gurobi\_options string. After solving with this option, the total setup time and total solve time are displayed in the listing, and are also returned in the AMPL expressions ???.time\_setup and ???.time\_solver, where ??? is replaced by the name of your objective function.

- Defined by, for example,  
option gurobi\_options ‘timing=1 …’;  
where … is replaced by any other options you may be using.

\*\* Currently, use “option solver cplexmp;” to get the CPLEX version that has all the new features.

---

<div class="post-metadata">

**Author:** ![dmorill](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/dmorill/32/901_2.png) [@dmorill](https://discuss.ampl.com/u/dmorill)\
**Post date:** [April 17, 2024, 4:32pm UTC](https://discuss.ampl.com/t/re-ampl-25019-inquiry-regarding-discrepancy-in-solve-time-metrics/1037/6 "2024-04-17T16:32:30Z")

</div>

Thank you, it was what I was looking for.
