Try our new documentation site (beta).


GRBXaddrangeconstrs

int GRBXaddrangeconstrs ( GRBmodel *model,
    int numconstrs,
    size_t numnz,
    size_t *cbeg,
    int *cind,
    double *cval,
    double *lower,
    double *upper,
    const char **constrnames )

The size_t version of GRBaddrangeconstrs. The argument that counts non-zero values is of type size_t in this version to support models with more than 2 billion non-zero values.

Add new range constraints to a model. A range constraint states that the value of the input expression must be between the specified lower and upper bounds in any solution. Note that, due to our lazy update approach, the new constraints won't actually be added until you update the model (using GRBupdatemodel), optimize the model (using GRBoptimize), or write the model to disk (using GRBwrite).

Return value:

A non-zero return value indicates that a problem occurred while adding the constraints. Refer to the Error Code table for a list of possible return values. Details on the error can be obtained by calling GRBgeterrormsg.

Arguments:

model: The model to which the new constraints should be added.

numconstrs: The number of new constraints to add.

numnz: The total number of non-zero coefficients in the new constraints.

cbeg: Constraint matrix non-zero values are passed into this routine in Compressed Sparse Row (CSR) format by this routine. Each constraint in the constraint matrix is represented as a list of index-value pairs, where each index entry provides the variable index for a non-zero coefficient, and each value entry provides the corresponding non-zero value. Each new constraint has an associated cbeg value, indicating the start position of the non-zeros for that constraint in the cind and cval arrays. This routine requires that the non-zeros for constraint i immediately follow those for constraint i-1 in cind and cval. Thus, cbeg[i] indicates both the index of the first non-zero in constraint i and the end of the non-zeros for constraint i-1. To give an example of how this representation is used, consider a case where cbeg[2] = 10 and cbeg[3] = 12. This would indicate that constraint 2 has two non-zero values associated with it. Their variable indices can be found in cind[10] and cind[11], and the numerical values for those non-zeros can be found in cval[10] and cval[11].

cind: Variable indices associated with non-zero values. See the description of the cbeg argument for more information.

cval: Numerical values associated with constraint matrix non-zeros. See the description of the cbeg argument for more information.

lower: Lower bounds for the linear expressions.

upper: Upper bounds for the linear expressions.

constrnames: Names for the new constraints. This argument can be NULL, in which case all constraints are given default names.

Important notes:

Note that adding a range constraint to the model adds both a new constraint and a new variable. If you are keeping a count of the variables in the model, remember to add one for each range constraint.

Note also that range constraints are stored internally as equality constraints. We use the extra variable that is added with a range constraint to capture the range information. Thus, the Sense attribute on a range constraint will always be GRB_EQUAL.

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