gurobi | ( model ) |
gurobi | ( model, params ) |
This function optimizes the given model. The algorithm used for the optimization depends on the model type (simplex or barrier for a continuous model; branch-and-cut for a MIP model). Upon successful completion it will return a struct variable containing solution information.
Please consult Variables and Constraints section in the reference manual for a discussion of some of the practical issues associated with solving a precisely defined mathematical model using finite-precision floating-point arithmetic.
Arguments:
model: The model struct must contain a valid Gurobi model. See the model argument section for more information.
params: The params struct, when provided, contains a list of modified Gurobi parameters. See the params argument section for more information.
Example usage:
result = gurobi(model, params); if strcmp(result.status, 'OPTIMAL'); fprintf('Optimal objective: %e\n', result.objval); disp(result.x) else fprintf('Optimization returned status: %s\n', result.status); endReturn value:
The optimization result
The gurobi function returns a struct, with the various results of the optimization stored in its fields. The specific results that are available depend on the type of model that was solved, the parameters used, and the status of the optimization. The following is a list of fields that might be available in the returned result. We will discuss the circumstances under which each will be available after presenting the list.
Model fields
Variable fields
Linear constraint fields
Quadratic constraint fields
Solution Pool fields
What is Available When
The status field will be present in all cases. It indicates whether Gurobi was able to find a proven optimal solution to the model. In cases where a solution to the model was found, optimal or otherwise, the objval and x fields will be present.
For linear and quadratic programs, if a solution is available, then the pi and rc fields will also be present. For models with quadratic constraints, if the parameter qcpdual is set to 1, the field qcpi will be present. If the final solution is a basic solution (computed by simplex), then vbasis and cbasis will be present. If the model is an unbounded linear program and the InfUnbdInfo parameter is set to 1, the field unbdray will be present. Finally, if the model is an infeasible linear program and the InfUnbdInfo parameter is set to 1, the fields farkasdual and farkasproof will be set.
For mixed integer problems, no dual information (i.e. pi, slack, rc, vbasis, cbasis, qcslack, qcpi, ubdray or farkasdual) is ever available. When multiple solutions are found, the pool and poolobjbound fields will be present. Depending on the status field value, the fields nodecount, objbound, objbundc and mipgap will be available.
For continuous and mixed-integer models, under normal execution, the fields runtime, work, itercount and baritercount will be available.