Gurobi Technical FAQs
License Keys
How do I put the license key file in an alternate location?
Set the environment variable
GRB_LICENSE_FILEto point to the exact location of the file. For example, if the license filegurobi.licis in the directoryd:\work, then setGRB_LICENSE_FILEtod:\work\gurobi.lic. For more information, see the section "How to Obtain and Install a Gurobi License" in the Quick Start Guide.How do you install a license key on a computer that cannot run grbgetkey due to a firewall or other issue?
For customers who have purchased a license or have contacted Gurobi sales for a time-limited evaluation license, a manual key installation process is available. Login to the Gurobi website and select the license ID. When you see the detailed instructions, click on the link marked "click here for additional instructions".
The computer uses a shared license via the token server. After solving an optimization model from a Java or .NET program, sometimes the Gurobi license is temporarily unavailable for other programs. How do you release the license to the token server?
After solving the model, call
GRBModel.dispose()[Java] orGRBModel.Dispose()[.NET] on all yourGRBModelobjects, then callGRBEnv.dispose()[Java] orGRBEnv.Dispose()[.NET] on theGRBEnvobject. For more information, see the information about the dispose methods in the Reference Manual.Academic Licenses
How many free trial or free academic licenses can I get?
There is no limit on free trial or free academic licenses.
How can I use a free academic license on a home computer?
To install a free academic license, the computer must be connected to the university network, via either a physical connection or VPN. If you use VPN, the connection to the Gurobi servers must go through the VPN. Once the license has been installed successfully, a connection to the university network is no longer required.
We would like to install free academic licenses in a computer lab where many students will use the software. Do we have to install keys separately for each computer and each user?
Yes. Free academic licenses are required for each user on each computer, and each license key must be requested and installed separately. Alternately, Gurobi offers paid academic licenses that can use a central license server; this eliminates the need to request and install a license key for each user on each computer. Details can be found by logging into the Gurobi website and viewing the Pricing information.
My free academic license works fine at my university, but it fails when my Mac is connected to another network, such as in my home. How can I setup a license that works in all locations?
On some Mac configurations, the computer name can change with different network connections. Open the Terminal and copy the file
~/.grbacademic.oldhostnameto~/.grbacademic.newhostname, changing the values of "oldhostname" and "newhostname" as applicable.How do I cite Gurobi software for an academic publication?
If you would like to cite Gurobi software, we suggest the following BibTeX citation:
@misc{gurobi, author = "Gurobi Optimization, Inc.", title = "Gurobi Optimizer Reference Manual", year = 2012, url = "http://www.gurobi.com" }Parameters
Why does Gurobi ignore the parameter values that I set in my program?
Each model gets its own copy of the Gurobi environment; this allows each model to have its own parameter values. However, this means that you must set parameters on the environment for the model, rather than on the master environment. To see how to set parameters on the environment for a model, see the source code in the examples subdirectory, such as the params example.
Is there a parameter to send the solver output to a log file without also printing that information on the screen?
This can't be done with a parameter, but it's easy to do with an informational callback. To capture the standard solver output, write a callback function that gets the
MSG_STRINGvalue when the 'where' value isMESSAGE. You can also create custom logs via callbacks; see the callback example for an illustration.I have tuned parameters for another solver; how do I get similar performance from Gurobi?
In terms of performance tuning, there are three types of parameters: termination criteria, tolerance values and algorithm behavior. For termination criteria (ex:
MIPGap) or tolerance values (ex:IntFeasTol), Gurobi parameters should correspond closely to those from other solvers. However, in terms of algorithm behavior, it's generally best to start with default values, since default values in Gurobi have been tested to be fast and robust across a wide variety of models. See the Parameters table in the Reference Manual as well as the Parameter Guidelines section that follows immediately afterwards.Modeling and algorithms
Why is Gurobi slow to build a model matrix?
You should only call the update function when necessary. See the next question for details.
When should I call the
update()function?Changes to a model can be efficiently processed all at once via 'lazy updates'. A program should only call the update function when it is necessary to reference something that has been created. For instance, to add new variables x and y and a constraint x+y >= 2, first create the two new variables, then call the
update()function, then add the new constraint.How do I manage multiple models in a program?
The Gurobi environment can manage multiple models concurrently; create just one Gurobi environment (ex:
GRBEnv), and create the models from that one environment.How do I model logical expressions?
Gurobi has no dedicated interface to model logical expressions, but virtually any logical expression can be transformed into linear constraints and variables. For an explanation on how to do this, see the book "Model Building in Mathematical Programming" by H. P. Williams.
How do I model piecewise linear functions such as absolute value functions?
Gurobi has no dedicated interface to model piecewise linear expressions, but these can be solved easily via special ordered sets of type 2 (SOS-2).
Where can I learn more about building optimization models?
Model Building in Mathematical Programming is a classic book that covers general modeling principles as well as a wide variety of industrial applications.
How do you implement lazy constraints in Gurobi?
Currently, the only way to add a lazy constraint is to stop solving, add the new constraint, and start solving again. Cut callbacks cannot be used to implement lazy constraints: cuts are used strictly to eliminate fractional solutions, and you will get unpredictable results if you use cut callbacks to add constraints that eliminate integer feasible solutions. Native support for lazy constraints will be added in version 5.0.
Can you modify the branch-and-bound algorithm or create a branch-cut-and-price algorithm?
The only way to create a custom algorithm like this is to stop solving, modify the model, and start solving again.
Does Gurobi have a solution polishing algorithm?
Gurobi does not have the exact same algorithm due to pending patents, but other solution improvement methods can be enabled via either the
ImproveStartTimeorImproveStartGapparameters.I have a maximization model in MPS format. Why does Gurobi report a completely different objective value than what I obtained from another solver?
The MPS file format does not indicate whether the objective should be maximized or minimized, and each solver interprets this differently. To instruct Gurobi to treat the file as a maximization model, add the lines:
OBJSENSE MAXto the top of the MPS file.
Computer hardware and software
How does Gurobi perform on different computer hardware?
You can get a rough comparison of CPU performance by browsing the SPEC CPU2006 benchmarks: http://www.spec.org/cpu2006/results/. Specifically, the results in SPECfp2006 should help you compare single-threaded performance (simplex and root node of a MIP), while the results in SPECfp_rate2006 should help you compare parallel performance (barrier and MIP nodes). As for memory, you should have enough memory so that the model can be solved in physical memory - without using virtual memory. Most of the computers Gurobi uses for testing have 12GB, which is sufficient for most customer models. Apart from cost considerations, having too much memory is no problem, while having too little can create severe problems for performance. Finally, if you are solving a MIP where you need to explore a large number of nodes, you can save memory by setting the NodefileStart parameter; this is much more efficient than relying on virtual memory.
Why is Gurobi unable to read an LP model file that worked fine with another solver?
The LP file format is not standardized. Some solvers, including Gurobi Optimizer, require spaces between variables, coefficients and operators in an LP file. For example, use
x + y + 2 z <= 2to represent the constraint x+y+2z<=2 in an LP file.A Java program is giving out-of-memory errors, yet the same model can be solved as an LP or MPS file. How can this be fixed?
The memory heap in Java is fixed at runtime, which can lead to an out-of-memory condition. However, you can adjust the size of the memory heap by setting the
-Xmxparameter when you launch the Java VM.How do I configure a new Gurobi C++ project with Microsoft Visual Studio 2010?
It's easiest to modify one of the existing projects in the
examples\buildsubdirectory. However, if you prefer to create a new project from scratch, here are the key steps:- Under the File menu, select New > Project...; on the Installed Templates panel, select Other Languages > Visual C++ > Win32, then select Win32 Console Application. For illustration, let's call it
gurobitest. Press the Finish button to close the Wizard. - To add an existing source file:
- Under Source Files below the project name in the Solution Explorer panel, right click on the initial source file that Visual Studio adds to the project (
gurobitest.cppin our example). Select Remove, then press Delete. - Right-click on the project name in the Solution Explorer panel, then select Add > Existing Item..., then choose your C++ source file.
- Under Source Files below the project name in the Solution Explorer panel, right click on the initial source file that Visual Studio adds to the project (
- Right-click on the project name in the Solution Explorer panel, then select Properties.
- Under C/C++ / Precompiled Headers / Precompiled Header, select Not Using Precompiled Headers.
- For 32-bit Gurobi libraries:
- Under C/C++ / General / Additional Include Directories, add:
c:\gurobiXYZ\win32\include - Under Linker / General / Additional Library Directories, add:
c:\gurobiXYZ\win32\lib
- Under C/C++ / General / Additional Include Directories, add:
- For 64-bit Gurobi libraries:
- Under C/C++ / General / Additional Include Directories, add:
c:\gurobiXYZ\win64\include - Under Linker / General / Additional Library Directories, add:
c:\gurobiXYZ\win64\lib - Press the Configuration Manager... button. Under Active solution platform, select New. Set the new platform to x64, and press OK.
- Under C/C++ / General / Additional Include Directories, add:
- Under Linker / Input / Additional Dependencies, add
gurobiXY.libandgurobi_c++mdd2010.lib
- Under the File menu, select New > Project...; on the Installed Templates panel, select Other Languages > Visual C++ > Win32, then select Win32 Console Application. For illustration, let's call it
How do I use Gurobi in an Eclipse Java project?
Windows: First, add the file
gurobi.jarto the project: select Project > Properties, select Java Build Path, select Libraries, and addgurobi.jaras an External JAR; the filegurobi.jaris in thelibsubdirectory of the Gurobi installation. Next, add the native libraries to the path for the Run Configuration: select the Run Configuration, select the Environment tab, and set the environment variablePATHto the absolute location of thebinsubdirectory of the Gurobi installation (ex:c:\gurobiXYZ\win64\binfor Gurobi Optimizer X.Y.Z on 64-bit Windows).Linux: First, add the file
gurobi.jarto the project: select Project > Properties, select Java Build Path, select Libraries, and addgurobi.jaras an External JAR; the filegurobi.jaris in thelibsubdirectory of the Gurobi installation. Next, add the native libraries to the path for the Run Configuration: select the Run Configuration, select the Environment tab, and set the environment variableLD_LIBRARY_PATHto the absolute location of thelibsubdirectory of the Gurobi installation.Mac OS X: No special configuration is necessary with the default installation of Gurobi Optimizer.
