Documentation

GRBModel.AddGenConstrXxx()


GRBModel.AddGenConstrXxx()

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 (AddGenConstrMax): set a decision variable equal to the maximum value from among a set of decision variables
  • MIN (AddGenConstrMin): set a decision variable equal to the minimum value from among a set of decision variables
  • ABS (AddGenConstrAbs): set a decision variable equal to the absolute value of some other decision variable
  • AND (AddGenConstrAnd): set a binary variable equal to one if and only if all of a set of binary decision variables are equal to one
  • OR (AddGenConstrOr): 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 (AddGenConstrIndicator): whenever a given binary variable takes a certain value, then the given linear constraint must be satisfied
Please refer to this section for additional details on general constraints.




Subsections