Frequently Asked Questions


Question Areas  
License Keys Parameters
Academic Licenses Modeling and Algorithms
Computer Hardware and Software

If you would like to get additional help or learn more click on one of the links below:



License Keys

  Question Answer
1. How do I put the license key file in an alternate location? Set the environment variable GRB_LICENSE_FILE to point to the exact location of the file. For example, if the license file gurobi.lic is in the directory D:\work, then set GRB_LICENSE_FILE to D:\work\gurobi.lic. For more information, see the section "How to Obtain and Install a Gurobi License" in the Quick Start Guide.
2. 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".
3. I want to run an older version of Gurobi Optimizer. How can I get a license for it?

A license key is also valid for an older version. However, the older version needs to see the license key, either by copying it to the default directory for that version or by setting the GRB_LICENSE_FILE environment variable.

4.

The computer uses the Gurobi Compute Server or a shared license via the token server. After solving an optimization model, sometimes the solver is temporarily unavailable for other programs. How do you release the license?

After solving the model, you must release the Gurobi environment. The steps vary by programming language:
  • C: Call GRBfreemodel() for each model, then call GRBfreeenv() for the Gurobi environment
  • C++: If you use pointers to GRBModel and GRBEnv objects, delete all GRBModel objects, then delete the GRBEnv object
  • .Java: Call GRBModel.dispose() on all GRBModel objects, then call GRBEnv.dispose() on the GRBEnv object
  • .NET: Call GRBModel.Dispose() on all GRBModel objects, then call GRBEnv.Dispose() on the GRBEnv object
  • Python: Delete all Model objects, delete the Env object (if used), then call disposeDefaultEnv()
5. What system changes can cause a Gurobi license key to fail?
  • For Windows systems: modifying the primary disk volume ID, which can be caused by formatting or replacing the boot drive
  • For Linux and Mac OS X: modifying the primary network adaptor
  • For named-user licenses: running under a different username
Note: When running Gurobi Optimizer on a virtual machine, some of these identifiers may change if you "copy" the virtual machine. To migrate a virtual machine to a new host, select the option in your virtualization system to "move" the virtual machine rather than "copying" or "cloning" it.


Academic Licenses

  Example Description
6. How many free academic licenses can I get? There is no limit on free academic licenses.
7. 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. If your computer cannot be connected to the university network, contact support@gurobi.com for assistance.
8. 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 a Multi-user academic site license that provides a central license server; this eliminates the need to request and install a license key for each user on each computer. For details, see Gurobi for Universities.
9. 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? This was addressed in version 5.0.2. Please upgrade to the newest version and obtain a new license key via the Gurobi website.
10. 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 = 2016,
   url = "http://www.gurobi.com"
 }


Parameters

  Example Description
11. 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.
12. Is there a parameter to send the solver output to a log file without also printing that information on the screen? This can be done by setting the LogToConsole parameter to 0 and keeping the OutputFlag parameter at its default value of 1.
13. How do you set multiple termination criteria for a model? When you set multiple termination parameters, Gurobi Optimizer will stop when it reaches the first one. For example, if you want to stop if you get to a 10% MIP gap or if 60 seconds have elapsed, then set MIPGap=0.1 and TimeLimit=60. If you want a more complex set of stopping criteria, you will need to use warm starts. For example, suppose you need a 1% MIP gap, but you would prefer a smaller MIP gap if it takes less than 300 seconds. In this case, start with TimeLimit=300. If the value of the MIPGap attribute is greater than 0.01 when the time limit is reached, then increase the TimeLimit parameter, set the MIPGap parameter to 0.01, and continue to solve the MIP.
14. 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

  Example Description
