Parameters control the operation of the Gurobi solvers. They must 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. For a discussion of when you might want to change parameter values, refer to our Parameter Guidelines.
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, DBL, or STR. 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 three enums: GRB_DoubleParam, GRB_IntParam, and GRB_StringParam. 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 and .NET interfaces, parameters are also grouped by datatype into three enums: GRB.DoubleParam, GRB.IntParam, and GRB.StringParam. 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 |
| .NET | 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 |
|---|---|---|---|---|---|
| BarIterLimit | int | Infinity | 0 | Infinity | Limits the number of barrier iterations performed (barrier only). |
| Cutoff | double | Infinity for minimization, -Infinity for maximization | -Infinity | Infinity | Indicates that you aren't interested in solutions whose objective values are worse than the specified value. If the objective value for the optimal solution is better than the specified cutoff, the solver will return the optimal solution. Otherwise, it will terminate with a Cutoff status. |
| 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). Note that all runtimes in the Gurobi Optimizer are wall-clock times. |
Tolerances: These parameters control the allowable feasibility or optimality violations.
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| BarConvTol | double | 1e-8 | 1e-10 | 1.0 | Barrier convergence tolerance (barrier only). The barrier solver terminates when the relative difference between the primal and dual objective values is less than the specified tolerance. |
| 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 solver will terminate (with an optimal result) when the relative gap between the lower and upper objective bound is less than MIPGap times the upper bound. |
| MIPGapAbs | double | 1e-10 | 0.0 | Infinity | Absolute MIP optimality gap (MIP only). The MIP solver will terminate (with an optimal result) when the absolute gap between the lower and upper objective bound is less than MIPGapAbs. |
| 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. |
| PSDTol | double | 1e-6 | 0 | GRB_INFINITY | Positive semi-definite tolerance (QP/MIQP only). Sets a limit on the amount of diagonal perturbation that the optimizer is allowed to perform on the Q matrix in order to correct minor PSD violations. If a larger perturbation is required, the optimizer will terminate with a GRB_ERROR_Q_NOT_PSD error. |
Simplex: These parameters control the operation of the simplex algorithms.
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| InfUnbdInfo | int | 0 | 0 | 1 | Determines whether simplex (and crossover) will compute additional information when a model is determined to be infeasible or unbounded. Set this parameter if you want to query the unbounded ray for unbounded models (through the GRB_DBL_ATTR_UNBDRAY attribute), or the infeasibility proof for infeasible models (through the GRB_DBL_ATTR_FARKASDUAL and GRB_DBL_ATTR_FARKASPROOF attributes). |
| 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. |
| Sifting | int | -1 | -1 | 2 | Enables or disables sifting within dual simplex. Sifting is often useful for LP models where the number of variables is many times larger than the number of constraints. Options are Automatic (-1), Off (0), Moderate (1), and Aggressive (2). With a Moderate setting, sifting will be applied to LP models and to the root node for MIP models. With an Aggressive setting, sifting will be applied any time dual simplex is used, including at the nodes of a MIP. Note that this parameter has no effect if you aren't using dual simplex. Note also that sifting will be skipped in cases where it is obviously a worse choice than dual simplex, even when sifting has been selected. |
| SiftMethod | int | -1 | -1 | 2 | LP method used to solve sifting sub-problems. Options are Automatic (-1), Primal Simplex (0), Dual Simplex (1), and Barrier (2). Note that this parameter only has an effect when you are using dual simplex and sifting has been selected (either by the automatic method, or through the Sifting parameter). |
| SimplexPricing | int | -1 | -1 | 3 | Determines the simplex variable pricing strategy. Available options are Automatic (-1), Partial Pricing (0), Steepest Edge (1), Devex (2), and Quick-Start Steepest Edge (3). |
Barrier: These parameters control the operation of the barrier solver.
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| BarCorrectors | int | -1 | -1 | Infinity | Limits the number of central corrections performed in each barrier iteration. The default value chooses automatically, depending on problem characteristics. |
| BarOrder | int | -1 | -1 | 1 | Chooses the barrier sparse matrix fill-reducing algorithm. A value of 0 chooses Approximate Minimum Degree ordering, while a value of 1 chooses Nested Dissection ordering. The default value of -1 chooses automatically. |
| Crossover | int | -1 | -1 | 4 | Determines the crossover strategy used to transform the barrier solution into a basic solution (note that crossover is not available for QP models). Use value 0 to disable crossover; the solver will return an interior solution. Other options control whether the crossover algorithm tries to push primal or dual variables to bounds first, and then which simplex algorithm is used once variable pushing is complete. Options 1 and 2 push dual variables first, then primal variables. Option 1 finishes with primal, while option 2 finishes with dual. Options 3 and 4 push primal variables first, then dual variables. Option 3 finishes with primal, while option 4 finishes with dual. The default value of -1 chooses automatically. |
| CrossoverBasis | int | 0 | 0 | 1 | Determines the initial basis construction strategy for crossover. The default value (0) chooses an initial basis quickly. A value of 1 can take much longer, but often produces a more numerically stable start basis. |
MIP: These parameters control the operation of the MIP algorithms.
| Parameter name | Type | Default | Min | Max | Description |
|---|---|---|---|---|---|
| BranchDir | int | 0 | -1 | 1 | Determines which child node is explored first in the branch-and-cut search. The default value chooses automatically. A value of -1 will always explore the down branch first, while a value of 1 will always explore the up branch first. |
| 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. |
| ImproveStartGap | double | 0.0 | 0.0 | GRB_INFINITY | The MIP solver can change parameter settings in the middle of the search in order to adopt a strategy that gives up on moving the best bound and instead devotes all of its effort towards finding better feasible solutions. This parameter allows you to specify an optimality gap at which the MIP solver will switch to this strategy. For example, setting this parameter to 0.1 will cause the MIP solver to switch once the relative optimality gap is smaller than 0.1. |
| ImproveStartTime | double | GRB_INFINITY | 0.0 | GRB_INFINITY | The MIP solver can change parameter settings in the middle of the search in order to adopt a strategy that gives up on moving the best bound and instead devotes all of its effort towards finding better feasible solutions. This parameter allows you to specify a time limit when the MIP solver will switch to this strategy. For example, setting this parameter to 10 will cause the MIP solver to switch 10 seconds after starting the optimization. |
| MinRelNodes | int | 0 | 0 | Infinity | Number of nodes to explore in the Minimum Relaxation heuristic. Note that this heuristic is only applied at the end of the MIP root, and only when no other root heuristic finds a feasible solution. |
| MIPFocus | int | 0 | 0 | 3 | Controls the focus of the MIP solver. The default value tries to strike a balance between finding good feasible solutions and proving optimality. A value of 1 shifts the focus towards finding feasible solutions. A value of 2 shifts the focus towards proving optimality. A value of 3 focuses almost entirely on moving the best objective 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. |
| NodeMethod | int | 1 | 0 | 2 | Algorithm used for MIP node relaxations (0=primal simplex, 1=dual simplex, 2=barrier). Note that barrier is not an option for MIQP node relaxations. |
| PumpPasses | int | 0 | 0 | Infinity | Number of passes of the feasibility pump heuristic. Note that this heuristic is only applied at the end of the MIP root, and only when no other root heuristic finds a feasible solution. |
| RINS | int | -1 | -1 | Infinity | Frequency of the RINS heuristic. Default value (-1) chooses automatically. A value of 0 shuts off RINS. A positive value n applies RINS at every n-th node of the MIP search tree. |
| SolutionNumber | int | 0 | 0 | Infinity | When querying attribute Xn to retrieve an alternate MIP solution, this parameter determines which alternate solution is retrieved. The value of this parameter should be less than the value of the SolutionCount attribute. |
| 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. |
| Symmetry | int | -1 | 2 | -1 | Controls MIP symmetry detection. A value of -1 corresponds to an automatic setting. Other options are off (0), conservative (1), or aggressive (2). |
| 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). |
| ZeroObjNodes | int | 0 | 0 | Infinity | Number of nodes to explore in the zero objective heuristic. Note that this heuristic is only applied at the end of the MIP root, and only when no other root heuristic finds a feasible solution. |
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. |
| ModKCuts | int | -1 | -1 | 2 | Controls mod-k cut generation. Overrides the Cuts parameter. |
| NetworkCuts | int | -1 | -1 | 2 | Controls network cut generation. Overrides the Cuts parameter. |
| SubMIPCuts | int | -1 | -1 | 2 | Controls sub-MIP 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. |
| CutPasses | int | -1 | -1 | Infinity | A non-negative value indicates the maximum number of cutting plane passes performed during root cut generation. The default value chooses the number of cut passes automatically. |
| 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 |
|---|---|---|---|---|---|
| AggFill | int | 10 | 0 | Infinity | Controls the amount of fill allowed during presolve aggregation. Larger values generally lead to presolved models with fewer rows and columns, but with more constraint matrix non-zeros. |
| 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. |
| LogFile | string | "" | Determines the name of the Gurobi log file. Modifying this parameter closes the current log file and opens the specified file. | ||
| Method | int | -1 | -1 | 4 | Algorithm used to solve continuous models or the root node of a MIP model (-1=automatic, 0=primal simplex, 1=dual simplex, 2=barrier, 3=concurrent, 4=deterministic concurrent). Concurrent optimizers run multiple solvers on multiple threads simultaneously, and choose the one that finishes first. Deterministic concurrent (Method=4) gives the exact same result each time, while Method=3 is often faster but can produce different optimal bases when run multiple times. In the current release, the default Automatic (-1) will typically choose non-deterministic concurrent (Method=3) for an LP, barrier (Method=2) for a QP, and dual (Method=1) for the MIP root node. Only simplex and barrier algorithms are available for continuous QP models. Only primal and dual simplex are available for solving the root of an MIQP model. |
| OutputFlag | int | 1 | 0 | 1 | Enables or disables solver 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. |
| PreDepRow | int | -1 | -1 | 1 | Controls the presolve dependent row reduction, which eliminates linearly dependent constraints from the constraint matrix. The default setting (-1) applies the reduction to continuous models but not to MIP models. Setting 0 turns the reduction off for all models. Setting 1 turns it on for all models. |
| PreDual | int | -1 | -1 | 2 | Controls whether presolve forms the dual of a continuous model. Depending on the structure of the model, solving the dual can reduce overall solution time. The default setting uses a heuristic to decide. Setting 0 forbids presolve from forming the dual, while setting 1 forces it to take the dual. Setting 2 employs a more expensive heuristic that forms both the presolved primal and dual models (on two threads), and heuristically chooses one of them. |
| PreMIQPMethod | int | -1 | -1 | 1 | Chooses the transformation presolve performs on MIQP models. Option 1 attempts to transform the model into an MILP. Option 0 always leaves the model as an MIQP. The default setting (-1) chooses automatically. |
| PrePasses | int | -1 | -1 | Infinity | Limits the number of passes performed by presolve. The default setting (-1) chooses the number of passes automatically. |
| 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). |
| PreSparsify | int | 0 | 0 | 1 | Enables the presolve sparsify reduction for MIP models. This reduction can sometimes significantly reduce the number of nonzero values in the presolved model. |
| ResultFile | string | "" | Specifies the name of the result file to be written upon completion of optimization. The type of the result file is determined by the file suffix. Possible suffixes are .sol (the solution vector), .bas (the simplex basis), or .mst (the solution vector on the integer variables). More information on the file formats can be found in the File Format section. | ||
| Threads | int | 0 | 0 | NProc | Controls the number of threads to apply to parallel barrier or parallel MIP. The default value of 0 sets the thread count equal to the maximum value, which is the number of logical cores in the machine. |