Gurobi Runtime属性是否包含Matlab与Gurobi的通信开销?
result.runtime in MATLAB Great question! Let me break down exactly what's included (and what's not) in the result.runtime value you get after calling result = gurobi(model) in MATLAB.
What result.runtime includes
This value represents the wall-clock time Gurobi's optimizer spends actively working on your problem. The timer starts the moment Gurobi fully receives and initializes your model, and stops when it finishes computing the solution and prepares to send results back. Specifically, it covers:
- Model preprocessing: Internal steps like constraint reduction, variable type inference, dual formulation conversions, and other prep work Gurobi does before starting the core solve.
- Core solver computation: The actual optimization work—whether that's branch-and-bound iterations for MIP problems, simplex/inner-point method calculations for LP/QP problems, or any other algorithmic steps to find a solution.
- Post-processing: Time spent generating final solution details (like basis information, dual values, or status flags) once the core solve completes.
What result.runtime does NOT include
Crucially, the communication overhead between MATLAB and Gurobi is not counted in this value:
- The timer doesn't start until Gurobi has fully received the model data from MATLAB, so the time to serialize your MATLAB model object and pass it to Gurobi's backend is excluded.
- Similarly, the time to send solved result data back from Gurobi to MATLAB isn't part of
result.runtimeeither.
Measuring total end-to-end time (including communication)
If you want to capture the full time from calling gurobi(model) to getting the result object in MATLAB (communication + solve time), use MATLAB's built-in timing tools:
tic; result = gurobi(model); total_end_to_end_time = toc;
This total_end_to_end_time accounts for all steps: model transfer, Gurobi's solve time (which matches result.runtime), and result transfer back to MATLAB.
内容的提问来源于stack exchange,提问作者Christoph Neumann

