Gurobi versions 12.0 and later can solve models with linear constraints, quadratic constraints (both convex and non-convex), second-order cone constraints, and multivariate composite nonlinear function constraints. This can involve any combination of continuous and integer variables. The canonical form is:
$$\begin{alignat}{3} \min_x\ x^\top Q x + c^\top x &+ d && && \textrm{(Objective)} \\ \textrm{s.t.} \qquad\qquad\enspace Ax &= b && && \textrm{(Linear constraints)} \\x^\top Q_i x + c_i^\top x &\le d_i && \forall i \in I && \textrm{(Quadratic constraints)} \\ f_j(x) &= 0 && \forall j \in J && \textrm{(Nonlinear constraints)} \\ \ell \le x &\le u && && \textrm{(Bound constraints)} \\ x_k &\in \mathbb{Z} && \forall k \in K && \textrm{(Integrality constraints)} \\ x_h &\in \textrm{second-order cones} \quad && \forall h \in H && \textrm{(Cone constraints)} \\ x_m &\in \textrm{SOS} && \forall m \in M \qquad && \textrm{(Special-ordered set constraints)} \end{alignat}$$
Not all elements are required. For instance, if \( Q = 0 \) and \( I = J = H = \emptyset \), then the model is a mixed-integer linear program (MILP).
Version-specific information
Non-convex models
Starting with 9.0, Gurobi supports general non-convex quadratic constraints and objective functions, including bilinear and quadratic equality constraints. Quadratic matrices \( Q \) and \( Q_i \) are not required to be positive semi-definite with versions 9.0 and higher.
However, non-convex models are typically harder to solve than convex models. If possible, consider reformulating the model into a convex problem.
Changes with 11.0
In versions prior to 11.0, the NonConvex parameter had to be set to 2 to enable optimization for problems with non-convex constraints or objective function. From version 11.0 onwards, the behavior of the NonConvex parameter changed, and non-convex models can be solved leaving this parameter at default. For full details, see the Quadratic Constraints section of the reference manual.
Nonlinear constraints
Versions up to 11.0
In versions up to Gurobi 11.0, nonlinear functions could only be used to set one variable equal to a nonlinear function of one other variable using Function Constraints.
Changes with 12.0
Gurobi 12.0 introduced nonlinear constraints, with nlfunc helper functions in Python, or Expression Trees in C, C++, .NET or Java. Nonlinear constraints allow including multivariate composite nonlinear functions \( f_j \) in the canonical form above.
Function constraints
Changes with 11.0
Starting with Gurobi 11.0, Function Constraints could be treated exactly by setting the FuncNonlinear parameter to 1 or the FuncNonlinear attribute of the respective function constraint to 1 (see Function Constraints with Dynamic Piecewise-Linear Approximation). Before Gurobi 11.0, the functions constraints were approximated with piecewise-linear constraints (see Function Constraints with Static Piecewise-Linear Approximation).
Changes with 12.0
Starting with Gurobi 12.0, Dynamic Piecewise-Linear Approximation is the default behavior to treat function constraints.
Changes with 13.0
Starting with Gurobi 13.0, Function Constraints are deprecated. We recommend using Nonlinear constraints instead.
Details on deprecated functionality related to Function Constraints starting with Gurobi 13.0:
- Functions and methods such as:
addGenConstrExp(inC,C++,Java,.NETandPython),addGenConstrLog(inC,C++,Java,.NETandPython), etc. - Attributes: FuncPieceError, FuncPieceLength, FuncPieceRatio, FuncPieces, FuncNonlinear.
- Parameters: FuncPieceError, FuncPieceLength, FuncPieceRatio, FuncPieces, FuncNonlinear.