Python and Python Matrix interface
In this example, we use the default environment.
C interface
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.
As we'll discuss shortly, nearly every Gurobi method returns an error code. A zero value indicates that no error was encountered. It is important that you check every returned error code.
/* 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.
C++ interface
The first executable statement in our example obtains a Gurobi environment (using the GRBEnv()
constructor):
// Create an environment GRBEnv env = GRBEnv(true); env.set("LogFile", "mip1.log"); env.start();
In this call we requested an empty environment, chose a log file, and started the environment.
Later calls to create an optimization model will always require an environment, so environment creation is typically the first step in a Gurobi application.
Java interface
The first executable statement in our example obtains a Gurobi environment (using the GRBEnv()
constructor):
// Create empty environment, set options, and start GRBEnv env = new GRBEnv(true); env.set("logFile", "mip1.log"); env.start();
In this call we requested an empty environment, chose a log file, and started the environment.
Later calls to create an optimization model will always require an environment, so environment creation is typically the first step in a Gurobi application.
.NET interface
The first executable statement in our example obtains a Gurobi environment (using the GRBEnv()
constructor):
// Create an empty environment, set options and start GRBEnv env = new GRBEnv(true); env.Set("LogFile", "mip1.log"); env.Start();
In this case, we create an empty environment, select a log file to use, and start the environment for latter use.
Later calls to create an optimization model will always require an active environment, so environment creation is typically the first step in a Gurobi application.
MATLAB interface
The environment here is built-in to the model object.
R interface
The environment here is built-in to the model object.
Comments
0 comments
Please sign in to leave a comment.