Attribute Management#

int GRBgetattrinfo(GRBmodel *model, const char *attrname, int *datatypeP, int *attrtypeP, int *settableP)#

Obtain information about an attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of an attribute. Available attributes are listed and described in the Attributes section of this document.

  • datatypeP – On completion, the integer pointed to by this argument will indicate the data type of the attribute. Possible types are char (0), int (1), double (2), or string(3). This argument can be NULL.

  • attrtypeP – On completion, the integer pointed to by this argument will indicate the type of the attribute. Possible types are model attribute (0), variable attribute (1), linear constraint attribute (2), (3) SOS constraint attribute, (4) quadratic constraint attribute, or (5) general constraint attribute. This argument can be NULL.

  • settableP – On completion, the integer pointed to by this argument will indicate whether the attribute can be set (1) or not (0). This argument can be NULL.

Example:
int datatype, attrtype, settable;
error = GRBgetattrinfo(model, "ModelName", &datatype, &attrtype, &settable);
int GRBgetintattr(GRBmodel *model, const char *attrname, int *valueP)#

Query the value of an integer-valued model attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of an integer-valued model attribute. Available attributes are listed and described in the Attributes section of this document.

  • valueP – The location in which the current value of the requested attribute should be placed.

Important

Note that this method should be used for scalar attributes only (i.e., model attributes). To query a single element of an array attribute, use GRBgetintattrelement instead.

Example:
error = GRBgetintattr(model, "NumBinVars", &numbin);
int GRBsetintattr(GRBmodel *model, const char *attrname, int newvalue)#

Set the value of an integer-valued model attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of an integer-valued model attribute. Available attributes are listed and described in the Attributes section of this document.

  • newvalue – The desired new value of this attribute.

Important

Note that this method should be used for scalar attributes only (i.e., model attributes). To modify a single element of an array attribute, use GRBsetintattrelement instead.

Example:
error = GRBsetintattr(model, "ModelSense", -1);
int GRBgetintattrelement(GRBmodel *model, const char *attrname, int element, int *valueP)#

Query a single value from an integer-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of an integer-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • element – The index of the requested array element.

  • valueP – A pointer to the location where the requested value should be returned.

Important

Note that this method should be used for array attributes only (i.e., variable or constraint attributes). To query a scalar attribute (i.e., a model attribute), use GRBgetintattr instead.

Example:
int first_one;
error = GRBgetintattrelement(model, "VBasis", 0, &first_one);
int GRBsetintattrelement(GRBmodel *model, const char *attrname, int element, int newvalue)#

Set a single value in an integer-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of an integer-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • element – The index of the array element to be changed.

  • newvalue – The value to which the attribute element should be set.

Important

Note that this method should be used for array attributes only (i.e., variable or constraint attributes). To modify a scalar attribute (i.e., a model attribute), use GRBsetintattr instead.

Example:
error = GRBsetintattrelement(model, "VBasis", 0, GRB_BASIC);
int GRBgetintattrarray(GRBmodel *model, const char *attrname, int start, int len, int *values)#

Query the values of an integer-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of an integer-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • start – The index of the first entry in the array to retrieve.

  • len – The number of array entries to retrieve.

  • values – A pointer to the location where the array attribute should be returned. Note that the result array must be as long as the requested sub-array.

Example:
int cbasis[NUMCONSTRS];
error = GRBgetintattrarray(model, "CBasis", 0, NUMCONSTRS, cbasis);
int GRBsetintattrarray(GRBmodel *model, const char *attrname, int start, int len, int *values)#

Set the values of an integer-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of an integer-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • start – The index of the first entry in the array to set.

  • len – The number of array entries to set.

  • values – A pointer to the desired new values for the specified sub-array of the attribute. Note that the values array must be as long as the sub-array to be changed.

Example:
int cbasis[] = {GRB_BASIC, GRB_BASIC, GRB_NONBASIC_LOWER, GRB_BASIC};
error = GRBsetintattrarray(model, "CBasis", 0, 4, cbasis);
int GRBgetintattrlist(GRBmodel *model, const char *attrname, int len, int *ind, int *values)#

Query the values of an integer-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of an integer-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • len – The number of attribute elements to retrieve.

  • ind – The indices of the desired attribute elements.

  • values – A pointer to the location where the requested attribute elements should be returned. Note that the result array must be as long as the requested index list.

