Creating the environment
After declaring the necessary program variables, the example continues by creating an environment, by first requesting an empty environment, then setting some options - as log file name - and then starting the environment.
/* Create environment */ error = GRBemptyenv(&env); if (error) goto QUIT; error = GRBsetstrparam(env, "LogFile", "mip1.log"); if (error) goto QUIT; error = GRBstartenv(env); if (error) goto QUIT;
Later requests to create optimization models will always require an active environment, so environment creation should always be the first step when using the Gurobi optimizer.
Note that environment creation may fail, so you should check the return value of the call.