Additions, Changes, and Removals in Gurobi 14.0#
Release Highlights#
Gurobi 14.0 provides performance improvements across a variety of model families, including LP, MIP, and MINLP. No parameter settings or application code changes are necessary to benefit from these performance improvements. Detailed results will be posted on our website.
Two new MIP heuristics geared towards finding high-quality solutions quickly have been added to Gurobi 14: a PDHG-based heuristic with optional GPU acceleration, and a NoRel heuristic that is integrated with Gurobi’s branch-and-bound tree search.
Nonlinear objective functions and constraints are now first-class modeling entities in Gurobi 14.0. All APIs feature new methods and attributes for creation and modification of such nonlinear model components. Also, .NET languages now support expression-based nonlinear modeling.
New Features#
NoRel Tree Heuristic#
Gurobi’s popular NoRel heuristic is now integrated directly into the branch-and-bound tree search (“NoRel tree heuristic”). It is a more dynamic alternative to the standard NoRel heuristic, which runs prior to the root relaxation on a fixed budget (time, work, etc.).
Running the NoRel heuristic this way can be useful for models in which solving LP relaxations and processing search tree nodes is not too hard, but still finding high-quality solutions turns out to be difficult. Moreover, it can be useful for situations in which a tight time limit is in play and the goal is to find a solution within this time frame that is as good as possible.
You can control the effort spent in NoRel during the tree search through the newly introduced parameter NoRelTreeHeur. The existing NoRel heuristic and its controlling parameters are not influenced by this setting. Also, the NoRel tree heuristic is activated automatically if the high-level optimization strategy is set to emphasize finding feasible solutions (MIPFocus=1).
While activating this heuristic promotes finding high-quality solutions, the time for proving optimality of the solution may increase.
PDHG-Based MIP Heuristic#
In situations where the initial root node LP relaxation of a MIP takes a significant amount of time, you can try to use a newly added PDHG-based MIP heuristic. It runs prior to the solution of the root node LP relaxation and can compute high-quality MIP solutions based on relatively cheap PDHG iterations on the LP relaxation of the underlying MIP. Upon completion of this heuristic, the standard solve process follows suit, taking advantage of any incumbent solution that the PDHG-based MIP heuristic may have found.
You can use the parameters PDHGMIPHeurTime and PDHGMIPHeurWork to limit the time and work spent in this heuristic, and PDHGMIPHeurSolutions to stop the heuristic as soon as it has found the specified number of solutions. Note that this heuristic may also stop before it reaches any of the specified limits.
This heuristic can also benefit from GPU acceleration by running PDHG on the GPU; you can control this behavior through the PDHGGPU parameter.
PDHG Concurrent Crossover#
When solving an LP with PDHG, it is usually combined with a crossover step to eventually return a basic LP solution. Starting with Gurobi 14, multiple crossover threads run concurrently with the PDHG iterations, often reducing the total run time until an optimal basic solution is found.
Through the newly added parameter PDHGEarlyCrossover you can control how early into the PDHG iterations the concurrent crossover phase is started. Concurrent crossover is the new default. You can disable this new feature by setting the parameter to 0, reverting to the behavior of Gurobi 13.
Nonlinear Constraints and Objective#
Gurobi 14 introduces Nonlinear Constraints as a first-class modeling entity throughout the product. Unlike for the existing General Nonlinear constraints (which are deprecated in Gurobi 14), you can set constraint senses and right-hand side values through a set of newly added Nonlinear Constraint Attributes.
You can add, query, or delete nonlinear constraints by means of the following functions and methods:
C:
GRBaddnlconstr,GRBgetnlconstr,GRBgetnlconstrbyname,GRBdelnlconstrsC++:
GRBModel::addNLConstr,GRBModel::getNLConstr,GRBModel::getNLConstrs,GRBModel::getNLConstrByName,GRBModel::getNLConstrLHS,GRBModel::removeJava:
GRBModel.addNLConstr,GRBModel.getNLConstr,GRBModel.getNLConstrs,GRBModel.getNLConstrByName,GRBModel.getNLConstrLHS,GRBModel.remove.NET:
GRBModel.AddNLConstr,GRBModel.GetNLConstrs,GRBModel.GetNLConstrByName,GRBModel.GetNLConstrLHS,GRBModel.RemovePython:
Model.addNLConstr,Model.addNLConstrAdv,Model.getNLConstrs,Model.getNLConstrLHS,Model.getNLConstrLHSAdv,Model.removeMatlab: Nonlinear constraints can be specified as part of the model argument.
A new nonlinear constraint
object class (GRBNLConstr) has been added to the Python,
C++, Java, and
.NET APIs. Specific nonlinear
attributes can be queried and set on these objects using
the standard get/set methods.
Similarly you can now directly specify a nonlinear objective. New methods allow setting, querying, and deleting a nonlinear objective function specified as an expression tree:
C++:
GRBModel::setNLObj,GRBModel::getNLObj,GRBModel::delNLObjJava:
GRBModel.setNLObj,GRBModel.getNLObj,GRBModel.delNLObj.NET:
GRBModel.SetNLObj,GRBModel.GetNLObj,GRBModel.DelNLObjPython:
Model.setNLObj,Model.getNLObj,Model.delNLObjMatlab: A nonlinear objective can be specified as part of the model argument.
For details on the expression tree format, refer to Expression Trees. For details on nonlinear objectives, refer to Nonlinear Objectives.
Expression-based nonlinear modeling in .NET#
When using C# or Visual Basic you can now use expression-based modeling
patterns to build nonlinear constraints or objective functions. For example, if
x and y are GRBVar objects, then Sqrt(x), x /
y, Log(x) * x, and x * x * x all become GRBNLExpr
objects. Operations that have no corresponding C# operator (e.g., Sqrt,
Log, Logistic) are provided as static factory methods on this class.
Changes in gurobipy#
Nonlinear API#
gurobipy adopts the new Nonlinear Constraints type in version 14. In particular:
Model.setObjectivenow accepts nonlinear expressions, andModel.addConstrnow accepts nonlinear constraint expressions in any form and with any sense.
For example, you can add a constraint \(\tanh(x) \geq 0.1\) to a model by doing:
model.addConstr(nlfunc.tanh(x) >= 0.1)
If you are upgrading from a previous version, note that the constraint
type returned by Model.addConstr when applied to nonlinear
expression arguments will change. For example, in previous versions the
following code:
nlc = model.addConstr(y == nlfunc.sin(x))
created a general nonlinear constraint of the form y = sin(x), and returned a
GenConstr (or MGenConstr) object. In version 14 this code
creates an equivalent nonlinear constraint of the form y - sin(x) == 0, and
returns an NLConstr (or MNLConstr) object. The
underlying model is slightly different, and the returned object has a different
set of attributes.
We generally recommend using Model.setObjective and
Model.addConstr to build nonlinear models. The API will create the
appropriate constraint or objective type for the provided expression.
For more fine-grained control over nonlinear constraints, you can use:
the new methods
Model.addNLConstrandModel.addNLConstrAdvfor adding nonlinear constraints with a comparison operator and right-hand side; andthe new methods
Model.getNLConstrs,Model.getNLConstrLHS, andModel.getNLConstrLHSAdvfor querying nonlinear constraints.
For more fine-grained control over the separate quadratic and nonlinear components of the objective function, you can use:
the new methods
Model.setNLObj,Model.getNLObj, andModel.delNLObjfor managing nonlinear objectives; andthe new methods
Model.addQPTerms,Model.getQPTerms, andModel.delQPTermsfor managing quadratic objective terms separately from linear and nonlinear objective components.
Other Changes#
Model.cbUseSolutionnow returnsGRB.UNDEFINEDinstead ofGRB.INFINITYif no improved solution is found or the method has been called fromGRB.Callback.MIPorGRB.Callback.MIPSOL. Recall that setting a solution within aGRB.Callback.MIPorGRB.Callback.MIPSOLcallback only buffers the solution and processes it later. Therefore, when callingModel.cbUseSolutionin these cases, the solution cannot be checked for feasibility, and no objective value can be returned.All methods that take a file path as an argument now also accept a
pathlib.Pathobject (or anyos.PathLiketype).gurobipynow only installs a signal handler to catch CTRL-C interrupts for optimizations started from the main thread, matching Python’s own behavior. This avoids overriding Python’s signal handler when the optimizer is run on a background thread.
Changes to Other APIs#
GRBcbsolutionnow returnsGRB_UNDEFINEDinstead ofGRB_INFINITYif no improved solution is found or the routine has been called from a callback other thanGRB_CB_MIPNODE. Recall that setting a solution within aGRB_CB_MIPorGRB_CB_MIPSOLcallback only buffers the solution and processes it later. Therefore, the solution cannot be checked for feasibility and no objective value can be returned. Similar adjustments were made forC++,.NET, andJava.Java objects
GRBEnv,GRBModel, andGRBBatchnow implement theAutoCloseableinterface.
Other Notable Changes#
A new parameter OACuts was introduced to control generation of outer approximation cuts.
An MPS or LP file written by Gurobi now contains a comment “Note: variable lower bounds are 0 unless specified otherwise” in the Bounds section.
Two new parameters NLBarInitMu and NLBarStartPush were introduced to control the initial behavior of the NL barrier algorithm.
Default value for NLBarIterLimit was increased from 1000 to 10000.
When performing another presolve in a MIP solve, Gurobi now also prints the presolved model size after that additional presolve. So, a log could now look as follows with the additional “Presolved:” and “Variable types:” lines at the end:
Optimize a model with 143787 rows, 12502 columns and 358516 nonzeros (Max) Model fingerprint: 0xcc9adb3f Model has 605 linear objective coefficients Variable types: 0 continuous, 12502 integer (12502 binary) Coefficient statistics: Matrix range [1e+00, 4e+01] Objective range [1e+00, 4e+01] Bounds range [1e+00, 1e+00] RHS range [1e+00, 5e+03] Presolve removed 140063 rows and 11165 columns Presolve time: 0.07s Presolved: 3724 rows, 1337 columns, 12576 nonzeros Variable types: 0 continuous, 1337 integer (1337 binary) Performing another presolve... Presolve removed 3091 rows and 83 columns Presolve time: 0.02s Presolved: 633 rows, 1254 columns, 5009 nonzeros Variable types: 0 continuous, 1254 integer (1254 binary)
Gurobi would now use
lbzip2to compress and uncompress*.bz2files, if it finds this binary in the PATH. This tool uses parallel threads and is often much faster thanbzip2.The special meaning of value 1 for the SolutionLimit parameter has been removed. Previously, value 1 implicitly activated some additional heuristics that are good for finding a first feasible solution. This is now no longer the case. We decided that it is more important that any limit parameter, such as TimeLimit or NodeLimit, can only change the solution path at the moment when the limit is hit. From now on, setting SolutionLimit to 1 will not cause any change to the solution path either. In order to get closer to the behavior of previous Gurobi versions, you can activate these additional heuristics by setting the MIPFocus parameter to 1.
A new IsConvex attribute has been added to indicate whether the most recent optimization found the objective and constraints to be convex after presolve.
A new IsNLP attribute has been added to indicate whether the model contains any nonlinear constraint or objective.
The Gurobi Optimizer’s capacity to detect convexity has been extended to nonlinear models in some cases.
The new attributes PreCrossoverStatus, PreCrossoverX, and PreCrossoverPi are the preferred aliases for the deprecated attributes BarStatus, BarX, and BarPi. This name change clarifies that the attributes apply to any pre-crossover algorithm (both barrier and PDHG).
The
--printqualityoption of gurobi_cl now prints primal and dual residuals for continuous models in addition to violations.When tuning multi-objective models, you can now use the MIP gap as TuneCriterion. If a multi-objective model cannot be solved to optimality within the specified time limit, the tuner first compares parameter settings based on the number of objective passes that remain unsolved. If multiple settings leave the same number of objective passes unsolved, the tuner uses the MIP gap as a secondary criterion and favors the setting with the smaller gap.
Setting ConcurrentMethod to
4when using the concurrent LP solver now runs PDHG, dual simplex, and primal simplex.
Changes in Parameter Inheritance#
When creating a concurrent environment or a multi-objective environment all parameters are left at their default value, instead of their value being copied from the model environment. In addition, the automatic setting of the InheritParams parameter changed from 0 (don’t inherit) to 1 (do inherit). This change means that it no longer matters whether parameters in the model environment are changed before or after the supporting environment is created, as long as they are changed before the optimization is started. Refer to Inheritance of Parameter Values for more details.
Local optimization applicability#
With the introduction of the new nonlinear constraint API the support for General Nonlinear Constraints in local optimization (see OptimalityTarget parameter) has been removed.
Deprecated functionality#
If you are upgrading from a previous version of Gurobi, we recommend
first running your code with Gurobi 13 and warnings enabled to catch
deprecations in gurobipy. Fixing these deprecated usages will help
to keep compatibility for Gurobi 14 and later versions. Warnings can be
enabled by running your code with the -X dev or -W default
flags. See the Python Development
Mode or
warnings package
documentation for further details.
In Gurobi 14, the following usage is deprecated and will be removed in a future version:
Function constraints from our general constraints framework are deprecated. This includes:
functions and methods such as
addGenConstrExp(inC,C++,Java,.NET, andPython),addGenConstrLog(inC,C++,Java,.NET, andPython),addGenConstrNL(inC,C++,Java,.NET, andPython), etc.,the corresponding related attributes FuncPieceError, FuncPieceLength, FuncPieceRatio, FuncPieces, and FuncNonlinear,
parameters FuncPieceError, FuncPieceLength, FuncPieceRatio, FuncPieces, and FuncNonlinear.
Use nonlinear constraints instead: nlfunc helper functions in Python, or Expression Trees in C, C++, .NET, or Java.
The BarStatus, BarX, and BarPi attributes are deprecated. Use the equivalent attributes PreCrossoverStatus, PreCrossoverX, and PreCrossoverPi instead.
Removal of deprecated functionality#
Removals from gurobipy#
Wildcard matching of file paths in the
readandModel.readmethods has been removed.