2
$\begingroup$

I would like to seek some advice on the following:

I am currently using Pyomo to generate my MILP model in Pyomo and solve it using Gurobi, respectively.

As the solution process is iterative, I would like to enquire on how to obtain the following timings for each iteration:

  1. the time to build the Pyomo model
  2. the time to translate the Pyomo model into the format used by the solver
  3. the time spent inside the solver, i.e., the solution time
  4. the time spent loading the solver solution back into Pyomo.

Thank you!

$\endgroup$
1
$\begingroup$

For timing within the gurobi solver, maybe you can call <optimizer>.solve() method with report_timing=True, as described in pyomo's documentation at https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gurobi_persistent.html

I haven't used Gurobi before. If gurboipy logs the starting and ending time of the optimization, then you can manually time the start and end of your whole program. That would give you 4 and 1 + 2.

I think importing python library is slow. You can exclude the time for importing libraries.

I don't know how to split 1 and 2 at the moment.

$\endgroup$
4
  • $\begingroup$ Thanks, but this is jus echoing the output to the screen, besides I am not using the 'gurobi_persistent' for the solver factory. I am just using 'gurobi' for the solver factory $\endgroup$
    – Mike
    Jun 29 at 8:06
  • $\begingroup$ capture stdout and extract the timing. $\endgroup$ Jun 29 at 12:44
  • $\begingroup$ groups.google.com/g/pyomo-forum/c/ajoPqgmJ0rQ?pli=1 $\endgroup$ Jun 29 at 13:59
  • $\begingroup$ Thanks, but I am not sure if it is of any help, as I would like to log it down programmatically into dictionary with with keys being that of each iteration number. $\endgroup$
    – Mike
    Jun 29 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.