Try our new documentation site (beta).


GRBaddsos

int GRBaddsos ( GRBmodel *model,
    int numsos,
    int nummembers,
    int *types,
    int *beg,
    int *ind,
    double *weight )

Add new Special Ordered Set (SOS) constraints to an existing model. Note that the new SOS constraints won't actually be added until the next call to GRBoptimize or GRBupdatemodel.

Return value:

A non-zero return value indicates that a problem occurred while adding the SOS 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 SOSs should be added.

numsos: The number of new SOSs to add.

nummembers: The total number of SOS members in the new SOSs.

types: The types of the SOS sets. SOS sets can be of type GRB_SOS_TYPE1 or GRB_SOS_TYPE2.

beg: The members of the added SOS sets are passed into this routine in Compressed Sparse Row (CSR) format. Each SOS is represented as a list of index-value pairs, where each index entry provides the variable index for an SOS member, and each value entry provides the weight of that variable in the corresponding SOS set. Each new SOS has an associated beg value, indicating the start position of the SOS member list in the ind and weight arrays. This routine requires that the members for SOS i immediately follow those for SOS i-1 in ind and weight. Thus, beg[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 beg[2] = 10 and beg[3] = 12. This would indicate that SOS number 2 has two members. Their variable indices can be found in ind[10] and ind[11], and the associated weights can be found in weight[10] and weight[11].

ind: Variable indices associated with SOS members. See the description of the beg argument for more information.

weight: Weights associated with SOS members. See the description of the beg argument for more information.

Example usage:

  int    types[]  = {GRB_SOS_TYPE1, GRB_SOS_TYPE1};
  int    beg[]    = {0, 2};
  int    ind[]    = {1, 2, 1, 3};
  double weight[] = {1, 2, 1, 2};
  error = GRBaddsos(model, 2, 4, types, beg, ind, weight);

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