Try our new documentation site (beta).


GRBModel.AddConstrs()

Add new linear constraints to a model.

We recommend that you build your model one constraint at a time (using AddConstr), since it introduces no significant overhead and we find that it produces simpler code. Feel free to use these methods if you disagree, though.

GRBConstr[] AddConstrs ( int count )

Add count new linear constraints to a model. The new constraints are all of the form 0 <= 0.

Arguments:

count: Number of constraints to add.

Return value:

Array of new constraint objects.

GRBConstr[] AddConstrs ( GRBLinExpr[] lhsExprs,
    char[] senses,
    double[] rhsVals,
    string[] names )

Add new linear constraints to a model. The number of added constraints is determined by the length of the input arrays (which must be consistent across all arguments).

Arguments:

lhsExprs: Left-hand side expressions for the new linear constraints.

senses: Senses for new linear constraints (GRB.LESS_EQUAL, GRB.EQUAL, or GRB.GREATER_EQUAL).

rhsVals: Right-hand side values for the new linear constraints.

names: Names for new constraints.

Return value:

Array of new constraint objects.

GRBConstr[] AddConstrs ( GRBLinExpr[] lhsExprs,
    char[] senses,
    GRBLinExpr[] rhsExprs,
    int start,
    int len,
    string[] names )

Add new linear constraints to a model. This signature allows you to use arrays to hold the various constraint attributes (left-hand side, sense, etc.), without forcing you to add one constraint for each entry in the array. The start and len arguments allow you to specify which constraints to add.

Arguments:

lhsExprs: Left-hand side expressions for the new linear constraints.

senses: Senses for new linear constraints (GRB.LESS_EQUAL, GRB.EQUAL, or GRB.GREATER_EQUAL).

rhs: Right-hand side expressions for the new linear constraints.

start: The first constraint in the list to add.

len: The number of variables to add.

names: Names for new constraints.

Return value:

Array of new constraint objects.

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search

Gurobi Optimization