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 ignored.

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.

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search