Parameter Management#

int GRBgetdblparam(GRBenv *env, const char *paramname, double *valueP)#

Retrieve the value of a double-valued parameter.

Note that a model gets its own copy of the environment when it is created. Changes to the original environment have no effect on the copy, and vice versa. Use GRBgetenv to retrieve the environment associated with a model if you would like to query the parameter value for that model.

Return value:

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

Arguments:
  • env – The environment whose parameter value is being queried.

  • paramname – The name of the parameter. Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

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

Example:
double cutoff;
error = GRBgetdblparam(GRBgetenv(model), "Cutoff", &cutoff);
int GRBgetintparam(GRBenv *env, const char *paramname, int *valueP)#

Retrieve the value of an integer-valued parameter.

Note that a model gets its own copy of the environment when it is created. Changes to the original environment have no effect on the copy, and vice versa. Use GRBgetenv to retrieve the environment associated with a model if you would like to query the parameter value for that model.

Return value:

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

Arguments:
  • env – The environment whose parameter value is being queried.

  • paramname – The name of the parameter. Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

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

Example:
int limit;
error = GRBgetintparam(GRBgetenv(model), "SolutionLimit", &limit);
int GRBgetstrparam(GRBenv *env, const char *paramname, char *value)#

Retrieve the value of a string-valued parameter.

Note that a model gets its own copy of the environment when it is created. Changes to the original environment have no effect on the copy, and vice versa. Use GRBgetenv to retrieve the environment associated with a model if you would like to query the parameter value for that model.

Return value:

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

Arguments:
  • env – The environment whose parameter value is being queried.

  • paramname – The name of the parameter. Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

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

Example:
char logfilename[GRB_MAX_STRLEN];
error = GRBgetstrparam(GRBgetenv(model), "LogFile", logfilename);
int GRBsetdblparam(GRBenv *env, const char *paramname, double newvalue)#

Modify the value of a double-valued parameter.

Note that a model gets its own copy of the environment when it is created. Changes to the original environment have no effect on the copy, and vice versa. Use GRBgetenv to retrieve the environment associated with a model if you would like to change the parameter value for that model.

Return value:

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

Arguments:
  • env – The environment whose parameter value is being modified.

  • paramname – The name of the parameter. Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

  • newvalue – The desired new value of the parameter.

Example:
error = GRBsetdblparam(GRBgetenv(model), "Cutoff", 100.0);
int GRBsetintparam(GRBenv *env, const char *paramname, int newvalue)#

Modify the value of an integer-valued parameter.

Note that a model gets its own copy of the environment when it is created. Changes to the original environment have no effect on the copy, and vice versa. Use GRBgetenv to retrieve the environment associated with a model if you would like to change the parameter value for that model.

Return value:

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

Arguments:
  • env – The environment whose parameter value is being modified.

  • paramname – The name of the parameter. Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

  • newvalue – The desired new value of the parameter.

Example:
error = GRBsetintparam(GRBgetenv(model), "SolutionLimit", 5);
int GRBsetstrparam(GRBenv *env, const char *paramname, const char *newvalue)#

Modify the value of a string-valued parameter.

Note that a model gets its own copy of the environment when it is created. Changes to the original environment have no effect on the copy, and vice versa. Use GRBgetenv to retrieve the environment associated with a model if you would like to change the parameter value for that model.

Return value:

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

Arguments:
  • env – The environment whose parameter value is being modified.

  • paramname – The name of the parameter. Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

  • newvalue – The desired new value of the parameter.

Example:
error = GRBsetstrparam(GRBgetenv(model), "LogFile", "/tmp/new.log");
int GRBgetdblparaminfo(GRBenv *env, const char *paramname, double *valueP, double *minP, double *maxP, double *defaultP)#

Retrieve information about a double-valued parameter. Specifically, retrieve the current value of the parameter, the minimum and maximum allowed values, and the default value.

Return value:

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

Arguments:
  • env – The environment whose parameter information is being queried.

  • paramname – The name of the parameter. Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

  • valueP – (optional) The location in which the current value of the specified parameter should be placed.

  • minP – (optional) The location in which the minimum allowed value of the specified parameter should be placed.

  • maxP – (optional) The location in which the maximum allowed value of the specified parameter should be placed.

  • defaultP – (optional) The location in which the default value of the specified parameter should be placed.

Example:
error = GRBgetdblparaminfo(GRBgetenv(model), "MIPGap", &currentGap,
                           &minAllowedGap, NULL, &defaultGap);
int GRBgetintparaminfo(GRBenv *env, const char *paramname, int *valueP, int *minP, int *maxP, int *defaultP)#

Retrieve information about an int-valued parameter. Specifically, retrieve the current value of the parameter, the minimum and maximum allowed values, and the default value.

Return value:

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

Arguments:
  • env – The environment whose parameter information is being queried.

  • paramname – The name of the parameter. Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

  • valueP – (optional) The location in which the current value of the specified parameter should be placed.

  • minP – (optional) The location in which the minimum allowed value of the specified parameter should be placed.

  • maxP – (optional) The location in which the maximum allowed value of the specified parameter should be placed.

  • defaultP – (optional) The location in which the default value of the specified parameter should be placed.

Example:
error = GRBgetintparaminfo(GRBgetenv(model), "SolutionLimit", &current,
                           &minAllowedLimit, NULL, &defaultLimit);
int GRBgetstrparaminfo(GRBenv *env, const char *paramname, char *value, char *defaultP)#

Retrieve information about a string-valued parameter. Specifically, retrieve the current and default values of the parameter.

Return value:

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

Arguments:
  • env – The environment whose parameter information is being queried.

  • paramname – The name of the parameter. Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

  • value – (optional) The location in which the current value of the specified parameter should be placed.

  • defaultP – (optional) The location in which the default value of the specified parameter should be placed.

Example:
char defaultval[GRB_MAX_STRLEN];
char currentval[GRB_MAX_STRLEN];
error = GRBgetstrparaminfo(GRBgetenv(model), "LogFile", currentval,
                           defaultval);
int GRBreadparams(GRBenv *env, const char *filename)#

Import a set of parameter modifications from a file.

Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

Return value:

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

Arguments:
  • env – The environment into which the parameter changes should be imported.

  • filename – The path to the file to be read. The suffix on a parameter file should be .prm, optionally followed by .zip, .gz, .bz2, or .7z.

Example:
error = GRBreadparams(env, "/tmp/model.prm.bz2");
int GRBwriteparams(GRBenv *env, const char *filename)#

Write the set of changed parameter values to a file.

Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.

Return value:

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

Arguments:
  • env – The environment whose parameter changes are being written.

  • filename – The path to the file to be written. The suffix on a parameter file should be .prm, optionally followed by .gz, .bz2, or .7z.

Example:
error = GRBwriteparams(env, "/tmp/model.prm");