Example:
int desired[] = {0, 2, 4, 6};
int cbasis[4];
error = GRBgetintattrlist(model, "CBasis", 4, desired, cbasis);
int GRBsetintattrlist(GRBmodel *model, const char *attrname, int len, int *ind, int *values)#

Set the values of an integer-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of an integer-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • len – The number of array entries to set.

  • ind – The indices of the array attribute elements that will be set.

  • values – A pointer to the desired new values for the specified elements of the attribute. Note that the values array must be as long as the list of indices.

Example:
int change[] = {0, 1, 3};
int newbas[] = {GRB_BASIC, GRB_NONBASIC_LOWER, GRB_NONBASIC_LOWER};
error = GRBsetintattrlist(model, "VBasis", 3, change, newbas);
int GRBgetdblattr(GRBmodel *model, const char *attrname, double *valueP)#

Query the value of a double-valued model attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a double-valued model attribute. Available attributes are listed and described in the Attributes section of this document.

  • valueP – The location in which the current value of the requested attribute should be placed.

Important

Note that this method should be used for scalar attributes only (i.e., model attributes). To query a single element of an array attribute, use GRBgetdblattrelement instead.

Example:
error = GRBgetdblattr(model, "ObjCon", &objcon);
int GRBsetdblattr(GRBmodel *model, const char *attrname, double newvalue)#

Set the value of a double-valued model attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a double-valued model attribute. Available attributes are listed and described in the Attributes section of this document.

  • newvalue – The desired new value of this attribute.

Important

Note that this method should be used for scalar attributes only (i.e., model attributes). To modify a single element of an array attribute, use GRBsetdblattrelement instead.

Example:
error = GRBsetdblattr(model, "ObjCon", 0.0);
int GRBgetdblattrelement(GRBmodel *model, const char *attrname, int element, double *valueP)#

Query a single value from a double-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a double-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • element – The index of the requested array element.

  • valueP – A pointer to the location where the requested value should be returned.

Important

Note that this method should be used for array attributes only (i.e., variable or constraint attributes). To query a scalar attribute (i.e., a model attribute), use GRBgetdblattr instead.

Example:
double first_one;
error = GRBgetdblattrelement(model, "X", 0, &first_one);
int GRBsetdblattrelement(GRBmodel *model, const char *attrname, int element, double newvalue)#

Set a single value in a double-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a double-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • element – The index of the array element to be changed.

  • newvalue – The value to which the attribute element should be set.

Important

Note that this method should be used for array attributes only (i.e., variable or constraint attributes). To modify a scalar attribute (i.e., a model attribute), use GRBsetdblattr instead.

Example:
error = GRBsetdblattrelement(model, "Start", 0, 1.0);
int GRBgetdblattrarray(GRBmodel *model, const char *attrname, int start, int len, double *values)#

Query the values of a double-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a double-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • start – The index of the first entry in the array to retrieve.

  • len – The number of array entries to retrieve.

  • values – A pointer to the location where the array attribute should be returned. Note that the result array must be as long as the requested sub-array.

Example:
double lb[NUMVARS];
error = GRBgetdblattrarray(model, "LB", 0, cols, lb);
int GRBsetdblattrarray(GRBmodel *model, const char *attrname, int start, int len, double *values)#

Set the values of a double-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a double-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • start – The index of the first entry in the array to set.

  • len – The number of array entries to set.

  • values – A pointer to the desired new values for the specified sub-array of the attribute. Note that the values array must be as long as the sub-array to be changed.

Example:
double start[] = {1.0, 1.0, 0.0, 1.0};
error = GRBsetdblattrarray(model, "Start", 0, 4, start);
int GRBgetdblattrlist(GRBmodel *model, const char *attrname, int len, int *ind, double *values)#

Query the values of a double-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a double-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • len – The number of attribute elements to retrieve.

  • ind – The indices of the desired attribute elements.

  • values – A pointer to the location where the requested attribute elements should be returned. Note that the result array must be as long as the requested index list.

Example:
int desired[] = {0, 2, 4, 6};
double x[4];
error = GRBgetdblattrlist(model, "X", 4, desired, cbasis);
int GRBsetdblattrlist(GRBmodel *model, const char *attrname, int len, int *ind, double *values)#

Set the values of a double-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a double-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • len – The number of array entries to set.

  • ind – The indices of the array attribute elements that will be set.

  • values – A pointer to the desired new values for the specified elements of the attribute. Note that the values array must be as long as the list of indices.