15. Why is Gurobi slow to build a model matrix? You should only call the update function when necessary; see the next question for details. Also, for .NET and Python programs, it is much more efficient to build a linear or quadratic expression by modifying an existing expression rather than repeatedly creating new expressions. So for .NET, use the AddTerm/AddTerms methods instead of the overloaded operators, and for Python, use the += or -= operators rather than creating new expressions.
16. When should I call the update() function? Version 6.5 added the UpdateMode parameter; if you set UpdateMode=1, the solver will automatically call the update() function when necessary. (UpdateMode=1 is the default behavior starting with version 7.0.) For best performance, you should create all variables first, then add constraints. Finally, if a manual update is required, you will get an error, and you can modify your program to add an explicit call to the update() function.
17. How do I manage multiple models in a program? One Gurobi environment can manage multiple models; create just one Gurobi environment (ex: GRBEnv), and create the models from that one environment.
18. How do I model logical expressions? Version 7.0 added General constraints, which captures many popular types of logical expressions. More complex logical expressions can be created via combinations of General constraints.
19. How do I model piecewise linear functions? Version 6.0 added an interface for piecewise linear objective functions. For constraints, there is no dedicated interface for piecewise linear expressions, but these can be solved easily via special ordered sets of type 2 (SOS-2).
20. Where can I learn more about building optimization models? "Model Building in Mathematical Programming" by H.P. Williams is a classic book that covers general modeling principles as well as a wide variety of industrial applications. You can learn more about this book and other useful books and blogs on our books page.
21. How do you implement lazy constraints in Gurobi? There are two ways to implement lazy constraints for a MIP model. If the constraints can be enumerated up front, simply set the Lazy attribute on the constraints that should be treated as lazy. If the constraints must be generated during the MIP search, you need to write a callback function. Details can be found in the lazy functions of the Reference manual, and a TSP example can be found in the examples subdirectory. There is no support for lazy constraints in continous models (LP, QP or SOCP); the only way to add a lazy constraint in a continuous model is to stop solving, add the new constraint, and start solving again.
22. 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.
23. Can I add locally valid constraints in Gurobi MIP? No. You can only add globally valid constraints inside a callback.
24. 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 ImproveStartTime or ImproveStartGap parameters.
25. How do I find additional solutions to a model? Version 7.0 added a feature for MIP Solution Pools. Specifically, you can now request the N best solutions, or N solutions that are less than a specified gap from the optimal solution. For details, see the solution pool section in the Reference Manual.
26. Why does Gurobi sometimes return values for integer variables that are not integers? Gurobi solves MIP models via a series of linear programs. A solution is integer feasible when all the integer variables are within IntFeasTol of integer values. This can produce solution values that are not exactly integers, such as 0.000000001. Furthermore, if a model contains a wide range of numerical coefficients, then rounding a solution to exact integer values can change the solution; in this case, the model should be reformulated to reduce the range of coefficients.
27. Does the barrier algorithm return a basic solution for LPs? Yes, unless you set the Crossover parameter to 0.
28. 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
  MAX
to the top of the MPS file.
29. What are the differences between LP and MPS file format? LP file format is designed to be human-readable, so Gurobi writes coefficients in LP files with fewer decimal digits. Also, the LP file format does not preserve the order of variables, so when you export a model in LP format and read it again, the solution path may be different. Gurobi writes MPS files with full precision and maintains variable order. Thus, LP format is best for model debugging, and MPS format is best for saving a model for future testing.


Computer Hardware and Software

  Example Description
30. How does Gurobi perform on different computer hardware? You can get a rough comparison of CPU performance by browsing the SPEC CPU2006 benchmarks. Specifically, the results in SPECfp2006 should help you compare single-threaded performance (simplex and root node of a MIP). Parallel performance (for barrier and MIP tree exploration) is highly problem dependent. SPECfp_rate2006 is useful to estimate the best-case parallel performance, but actual testing is required to determine real-world performance. As for memory, you should have enough memory so that the model can be solved in physical memory - without using virtual memory. Based on models that customers share with Gurobi, 32GB is sufficient for most models, and many can be solved with much less memory. 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.
31. When will more threads make it faster to solve a model? When solving a continuous model (LP, QP, SOCP) with the barrier algorithm (Method=2), the matrix factorization is faster with more threads. However, more threads will not make the simplex method any faster. For MIP, more threads can solve a model faster if it takes a large number of nodes to solve the model. For a MIP that is solved at or near the root node, more threads will not help much, if at all.
32. What can be done to avoid an out-of-memory condition?
  1. When possible, use the 64-bit version of Gurobi Optimizer on a 64-bit system, which can handle much more memory than a 32-bit system.
  2. For a continuous (LP, QP, SOCP) model, use the simplex algorithm (Method=1 or 0), which requires less memory than the barrier or concurrent algorithms.
  3. For a MIP that requires a large amount of nodes, use node files, which are specially designed for optimization; they are more efficient than general-purpose virtual memory from the operating system. To use node files, set the NodefileStart parameter to a value like 0.5. Note that NodefileStart has no effect for continuous models or for MIP models that solve at or near the root node.
  4. Try decreasing the Threads parameter, since its default behavior uses all cores in the computer.
  5. Try the Gurobi Compute Server or the Gurobi Cloud to offload the computing to another machine that has more memory.
Ideally, the best solution is simply to have enough memory. Memory is relatively inexpensive, and we recommend having sufficient memory so that the model can be loaded and solved in physical memory (RAM).
33. Why do I get random errors when solving the same model on the same computer?

Gurobi staff have investigated many reports of random errors with the same model on the same computer. Almost always, the cause was a hardware failure. Use a standard tool such as Memtest86 to test your computer for hardware problems.

