Try our new documentation site (beta).
Linear Constraints
A linear constraint allows you to restrict the value of a linear
expression. For example, you may require that any feasible solution
satisfies the constraint
. Note that the
matrix-oriented Gurobi APIs (C, MATLAB, and R) require the right-hand
side of a linear constraint to be a constant, while the
object-oriented APIs (C++, Java, .NET, and Python) allow arbitrary
linear expressions on both sides of the comparator.
The computed solution should satisfy the stated constraint to within FeasibilityTol (although it may not in cases of numerical ill-conditioning — we'll discuss this shortly).
Gurobi supports a limited set of comparators. Specifically, you can
constrain an expression to be less-than-or-equal,
greater-than-or-equal, or equal another. We do not support strict
less-than, strict greater-than, or not-equal comparators. While these
other comparators may seem appropriate for mathematical programming,
we exclude them to avoid potential confusion related to numerical
tolerances. Consider a simple example of a strict inequality
constraint on a pair of continuous variables: . How large
would
need to be in order to satisfy the constraint? Rather
than trying to embed a subtle and potentially confusing strategy for
handling such constraints into the solver, we've chosen not to support
them instead.
![](/wp-content/plugins/hd_documentations/content/images/documentation-ampl-guide.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-cloud.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-example-tour.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-quick-start.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-reference-manuals.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/documentation-remote-services.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/quickstart-os-linux.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/quickstart-os-mac-osx.webp?x70725)
![](/wp-content/plugins/hd_documentations/content/images/quickstart-os-windows.webp?x70725)