The params argument

The params argument

As mentioned previously, the Gurobi optimizer provides a set of parameters that allow you to control many of the details of the optimization process. Factors like feasibility and optimality tolerances, choices of algorithms, strategies for exploring the MIP search tree, etc., can be controlled by modifying Gurobi parameters before beginning the optimization.

Parameter changes are specified using a struct variable having multiple fields, which is passed as an argument to the appropriate Gurobi function (e.g., gurobi). The name of each field must be the name of a Gurobi parameter, and the associated value should be the desired value of that parameter. You can find a complete list of the available Gurobi parameters here.

To create a struct that would set the Gurobi Method parameter to 2 and the ResultFile parameter to model.mps, you would do the following:

params.Method = 2;
params.ResultFile = 'model.mps';

We should say a bit more about the ResultFile parameter. If this parameter is set, the optimization model that is eventually passed to Gurobi will also be output to the specified file. The filename suffix should be one of .mps, .lp, .rew, or .rlp, to indicate the desired file format (see the file format section for details on Gurobi file formats).