Using a gurobi.env file

When you want to change the values of Gurobi parameters, you actually have several options available for doing so. We've already discussed parameter changes through the command-line tool (e.g., gurobi_cl Threads=1 coins.lp), and through interactive shell commands (e.g., m.setParam('Threads', 1)). Each of our language APIs also provides methods for setting parameters. The other option we'd like to mention now is the gurobi.env file.

Whenever the Gurobi library starts, it will look for file gurobi.env in the current working directory, and will apply any parameter changes contained therein. This is true whether the Gurobi library is invoked from the command-line, from the interactive shell, or from any of the Gurobi APIs. Parameter settings are stored one per line in this file, with the parameter name first, followed by at least one space, followed by the desired value. Lines beginning with the # sign are comments and are ignored. To give an example, the following (Linux) commands:

  echo "Threads 1" > gurobi.env
  gurobi_cl coins.lp
would read the new value of the Threads parameter from file gurobi.env and then optimize model coins.lp using one thread. Note that if the same parameter is changed in both gurobi.env and in your program (or through the Gurobi command-line), the value from gurobi.env will be overridden.

The distribution includes a sample gurobi.env file (in the bin directory). The sample includes every parameter, with the default value for each, but with all settings commented out.