Parameter Management#

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

Retrieve the value of a double-valued parameter.

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.

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.

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.

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.

Important note:

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. Use GRBgetenv to retrieve the environment associated with a model if you would like a parameter change to affect that model.

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.

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.

Important note:

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. Use GRBgetenv to retrieve the environment associated with a model if you would like a parameter change to affect that model.

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.

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.

Important note:

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. Use GRBgetenv to retrieve the environment associated with a model if you would like a parameter change to affect that model.

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 GRBresetparams(GRBenv *env)#

Reset the values of all parameters to their default values.

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 resetting parameters. 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 for which the parameters should be reset to their default value.

Example:
error = GRBresetparams(env);
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");