Example:
int change[] = {0, 1, 3};
double start[] = {1.0, 3.0, 2.0};
error = GRBsetdblattrlist(model, "Start", 3, change, start);
int GRBgetcharattrelement(GRBmodel *model, const char *attrname, int element, char *valueP)#

Query a single value from a character-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a character-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • element – The index of the requested array element.

  • valueP – A pointer to the location where the requested value should be returned.

Example:
char first_one;
error = GRBgetcharattrelement(model, "VType", 0, &first_one);
int GRBsetcharattrelement(GRBmodel *model, const char *attrname, int element, char newvalue)#

Set a single value in a character-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a character-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • element – The index of the array element to be changed.

  • newvalue – The value to which the attribute element should be set.

Example:
error = GRBsetcharattrelement(model, "VType", 0, GRB_BINARY);
int GRBgetcharattrarray(GRBmodel *model, const char *attrname, int start, int len, char *values)#

Query the values of a character-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a character-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • start – The index of the first entry in the array to retrieve.

  • len – The number of array entries to retrieve.

  • values – A pointer to the location where the array attribute should be returned. Note that the result array must be as long as the requested sub-array.

Example:
char vtypes[NUMVARS];
error = GRBgetcharattrarray(model, "VType", 0, NUMVARS, vtypes);
int GRBsetcharattrarray(GRBmodel *model, const char *attrname, int start, int len, char *values)#

Set the values of a character-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a character-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • start – The index of the first entry in the array to set.

  • len – The number of array entries to set.

  • values – A pointer to the desired new values for the specified sub-array of the attribute. Note that the values array must be as long as the sub-array to be changed.

Example:
char vtypes[] = {GRB_BINARY, GRB_CONTINUOUS, GRB_INTEGER, GRB_BINARY};
error = GRBsetcharattrarray(model, "VType", 0, 4, vtypes);
int GRBgetcharattrlist(GRBmodel *model, const char *attrname, int len, int *ind, char *values)#

Query the values of a character-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a character-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • len – The number of attribute elements to retrieve.

  • ind – The indices of the desired attribute elements.

  • values – A pointer to the location where the requested attribute elements should be returned. Note that the result array must be as long as the requested index list.

Example:
int desired[] = {0, 2, 4, 6};
char vtypes[4];
error = GRBgetcharattrlist(model, "VType", 4, desired, vtypes);
int GRBsetcharattrlist(GRBmodel *model, const char *attrname, int len, int *ind, char *values)#

Set the values of a character-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a character-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • len – The number of array entries to set.

  • ind – The indices of the array attribute elements that will be set.

  • values – A pointer to the desired new values for the specified elements of the attribute. Note that the values array must be as long as the list of indices.

Example:
int change[] = {0, 1, 3};
char vtypes[] = {GRB_BINARY, GRB_BINARY, GRB_BINARY};
error = GRBsetcharattrlist(model, "Vtype", 3, change, vtypes);
int GRBgetstrattr(GRBmodel *model, const char *attrname, char **valueP)#

Query the value of a string-valued model attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a string-valued model attribute. Available attributes are listed and described in the Attributes section of this document.

  • valueP – The location in which the current value of the requested attribute should be placed.

Important

Note that all interface routines that return string-valued attributes are returning pointers into internal Gurobi data structures. The user should copy the contents of the pointer to a different data structure before the next call to a Gurobi library routine. The user should also be careful to never modify the data pointed to by the returned character pointer.

Important

Note that this method should be used for scalar attributes only (i.e., model attributes). To query a single element of an array attribute, use GRBgetstrattrelement instead.

Example:
char *modelname;
error = GRBgetstrattr(model, "ModelName", &modelname);
int GRBsetstrattr(GRBmodel *model, const char *attrname, const char *newvalue)#

Set the value of a string-valued model attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a string-valued model attribute. Available attributes are listed and described in the Attributes section of this document.

  • newvalue – The desired new value of this attribute.

Important

Note that this method should be used for scalar attributes only (i.e., model attributes). To modify a single element of an array attribute, use GRBsetstrattrelement instead.

Example:
error = GRBsetstrattr(model, "ModelName", "Modified name");
int GRBgetstrattrelement(GRBmodel *model, const char *attrname, int element, char **valueP)#

Query a single value from a string-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a string-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • element – The index of the requested array element.

  • valueP – A pointer to the location where the requested value should be returned.

Important

Note that all interface routines that return string-valued attributes are returning pointers into internal Gurobi data structures. The user should copy the contents of the pointer to a different data structure before the next call to a Gurobi library routine. The user should also be careful to never modify the data pointed to by the returned character pointer.

