# Adding constraints to the model

Filter Content By
Version
Languages

## Adding constraints to the model

The next step in the example is to add the linear constraints. The first constraint is added here:

  // Add constraint: x + 2 y + 3 z <= 4
GRBLinExpr expr;

expr = new GRBLinExpr();

The first argument to addConstr() is the left-hand side of the constraint. We built the left-hand side by first creating an empty linear expression object, and then adding three terms to it. The second argument is the constraint sense (GRB_LESS_EQUAL, GRB_GREATER_EQUAL, or GRB_EQUAL). The third argument is the right-hand side (a constant in our example). The final argument is the constraint name. Several signatures are available for addConstr(). Please consult the Gurobi Reference Manual for details.
  // Add constraint: x + y >= 1