34. Why is Gurobi unable to read an LP model file that worked fine with another solver? The LP file format is not standardized. For example, some solvers, including Gurobi Optimizer, require spaces between variables, coefficients and operators in an LP file, so you must use x + y + 2 z <= 2 to represent the constraint x + y + 2z ≤ 2 in an LP file. If Gurobi Optimizer is unable to read an LP file written by another solver, try the MPS format instead.
35. How can Gurobi Optimizer use a model file from lp_solve? Model files from lp_solve can be problematic. LP files from lp_solve have many differences from the LP format supported by Gurobi and most other solvers. Avoid using their LP files with Gurobi Optimizer. In MPS files, they may write binary variables as unbounded general integers. Thus, before writing an MPS file from lp_solve, explicitly set an upper bound of 1 for all binary variables.
36. Can I use Python 3.x on Mac OS X? Support for Python 3.5 was added in version 7.0.
37.

When I run my Gurobi application on another Windows computer, I get the error message The application has failed to start because its side-by-side configuration is incorrect. How do I fix this?

Some Windows computers require the Microsoft Visual C++ 2008 Redistributable Package. For 64-bit Windows, it is available at https://www.microsoft.com/en-us/download/details.aspx?id=2092, and for 32-bit Windows, it is available at https://www.microsoft.com/en-us/download/details.aspx?id=5582.
38. 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 -Xmx parameter when you launch the Java VM.

39. Can I compile Gurobi programs using Microsoft Visual Studio Express? Microsoft Visual Studio Express is limited to 32-bit applications. You will get linker errors if you try to use 64-bit Gurobi libraries with Microsoft Visual Studio Express. To use Microsoft Visual Studio Express, use 32-bit Gurobi libraries. To use 64-bit Gurobi libraries, upgrade to a 64-bit version of Microsoft Visual Studio.
40. How do I configure a new Gurobi C++ project with Microsoft Visual Studio 2015? It's easiest to modify one of the existing projects in the examples\build subdirectory. However, if you prefer to create a new project from scratch, here are the key steps:
  1. 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.
  2. 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.cpp in 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.
  3. Right-click on the project name in the Solution Explorer panel, then select Properties.
  4. For 32-bit Gurobi libraries:
    • Set Platform to Win32 (if not already selected)
    • Under C/C++ / General / Additional Include Directories, add: c:\gurobi701\win32\include
    • Under Linker / General / Additional Library Directories, add: c:\gurobi701\win32\lib
  5. For 64-bit Gurobi libraries:
    • Set Platform to x64 (if not already selected)
    • Under C/C++ / General / Additional Include Directories, add: c:\gurobi701\win64\include
    • Under Linker / General / Additional Library Directories, add: c:\gurobi701\win64\lib
  6. Under C/C++ / Precompiled Headers / Precompiled Header, select Not Using Precompiled Headers
  7. Under Linker / Input / Additional Dependencies, add gurobi70.lib and gurobi_c++mdd2015.lib
41. How do I use Gurobi in an Eclipse Java project?
  • Windows: First, add the file gurobi.jar to the project: select Project > Properties, select Java Build Path, select Libraries, and add gurobi.jar as an External JAR; the file gurobi.jar is in the lib subdirectory 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 variable PATH to the absolute location of the bin subdirectory of the Gurobi installation (ex: c:\gurobi700\win64\bin for Gurobi Optimizer 7.0.0 on 64-bit Windows).
  • Linux: First, add the file gurobi.jar to the project: select Project > Properties, select Java Build Path, select Libraries, and add gurobi.jar as an External JAR; the file gurobi.jar is in the lib subdirectory 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 variable LD_LIBRARY_PATH to the absolute location of the lib subdirectory of the Gurobi installation.
  • Mac OS X: No special configuration is necessary with the default installation of Gurobi Optimizer.
42.

We would like to create a custom installer for our Gurobi application; can you deploy a Gurobi application without installing the full Gurobi system?

Yes. The exact configuration depends on the API used by the application:
  • Any program that uses Gurobi needs to have the Gurobi native-code library (gurobi70.dll for Windows, libgurobi70.so for Linux and OS X), and the program must be able to find the library when it runs. You can either place the file in the same directory as your program, or you can set the appropriate environment variable so that your program can find it (PATH on Windows, LD_LIBRARY_PATH on Linux, DYLD_LIBRARY_PATH on OS X).
  • Each computer will need a Gurobi license file. You can either place it in one of the default directories where Gurobi looks for a license file, or you can set the GRB_LICENSE_FILE environment variable to point to the file.
  • For Java programs, you also need to install the Gurobi JNI library (GurobiJni70.dll on Windows, libGurobiJni70.so on Linux, libGurobiJni70.jnilib on OS X). Again, you must ensure that your program can find it.
  • For .NET programs, you also need to install the Gurobi .NET library (Gurobi70.NET.dll). Again, you must ensure that your program can find it.