Important

Note that this method should be used for array attributes only (i.e., variable or constraint attributes). To query a scalar attribute (i.e., a model attribute), use GRBgetstrattr instead.

Example:
char **varname;
error = GRBgetstrattrelement(model, "VarName", 1, varname);
int GRBsetstrattrelement(GRBmodel *model, const char *attrname, int element, char *newvalue)#

Set a single value in a string-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a string-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • element – The index of the array element to be changed.

  • newvalue – The value to which the attribute element should be set.

Important

Note that this method should be used for array attributes only (i.e., variable or constraint attributes). To modify a scalar attribute (i.e., a model attribute), use GRBsetstrattr instead.

Example:
error = GRBsetstrattrelement(model, "ConstrName", 0, "NewConstr");
int GRBgetstrattrarray(GRBmodel *model, const char *attrname, int start, int len, char **values)#

Query the values of a string-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a string-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • start – The index of the first entry in the array to retrieve.

  • len – The number of array entries to retrieve.

  • values – A pointer to the location where the array attribute should be returned. Note that the result array must be as long as the requested sub-array.

Important

Note that all interface routines that return string-valued attributes are returning pointers into internal Gurobi data structures. The user should copy the contents of the pointer to a different data structure before the next call to a Gurobi library routine. The user should also be careful to never modify the data pointed to by the returned character pointer.

Example:
char **varnames[NUMVARS];
error = GRBgetstrattrarray(model, "VarName", 0, NUMVARS, varnames);
int GRBsetstrattrarray(GRBmodel *model, const char *attrname, int start, int len, char **values)#

Set the values of a string-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a string-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • start – The index of the first entry in the array to set.

  • len – The number of array entries to set.

  • values – A pointer to the desired new values for the specified sub-array of the attribute. Note that the values array must be as long as the sub-array to be changed.

Example:
char **varnames[NUMVARS];
error = GRBsetstrattrarray(model, "VarName", 0, NUMVARS, varnames);
int GRBgetstrattrlist(GRBmodel *model, const char *attrname, int len, int *ind, char **values)#

Query the values of a string-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a string-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • len – The number of attribute elements to retrieve.

  • ind – The indices of the desired attribute elements.

  • values – A pointer to the location where the requested attribute elements should be returned. Note that the result array must be as long as the requested index list.

Important

Note that all interface routines that return string-valued attributes are returning pointers into internal Gurobi data structures. The user should copy the contents of the pointer to a different data structure before the next call to a Gurobi library routine. The user should also be careful to never modify the data pointed to by the returned character pointer.

Example:
int desired[] = {0, 2, 4, 6};
char **varnames[4];
error = GRBgetstrattrlist(model, "VarName", 4, desired, varnames);
int GRBsetstrattrlist(GRBmodel *model, const char *attrname, int len, int *ind, char **values)#

Set the values of a string-valued array attribute.

Return value:

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

Arguments:
  • model – A loaded optimization model, typically created by routine GRBnewmodel or GRBreadmodel.

  • attrname – The name of a string-valued array attribute. Available attributes are listed and described in the Attributes section of this document.

  • len – The number of array entries to set.

  • ind – The indices of the array attribute elements that will be set.

  • values – A pointer to the desired new values for the specified elements of the attribute. Note that the values array must be as long as the list of indices.

Example:
int chage[] = {0, 1, 3};
char **varnames[] = {"Var0", "Var1", "Var3"};
error = GRBsetstrattrlist(model, "VarName", 3, change, varnames);
int GRBgetbatchattrinfo(GRBbatch *batch, const char *attrname, int *datatypeP, int *settableP)#

Obtain information about a Batch attribute.

Return value:

A non-zero return value indicates that a problem occurred while obtaining information about a batch attribute. Refer to the Error Codes table for a list of possible return values. Details on the error can be obtained by calling GRBgeterrormsg.

Arguments:
  • batch – A batch request handle, typically created by routine GRBgetbatch.

  • attrname – The name of a batch attribute. Available attributes are listed and described in the Attributes section of this document.

  • datatypeP – On completion, the integer pointed to by this argument will indicate the data type of the attribute. Possible types are char (0), int (1), double (2), or string(3). This argument can be NULL.

  • settableP – On completion, the integer pointed to by this argument will indicate whether the attribute can be set (1) or not (0). This argument can be NULL.

Example:
int datatype, settable;
error = GRBgetbatchattrinfo(batch, "BatchID", &datatype, &settable);