pyomo using Gurobi with parameters

754 views
Skip to first unread message

xiwen

unread,
Sep 10, 2015, 4:53:12 PM9/10/15
to Pyomo Forum
Hi All,
I am using gurobi as a solver: 

self._opt_solver = coopr.opt.base.solvers.SolverFactory('gurobi')
I want to set the mipgap, and also the threads to use, can any one tell me how to do it?
I have tried:
self._opt_solver.options["mipgap"] = 0.05
self._opt_solver.options["Threads"]=12
But it looks not working.
thanks
xiwen

Gabriel Hackebeil

unread,
Sep 10, 2015, 6:40:14 PM9/10/15
to pyomo...@googlegroups.com
The following works for me.

options[“threads”]=4

If you add tee=True to the solve you should be able to verify this from Gurobi’s output. If that does not, work you might consider updating to the latest version of Pyomo.

Gabe

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

xiwen

unread,
Sep 11, 2015, 9:35:25 AM9/11/15
to Pyomo Forum
Hi Gabriel,
thanks

Below is my gurobi.log, looks like gurobi changes MIPGap = 0.05 and threads = 4.
But from gurobi.txt, i found
       message: Model was solved to optimality (subject to tolerances), and an optimal solution is available.
       objective: 33203254.0977
       gap: 0.0
To me, it looks gurobi stop when the gap = 0?
thanks
xiwen

~~~~~~~~~~~~~~~~~~~~log~~~~~~~~~~~~~~~~~~~~~~~~~
Solver command line: ['C:\\gurobi550\\win64\\bin\\gurobi.bat']

Read LP format model from file c:\\users\\richar~1\\appdata\\local\\temp\\2\\tmpivgz5z.pyomo.lp
Reading time = 0.51 seconds
(null): 135531 rows, 65811 columns, 271107 nonzeros
Optimize a model with 135531 rows, 65811 columns and 271107 nonzeros

Concurrent LP optimizer: dual simplex and barrier
Showing barrier log only...

Presolve removed 114111 rows and 57955 columns
Presolve time: 0.10s
Presolved: 21420 rows, 7856 columns, 46959 nonzeros

Ordering time: 0.00s

Barrier statistics:
 AA' NZ     : 8.333e+04
 Factor NZ  : 1.088e+05 (roughly 13 MBytes of memory)
 Factor Ops : 7.040e+05 (less than 1 second per iteration)
 Threads    : 1

                  Objective                Residual
Iter       Primal          Dual         Primal    Dual     Compl     Time
   0   1.14552733e+08 -6.74649395e+08  1.31e+05 5.56e+00  6.58e+05     0s
   1   9.58055676e+07 -3.54152176e+08  3.78e+04 2.45e+02  1.90e+05     0s
   2   9.58081766e+07 -1.91137390e+08  5.66e+03 3.94e+01  3.63e+04     0s
   3   8.73244174e+07 -6.96007313e+07  5.68e+02 1.28e+01  1.11e+04     0s
   4   6.63838418e+07  2.53867715e+06  9.89e+00 3.20e+00  3.03e+03     0s
   5   5.03466569e+07  1.50462602e+07  2.26e+00 1.80e+00  1.46e+03     0s
   6   4.49162210e+07  2.35089320e+07  1.22e+00 9.68e-01  8.00e+02     0s
   7   3.96912998e+07  2.79845813e+07  5.84e-01 4.93e-01  4.09e+02     0s
   8   3.61693123e+07  2.96189725e+07  2.34e-01 3.26e-01  2.24e+02     0s
   9   3.55666060e+07  3.01633116e+07  1.83e-01 2.73e-01  1.84e+02     0s
  10   3.45721150e+07  3.15842828e+07  1.01e-01 1.39e-01  9.96e+01     0s
  11   3.39459651e+07  3.21799681e+07  5.47e-02 8.35e-02  5.87e+01     0s
  12   3.35827505e+07  3.25999900e+07  2.75e-02 4.66e-02  3.26e+01     0s
  13   3.33817056e+07  3.28823269e+07  1.34e-02 2.29e-02  1.65e+01     0s
  14   3.33025291e+07  3.30333296e+07  7.66e-03 1.13e-02  8.82e+00     0s
  15   3.32565535e+07  3.31238257e+07  4.08e-03 5.15e-03  4.30e+00     0s
  16   3.32225926e+07  3.31693149e+07  1.52e-03 1.91e-03  1.72e+00     0s
  17   3.32103679e+07  3.31932602e+07  6.00e-04 4.60e-04  5.42e-01     0s
  18   3.32054229e+07  3.32008877e+07  1.77e-04 8.03e-05  1.41e-01     0s
  19   3.32035508e+07  3.32029814e+07  1.87e-05 1.67e-06  1.72e-02     0s
  20   3.32032975e+07  3.32031972e+07  2.46e-06 2.26e-07  3.04e-03     0s
  21   3.32032656e+07  3.32032412e+07  6.19e-07 3.94e-08  7.38e-04     0s
  22   3.32032544e+07  3.32032533e+07  1.01e-08 3.64e-10  3.34e-05     0s
  23   3.32032541e+07  3.32032541e+07  9.79e-11 1.72e-13  2.81e-09     0s

Barrier solved model in 23 iterations and 0.39 seconds
Optimal objective 3.32032541e+07

Crossover log...

       0 DPushes remaining with DInf 1.5813809e-12                 0s

      24 PPushes remaining with PInf 0.0000000e+00                 0s
       0 PPushes remaining with PInf 0.0000000e+00                 0s

  Push phase complete: Pinf 0.0000000e+00, Dinf 1.5813809e-12      0s

Iteration    Objective       Primal Inf.    Dual Inf.      Time
    1070    3.3203254e+07   0.000000e+00   0.000000e+00      0s
    1070    3.3203254e+07   0.000000e+00   0.000000e+00      0s

Solved with dual simplex
Solved in 13404 iterations and 0.57 seconds
Optimal objective  3.320325410e+07
Changed value of parameter QCPDual to 1
   Prev: 0   Min: 0   Max: 1   Default: 0
Changed value of parameter MIPGap to 0.05
   Prev: 0.0001   Min: 0.0   Max: 1e+100   Default: 0.0001
Parameter MIPGap unchanged
   Value: 0.05   Min: 0.0   Max: 1e+100   Default: 0.0001
Parameter MIPGap unchanged
   Value: 0.05   Min: 0.0   Max: 1e+100   Default: 0.0001
Changed value of parameter Threads to 4
   Prev: 0   Min: 0   Max: 16   Default: 0

Watson, Jean-Paul

unread,
Sep 11, 2015, 10:52:12 AM9/11/15
to pyomo...@googlegroups.com
At the bottom of the trace, you’l see that the options are actually being processed as you indicate. However, this is a linear (as opposed to mixed-integer) model – it was solved, apparently, by both barrier and dual simplex. Thus, there isn’t a gap; the mipgap parameter is not applicable.

jpw
Reply all
Reply to author
Forward
0 new messages