Documentation


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 a model. Note that, due to our lazy update approach, the new SOS 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).

Please refer to this section for details on SOS constraints.

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);