Search code examples
matlaboptimizationgurobi

Does Gurobi's Runtime attribute include time for the interface


I call Gurobi from some Matlab program to solve an optimization problem model with result = gurobi(model). From Gurobi's website, I get that with result.runtimeI obtain the

Runtime for the most recent optimization (in seconds). Note that all times reported by the Gurobi Optimizer are wall-clock times.

What exactly does runtime include? In particular, I want to know if it makes a difference, i.e. if there is some overhead in the communication from matlab to Gurobi which contributes to the runtime, if I read a model from an .mps-file and directly solve it, i.e.

model = gurobi_read(model.mps);
result = gurobi_read(model.mps);
time = result.runtime;

or if I do manipulations to the model before actually solving it, i.e.

model = gurobi_read(model.mps);
model.A(model.sense=='>',:) = -model.A(model.sense=='>',:);
model.rhs(model.sense=='>',:) = -model.rhs(model.sense=='>',:);
model.sense(model.sense=='>') = '<';
result = gurobi(model);
time = result.runtime;

Solution

  • The Runtime attribute reports the solve time only; it does not include any runtime from the APIs. Part of the reason for this is that all Gurobi interfaces are built on the C API, so the MATLAB interface obtains the runtime value from the C API, which does not know about any MATLAB overhead.