Parameters
Parameters control the operation of the Gurobi engines. They should be modified before the optimization begins. While you should feel free to experiment with different parameter settings, we recommend that you leave parameters at their default settings unless you find a compelling reason not to. This section begins with a discussion of how parameters are adjusted.
Parameter names are represented using strings in the Gurobi APIs. The case of the string is ignored, as are underscores. Thus, TIME_LIMIT and TimeLimit are equivalent. The Gurobi language APIs all provide a set of pre-defined constants or enums that can be used to refer to the parameters without using hard-coded strings. The pre-defined names vary from language to language, in order to better conform to the conventions of the language.
In the C interface, the symbolic constant for each parameter name is prefixed by GRB_type_PAR_, where type is either INT or DBL. For example, the constant definition for the Threads parameter (found in C header file gurobi_c.h) is:
#define GRB_INT_PAR_THREADS "Threads"
In the C++ interface, parameters are grouped by datatype into two enums: GRB_DoubleParam and GRB_IntParam. You refer to a specific parameter by appending the parameter name to the enum name. For example, the Threads parameter is GRB_IntParam_Threads.
In the Java interface, parameters are also grouped by datatype into two enums: GRB.DoubleParam and GRB.IntParam. You would refer to the Threads parameter as GRB.IntParam.Threads.
In the Python interface, parameters are listed as constants within the GRB.Param class. You would refer to the Threads parameter as GRB.Param.Threads.
To give another example, the MIPGap parameter would be referred to in the different interfaces as:
| Language | Parameter |
|---|---|
| C | GRB_DBL_PAR_MIPGAP |
| C++ | GRB_DoubleParam_MIPGap |
| Java | GRB.DoubleParam.MIPGap |
| Python | GRB.Param.MIPGap |
The available parameters are as follows:
Termination: These parameters affect the termination of the algorithms. If the algorithm exceeds any of these limits, it will terminate and report a non-optimal termination status (see the Status Code section for further details).
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| Cutoff | double | Infinity for minimization, -Infinity for maximization | -Infinity | Infinity | Sets a target objective value; optimization will terminate if the engine determines that the optimal objective value for the model is worse than the specified cutoff. |
| IterationLimit | double | Infinity | 0 | Infinity | Limits the number of simplex iterations performed. |
| NodeLimit | double | Infinity | 0 | Infinity | Limits the number of MIP nodes explored (MIP only). |
| SolutionLimit | int | Infinity | 1 | Infinity | Limits the number of feasible solutions found (MIP only). |
| TimeLimit | double | Infinity | 0 | Infinity | Limits the total time expended (in seconds). |
Tolerances: These parameters control the allowable feasibility or optimality violations.
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| FeasibilityTol | double | 1e-6 | 1e-9 | 1e-2 | Primal feasibility tolerance. All constraints must be satisfied to a tolerance of FeasibilityTol. |
| IntFeasTol | double | 1e-5 | 1e-9 | 1e-1 | Integer feasibility tolerance (MIP only). An integrality restriction on a variable is considered satisfied when the variable's value is less than INTFEASTOL from the nearest integer value. |
| MarkowitzTol | double | 0.0078125 | 1e-4 | 0.999 | Threshold pivoting tolerance. Used to limit numerical error in the simplex algorithm. A larger value may avoid numerical problems in rare situations, but it will also harm performance. |
| MIPGap | double | 1e-4 | 0.0 | Infinity | Relative MIP optimality gap (MIP only). The MIP engine will terminate (with an optimal result) when the gap between the lower and upper objective bound is less than MIPGap times the upper bound. |
| OptimalityTol | double | 1e-6 | 1e-9 | 1e-2 | Dual feasibility tolerance. Reduced costs must all be smaller than OptimalityTol in the improving direction in order for a model to be declared optimal. |
Simplex: These parameters control the operation of the simplex algorithms.
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| LPMethod | int | 1 | 0 | 1 | Simplex algorithm (0=primal, 1=dual). The selected algorithm is used when solving continuous models, and when solving node relaxations within the MIP solver. |
| NormAdjust | int | -1 | -1 | 3 | Chooses from among multiple pricing norm variants. The default value of -1 chooses automatically. |
| ObjScale | double | 0.0 | -1 | Infinity | Divides the model objective by the specified value to avoid numerical errors that may result from very large objective coefficients. The default value of 0 decides on the scaling automatically. A value less than zero uses the maximum coefficient to the specified power as the scaling (so ObjScale=-0.5 would scale by the square root of the largest objective coefficient). |
| PerturbValue | double | 0.0002 | 0 | 0.01 | Magnitude of simplex perturbation (when required). |
| Quad | int | -1 | -1 | 1 | Enables or disables quad precision computation in simplex. The -1 default setting allows the algorithm to decide. |
| ScaleFlag | int | 1 | 0 | 1 | Enables or disables model scaling. |
| SimplexPricing | int | -1 | -1 | 3 | Determines simplex variable pricing strategy. Available options are Automatic (-1), Partial Pricing (0), Steepest Edge (1), Devex (2), and Quick-Start Steepest Edge (3). |
MIP: These parameters control the operation of the MIP algorithms.
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| Heuristics | double | 0.05 | 0.0 | 1.0 | Controls the amount of time spent in MIP heuristics. Larger values produce more and better feasible solutions, at a cost of slower progress in the best bound. |
| NodefileDir | string | "." | Determines the directory into which nodes are written when node memory usage exceeds the specified NodefileStart value. | ||
| NodefileStart | double | Infinity | 0.0 | Infinity | Controls the point at which MIP tree nodes are written to disk. Whenever node storage exceeds the specified value (in GBytes), nodes are written to disk. |
| RootMethod | int | 1 | 0 | 1 | Simplex algorithm used for MIP root relaxation (0=primal, 1=dual). |
| SubMIPNodes | int | 500 | 0 | Infinity | Limits the number of nodes explored by the RINS heuristic. Exploring more nodes can produce better solutions, but it generally takes longer. |
| VarBranch | int | -1 | -1 | 3 | Controls the branch variable selection strategy. The default -1 setting makes an automatic choice, depending on problem characteristics. Available alternatives are Pseudo Reduced Cost Branching (0), Pseudo Shadow Price Branching (1), Maximum Infeasibility Branching (2), and Strong Branching (3). |
MIP Cuts: These parameters affect the generation of MIP cutting planes. In all cases, a value of -1 corresponds to an automatic setting, which allows the solver to determine the appropriate level of aggressiveness in the cut generation. Unless otherwise noted, settings of 0, 1, and 2 correspond to no cut generation, conservative cut generation, or aggressive cut generation, respectively. The Cuts parameter provides global cut control, affecting the generation of all cuts. This parameter also has a setting of 3, which corresponds to very aggressive cut generation. The other parameters override the global Cuts parameter (so setting Cuts to 2 and CliqueCuts to 0 would generate all cut types aggressively, except clique cuts which would not be generated at all).
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| Cuts | int | -1 | -1 | 3 | Global cut generation control. |
| CliqueCuts | int | -1 | -1 | 2 | Controls clique cut generation. Overrides the Cuts parameter. |
| CoverCuts | int | -1 | -1 | 2 | Controls cover cut generation. Overrides the Cuts parameter. |
| FlowCoverCuts | int | -1 | -1 | 2 | Controls flow cover cut generation. Overrides the Cuts parameter. |
| FlowPathCuts | int | -1 | -1 | 2 | Controls flow path cut generation. Overrides the Cuts parameter. |
| GUBCoverCuts | int | -1 | -1 | 2 | Controls GUB cover cut generation. Overrides the Cuts parameter. |
| ImpliedCuts | int | -1 | -1 | 2 | Controls implied bound cut generation. Overrides the Cuts parameter. |
| MIPSepCuts | int | -1 | -1 | 2 | Controls MIP separation cut generation. Overrides the Cuts parameter. |
| MIRCuts | int | -1 | -1 | 2 | Controls MIR cut generation. Overrides the Cuts parameter. |
| ZeroHalfCuts | int | -1 | -1 | 2 | Controls zero-half cut generation. Overrides the Cuts parameter. |
| CutAggPasses | int | -1 | -1 | Infinity | A non-negative value indicates the maximum number of constraint aggregation passes performed during cut generation. Overrides the Cuts parameter. |
| GomoryPasses | int | -1 | -1 | Infinity | A non-negative value indicates the maximum number of Gomory cut passes performed. Overrides the Cuts parameter. |
Other: Other parameters.
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| Aggregate | int | 1 | 0 | 1 | Enables or disables aggregation in presolve. In rare instances, aggregation can lead to an accumulation of numerical errors. Turning it off can sometimes improve solution accuracy. |
| DisplayInterval | int | 5 | 1 | Infinity | Controls the frequency at which log lines are printed (in seconds). |
| IISMethod | int | -1 | -1 | 1 | Chooses the IIS method to use. Method 0 is often faster, while method 1 can produce a smaller IIS. The default value of -1 chooses automatically. |
| LogfileName | string | "" | Determines the name of the Gurobi log file. Modifying this parameter closes the current log file and opens the specified file. | ||
| OutputFlag | int | 1 | 0 | 1 | Enables or disables engine output. |
| PreCrush | int | 0 | 0 | 1 | Allows presolve to translate constraints on the original model to equivalent constraints on the presolved model. Turn this parameter on when you are using callbacks to add your own cuts. |
| Presolve | int | -1 | -1 | 2 | Controls the presolve level. A value of -1 corresponds to an automatic setting. Other options are off (0), conservative (1), or aggressive (2). |
| Threads | int | 0 | 0 | NProc | Controls the number of threads to apply to parallel MIP. The default value of 0 sets the thread count equal to the maximum value, which is the number of processors in the machine. |
Subsections
