Gurobi does not support strict inequality constraints like \( x < a \). Attempting to add a strict inequality constraint to a model through the Gurobi Python API will result in a `NotImplementedError` exception or an exception like the following:

`TypeError: '<' not supported between instances of 'Var' and 'int'.`

Instead, all constraints must be either non-strict inequality constraints like \( x \leq a \) or equality constraints like \( x = a \).

There are both theoretical and practical reasons why strict inequality constraints cannot be used in mathematical models:

- Strict inequality constraints define open sets, not closed sets. As a result, optimization problems that include strict inequality constraints may have no optimal solution.
- Due to floating-point numerics, solvers like Gurobi solve problems using tolerances. In practice, the constraint \( x < a \) is no different from the constraint \( x \leq a \). This is because two numbers that are extremely close to one another cannot be differentiated by machines using finite floating-point arithmetic.

If you really want to include a constraint that stipulates \( x \) is *strictly* less than \( a \), you must define the finite threshold that determines whether or not a number is effectively equal to \( a \). For example, you could model such an inequality constraint as \( x \leq a - 10^{-3} \). The exact size of this threshold (in this case, \( 10^{-3} \)) depends on the application. Would \( a - 10^{-3} \) be considered less than \( a \) in the context of your application? As this decision is heavily application dependent, Gurobi leaves it to the user to manually set this threshold in the model's constraints.

## Comments

0 comments

Article is closed for comments.