# Speeding up running time

**URL:** <https://discuss.ampl.com/t/speeding-up-running-time/1028>\
**Category:** Support\
**Tags:** solvers, modeling\
**Created:** [April 4, 2024, 3:12pm UTC](https://discuss.ampl.com/t/speeding-up-running-time/1028 "2024-04-04T15:12:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sara\_Ghaboulian\_Zare](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/sara_ghaboulian_zare/32/724_2.png) [@Sara\_Ghaboulian\_Zare](https://discuss.ampl.com/u/Sara_Ghaboulian_Zare)\
**Post date:** [April 4, 2024, 3:12pm UTC](https://discuss.ampl.com/t/speeding-up-running-time/1028/1 "2024-04-04T15:12:28Z")

</div>

Hello,

I’m working on a large-scale LP problem in AMPL, structured as follows:

```auto
reset;
model ETEM.mod;
data _EtemData.txt;
data SAS_modification.txt;
option solver amplcplex;
option cplex_options 'display=1 clocktype=2 startalgorithm=4';
solve;

```

The problem has 2,615,940 variables and 2,368,400 constraints. To speed up the process, I’ve attempted several strategies:

1. Upgrading the computer’s hardware.
2. Switching the algorithm in CPLEX from 1 to 4 (barrier method).
3. Decreasing the number of variables and constraints.

Despite these efforts, it still requires 6 to 10 hours to complete. I’m seeking advice on reducing the computation time.

Could you suggest any methods to make it run faster? Additionally, would utilizing a warm start be beneficial, and if so, how can I generate a .dat file for a problem of this magnitude?

Thanks in advance for your assistance.

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [April 5, 2024, 5:30pm UTC](https://discuss.ampl.com/t/speeding-up-running-time/1028/2 "2024-04-05T17:30:25Z")

</div>

To be sure that you are getting complete log output from AMPL and CPLEX, use these options:

```auto
option show_stats 1;
option cplex_options 'display=1 bardisplay=1 mipdisplay=2 clocktype=2 startalgorithm=4';

```

Then copy all of the output into a text file, and attach the file to your reply. (To create an attachment, click on the upload icon in the Discourse editor window.)

---

<div class="post-metadata">

**Author:** ![Sara\_Ghaboulian\_Zare](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/sara_ghaboulian_zare/32/724_2.png) [@Sara\_Ghaboulian\_Zare](https://discuss.ampl.com/u/Sara_Ghaboulian_Zare)\
**Post date:** [April 7, 2024, 5:01pm UTC](https://discuss.ampl.com/t/speeding-up-running-time/1028/3 "2024-04-07T17:01:38Z")

</div>

[long-runnig-time.txt](https://discuss.ampl.com/uploads/short-url/yEyPt0vaP8LwIL5pxRhF5MPRB2S.txt) (1.9 KB)  
Hello,

Thank you for your advice. I’ve attached the initial part of the run, as it lasts about 8 hours and I’m not continuously connected to the server. Please inform me if additional information is required.

Additionally, I have a question regarding the warm start. I’ve experimented with various formats for the warm start file. Could you advise which format the variable values should follow:

1. `let VAR_COM ['1','H0','MTL', 'AGRTECH','LFO']:=0.006377`
2. `activity ['1','H0','MTL','AGRTECH'] := 0.339210`?

If you have any examples, could you kindly share them so I can understand the format better?

Thank you so much.

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [April 8, 2024, 11:58am UTC](https://discuss.ampl.com/t/speeding-up-running-time/1028/4 "2024-04-08T11:58:56Z")

</div>

Any of the methods of specifying data values for AMPL params can also be used to specify values for the variables — which will be used in a warmstart. Thus one possibility is to use “let” statements as in your option 1 (with a ; at the end of each statement). But that can get tedious; you can alternatively use, for example, the AMPL .dat file format, with the keyword “param” replaced by “var”.

Warmstarts are not as useful for linear programming as one might think, however, especially for the barrier method. So that we can provide more specific advice, can you also show the last 100 or so lines of the listing?

---

<div class="post-metadata">

**Author:** ![Sara\_Ghaboulian\_Zare](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/sara_ghaboulian_zare/32/724_2.png) [@Sara\_Ghaboulian\_Zare](https://discuss.ampl.com/u/Sara_Ghaboulian_Zare)\
**Post date:** [April 8, 2024, 9:40pm UTC](https://discuss.ampl.com/t/speeding-up-running-time/1028/5 "2024-04-08T21:40:51Z")

</div>

[long-run-2hrs.txt](https://discuss.ampl.com/uploads/short-url/cxTWBVr3zgFxM54Owm7Ct5JhyMZ.txt) (90.2 KB)

Fortunately, I could reduce running time to about 2 hrs, and I am still looking to reduce it more.

I have attached the full iterations.

I appreciate your guidance in this regard.

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [April 10, 2024, 4:16pm UTC](https://discuss.ampl.com/t/speeding-up-running-time/1028/6 "2024-04-10T16:16:20Z")

</div>

CPLEX is running the primal simplex, dual simplex, and barrier methods in parallel. It finishes with the message

```auto
Dual simplex solved model.

```

which means that that dual simplex method was the first one to find a solution. You can speed up the solve somewhat by specifying

```auto
option cplex_options "dualopt display=1 clocktype=2";

```

which avoids some system overhead by running only the dual simplex method. (Because you have no integer variables, the `mipdisplay=2` and `startalgorithm=4` options are ignored.)

Also try running with different settings of CPLEX’s `dgradient` option:

```auto
dgradient Pricing algorithm for dual simplex (default 0):
              0 = choose automatically
              1 = standard dual pricing
              2 = steepest-edge pricing
              3 = steepest-edge pricing in slack space
              4 = steepest-edge with unit initial norms
              5 = devex pricing.

```

These offer different tradeoffs between time per iteration and number of iterations, and sometimes one of them works substantially better than CPLEX’s automatic choice (which is the default).
