Each of the functions described below adds a new general constraint to a model.
Mathematical programming has traditionally defined a set of fundamental constraint types: variable bound constraints, linear constraints, quadratic constraints, integrality constraints, and SOS constraints. These are typically treated directly by the underlying solver (although not always), and are fundamental to the overall algorithm.
Gurobi accepts a number of additional constraint types, which we collectively refer to as general constraints. These are typically not treated directly by the solver. Rather, they are transformed by presolve into mathematically equivalent sets of constraints (and variables), chosen from among the fundamental types listed above. These general constraints are provided as a convenience to users. If such constraints appear in your model, but if you prefer to reformulate them yourself using fundamental constraint types instead, you can certainly do so. However, note that Gurobi can sometimes exploit information contained in the other constraints in the model to build a more efficient formulation than what you might create.
The additional constraint types that fall under this general constraint umbrella are:
- MAX (GRBaddgenconstrMax): set a decision variable equal to the maximum value from among a set of decision variables
- MIN (GRBaddgenconstrMin): set a decision variable equal to the minimum value from among a set of decision variables
- ABS (GRBaddgenconstrAbs): set a decision variable equal to the absolute value of some other decision variable
- AND (GRBaddgenconstrAnd): set a binary variable equal to one if and only if all of a set of binary decision variables are equal to one
- OR (GRBaddgenconstrOr): set a binary variable equal to one if and only if at least one variable out of a set of binary decision variables is equal to one
- INDICATOR (GRBaddgenconstrIndicator): a given binary variable may only take a certain value if a given linear constraint is satisfied