Concepts
Features
Reference
Gurobi environment object. Gurobi models are always associated with anenvironment. You must create an environment before you can create andpopulate a model. You will generally only need a single environmentobject in your program.
The methods on environment objects are mainly used to manage Gurobiparameters (e.g.,get,getParamInfo,set).
Constructor forGRBEnv object. Creates a Gurobi environment (withlogging disabled). This method will also populate any parameter(ComputeServer,TokenServer,ServerPassword, etc.) specified in yourgurobi.licfile. This method will also check the current working directory for afile namedgurobi.env, and it will attempt to read parameter settingsfrom this file if it exists. The file should be inPRMformat (briefly, each line should contain a parameter name, followed bythe desired value for that parameter).
In general, you should aim to create asingle Gurobi environment in your program, even if you plan to work withmultiple models. Reusing one environment is much more efficient thancreating and destroying multiple environments. The one exception is ifyou are writing a multi-threaded program, since environments are notthread safe. In this case, you will need a separate environment for eachof your threads.
An environment object (with no associated log file).
Constructor forGRBEnv object. Ifempty=true, creates anempty environment. UseGRBEnv::start to startthe environment. Ifempty=false, the result is the same asproviding no arguments to the constructor.
In general, you should aim to create asingle Gurobi environment in your program, even if you plan to work withmultiple models. Reusing one environment is much more efficient thancreating and destroying multiple environments. The one exception is ifyou are writing a multi-threaded program, since environments are notthread safe. In this case, you will need a separate environment for eachof your threads.
empty – Indicates whether the environment should be empty. Youshould useempty=true if you want to set parameters before actuallystarting the environment. This can be useful if you want to connect to aCompute Server, a Token Server, the Gurobi Instant Cloud, a ClusterManager or use a WLS license. See theEnvironment Section for more details.
An environment object.
Constructor forGRBEnv object. Creates a Gurobi environment (withlogging enabled). This method will also populate any parameter(ComputeServer,TokenServer,ServerPassword, etc.) specified in yourgurobi.licfile. This method will also check the current working directory for afile namedgurobi.env, and it will attempt to read parameter settingsfrom this file if it exists. The file should be inPRMformat (briefly, each line should contain a parameter name, followed bythe desired value for that parameter).
In general, you should aim to create asingle Gurobi environment in your program, even if you plan to work withmultiple models. Reusing one environment is much more efficient thancreating and destroying multiple environments. The one exception is ifyou are writing a multi-threaded program, since environments are notthread safe. In this case, you will need a separate environment for eachof your threads.
logFileName – The desired log file name.
An environment object.
Query the value of a parameter.
param – The parameter being queried. Please consult theparameter section for a complete list of Gurobiparameters, including descriptions of their purposes and their minimum,maximum, and default values.
The current value of the requested parameter.
Query the error message for the most recent exception associated withthis environment.
The error string.
Obtain detailed information about a double or integer parameter.
param – The parameter of interest. Please consult theparameter section for a complete list of Gurobiparameters, including descriptions of their purposes and their minimum,maximum, and default values.
valP – The current value of the parameter.
minP – The minimum allowed value of the parameter.
maxP – The maximum allowed value of the parameter.
defP – The default value of the parameter.
Obtain detailed information about a string parameter.
param – The parameter of interest. Please consult theparameter section for a complete list of Gurobiparameters, including descriptions of their purposes and their minimum,maximum, and default values.
valP – The current value of the parameter.
defP – The default value of the parameter.
Write a message to the console and the log file.
message – The message to be written.
Note
This call has no effect unless theOutputFlag parameter is set. In addition, it is ignoredfrom within aMESSAGE callback (seeWHERE values)and logging callback. The console logging can becontroled withLogToConsole.
Read new parameter settings from a file.
Please consult theparameter section for a complete list of Gurobiparameters, including descriptions of their purposes and their minimum,maximum, and default values.
Parameters should be listed one per line, with the parameter name firstand the desired value second. For example:
# Gurobi parameter fileThreads 1MIPGap 0
Blank lines and lines that begin with the hash symbol are ignored.
paramfile – Name of the file containing parameter settings.
Reset all parameters to their default values.
Please consult theparameter section for a complete list of Gurobiparameters, including descriptions of their purposes and their minimum,maximum, and default values.
Set the value of a parameter.
param – The parameter being modified. Please consult theparameter section for a complete list of Gurobiparameters, including descriptions of their purposes and their minimum,maximum, and default values.
newvalue – The desired new value of the parameter.
Note
Note that a model gets its own copy of the environment when it iscreated. Changes to the original environment have no effect on the copy,and vice versa. Use the appropriate version of the overloaded methodGRBModel::setto change a parameter on an existing model.
Set the value of any parameter using strings alone.
param – The name of the parameter being modified.Please consult theparameter section for a complete list of Gurobiparameters, including descriptions of their purposes and their minimum,maximum, and default values.
newvalue – The desired new value of the parameter.
Note
Note that a model gets its own copy of the environment when it iscreated. Changes to the original environment have no effect on the copy,and vice versa. Use the appropriate version of the overloaded methodGRBModel::setto change a parameter on an existing model.
Start an empty environment. If the environment has already been started,this method will do nothing. If the call fails, the environment willhave the same state as it had before the call to this method.
This method will also populate any parameter(ComputeServer,TokenServer,ServerPassword, etc.) specified in yourgurobi.licfile. This method will also check the current working directory for afile namedgurobi.env, and it will attempt to read parametersettings from this file if it exists. The file should be inPRM format (briefly, each line should contain a parameter name,followed by the desired value for that parameter). After that, it willapply all parameter changes specified by the user prior to this call.Note that this might overwrite parameters set in the license file, or inthegurobi.env file, if present.
After all these changes are performed, the code will actually activatethe environment, and make it ready to work with models.
In general, you should aim to create asingle Gurobi environment in your program, even if you plan to work withmultiple models. Reusing one environment is much more efficient thancreating and destroying multiple environments. The one exception is ifyou are writing a multi-threaded program, since environments are notthread safe. In this case, you will need a separate environment for eachof your threads.
Please consult theparameter section for a complete list of Gurobiparameters, including descriptions of their purposes and their minimum,maximum, and default values.
Write all non-default parameter settings to a file.
Please consult theparameter section for a complete list of Gurobiparameters, including descriptions of their purposes and their minimum,maximum, and default values.
paramfile – Name of the file to which non-default parametersettings should be written. The previous contents are overwritten.
Help and Feedback