Access Gurobi Work Time

I’m solving a linear problem with amplpy and gurobi. As shown below, the work time (cpu time) required by Gurobi is 0.12 seconds. However, the times I get from ampl (solve_time, etc) are different. Is there a way to access the work time reported by Gurobi?

solve_time= 0.560407
solve_user_time = 0.5321859999999999
ampl_elapsed_time = 0.7073279999999997
solve_elapsed_time = 0.5976950000000001

Gurobi Optimizer version 10.0.1 build v10.0.1rc0 (linux64)

CPU model: Intel(R) Xeon(R) Gold 6230R CPU @ 2.10GHz, instruction set [SSE2|AVX|AVX2|AVX512]
Thread count: 52 physical cores, 52 logical processors, using up to 1 threads

Optimize a model with 200 rows, 1000 columns and 200000 nonzeros
Model fingerprint: 0x1df715c0
Coefficient statistics:
Matrix range [2e-05, 2e+01]
Objective range [1e-03, 3e+00]
Bounds range [2e-03, 2e+01]
RHS range [8e-01, 3e+01]
Presolve time: 0.05s
Presolved: 200 rows, 1000 columns, 200000 nonzeros

Iteration Objective Primal Inf. Dual Inf. Time
0 -4.2643980e+05 4.652726e+07 0.000000e+00 0s
424 -2.2936302e+03 0.000000e+00 0.000000e+00 0s

Solved in 424 iterations and 0.12 seconds (0.19 work units)
Optimal objective -2.293630200e+03

1 Like

Hi @salvapineda,

We have just released Gurobi 20240311 (GUROBI Changelog — AMPL Resources) and this version adds the option `tech:reportwork` (GUROBI Options — AMPL Resources) that when set to 1, returns the work ammount reported by Gurobi as a problem suffix (If you don’t have problem definitions, the default problem is `Initial`).

You can use this feature as follows:

``````ampl = AMPL()
...
ampl.solve(solver="gurobi", gurobi_options="outlev=1 tech:reportwork=1")
print("Work:", ampl.get_value("Initial.work"))
``````

Please let us know if you encounter any issues using it!