Filter Content By
Version
Languages

## Configuration parameters

When you start a Gurobi session, you often have to provides details about your configuration. You may need to indicate whether you want to use a license on your local machine, a license from a Token Server, or perhaps you want to offload your computation to a Compute Server or to Gurobi Instant Cloud. In the case of a Token Server or a Compute Server, you have to provide the name of the server. For Compute Server and Instant Cloud, you also need to provide login credentials.

In many situations, the configuration information you need is already stored in your license file (gurobi.lic) or in your environment file (gurobi.env). These files are read automatically, so you can simply create a standard Gurobi environment object (using GRBloadenv in C, or through the appropriate GRBEnv constructor in the object-oriented interfaces).

What if you need to provide configuration information from your application at runtime instead? You can use an empty environment to split environment creation into a few steps (as opposed to the standard, single-step approach mentioned above). In the first step, you would create an empty environment object (using GRBemptyenv in C, or through the appropriate GRBEnv constructor in the object-oriented interfaces). You would then set configuration parameters on this environment using the standard parameter API. Finally, you would start the environment (using GRBstartenv in C, or using the env.start() method in the object-oriented interfaces), which will use the configuration parameters you just set.

Empty environment example

To give a simple example, if you want your Python program to offload the optimization computation to a Compute Server named server1, you could say:

import gurobipy as gp
from gurobipy import GRB

# Set up environment
env = gp.Env(empty=True)
env.setParam('ComputeServer', 'server1:61000')
env.start()

model.optimize()


An equivalent Java program would look like this:

import gurobi.*;
...
// Set up environment
GRBenv env = new GRBEnv(true);
env.set(GRB.StringParam.ComputeServer,  "server1:61000");
env.start();

GRBModel model = new GRBModel(env, "misc07.mps");
model.optimize()


An equivalent C program would look like this:

#include "gurobi_c.h"
int main(void) {
GRBenv   *env   = NULL;
GRBmodel *model = NULL;
int error   = 0;

/* Set up environment */
error = GRBemptyenv(&env);
if (error) goto QUIT;
error = GRBsetstrparam(GRB_STR_PAR_COMPUTESERVER, "server1:61000");
if (error) goto QUIT;
if (error) goto QUIT;
error = GRBstartenv(env);
if (error) goto QUIT;

/* Load model and optimize */