GUROBI OPTIMIZER QUICK START GUIDE. Version 6.5, Copyright c 2016, Gurobi Optimization, Inc.

Size: px
Start display at page:

Download "GUROBI OPTIMIZER QUICK START GUIDE. Version 6.5, Copyright c 2016, Gurobi Optimization, Inc."

Transcription

1 GUROBI OPTIMIZER QUICK START GUIDE Version 6.5, Copyright c 2016, Gurobi Optimization, Inc.

2 Contents 1 Introduction 4 2 Obtaining a Gurobi License Creating a new academic license Software Installation Guide 7 4 Retrieving and Setting Up a Gurobi License Retrieving a Free Academic license Academic validation Retrieving a Named-User, Single-Machine, or Single-Use license Setting up and using a Floating license Retrieving a Floating license Starting a token server Upgrading a token server Creating a token server client license Setting up and using a Compute Server license Retrieving a Compute Server license Creating a Compute Server client license Starting Gurobi Remote Services Upgrading Gurobi Remote Services Testing your license Solving a Simple Model - The Gurobi Command Line 27 6 Interactive Shell 33 7 Attributes 45 8 C Interface 46 2

3 9 C++ Interface Java Interface NET Interface (C#) Python Interface Simple Python Example Python Dictionary Example Building and running the examples MATLAB Interface R Interface Recommended Reading Installing the Anaconda Python distribution Using the Spyder IDE Using the ipython Notebook Windows Command Line File Overview 105 3

4 Introduction Welcome to the Gurobi TM Optimizer Quick Start Guide for Windows users! This document provides a basic introduction to the Gurobi Optimizer, including: Information on Obtaining a Gurobi License. A Software Installation Guide, which includes information on Retrieving and Setting Up your License. An example of how to create a simple optimization model and solve it with the Gurobi Command Line, and A discussion of the Gurobi Interactive Shell. We suggest that all users read these rst ve sections. Once you have done this, you will probably want to choose a programming environment from which to use Gurobi. If you don't have a strong preference, we recommend that you use our Python R interface, which provides a number of benets. First, Python is a very nice programming language that can be used for anything from experimentation to prototyping to deployment. Beyond this, though, our Python interface includes a set of higher-level modeling constructs that make it much easier to build optimization models. We also include instructions for installing the Anaconda Python distribution, which includes both a graphical development environment (Spyder) and a notebookstyle interface (ipython Notebook). If you already have a preferred programming language, you can select from among our available interfaces: C interface, C++ interface, Java R interface, Microsoft R.NET interface, Python interface, MATLAB R interface, or R interface. At the end of the Quick Start Guide, you'll nd a File Overview that lists the les included in the Gurobi distribution. 4

5 Additional resources Once you are done with the Quick Start Guide, the next step is to explore these additional resources: If you are familiar with mathematical modeling and are ready to use Gurobi from one of our programming language APIs, consult the Gurobi Reference Manual. If you would like to see examples of ways to use Gurobi, consult the Gurobi Example Tour. If you would like to learn more about mathematical programming or modeling, we've collected a set of references in our recommended reading section. Getting help Have a question that isn't answered in this guide? Post it to the Gurobi Google Group. Clients with current maintenance contracts can send questions to support@gurobi.com. Ready to get started? Your rst step is to Obtain a License. 5

6 Obtaining a Gurobi License You will need a license in order to install and use the Gurobi Optimizer. There are several ways to obtain one, depending on your situation: If you would like a free evaluation license, please us at sales@gurobi.com to request one. If you are an academic user, you can obtain a free academic license on our website. If you have purchased a license from us, that license should be visible through the Current tab of your Licenses page on our website (you will need to login to your account to see this page). If you are planning to use Gurobi as a client of a machine that is already set up as a Gurobi token server or compute server, you will need to create a token server client license or create a compute server client license. Once you have a license, your next step is to install the software. 2.1 Creating a new academic license If you are an academic user at a degree-granting institution and wish to use an academic Gurobi license, you can create one yourself. To do so, visit the Free Academic License page on our website. You will need to read and agree to the End User License Agreement and the Conditions for academic use. Once you have done so, click on Request License. Your new license will be visible immediately on the Current page. You can create as many academic licenses as you like. Your next step is to install the software. 6

7 Software Installation Guide Before using the Gurobi Optimizer, you'll need to install the software on your computer. If you haven't already done so, please go to our download page. Select your platform (32-bit or 64-bit Windows) and click on the Download button. Make a note of the name and location of the downloaded le. Your next step is to double-click on the Gurobi installer that you downloaded from our website (e.g., Gurobi win64.msi for the 64-bit version of Gurobi 6.5.0). Note: if you selected Run when downloading you've already run the installer and don't need to do it again. By default, the installer will place the Gurobi les in directory c:\gurobi650\win64 (or c:\gurobi650\win32 for 32-bit Windows installs). The installer gives you the option to change the installation target. We'll refer to the installation directory as <installdir>. Command-Line Installation You can also install Gurobi using the command-line interface to the Windows Installer. Open a cmd prompt, use cd to go to the directory that contains the Gurobi installer image, and enter the following command: msiexec /i Gurobi win64.msi /norestart If you are unfamiliar with running command-line commands on a Windows system, you can learn more here. Installing 32-bit and 64-bit simultaneously You should normally only install the Gurobi version that is targeted to your platform (32-bit or 64-bit Windows). If you want to install both on the same machine, note that the Gurobi installer 7

8 sets Windows environment variables that will point to one particular version. This can cause confusion, particularly when a program asks Windows to load the Gurobi DLL. If you understand the implications, feel free to install both. Helpful tools To work with compressed les within the Gurobi Optimizer, we recommend that you install gzip ( and/or 7zip ( You are now ready to proceed to the section on Retrieving Your Gurobi License. If you would like an overview of the les included in the Gurobi distribution, you can also view the File Overview section. 8

9 Retrieving and Setting Up a Gurobi License Once your license is visible on the Current Page of the website, click on the License ID to view the License Detail page: Your next step is to install this Gurobi license on your machine. You do this by obtaining a license key le. Please consult the License Type eld on the License Detail page to identify your license type, and click on the appropriate link below to proceed: Free Academic Named User Single-Machine Single-Use Floating Compute Server 9

10 If your license includes the Distributed Add-On and you plan to use any of the Gurobi distributed algorithms, you'll also need to set up Gurobi Remote Services on your distributed worker machines. 4.1 Retrieving a Free Academic license To obtain a Gurobi license key you'll need to run the grbgetkey command on your machine. Note that the machine must be connected to the Internet from a recognized academic domain in order to retrieve a free academic license. An Internet connection is not required after you have obtained your license key. The exact command to run for a specic license is indicated at the bottom of the License Detail page (e.g., grbgetkey 253e22f3-...). We recommend that you use copy-paste to copy the entire grbgetkey command from our website and paste it directly into the Windows Search box (and then hit Enter): If you are unfamiliar with running command-line commands on a Windows system, you can learn more here. The grbgetkey program passes identifying information about your machine back to our website, and the website responds with your license key. Once this exchange has occurred, grbgetkey will ask for the name of the directory in which to store your license key le (gurobi.lic). You should see a prompt that looks like this: 10

11 You can store the license key le anywhere, but we strongly recommend that you accept the default location by hitting Enter. Setting up a non-default location is error-prone and a frequent source of trouble. If you receive an error message at this stage, it typically means that we were unable to validate your academic domain. Please consult the Academic Validation section for more information. Using a non-default license le location When you run the Windows version of the Gurobi Optimizer, it will look for the gurobi.lic key le in three dierent default locations. It will always look in your home directory. In addition, Gurobi Optimizer will also look in c:\gurobi and c:\gurobi650. Note that these default paths are absolute, so for example Gurobi will look for the license key le in c:\gurobi, even if the software is installed in d:\gurobi. If you would still like to use a non-default license key le location, you can do so by setting environment variable GRB_LICENSE_FILE to point to the license key le. Important note: the environment variable should point to the license key le itself, not to the directory that contains the le. On Windows systems, environment variables are created and modied through the Control Panel. Searching for Environment Variables from the Control Panel search box will lead you to the appropriate screen. You will need to add a new System variable named GRB_LICENSE_FILE, and set it to the location of your license le (e.g., d:\gurobi\gurobi.lic). Important note: your new environment variable must be a System variable, not a User variable. Next steps If your license includes the Distributed Add-On and you plan to use any of the Gurobi distributed algorithms, you'll also need to set up Gurobi Remote Services on your distributed worker machines. Once you have followed the steps above and have obtained a license key le, your next step is to test your license. 11

12 4.1.1 Academic validation If you are using a free academic license, grbgetkey will perform an academic validation step before retrieving your license key. This step checks your domain name against our list of known academic domains. This section will help you resolve validation errors. Not a recognized academic domain If grbgetkey produces a message that looks like this: ERROR 303: hostname mymachine.mydomain ( ) not recognized as belonging to an academic domain it means your domain isn't on our academic domain list. Please make sure you are connected to your university network. If you are validating a home machine and the university provides a VPN, please connect to it before retrieving your license. If the reported host name is a valid university address, please send the specic error message you received to support@gurobi.com and we'll add your domain. If you are having trouble validating your license through a VPN, note that some VPNs are congured to use split tunneling, where trac to public internet sites is routed through your ISP. You should ask your network administrator whether the VPN can be congured to route trac to gurobi.com through the private network. Some machines connect to the internet through a proxy server. Unfortunately, such congurations are incompatible with our academic validation process. No reverse DNS information If grbgetkey produces a message that only references a numerical IP address, like this: ERROR 303: hostname ( ) not recognized as belonging to an academic domain it means your machine has no reverse DNS information. This usually happens when you are connecting to the Internet through a DHCP server that does NAT (network address translation) or PAT (port address translation), but does not provide DNS information for its clients. The simplest way to resolve this issue is to ask your network administrator to add a DNS entry (a PTR record) for the DHCP device itself. There is unfortunately no way for us to validate your academic license without reverse DNS information. You can visit this site to check DNS information for your IP address and to obtain more information about reverse DNS. 4.2 Retrieving a Named-User, Single-Machine, or Single-Use license To obtain a Gurobi license key you'll need to run the grbgetkey command on your machine. Note that the machine must be connected to the Internet in order to run this command. An Internet connection is not required after you have obtained your license key. 12

13 If your computer isn't connected to the Internet or if your network security system does not allow the command below to function, we also oer a manual license key process. You'll nd manual instructions at the bottom of the License Detail page (by following the link labeled click here for additional instructions). The exact command to run for a specic license is indicated at the bottom of the License Detail page (e.g., grbgetkey 253e22f3-...). We recommend that you use copy-paste to copy the entire grbgetkey command from our website and paste it directly into the Windows Search box (and then hit Enter): If you are unfamiliar with running command-line commands on a Windows system, you can learn more here. The grbgetkey program passes identifying information about your machine back to our website, and the website responds with your license key. Once this exchange has occurred, grbgetkey will ask for the name of the directory in which to store your license key le (gurobi.lic). You should see a prompt that looks like this: 13

14 You can store the license key le anywhere, but we strongly recommend that you accept the default location by hitting Enter. Setting up a non-default location is error-prone and a frequent source of trouble. Using a non-default license le location When you run the Windows version of the Gurobi Optimizer, it will look for the gurobi.lic key le in three dierent default locations. It will always look in your home directory. In addition, Gurobi Optimizer will also look in c:\gurobi and c:\gurobi650. Note that these default paths are absolute, so for example Gurobi will look for the license key le in c:\gurobi, even if the software is installed in d:\gurobi. If you would like to use a non-default license key le location, you can do so by setting environment variable GRB_LICENSE_FILE to point to the license key le. Important note: the environment variable should point to the license key le itself, not to the directory that contains the le. On Windows systems, environment variables are created and modied through the Control Panel. Searching for Environment Variables from the Control Panel search box will lead you to the appropriate screen. You will need to add a new System variable named GRB_LICENSE_FILE, and set it to the location of your license le (e.g., d:\gurobi\gurobi.lic). Important note: your new environment variable must be a System variable, not a User variable. Next steps If your license includes the Distributed Add-On and you plan to use any of the Gurobi distributed algorithms, you'll also need to set up Gurobi Remote Services on your distributed worker machines. Once you have followed the steps above and have obtained a license key le, your next step is to test your license. 14

15 4.3 Setting up and using a Floating license When using a oating license, a program that calls the Gurobi Optimizer must obtain a token from a Gurobi token server before it can solve an optimization model. There are a few steps involved in setting up such licenses. The rst is to retrieve your license key. The key should be installed on the machine that will act as your token server. Once you have your key, you will need to start the Gurobi token server. The token server is a process that runs in the background, handing out available tokens to programs as they request them. Finally, each client for the token server will need to create a token server client license to allow client programs to nd the token server. Note that if you are setting up a machine as a client of an existing token server, you just need to create a token server client license Retrieving a Floating license If you are using a oating license, you will need to choose a machine to act as your Gurobi token server. This token server doles out tokens to client machines. A client will request a token from the token server when it creates a Gurobi environment, and it will return the token when it destroys that environment. The client machine can be any machine that can reach the token server over your network (including the token server itself). The client can run any supported operating system. Thus, for example, a Linux client can request tokens from a Windows token server. Once you've chosen a machine to act as your token server, you'll need to run the grbgetkey command on that machine to retrieve your Gurobi license key. Note that the machine must be connected to the Internet in order to run this command. An Internet connection is not required after you have obtained your license key. If your computer isn't connected to the Internet or if your network security system does not allow the command below to function, we also oer a manual license key process. You'll nd manual instructions at the bottom of the License Detail page (by following the link labeled click here for additional instructions). The exact command to run for a specic license is indicated at the bottom of the License Detail page (e.g., grbgetkey 253e22f3-...). We recommend that you use copy-paste to copy the entire grbgetkey command from our website and paste it directly into the Windows Search box (and then hit Enter): If you are unfamiliar with running command-line commands on a Windows system, you can learn more here. The grbgetkey program passes identifying information about your machine back to our website, and the website responds with your license key. Once this exchange has occurred, grbgetkey will ask for the name of the directory in which to store your license key le (gurobi.lic). You should see a prompt that looks like this: You can store the license key le anywhere, but we strongly recommend that you accept the default location by hitting Enter. Setting up a non-default location is error-prone and a frequent source of trouble. 15

16 Setting a password for your token server If you want to require clients of your token server to specify a password in order to check out a token, you'll need to add one line to your gurobi.lic le: PASSWORD=abcd1234 You should of course choose your own password. Clients will need to place this same line in their client license les. When adding this line to your gurobi.lic le, please be careful not to modify anything else in the le. 16

17 Using a non-default license le location The Windows token server will look for the gurobi.lic key le in two dierent default locations: c:\gurobi and c:\gurobi650 (for Gurobi 6.5.0). Note that these default paths are absolute, so for example Gurobi will look for the license key le in c:\gurobi, even if the software is installed in d:\gurobi. Note that the token server won't look for the license le in your home directory (it runs under username LocalService, so it doesn't have access to your home directory). If you would like to use a non-default license key le location, you can do so by setting system environment variable GRB_LICENSE_FILE to point to the license key le. Important note: the environment variable should point to the license key le itself, not to the directory that contains the le. On Windows systems, environment variables are created and modied through the Control Panel. Searching for Environment Variables from the Control Panel search box will lead you to the appropriate screen. You will need to add a new System variable named GRB_LICENSE_FILE, and set it to the location of your license le (e.g., d:\gurobi\gurobi.lic). Important note: your new environment variable must be a System variable, not a User variable. Once you have followed the steps above and have obtained a license key le, your next step is to start the token server Starting a token server Important note: most Gurobi licenses do not use the token server. You should only follow these instructions if you are setting up a oating license. If you are not sure whether you need to start a token server, you can examine the contents of your gurobi.lic le. If it contains the line TYPE=TOKEN, and does not contain the line MACHINELIMIT=0, then you need a token server. On a Windows system, you can start the token service by selecting the Gurobi Token Server menu item from the Gurobi folder of the Start menu. You should only do so after you have installed the Gurobi license key le. Firewalls The next step after starting the Gurobi token server depends on your anti-virus software and rewall settings. Most anti-virus software will immediately ask you to conrm that you are allowing program grb_ts.exe to receive network trac. Once you conrm this, the token server will start serving tokens. If you don't receive such a prompt, you will need to add grb_ts.exe to the rewall exceptions list. To do this, select Allow a program through Windows rewall under the Security area of the Control Panel (labeled Allow an app through Windows rewall in Windows 8). Some machines have more restrictive rewalls that may require additional action. The Gurobi token server uses port by default. If you are unable to reach the token server after taking the steps described, you should ask your network administrator for more information on how to open the required port. 17

18 Starting and stopping the grb_ts Windows service Once the token service has been started, you should see the grb_ts service listed in the Services tab of the Task Manager. To start or stop the service, click on the Services button at the bottom-right of the Services tab, and then right-click on the Gurobi Token Server item on this screen. You can also start or stop the Gurobi Token Server service from a Console window with administrator privileges. Running grb_ts -h lists command-line options. Issuing a grb_ts -s command stops a running token server. If you are unfamiliar with running command-line commands on a Windows system, you can learn more here. Add the line VERBOSE=1 to your gurobi.lic le to start the license service in verbose mode. Verbose mode produces a log message (in the Windows Event Log) each time a token is checked in or out. Next steps Clients of the token server also need simple license les. Your next step is to set up a client license. Once your token server is running and you've set up a client license, you can move on to testing the license. Once you've set up a client license, you can test the state of the token server at any time, as well as get a list of the clients that are currently using tokens, by typing gurobi_cl --tokens Upgrading a token server To upgrade your token server from an earlier version of the Gurobi Optimizer, you will need to perform the following steps (on the machine running the token server): 1. Stop the old token server. 2. Install the new version of the Gurobi Optimizer. 3. Upgrade your license le (or modify GRB_LICENSE_FILE to point to the new license le). 4. Start the new token server Creating a token server client license The purpose of a token server client license is quite simple: it tells the client where to nd the Gurobi token server. You can create this le yourself (using a text editor like WordPad, for example). The client gurobi.lic le typically contains a single line of text: TOKENSERVER=mymachine.mydomain.com 18

19 or: TOKENSERVER= You should of course substitute the name or IP address of your token server in the example above. If your token server was congured to use a non-default port, you'll also need a line that provides the port number: PORT=46325 The client license le may also include two optional lines. A TIMEOUT line allows you to specify the timeout (in seconds) in case the token server is unavailable. The default value is 30 seconds. A PASSWORD line allows you to connect to a password-protected token server (you'll need to get the password from the owner of the token server). A more complex client token le might look like this: TOKENSERVER= TIMEOUT=10 PASSWORD=abcd1234 We strongly recommend that you place your client gurobi.lic le in a default location for your platform (either your home directory or c:\gurobi). Setting up a non-default location is errorprone and a frequent source of trouble. (If you still want to use a non-default location, please refer to the instructions that appeared earlier in this section). If your client and the token server are both running on the same machine, they can share a single gurobi.lic le. You just need to add the following line to the gurobi.lic le you obtained from our website: TOKENSERVER=localhost The token server will ignore this line, and the client will ignore everything but this line. Your other option when both client and server are running on the same machine is to create a separate gurobi.lic le for the client, and to set the GRB_LICENSE_FILE environment variable to point to this le (following the earlier instructions for using a non-default license location). Once your client license is in place, you can test the license. If you are unable to connect to the server, you'll need to make sure the server is installed and running. Please consult the instructions for starting a token server for more information. 4.4 Setting up and using a Compute Server license When using a Compute Server license, programs that call the Gurobi Optimizer can ooad Gurobi computations onto one or more server machines. There are a few steps involved in setting up such licenses. The rst is to retrieve your license key. The key should be installed on the machine that 19

20 will act as a Compute Server. Once you have your key, you will need to start Gurobi Remote Services. Finally, client machines will need a Compute Server client license in order to nd the Compute Server(s). Note that if you are setting up a machine as a client of an existing Compute Server, you just need to create a Compute Server client license Retrieving a Compute Server license If you have purchased one or more Gurobi Compute Server licenses, you'll need to perform a few setup steps in order to start your Compute Servers. Once started, client machines will be able to ooad the work of solving an optimization model onto these servers. The clients and the Compute Servers can run any mix of supported operating systems. Thus, for example, multiple Linux machines could submit jobs to a pair of Compute Servers, one running Windows and the other running Linux. Any machine that can reach the Compute Server(s) over your network can be a client (including the Compute Servers themselves). Once you've chosen a machine to act as a Compute Server, you'll need to run the grbgetkey command on that machine to retrieve your Gurobi license key. Note that the machine must be connected to the Internet in order to run this command. An Internet connection is not required after you have obtained your license key. If your computer isn't connected to the Internet or if your network security system does not allow the command below to function, we also oer a manual license key process. You'll nd manual instructions at the bottom of the License Detail page (by following the link labeled click here for additional instructions). The exact command to run for a specic license is indicated at the bottom of the License Detail page (e.g., grbgetkey 253e22f3-...). We recommend that you use copy-paste to copy the entire grbgetkey command from our website and paste it directly into the Windows Search box (and then hit Enter): If you are unfamiliar with running command-line commands on a Windows system, you can learn more here. 20

21 The grbgetkey program passes identifying information about your machine back to our website, and the website responds with your license key. Once this exchange has occurred, grbgetkey will ask for the name of the directory in which to store your license key le (gurobi.lic). You should see a prompt that looks like this: You can store the license key le anywhere, but we strongly recommend that you accept the default location by hitting Enter. Setting up a non-default location is error-prone and a frequent source of trouble. Using a non-default license le location When you run the Windows version of the Gurobi Optimizer, it will look for the gurobi.lic key le in three dierent default locations. It will always look in your home directory. In addition, Gurobi Optimizer will also look in c:\gurobi and c:\gurobi650. Note that these default paths are absolute, so for example Gurobi will look for the license key le in c:\gurobi, even if the software is installed in d:\gurobi. If you would like to use a non-default license key le location, you can do so by setting environment variable GRB_LICENSE_FILE to point to the license key le. Important note: the environment variable should point to the license key le itself, not to the directory that contains the le. On Windows systems, environment variables are created and modied through the Control Panel. Searching for Environment Variables from the Control Panel search box will lead you to the appropriate screen. You will need to add a new System variable named GRB_LICENSE_FILE, and set it to the location of your license le (e.g., d:\gurobi\gurobi.lic). Important note: your new environment variable must be a System variable, not a User variable. Once you have followed the steps above and have obtained a license key le, your next step is to start Gurobi Remote Services. 21

22 4.4.2 Creating a Compute Server client license You have two options for indicating that a Gurobi program will act as a client of a Compute Server. If you are writing a program that calls the Gurobi C, C++, Java,.NET, or Python APIs, these APIs provide routines that allow you to specify the names of the Compute Servers (GRBloadclientenv in C, and special signatures for the GRBEnv constructor in the object-oriented languages). If you use these routines, Gurobi licenses aren't required on the client. Alternately, you can set up a gurobi.lic le that points to the Compute Server. This option allows you to use a Compute Server with nearly any program that calls Gurobi, without the need to modify the calling program. You can create your client gurobi.lic yourself (using a text editor like WordPad). The le should contain a line that looks like this: COMPUTESERVER=machine1.mydomain.com,machine2.mydomain.com,machine3.mydomain.com or like this: COMPUTESERVER= , ,192, This line provides a comma-separated list of Gurobi Compute Servers. If your Compute Servers use a password, you should also include a line that gives the password: PASSWORD=cspwd Please consult the Gurobi Compute Server section of the Gurobi Reference Manual for more information. Note that if your client and server are both running on the same machine, they can share the same gurobi.lic le. You just need to add a COMPUTESERVER=localhost line to the gurobi.lic le you obtained from our website. The Compute Server will ignore this line, and the client will ignore everything but this line. Another option in this situation is to create a separate gurobi.lic le for the client, and to set the GRB_LICENSE_FILE environment variable to point to this le (following the earlier instructions for using a non-default license location). Once your client license is in place, you can test the license. If you are unable to connect to the server, you'll need to make sure the server is installed and running. Please consult the instructions for setting up a Compute Server for more information. 4.5 Starting Gurobi Remote Services Important note: you only need to start Gurobi Remote Services if you are setting up a Compute Server or a distributed worker (for use in distributed algorihms). If you are not sure whether you need to start Gurobi Remote Services, you can examine the contents of your gurobi.lic le. If it contains the line CSENABLED=1, then you need Gurobi Remote Services. If it contains a line that begins with DISTRIBUTED=, and if you plan to run distributed algorithms, then you also need Gurobi Remote Services. 22

23 On Windows systems, Gurobi Remote Services is a Windows Service that allows a server to perform Gurobi computations on behalf of other client machines. The set of services the server provides depends on your license. If you are setting up a machine as a distributed worker, no license is required. In this case, the only service provided by the server is to act as a worker in a distributed algorithm. If you have a Compute Server license, then servers running Gurobi Remote Services can provide a variety of services, including ooading computation from a set of clients, balancing computational load among the servers, and providing failover capabilities, in addition to acting as a distributed worker. On a Windows system, you will need to start Gurobi Remote Services by selecting the Gurobi Remote Services menu item from the Gurobi folder of the Start menu. You should only do so after you have installed the Gurobi license key le. Firewalls The next step after starting Gurobi Remote Services depends on your anti-virus software and rewall settings. Most anti-virus software will ask you to conrm that you are allowing programs grb_rs.exe and grb_rsw.exe to receive network trac. Once you conrm this, Gurobi Remote Servides will start serving requests. If you don't receive such a prompt, you will need to add grb_rs.exe and grb_rsw.exe to the rewall exceptions list. Select Allow a program through Windows rewall under the Security area of the Control Panel (labeled Allow an app through Windows rewall in Windows 8). Some machines have more restrictive rewalls that may require additional action. Gurobi Remote Services uses ports by default. If you are unable to reach the Compute Server after taking the steps described, ask your network administrator for more information on how to open the required ports. Gurobi Remote Services parameters Note that Gurobi Remote Services has a few user-congurable parameters. You can set these by creating a grb_rs.cnf le and placing it in the same directory as grb_rs.exe. Please consult the Gurobi Remote Services section of the Reference Manual for details. Starting and stopping the grb_rs Gurobi service Once Gurobi Remote Services has been started, you should see the grb_rs service listed in the Services tab of the Task Manager. To start or stop the service, click on the Services button at the bottom-right of the Services tab, and then right-click on the Gurobi Remote Services item on this screen. You can also start or stop Gurobi Remote Services from a Console window with administrator privileges. Running grb_rs -h lists command-line options. Issuing a grb_rs -s command stops Gurobi Remote Services. If you are unfamiliar with running command-line commands on a Windows system, you can learn more here. Add the line VERBOSE=1 23

24 to your gurobi.lic le to start Gurobi Remote Services in verbose mode. Verbose mode produces a log message (in the Windows Event Log) each time a client starts a job. All output from Gurobi Remote Services goes to the Windows Event Log. You can access this through the Event Viewer. Type Event in the search box (under the Start menu in Windows Vista and Windows 7, toward the bottom left of the desktop in Windows 10) to launch the viewer. Next steps Once you've set up Gurobi Remote Services, you should test the state of the server. Type this command on your server: gurobi_cl --server=localhost --status If the output includes the following line: Gurobi Remote Services functioning normally then Remote Services is ready for use. Client programs will need to know how to reach your server. If you are using Gurobi Compute Server, this is typically done with a client license le. You should set that up now. If you've set up distributed workers in order to run a distributed algorithm, you'll use the WorkerPool parameter to tell the client machine how to access the servers. When you are ready, you can obtain more information in the distributed algorithm section of the Reference Manual Upgrading Gurobi Remote Services If you want to upgrade Gurobi Remote Services from an earlier version of the Gurobi Optimizer, you will need to perform the following steps (on the machine running Gurobi Remote Services): 1. Stop the old Gurobi Remote Services. 2. Install the new version of the Gurobi Optimizer. 3. Upgrade your license le (or modify GRB_LICENSE_FILE to point to the new license le). 4. Start the new Gurobi Remote Services. 4.6 Testing your license Once you have obtained a license key for your machine, you are ready to test your license using the Gurobi Interactive Shell. To do this, double-click on the Gurobi icon on your desktop. The shell should produce the following output: 24

25 Gurobi Interactive Shell, Version Copyright (c) 2015, Gurobi Optimization, Inc. Type "help()" for help gurobi> If you are running as a client of a Gurobi Compute Server, the message above will be preceded by a message like this: Server capacity available on myserver - running now Congratulations, your license is functioning correctly! You are now ready to use the Gurobi Optimizer. The next section will show you how to solve a simple optimization model. Possible errors If the Gurobi shell didn't produce the desired output, there's a problem with your license. We'll list a few common errors here. ERROR: No Gurobi license found (user smith, host mymachine, hostid 9d3128ce) indicates that your gurobi.lic le couldn't be found. Did you use a non-default license le location? When you run the Windows version of the Gurobi Optimizer, it will look for the gurobi.lic key le in three dierent default locations. It will always look in your home directory. In addition, Gurobi Optimizer will also look in c:\gurobi and c:\gurobi650. Note that these default paths are absolute, so for example Gurobi will look for the license key le in c:\gurobi, even if the software is installed in d:\gurobi. If you used a non-default license key le location, you should set environment variable GRB_LICENSE_FILE to point to the license key le. Important note: the environment variable points to the license key le itself, not to the directory that contains the le. The following message: ERROR: HostID mismatch (licensed to 9d3128ce, hostid is 7de025e9) indicates that your gurobi.lic isn't valid for this machine. You should make sure that you are using the right gurobi.lic le. If you are running as a client of a Gurobi token server and receive this message: ERROR: Failed to connect to token server 'myserver' (port 41954) the Compute Server isn't currently running. Please consult the section on setting up a token server. If you are running as a client of a Gurobi Compute Server and receive this message: 25

26 ERROR: No server available the Compute Server isn't currently running. Please consult the section on setting up a Compute Server. 26

27 Solving a Simple Model - The Gurobi Command Line Now that the Gurobi Optimizer is installed and the license key has been tested, you're ready to solve a simple math programming model. This section includes instructions on how to congure the math programming model le and how to use the Gurobi command-line interface to compute an optimal solution. If you are already familiar with mathematical modeling and LP-format les, feel free to skip to the end of this section. Note that this section gives only a brief glimpse into the capabilities of the Gurobi command-line interface. This interface plays a number of dierent roles. In addition to providing a simple interface for solving a model, it can also be used to launch a model on a Compute Server or on a cloud system, it can check on the status of a token server, and it provides tools that allow you to manage jobs and administer a Compute Server. If you'd like additional information, consult the Command-Line Tool section of our Reference Manual. The problem statement - producing coins Begin by stating the problem to be solved. Imagine that it is the end of the calendar year at the United States Mint. The Mint keeps an inventory of the various minerals used to produce the coins that are put into circulation, and it wants to use up the minerals on hand before retooling for next year's coins. The Mint produces several dierent types of coins, each with a dierent composition. The table below shows the make-up of each coin type (as reported in the US Mint coin specications). Penny Nickel Dime Quarter Dollar Copper (Cu) 0.06g 3.8g 2.1g 5.2g 7.2g Nickel (Ni) 1.2g 0.2g 0.5g 0.2g Zinc (Zi) 2.4g 0.5g Manganese (Mn) 0.3g Suppose the Mint wants to use the available materials to produce coins with the maximum total dollar value. Which coins should they produce? The optimization model In order to formulate this as an optimization problem, we'll need to do three things. First, we'll need to dene the decision variables. The goal of the optimization is to choose values for these variables. 27

28 Second, we'll dene a linear objective function. This is the function we'd like to minimize (or maximize). Third, we'll dene the linear constraints. The Gurobi Optimizer will consider all assignments of values to decision variables that satisfy the specied linear constraints, and return one that optimizes the stated objective function. The variables in this problem are quite straightforward. The solver will need to decide how many of each coin to produce. It is convenient to give the decision variables meaningful names. In this case, we'll call the variables Pennies, Nickels, Dimes, Quarters, and Dollars. We'll also introduce variables that capture the quantities of the various minerals actually used by the solution. We'll call them Cu, Ni, Zi, and Mn. Recall that the objective of our optimization problem is to maximize the total dollar value of the coins produced. Each penny produced is worth 0.01 dollars, each nickel is worth 0.05 dollars, etc. This gives the following linear objective: maximize: 0.01 Pennies Nickels Dimes Quarters + 1 Dollars The constraints of this model come from the fact that producing a coin consumes certain quantities of the available minerals, and the supplies of those minerals are limited. We'll capture these relationships in two parts. First, we'll create an equation for each mineral that captures the amount of that mineral that is consumed. For copper, that equation would be: Cu = 0.06 Pennies Nickels Dimes Quarters Dollars The coecients for this equation come from the earlier coin specication table: one penny uses 0.06g of copper, one nickel uses 3.8g, etc. The model must also capture the available quantities of each mineral. If we have 1000 grams of copper available, then the constraint would be: Cu <= 1000 For our example, we'll assume we have 1000 grams of copper and 50 grams of the other minerals. There is actually one other set of constraints that must be captured in order for our model to accurately reect the physical realities of our problem. While a dime is worth 10 cents, half of a dime isn't worth 5 cents. The variables that capture the number of each coin produced must take integer values. The model le The Gurobi Optimizer provides a variety of options for expressing an optimization model. Typically, you would build the model using an interface to a programming languages (C, C++, C#, Java, etc.) or using a higher-level application environment (a spreadsheet, a modeling system, MATLAB, 28

29 R, etc.). However, to keep our example as simple as possible, we're going to read the model from an LP format le. The LP format was designed to be human readable, and as such it is well suited for our needs. The LP format is mostly self-explanatory. Here is our model: Maximize.01 Pennies +.05 Nickels +.1 Dimes +.25 Quarters + 1 Dollars Subject To Copper:.06 Pennies Nickels Dimes Quarters Dollars - Cu = 0 Nickel: 1.2 Nickels +.2 Dimes +.5 Quarters +.2 Dollars - Ni = 0 Zinc: 2.4 Pennies +.5 Dollars - Zi = 0 Manganese:.3 Dollars - Mn = 0 Bounds Cu <= 1000 Ni <= 50 Zi <= 50 Mn <= 50 Integers Pennies Nickels Dimes Quarters Dollars End You'll nd this model in le coins.lp in the <installdir>/examples/data directory of your Gurobi distribution. Specically, assuming you've installed Gurobi in the recommended location, you'll nd the le in c:\gurobi650\win64\examples\data\coins.lp. To modify this le, open it in a text editor (like Wordpad). Editing the LP le Before you consider making any modications to this le or creating your own, we should point out a few rules about LP format les. 1. Ordering of the sections Our example contains an objective section (Maximize...), a constraint section (Subject To...), a variable bound section (Bounds...), and an integrality section (Integers...). The sections must come in that order. The complete list of section types and the associated ordering rules can be found in the le format section of the Gurobi Reference Manual. 2. Separating tokens Tokens must be separated by either a space or a newline. Thus, for example, the term: +.1 Dimes must include a space or newline between + and.1, and another between.1 and Dimes. 29

30 3. Arranging variables Variables must always appear on the left-hand side of a constraint. The right-hand side is always a constant. Thus, our constraint: Cu =.06 Pennies Nickels Dimes Quarters Dollars...becomes Pennies Nickels Dimes Quarters Dollars - Cu = 0 4. Variable default bounds Unless stated otherwise, a variable has a zero lower bound and an innite upper bound. Thus, Cu <= 1000 really means 0 <= Cu <= Similarly, any variable not mentioned in the Bounds section may take any non-negative value. Full details on the LP le format are provided in the le format section of the Gurobi Reference Manual. Solving the model using the Gurobi command-line interface The nal step in solving our optimization problem is to pass the model to the Gurobi Optimizer. We'll use the Gurobi command-line interface, as it is typically the simplest of our interfaces to use when solving a model stored in a le. To use the command-line interface, you'll rst need to open a Console window. If you are unfamiliar with running command-line commands on a Windows system, you can learn more here. (Note that the Gurobi Interactive Shell, which was used earlier to test your license, does not directly accept command-line program input). The name of the Gurobi command-line tool is gurobi_cl. To invoke it, type gurobi_cl, followed by the name of the model le. For example, if our model is stored in the le c:\gurobi650\win64\examples\data\coins.lp, you would type the following command into your command-line window... > gurobi_cl c:\gurobi650\win64\examples\data\coins.lp This command should produce the following output... Read LP format model from file c:\gurobi650\win64\examples\data\coins.lp Reading time = 0.00 seconds (null): 4 rows, 9 columns, 16 nonzeros Optimize a model with 4 rows, 9 columns and 16 nonzeros Presolve removed 1 rows and 5 columns Presolve time: 0.00s Presolved: 3 rows, 4 columns, 9 nonzeros Variable types: 0 continuous, 4 integer (0 binary) 30

31 Found heuristic solution: objective Found heuristic solution: objective Root relaxation: objective e+02, 4 iterations, 0.00 seconds Nodes Current Node Objective Bounds Work Expl Unexpl Obj Depth IntInf Incumbent BestBd Gap It/Node Time % - 0s % - 0s H % - 0s Explored 0 nodes (5 simplex iterations) in 0.00 seconds Thread count was 2 (of 2 available processors) Optimal solution found (tolerance 1.00e-04) Best objective e+02, best bound e+02, gap 0.0% Details on the format of the Gurobi log le can be found in the Gurobi Reference Manual. For now, you can simply note that the optimal objective value is Recall that the objective is denoted in dollars. We can therefore conclude that by a proper choice of production plan, the Mint can produce $ worth of coins using the available minerals. Moreover, because this value is optimal, we know that it is not possible to produce coins with value greater than $113.45! It would clearly be useful to know the exact number of each coin produced by this optimal plan. The gurobi_cl command allows you to set Gurobi parameters through command-line arguments. One particularly useful parameter for the purposes of this example is ResultFile, which instructs the Gurobi Optimizer to write a le once optimization is complete. The type of the le is encoded in the sux. To request a.sol le: > gurobi_cl ResultFile=coins.sol coins.lp The command will produce a le that contains solution values for the variables in the model: # Objective value = Pennies 0 Nickels 0 Dimes 2 Quarters 53 Dollars 100 Cu Ni 46.9 Zi 50 Mn 30 In the optimal solution, we'll produce 100 dollar coins, 53 quarters, and 2 dimes. 31

32 If we wanted to explore the parameters of the model (for example, to consider how the optimal solution changes with dierent quantities of available minerals), we could use a text editor to modify the input le. However, it is typically better to do such tests within a more powerful system. We'll now describe the Gurobi Interactive Shell, which provides an environment for creating, modifying, and experimenting with optimization models. 32

33 Interactive Shell The Gurobi interactive shell allows you to perform hands-on interaction and experimentation with optimization models. You can read models from les, perform complete or partial optimization runs on them, change parameters, modify the models, reoptimize, and so on. The Gurobi shell is actually a set of extensions to the Python shell. Python is a rich and exible programming language, and any capabilities that are available from Python are also available from the Gurobi shell. We'll touch on these capabilities here, but we encourage you to explore the help system and experiment with the interface in order to gain a better understanding of what is possible. One big advantage of working within Python is that the Python language is popular and well supported. One aspect of this support is the breadth of powerful Python Integrated Development Environments (IDEs) that are available, most of which can be downloaded for free from the internet. This document includes instructions for setting up Gurobi for use within the Anaconda distribution. Anaconda includes a powerful IDE (Spyder), as well as a notebook-style interface (ipython Notebook). Before diving into the details of the Gurobi interactive shell, we should remind you that Gurobi also provides a lightweight command line interface. If you just need to do a quick test on a model stored in a le, you will probably nd that that interface is better suited to simple tasks than the interactive shell. Important note for AIX users: due to limited Python support on AIX, our AIX port does not include the Interactive Shell or the Python interface. You can use the command line, or the C, C++, or Java interfaces. We will now work through a few simple examples of how the Gurobi shell might be used, in order to give you a quick introduction to its capabilities. More thorough documentation on this and other interfaces is available in the Gurobi Reference Manual. Reading and optimizing a model There are several ways to access the Gurobi Interactive Shell from Windows: Double-click on the Gurobi desktop shortcut. Select the Gurobi Interactive Shell from the Start Menu. Open a DOS command shell and type gurobi.bat. From Linux or Mac OS, you can simply type gurobi.sh from the command prompt. installed a Python IDE, the shell will also be available from that environment. If you've Once the optimizer has started, you are ready to load and optimize a model. We'll consider model coins.lp from <installdir>/examples/data... 33

34 > gurobi.bat (or gurobi.sh for Linux or Mac OS) Gurobi Interactive Shell, Version Copyright (c) 2015, Gurobi Optimization, Inc. Type "help()" for help gurobi> m = read('c:/gurobi650/win64/examples/data/coins.lp') Read LP format model from file c:/gurobi650/win64/examples/data/coins.lp Reading time = 0.00 seconds (null): 4 rows, 9 columns, 16 nonzeros gurobi> m.optimize() Optimize a model with 4 rows, 9 columns and 16 nonzeros Presolve removed 1 rows and 5 columns Presolve time: 0.00s Presolved: 3 rows, 4 columns, 9 nonzeros Variable types: 0 continuous, 4 integer (0 binary) Found heuristic solution: objective Found heuristic solution: objective Root relaxation: objective e+02, 4 iterations, 0.00 seconds Nodes Current Node Objective Bounds Work Expl Unexpl Obj Depth IntInf Incumbent BestBd Gap It/Node Time % - 0s % - 0s H % - 0s Explored 0 nodes (5 simplex iterations) in 0.00 seconds Thread count was 4 (of 4 available processors) Optimal solution found (tolerance 1.00e-04) Best objective e+02, best bound e+02, gap 0.0% The read() command reads a model from a le and returns a Model object. In the example, that object is placed into variable m. There is no need to declare variables in the Python language; you simply assign a value to a variable. Note that read() accepts wildcard characters, so you could also have said: gurobi> m = read('c:/gurobi650/win64/*/*/coin*') Note also that Gurobi commands that read or write les will also function correctly with compressed les. If gzip, bzip2, or 7zip are installed on your machine and available in your default path, then you simply need to add the appropriate sux (.gz,.bz2,.zip, or.7z) to the le name to read or write compressed versions. 34

35 The next statement in the example, m.optimize(), invokes the optimize method on the Model object (you can obtain a list of all methods on Model objects by typing help(model) or help(m)). The Gurobi optimization engine nds an optimal solution with objective Inspecting the solution Once a model has been solved, you can inspect the values of the model variables in the optimal solution with the printattr() method on the Model object: gurobi> m.printattr('x') Variable X Dimes 2 Quarters 53 Dollars 100 Cu Ni 46.9 Zi 50 Mn 30 This routine prints all non-zero values of the specied attribute X. Attributes play a major role in the Gurobi optimizer. We'll discuss them in more detail shortly. You can also inspect the results of the optimization at a ner grain by retrieving a list of all the variables in the model using the getvars() method on the Model object (m.getvars() in our example): gurobi> v = m.getvars() gurobi> print len(v) 9 The rst command assigns the list of all Var objects in model m to variable v. The Python len() command gives the length of the array (our example model coins has 9 variables). You can then query various attributes of the individual variables in the list. For example, to obtain the variable name and solution value for the rst variable in list v, you would issue the following command: gurobi> print v[0].varname, v[0].x Pennies 0.0 You can type help(var) or help(v[0]) to get a list of all methods on a Var object. You can type help(grb.attr) to get a list of all attributes. Simple model modication We will now demonstrate a simple model modication. Imagine that you only want to consider solutions where you make at least 10 pennies (i.e., where the Pennies variable has a lower bound 35

36 of 10.0). This is done by setting the lb attribute on the appropriate variable (the rst variable in the list v in our example)... gurobi> v = m.getvars() gurobi> v[0].lb = 10 The Gurobi optimizer keeps track of the state of the model, so it knows that the currently loaded solution is not necessarily optimal for the modied model. When you invoke the optimize() method again, it performs a new optimization on the modied model... gurobi> m.optimize() Optimize a model with 4 rows, 9 columns and 16 nonzeros Presolve removed 2 rows and 5 columns Presolve time: 0.00s Presolved: 2 rows, 4 columns, 5 nonzeros MIP start did not produce a feasible solution Variable types: 0 continuous, 4 integer (0 binary) Found heuristic solution: objective Root relaxation: objective e+01, 2 iterations, 0.00 seconds Nodes Current Node Objective Bounds Work Expl Unexpl Obj Depth IntInf Incumbent BestBd Gap It/Node Time * % - 0s Explored 0 nodes (2 simplex iterations) in 0.00 seconds Thread count was 4 (of 4 available processors) Optimal solution found (tolerance 1.00e-04) Best objective e+01, best bound e+01, gap 0.0% The result shows that, if you force the solution to include at least 10 pennies, the maximum possible objective value for the model decreases from to A simple check conrms that the new lower bound is respected: gurobi> print v[0].x 10.0 Simple experimentation with a more dicult model Let us now consider a more dicult model, glass4.mps. Again, we read the model and begin the optimization: 36

37 gurobi> m = read('c:/gurobi650/win64/examples/data/glass4') Read MPS format model from file c:/gurobi650/win64/examples/data/glass4.mps Reading time = 0.00 seconds glass4: 396 Rows, 322 Columns, 1815 NonZeros gurobi> m.optimize() Optimize a model with 396 Rows, 322 Columns and 1815 NonZeros Presolve removed 4 rows and 5 columns Presolve time: 0.00s Presolved: 392 Rows, 317 Columns, 1815 Nonzeros Found heuristic solution: objective e+09 Root relaxation: objective e+08, 72 iterations, 0.00 seconds Nodes Current Node Objective Bounds Work Expl Unexpl Obj Depth IntInf Incumbent BestBd Gap It/Node Time e e e % - 0s e e e % - 0s e e e % - 0s e e e % - 0s e e e % - 0s H e e % 5.2 0s H e e % 5.3 0s H e e % 5.1 0s H e e % 5.1 0s H e e % 5.1 0s H e e % 5.1 0s * e e % 4.9 0s * e e % 4.8 0s H e e % 4.8 0s H e e % 5.0 0s H e e % 4.1 0s H e e % 4.1 0s H e e % 2.5 1s H e e % 2.4 1s * e e % 2.4 1s * e e % 2.3 1s * e e % 2.3 1s * e e % 2.3 1s H e e % 2.3 1s * e e % 2.3 1s * e e % 2.3 1s * e e % 2.2 1s H e e % 2.3 2s e e e % 2.2 5s 37

38 e e e % s * e e % s * e e % s Interrupt request received Explored nodes ( simplex iterations) in seconds Thread count was 8 (of 8 available processors) Solve interrupted Best objective e+09, best bound e+08, gap % It quickly becomes apparent that this model is quite a bit more dicult than the earlier coins model. The optimal solution is actually 1,200,000,000, but nding that solution takes a while. After letting the model run for 10 seconds, we interrupt the run (by hitting CTRL-C, which produces the Interrupt request received message) and consider our options. Typing m.optimize() would resume the run from the point at which it was interrupted. Changing parameters Rather than continuing optimization on a dicult model like glass4, it is sometimes useful to try dierent parameter settings. When the lower bound moves slowly, as it does on this model, one potentially useful parameter is MIPFocus, which adjusts the high-level MIP solution strategy. Let us now set this parameter to value 1, which changes the focus of the MIP search to nding good feasible solutions. There are two ways to change the parameter value. You can either use method m.setparam(): gurobi> m.setparam('mipfocus', 1) Changed value of parameter MIPFocus to 1 Prev: 0 Min: 0 Max: 3 Default: 0...or you can use the m.params class... gurobi> m.params.mipfocus = 1 Changed value of parameter MIPFocus to 1 Prev: 0 Min: 0 Max: 3 Default: 0 Once the parameter has been changed, we call m.reset() to reset the optimization on our model and then m.optimize() to start a new optimization run: gurobi> m.reset() gurobi> m.optimize() Optimize a model with 396 Rows, 322 Columns and 1815 NonZeros Presolve removed 4 rows and 5 columns Presolve time: 0.00s 38

39 Presolved: 392 Rows, 317 Columns, 1815 Nonzeros Found heuristic solution: objective e+09 Root relaxation: objective e+08, 72 iterations, 0.00 seconds Nodes Current Node Objective Bounds Work Expl Unexpl Obj Depth IntInf Incumbent BestBd Gap It/Node Time e e e % - 0s e e e % - 0s e e e % - 0s e e e % - 0s H e e % - 0s H e e % - 0s e e e % - 0s e e e % - 0s H e e % - 0s H e e % - 0s e e e % - 0s H e e % 4.6 0s H e e % 4.6 0s H e e % 4.5 0s H e e % 4.3 0s H e e % 4.2 0s H e e % 4.0 0s H e e % 3.5 0s H e e % 3.5 0s H e e % 3.5 0s H e e % 3.4 0s H e e % 4.2 1s H e e % 4.3 1s H e e % 4.3 1s H e e % 4.3 1s H e e % 4.3 1s H e e % 4.2 1s e e e % 3.5 5s e e e % s H e e % s H e e % s H e e % s H e e % s H e e % s H e e % s Interrupt request received 39

40 Cutting planes: Gomory: 6 Implied bound: 26 MIR: 60 Explored nodes ( simplex iterations) in seconds Thread count was 8 (of 8 available processors) Solve interrupted Best objective e+09, best bound e+08, gap % Results are consistent with our expectations. We nd a better solution sooner by shifting the focus towards nding feasible solutions (objective value 1.525e9 versus 1.6e9). The setparam() method is designed to be quite exible and forgiving. It accepts wildcards as arguments, and it ignores character case. Thus, the following commands are all equivalent: gurobi> m.setparam('nodelimit', 100) gurobi> m.setparam('nodelimit', 100) gurobi> m.setparam('node*', 100) gurobi> m.setparam('n???limit, 100) You can use wildcards to get a list of matching parameters: gurobi> m.setparam('*cuts', 2) Matching parameters: ['Cuts', 'CliqueCuts', 'CoverCuts', 'FlowCoverCuts', 'FlowPathCuts', 'GUBCoverCuts', 'ImpliedCuts', 'MIPSepCuts', 'MIRCuts', 'ModKCuts', 'NetworkCuts', 'SubMIPCuts', 'ZeroHalfCuts'] Note that Model.Params is a bit less forgiving than setparam(). In particular, wildcards are not allowed with this approach. You don't have to worry about capitalization of parameter names in either approach, though, so m.params.heuristics and m.params.heuristics are equivalent. The full set of available parameters can be browsed using the paramhelp() command. You can obtain further information on a specic parameter (e.g., MIPGap) by typing paramhelp('mipgap'). Parameter tuning tool When confronted with the task of choosing parameter values that might lead to better performance on a model, the long list of Gurobi parameters may seem intimidating. To simplify the process, we include a simple automated parameter tuning tool. From the interactive shell, the command is tune: gurobi> m = read('misc07') gurobi> m.tune() 40

41 The tool tries a number of dierent parameter settings, and eventually outputs the best ones that it nds. For example: Tested 12 parameter sets in 47.77s Baseline parameter set: runtime 2.39s Improved parameter set 1 (runtime 1.72s): RINS 0 In this case, it found that setting the RINS parameter to 0 for model misc07 reduced the runtime from 2.39s to 1.72s. Note that tuning is meant to give general suggestions for parameters that might help performance. You should make sure that the results it gives on one model are helpful on the full range of models you plan to solve. You may sometimes nd that performance problems can't be xed with parameter changes alone, particulary if your model has severe numerical issues. Tuning is also available as a standalone program. From a command prompt, you can type: > grbtune c:\gurobi650\win64\examples\data\p0033 Please consult the Automated Tuning Tool section of the Gurobi Reference Manual for more information. Using a gurobi.env le When you want to change the values of Gurobi parameters, you actually have several options available for doing so. We've already discussed parameter changes through the command-line tool (e.g., gurobi_cl Threads=1 coins.lp), and through interactive shell commands (e.g., m.setparam('threads', 1)). Each of our language APIs also provides methods for setting parameters. The other option we'd like to mention now is the gurobi.env le. Whenever the Gurobi library starts, it will look for le gurobi.env in the current working directory, and will apply any parameter changes contained therein. This is true whether the Gurobi library is invoked from the command-line, from the interactive shell, or from any of the Gurobi APIs. Parameter settings are stored one per line in this le, with the parameter name rst, followed by at least one space, followed by the desired value. Lines beginning with the # sign are comments and are ignored. To give an example, the following (Linux) commands: echo "Threads 1" > gurobi.env gurobi_cl coins.lp would read the new value of the Threads parameter from le gurobi.env and then optimize model coins.lp using one thread. Note that if the same parameter is changed in both gurobi.env and in your program (or through the Gurobi command-line), the value from gurobi.env will be ignored. 41

42 The distribution includes a sample gurobi.env le (in the bin directory). The sample includes every parameter, with the default value for each, but with all settings commented out. Working with multiple models The Gurobi shell allows you to work with multiple models simultaneously. For example... gurobi> a = read('c:/gurobi650/win64/examples/data/p0033') Read MPS format model from file c:/gurobi650/win64/examples/data/p0033.mps Reading time = 0.00 seconds P0033: 16 Rows, 33 Columns, 98 NonZeros. gurobi> b = read('c:/gurobi650/win64/examples/data/stein9') Read MPS format model from file c:/gurobi650/win64/examples/data/stein9.mps Reading time = 0.00 seconds STEIN9: 13 Rows, 9 Columns, 45 NonZeros. The models() command gives a list of all active models. gurobi> models() Currently loaded models: a : <gurobi.model MIP instance P0033: 16 constrs, 33 vars> b : <gurobi.model MIP instance STEIN9: 13 constrs, 9 vars> Note that parameters can be set for a particular model with the Model.setParam() method or the Model.Params class, or they can be changed for all models in the Gurobi shell by using the global setparam() method. Help The interactive shell includes an extensive help facility. To access it, simply type help() at the prompt. As previously mentioned, help is available for all of the important objects in the interface. For example, as explained in the help facility, you can type help(model), help(var), or help(constr). You can also obtain detailed help on any of the available methods on these objects. For example, help(model.setparam) gives help on setting model parameters. You can also use a variable, or a method on a variable, to ask for help. For example, if variable m contains a Model object, then help(m) is equivalent to help(model), and help(m.setparam) is equivalent to help(model.setparam). Interface customization The Gurobi interactive shell lives within a full featured scripting language. This allows you to perform a wide range of customizations to suit your particular needs. Creating custom functions 42

43 requires some knowledge of the Python language, but you can achieve a lot by using a very limited set of language features. Let us consider a simple example. Imagine that you store your models in a certain directory on your disk. Rather than having to type the full path whenever you read a model, you can create your own custom read method: gurobi> def myread(filename):... return read('/home/john/models/'+filename) Note that the indentation of the second line is required. Dening this function allows you to do the following: gurobi> m = myread('stein9') Read MPS format model from file /home/john/models/stein9.mps If you don't want to type this function in each time you start the Gurobi shell, you can store it in a le. The le would look like the following: from gurobipy import * def myread(filename): return read('/home/john/models/'+filename) The from gurobipy import * line is required in order to allow you to use the read method from the Gurobi shell in your custom function. The name of your customization le must end with a.py sux. If the le is named custom.py, you would then type: gurobi> from custom import * in order to import this function. One le can contain as many custom functions as you'd like (see custom.py in <installdir>/examples/python for an example). If you wish to make site-wide customizations, you can also customize the gurobi.py le that is included in <installdir>/lib. Customization through callbacks Another type of customization we'd like to touch on briey can be achieved through Gurobi callbacks. Callbacks allow you to track the progress of the optimization process. For the sake of our example, let's say you want the MIP optimizer to run for 10 seconds before quitting, but you don't want it to terminate before it nds a feasible solution. The following callback method would implement this condition: from gurobipy import * def mycallback(model, where): 43

44 if where == GRB.Callback.MIP: time = model.cbget(grb.callback.runtime) best = model.cbget(grb.callback.mip_objbst) if time > 10 and best < GRB.INFINITY: model.terminate() Once you import this function (from custom import *), you can then say m.optimize(mycallback) to obtain the desired termination behavior. Alternatively, you could dene your own custom optimize method that always invokes the callback: def myopt(model): model.optimize(mycallback) This would allow you to say myopt(m). You can pass arbitrary data into your callback through the model object. For example, if you set m._mydata = 1 before calling optimize(), you can query m._mydata inside your callback function. Note that the names of user data elds must begin with an underscore. This callback example is included in <installdir>/examples/python/custom.py. Type from custom import * to import the callback and the myopt() function. You can type help(grb.callback) for more information on callbacks. You can also refer to the Callback class documentation in the Gurobi Reference Manual. The Gurobi Python Interface for Python Users While the Gurobi installation includes everything you need to use Gurobi from within Python, we understand that some users would prefer to use Gurobi from within their own Python environment. Doing so requires you to install the gurobipy module. The steps for doing this depend on your platform. On Windows, you can double-click on the pysetup program in the Gurobi <installdir>/bin directory. This program will prompt you for the location of your Python installation; it handles all of the details of the installation. On Linux or Mac OS, you will need to open a terminal window, change your current directory to the Gurobi <installdir> (the directory that contains the le setup.py), and issue the following command: python setup.py install Unless you are using your own private Python installation, you will need to run this command as super-user. Once gurobipy is successfully installed, you can type import gurobipy or from gurobipy import * from your Python shell and access all of the Gurobi classes and methods. Note that for this installation to succeed, your Python environment must be compatible with the Gurobi Python module. You should only install 32-bit Gurobi libraries into a 32-bit Python shell (similarly for 64-bit versions). In addition, your Python version must be compatible. With this release, gurobipy can be used with Python 2.7, 3.2, or 3.4 on Windows and Linux, and with Python 2.7 on Mac OS. 44

45 Attributes As mentioned in the previous section, most of the information associated with a Gurobi model is stored in a set of attributes. Some attributes are associated with the variables of the model, some with the constraints of the model, and some with the model itself. After you optimize a model, for example, the solution is stored in the X variable attribute. Attributes that are computed by the Gurobi optimizer (such as the solution attribute) cannot be modied directly by the user, while those that represent input data (such as the LB attribute which stores variable lower bounds) can. Each of the Gurobi language interfaces contains routines for querying or modifying attribute values. To retrieve or modify the value of a particular attribute, you simply pass the name of the attribute to the appropriate query or modication routine. In the C interface, for example, you'd make the following call to query the current solution value on variable 1: double x1; error = GRBgetdblattrelement(model, GRB_DBL_ATTR_X, 1, &x1); This routine returns a single element from an array-valued attribute containing double-precision data. Routines are provided to query and modify scalar-valued and array-valued attributes of type int, double, char, or char *. In the object oriented interfaces, you query or modify attribute values through the appropriate objects. For example, if variable v is a Gurobi variable object (a GRBVar), then the following calls would be used to modify the lower bound on v: C++: v.set(grb_doubleattr_lb, 0.0); Java: v.set(grb.doubleattr.lb, 0.0); C#: v.set(grb.doubleattr.lb, 0.0); Python: v.lb = 0.0 The exact syntax for querying or modifying an attribute varies slightly from one language to another, but the basic approach remains consistent: you call the appropriate query or modication method using the name of the desired attribute as an argument. The full list of Gurobi attributes can be found in the Attributes section of the Gurobi Reference Manual. 45

46 C Interface This section will work through a simple C example in order to illustrate the use of the Gurobi C interface. The example builds a simple Mixed Integer Programming model, optimizes it, and outputs the optimal objective value. This section assumes that you are already familiar with the C programming language. If not, a variety of books are available for learning the language (for example, The C Programming Language, by Kernighan and Ritchie). Our example optimizes the following model: maximize x + y + 2 z subject to x + 2 y + 3 z 4 x + y 1 x, y, z binary Example mip1_c.c This is the complete source code for our example (also available as <installdir>/examples/c/mip1_c.c)... #include <stdlib.h> #include <stdio.h> #include "gurobi_c.h" int main(int argc, char *argv[]) { GRBenv *env = NULL; GRBmodel *model = NULL; int error = 0; double sol[3]; int ind[3]; double val[3]; double obj[3]; char vtype[3]; int optimstatus; double objval; int zero = 0; /* Create environment */ 46

47 error = GRBloadenv(&env, "mip1.log"); if (error env == NULL) { fprintf(stderr, "Error: could not create environment\n"); exit(1); } /* Create an empty model */ error = GRBnewmodel(env, &model, "mip1", 0, NULL, NULL, NULL, NULL, NULL); if (error) goto QUIT; /* Add variables */ obj[0] = 1; obj[1] = 1; obj[2] = 2; vtype[0] = GRB_BINARY; vtype[1] = GRB_BINARY; vtype[2] = GRB_BINARY; error = GRBaddvars(model, 3, 0, NULL, NULL, NULL, obj, NULL, NULL, vtype, NULL); if (error) goto QUIT; /* Change objective sense to maximization */ error = GRBsetintattr(model, GRB_INT_ATTR_MODELSENSE, GRB_MAXIMIZE); if (error) goto QUIT; /* Integrate new variables */ error = GRBupdatemodel(model); if (error) goto QUIT; /* First constraint: x + 2 y + 3 z <= 4 */ ind[0] = 0; ind[1] = 1; ind[2] = 2; val[0] = 1; val[1] = 2; val[2] = 3; error = GRBaddconstr(model, 3, ind, val, GRB_LESS_EQUAL, 4.0, NULL); if (error) goto QUIT; /* Second constraint: x + y >= 1 */ ind[0] = 0; ind[1] = 1; val[0] = 1; val[1] = 1; 47

48 error = GRBaddconstr(model, 2, ind, val, GRB_GREATER_EQUAL, 1.0, NULL); if (error) goto QUIT; /* Optimize model */ error = GRBoptimize(model); if (error) goto QUIT; /* Write model to 'mip1.lp' */ error = GRBwrite(model, "mip1.lp"); if (error) goto QUIT; /* Capture solution information */ error = GRBgetintattr(model, GRB_INT_ATTR_STATUS, &optimstatus); if (error) goto QUIT; error = GRBgetdblattr(model, GRB_DBL_ATTR_OBJVAL, &objval); if (error) goto QUIT; error = GRBgetdblattrarray(model, GRB_DBL_ATTR_X, 0, 3, sol); if (error) goto QUIT; printf("\noptimization complete\n"); if (optimstatus == GRB_OPTIMAL) { printf("optimal objective: %.4e\n", objval); printf(" x=%.0f, y=%.0f, z=%.0f\n", sol[0], sol[1], sol[2]); } else if (optimstatus == GRB_INF_OR_UNBD) { printf("model is infeasible or unbounded\n"); } else { printf("optimization was stopped early\n"); } QUIT: /* Error reporting */ if (error) { printf("error: %s\n", GRBgeterrormsg(env)); exit(1); } /* Free model */ 48

49 GRBfreemodel(model); /* Free environment */ GRBfreeenv(env); } return 0; Example details Let us now walk through the example, line by line, to understand how it achieves the desired result of optimizing the indicated model. The example begins by including a few include les. Gurobi C applications should always start by including gurobi_c.h, along with the standard C include les (stdlib.h and stdio.h). Creating the environment After declaring the necessary program variables, the example continues by creating an environment: error = GRBloadenv(&env, "mip1.log"); if (error env == NULL) { fprintf(stderr, "Error: could not create environment\n"); exit(1); } Later attempts to create optimization models will always require an environment, so environment creation should always be the rst step when using the Gurobi optimizer. The second argument to GRBloadenv() provides the name of the Gurobi log le. If the argument is an empty string or NULL, no log le will be written. Note that environment creation may fail, so you should check the return value of the call. Creating the model Once an environment has been created, the next step is to create a model. A Gurobi model holds a single optimization problem. It consists of a set of variables, a set of constraints, and the associated attributes (variable bounds, objective coecients, variable integrality types, constraint senses, constraint right-hand side values, etc.). The rst step towards building a model that contains all of this information is to create an empty model object: 49

50 /* Create an empty model */ error = GRBnewmodel(env, &model, "mip1", 0, NULL, NULL, NULL, NULL, NULL); if (error) goto QUIT; The rst argument to GRBnewmodel() is the previously created environment. The second is a pointer to the location where the pointer to the new model should be stored. The third is the name of the model. The fourth is the number of variables to initially add to the model. Since we're creating an empty model, the number of initial variables is 0. The remaining arguments would describe the initial variables (lower bounds, upper bounds, variable types, etc.), had they been present. Adding variables to the model Once we create a Gurobi model, we can start adding variables and constraints to it. In our example, we'll begin by adding variables: /* Add variables */ obj[0] = 1; obj[1] = 1; obj[2] = 2; vtype[0] = GRB_BINARY; vtype[1] = GRB_BINARY; vtype[2] = GRB_BINARY; error = GRBaddvars(model, 3, 0, NULL, NULL, NULL, obj, NULL, NULL, vtype, NULL); The rst argument to GRBaddvars() is the model to which the variables are being added. The second is the number of added variables (3 in our example). Arguments three through six describe the constraint matrix coecients associated with the new variables. The third argument gives the number of non-zero constraint matrix entries associated with the new variables, and the next three arguments give details on these non-zeros. In our example, we'll be adding these non-zeros when we add the constraints. Thus, the non-zero count here is zero, and the following three arguments are all NULL. The seventh argument to GRBaddvars() is the linear objective coecient for each new variable. Since our example aims to maximize the objective, and by default Gurobi will minimize the objective, we'll need to change the objective sense. This is done in the next statement. Note we could have multiplied the objective coecients by -1 instead (since maximizing c x is equivalent to minimizing c x). The next two arguments specify the lower and upper bounds of the variables, respectively. The NULL values indicate that these variables should take their default values (0.0 and 1.0 for binary variables). The tenth argument species the types of the variables. In this example, the variables are all binary (GRB_BINARY). The nal argument gives the names of the variables. In this case, we allow the variable names to take their default values (X0, X1, and X2). 50

51 Changing the objective sense As we just noted, the default sense for the objective function is minimization. Since our example aims to maximize the objective, we need to modify the ModelSense attribute: /* Change objective sense to maximization */ error = GRBsetintattr(model, GRB_INT_ATTR_MODELSENSE, GRB_MAXIMIZE); if (error) goto QUIT; Updating the model - lazy modication Model modications in the Gurobi optimizer are done in a lazy fashion, meaning that the eects of the modications are not seen immediately. This approach makes it easier to perform a sequence of model modications, since the model doesn't change while it is being modied. However, lazy modications do require you to manually integrate model changes when needed. This is done with the following routine: /* Integrate new variables */ error = GRBupdatemodel(model); if (error) goto QUIT; In our example, the model would contain zero variables immediately before the call to GRBupdatemodel(), and three immediately after. Later attempts to add constraints to the model without rst making this call would fail, since the model would contain no variables. Adding constraints to the model Once the new variables are integrated into the model, the next step is to add our two constraints. Constraints are added through the GRBaddconstr() routine. To add a constraint, you must specify several pieces of information, including the non-zero values associated with the constraint, the constraint sense, the right-hand side value, and the constraint name. These are all specied as arguments to GRBaddconstr(): /* First constraint: x + 2 y + 3 z <= 4 */ ind[0] = 0; ind[1] = 1; ind[2] = 2; val[0] = 1; val[1] = 2; val[2] = 3; error = GRBaddconstr(model, 3, ind, val, GRB_LESS_EQUAL, 4.0, NULL); if (error) goto QUIT; The rst argument of GRBaddconstr() is the model to which the constraint is being added. The second is the total number of non-zero coecients associated with the new constraint. The next 51

52 two arguments describe the non-zeros in the new constraint. Constraint coecients are specied using a list of index-value pairs, one for each non-zero value. In our example, the rst constraint to be added is x + 2y + 3z 4. We have chosen to make x the rst variable in our constraint matrix, y the second, and z the third (note that this choice is arbitrary). Given our variable ordering choice, the index-value pairs that are required for our rst constraint are (0, 1.0), (1, 2.0), and (2, 3.0). These pairs are placed in the ind and val arrays. The fth argument to GRBaddconstr() provides the sense of the new constraint. Possible values are GRB_LESS_EQUAL, GRB_GREATER_EQUAL, or GRB_EQUAL. The sixth argument gives the right-hand side value. The nal argument gives the name of the constraint (we allow the constraint to take its default name here by specifying NULL for the argument). The second constraint is added in a similar fashion: /* Second constraint: x + y >= 1 */ ind[0] = 0; ind[1] = 1; val[0] = 1; val[1] = 1; error = GRBaddconstr(model, 2, ind, val, GRB_GREATER_EQUAL, 1.0, NULL); if (error) goto QUIT; Note that routine GRBaddconstrs() would allow you to add both constraints in a single call. The arguments for this routine are much more complex, though, without providing any signicant advantages, so we recommend that you add one constraint at a time. Optimizing the model Now that the model has been built, the next step is to optimize it: error = GRBoptimize(model); if (error) goto QUIT; This routine performs the optimization and populates several internal model attributes, including the status of the optimization, the solution, etc. Once the function returns, we can query the values of these attributes. In particular, we can query the status of the optimization process by retrieving the value of the Status attribute... error = GRBgetintattr(model, GRB_INT_ATTR_STATUS, &optimstatus); if (error) goto QUIT; The optimization status has many possible values. An optimal solution to the model may have been found, or the model have been determined to be infeasible or unbounded, or the solution process may have been interrupted. A list of possible statuses can be found in the Gurobi Reference Manual. For our example, we know that the model is feasible, and we haven't modied any parameters that might cause the optimization to stop early (e.g., a time limit), so the status will be GRB_OPTIMAL. 52

53 Another important model attribute is the value of the objective function for the computed solution. This is accessed through this call: error = GRBgetdoubleattr(model, GRB_DBL_ATTR_OBJVAL, &objval); if (error) goto QUIT; Note that this call would return a non-zero error result if no solution was found for this model. Once we know that the model was solved, we can extract the X attribute of the model, which contains the value for each variable in the computed solution: error = GRBgetdoublearrayattr(model, GRB_DBL_ATTR_X, 0, 3, x); if (error) goto QUIT; printf(" x=%.0f, y=%.0f, z=%.0f", x[0], x[1], x[2]); This routine retrieves the values of an array-valued attribute. The third and fourth arguments indicate the index of the rst array element to be retrieved, and the number of elements to retrieve, respectively. In this example we retrieve entries 0 through 2 (i.e., all three of them) Error reporting We would like to point out one additional aspect of the example. Almost all of the Gurobi methods return an error code. The code will typically be zero, indicating that no error was encountered, but it is important to check the value of the code in case an error arises. While you may want to print a specialized error code at each point where an error may occur, the Gurobi interface provides a more exible facility for reporting errors. The GRBgeterrormsg() routine returns a textual description of the most recent error associated with an environment: if (error) { printf("error: %s\n", GRBgeterrormsg(env)); exit(1); } Once the error reporting is done, the only remaining task in our example is to release the resources associated with our optimization task. In this case, we populated one model and created one environment. We call GRBfreemodel(model) to free the model, and GRBfreeenv(env) to free the environment. Building and running the example To build and run the example, please refer to the les in <installdir>/examples/build. For Windows platforms, this directory contains C_examples_2008.sln, C_examples_2010.sln, and C_examples_2012.sln (Visual Studio 2008, 2010, and 2012 solution les for the C examples). Double-clicking on the solution le will bring up Visual Studio. Clicking on the mip1_c project, 53

54 and then selecting Run from the Build menu will compile and run the example. For Linux or Mac OS platforms, the <installdir>/examples/build directory contains an example Makele. Typing make mip1_c will build and run this example. The C example directory <installdir>/examples/c contains a number of examples. We encourage you to browse and modify them in order to become more familiar with the Gurobi C interface. We also encourage you to read the Gurobi Example Tour for more information. 54

55 C++ Interface This section will work through a simple C++ example in order to illustrate the use of the Gurobi C++ interface. The example builds a model, optimizes it, and outputs the optimal objective value. This section assumes that you are already familiar with the C++ programming language. If not, a variety of books are available for learning the language (for example, The C++ Programming Language, by Stroustrup). Our example optimizes the following model: maximize x + y + 2 z subject to x + 2 y + 3 z 4 x + y 1 x, y, z binary Note that this is the same model that was modeled and optimized in the C Interface section. Example mip1_c++.cpp This is the complete source code for our example (also available in <installdir>/examples/c++/mip1_c++.cpp)... #include "gurobi_c++.h" using namespace std; int main(int argc, char *argv[]) { try { GRBEnv env = GRBEnv(); GRBModel model = GRBModel(env); // Create variables GRBVar x = model.addvar(0.0, 1.0, 0.0, GRB_BINARY, "x"); GRBVar y = model.addvar(0.0, 1.0, 0.0, GRB_BINARY, "y"); GRBVar z = model.addvar(0.0, 1.0, 0.0, GRB_BINARY, "z"); // Integrate new variables 55

56 model.update(); // Set objective: maximize x + y + 2 z model.setobjective(x + y + 2 * z, GRB_MAXIMIZE); // Add constraint: x + 2 y + 3 z <= 4 model.addconstr(x + 2 * y + 3 * z <= 4, "c0"); // Add constraint: x + y >= 1 model.addconstr(x + y >= 1, "c1"); // Optimize model model.optimize(); cout << x.get(grb_stringattr_varname) << " " << x.get(grb_doubleattr_x) << endl; cout << y.get(grb_stringattr_varname) << " " << y.get(grb_doubleattr_x) << endl; cout << z.get(grb_stringattr_varname) << " " << z.get(grb_doubleattr_x) << endl; cout << "Obj: " << model.get(grb_doubleattr_objval) << endl; } catch(grbexception e) { cout << "Error code = " << e.geterrorcode() << endl; cout << e.getmessage() << endl; } catch(...) { cout << "Exception during optimization" << endl; } } return 0; Example details Let us now walk through the example, line by line, to understand how it achieves the desired result of optimizing the indicated model. The example begins by including le gurobi_c++.h. Gurobi C++ applications should always start by including this le. 56

57 Creating the environment The rst executable statement in our example obtains a Gurobi environment (using the GRBEnv() constructor): GRBEnv env = GRBEnv(); Later calls to create an optimization model will always require an environment, so environment creation is typically the rst step in a Gurobi application. Creating the model Once an environment has been created, the next step is to create a model. A Gurobi model holds a single optimization problem. It consists of a set of variables, a set of constraints, and the associated attributes (variable bounds, objective coecients, variable integrality types, constraint senses, constraint right-hand side values, etc.). The rst step towards building a model that contains all of this information is to create an empty model object: GRBModel model = GRBModel(env); The constructor takes the previously created environment as its argument. Adding variables to the model The next step in our example is to add variables to the model. // Create variables GRBVar x = model.addvar(0.0, 1.0, 0.0, GRB_BINARY, "x"); GRBVar y = model.addvar(0.0, 1.0, 0.0, GRB_BINARY, "y"); GRBVar z = model.addvar(0.0, 1.0, 0.0, GRB_BINARY, "z"); Variables are added through the addvar() method on the model object. associated with a particular model. A variable is always The rst and second arguments to the addvar() call are the variable lower and upper bounds, respectively. The third argument is the linear objective coecient (zero here - we'll set the objective later). The fourth argument is the variable type. Our variables are all binary in this example. The nal argument is the name of the variable. The addvar() method has been overloaded to accept several dierent argument lists. Please refer to the Gurobi Reference Manual for further details. Updating the model - lazy modication Model modications in the Gurobi optimizer are done in a lazy fashion, meaning that the eects of the modications are not seen immediately. This approach makes it easier to perform a sequence 57

58 of model modications, since the model doesn't change while it is being modied. However, lazy modications do require you to manually integrate model changes when needed. This is done with the update method: // Integrate new variables model.update(); Setting the objective The next step in the example is to set the optimization objective: // Set objective: maximize x + y + 2 z model.setobjective(x + y + 2 * z, GRB_MAXIMIZE); The objective is built here using overloaded operators. The C++ API overloads the arithmetic operators to allow you to build linear and quadratic expression involving Gurobi variables. The second argument indicates that the sense is maximization. Note that while this simple example builds the objective in a single statement using an explicit list of terms, more complex programs will typically build it incrementally. For example: GRBLinExpr obj = 0.0; obj += x; obj += y; obj += 2*z; model.setobjective(obj, GRB_MAXIMIZE); Adding constraints to the model The next step in the example is to add the constraints. The rst constraint is added here: // Add constraint: x + 2 y + 3 z <= 4 model.addconstr(x + 2 * y + 3 * z <= 4, "c0"); As with variables, constraints are always associated with a specic model. They are created using the addconstr() or addconstrs() methods on the model object. We again use overloaded arithmetic operators to build the linear expression. operators are also overloaded to make it easy to build linear constraints. The second argument to addconstr gives the (optional) constraint name. The comparison Again, this simple example builds the linear expression for the constraint in a single statement using an explicit list of terms. More complex programs will typically build the expression incrementally. The second constraint in our model is added with this similar call: 58

59 // Add constraint: x + y >= 1 model.addconstr(x + y >= 1, "c1"); Optimizing the model Now that the model has been built, the next step is to optimize it: // Optimize model model.optimize(); This routine performs the optimization and populates several internal model attributes (including the status of the optimization, the solution, etc.). Reporting results - attributes Once the optimization is complete, we can query the values of the attributes. In particular, we can query the VarName and X attributes to obtain the name and solution value of each variable: cout << x.get(grb_stringattr_varname) << " " << x.get(grb_doubleattr_x) << endl; cout << y.get(grb_stringattr_varname) << " " << y.get(grb_doubleattr_x) << endl; cout << z.get(grb_stringattr_varname) << " " << z.get(grb_doubleattr_x) << endl; We can also query the ObjVal attribute on the model to obtain the objective value for the current solution: cout << "Obj: " << model.get(grb_doubleattr_objval) << endl; The names and types of all model, variable, and constraint attributes can be found in the Attributes section of the Gurobi Reference Manual. Error handling Errors in the Gurobi C++ interface are handled through the C++ exception mechanism. In the example, all Gurobi statements are enclosed inside a try block, and any associated errors would be caught by the catch block. Building and running the example To build and run the example, we refer the user to the les in <installdir>/examples/build. For Windows platforms, this directory contains C++_examples_2008.sln, C++_examples_2010.sln, 59

60 and C++_examples_2012.sln (Visual Studio 2008, 2010, and 2012 solution les for the C++ examples). Double-clicking on the solution le will bring up Visual Studio. Clicking on the mip1_c++ project, and then selecting Run from the Build menu will compile and run the example. For Linux or Mac OS platforms, the <installdir>/examples/build directory contains an example Makele. Typing make mip1_c++ will build and run this example. If you want to create your own project or makele to build a C++ program that calls Gurobi, the details will depend on your platform and development environment, but we'd like to point out a few common pitfalls: On Windows, be sure to choose the Gurobi C++ library that is compatible with your Visual Studio version and your choice of runtime library (Gurobi supports runtime library options /MD, /MDd, /MT, and /MTd). To give an example, use le gurobi_c++md2010.lib when you choose runtime library option /MD in Visual Studio Similarly, use le gurobi_c++mtd2012.lib when you choose runtime library option /MTd in Visual Studio A C++ program that uses Gurobi must link in both the Gurobi C++ library (e.g., gurobi_c++mt2010.lib on Windows, libgurobi_c++.a on Linux and Mac) and the Gurobi C library (gurobi65.lib on Windows, libgurobi65.so on Linux and Mac). The C++ example directory <installdir>/examples/c++ contains a number of examples. We encourage you to browse and modify them in order to become more familiar with the Gurobi C++ interface. We also encourage you to read the Gurobi Example Tour for more information. 60

61 Java Interface This section will work through a simple Java example in order to illustrate the use of the Gurobi Java interface. The example builds a model, optimizes it, and outputs the optimal objective value. This section assumes that you are already familiar with the Java programming language. If not, a variety of books and websites are available for learning the language (for example, the online Java tutorials). Our example optimizes the following model: maximize x + y + 2 z subject to x + 2 y + 3 z 4 x + y 1 x, y, z binary Note that this is the same model that was modeled and optimized in the C Interface section. Example Mip1.java This is the complete source code for our example (also available in <installdir>/examples/java/mip1.java)... import gurobi.*; public class Mip1 { public static void main(string[] args) { try { GRBEnv env = new GRBEnv("mip1.log"); GRBModel model = new GRBModel(env); // Create variables GRBVar x = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "x"); GRBVar y = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "y"); GRBVar z = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "z"); // Integrate new variables model.update(); // Set objective: maximize x + y + 2 z 61

62 GRBLinExpr expr = new GRBLinExpr(); expr.addterm(1.0, x); expr.addterm(1.0, y); expr.addterm(2.0, z); model.setobjective(expr, GRB.MAXIMIZE); // Add constraint: x + 2 y + 3 z <= 4 expr = new GRBLinExpr(); expr.addterm(1.0, x); expr.addterm(2.0, y); expr.addterm(3.0, z); model.addconstr(expr, GRB.LESS_EQUAL, 4.0, "c0"); // Add constraint: x + y >= 1 expr = new GRBLinExpr(); expr.addterm(1.0, x); expr.addterm(1.0, y); model.addconstr(expr, GRB.GREATER_EQUAL, 1.0, "c1"); // Optimize model model.optimize(); System.out.println(x.get(GRB.StringAttr.VarName) + " " +x.get(grb.doubleattr.x)); System.out.println(y.get(GRB.StringAttr.VarName) + " " +y.get(grb.doubleattr.x)); System.out.println(z.get(GRB.StringAttr.VarName) + " " +z.get(grb.doubleattr.x)); System.out.println("Obj: " + model.get(grb.doubleattr.objval)); // Dispose of model and environment model.dispose(); env.dispose(); } } } catch (GRBException e) { System.out.println("Error code: " + e.geterrorcode() + ". " + e.getmessage()); } 62

63 Example details Let us now walk through the example, line by line, to understand how it achieves the desired result of optimizing the indicated model. The example begins by importing the Gurobi classes (import gurobi.*). Gurobi Java applications should always start with this line. Creating the environment The rst executable statement in our example obtains a Gurobi environment (using the GRBEnv() constructor): GRBEnv env = new GRBEnv("mip1.log"); Later calls to create an optimization model will always require an environment, so environment creation is typically the rst step in a Gurobi application. The constructor argument species the name of the log le. Creating the model Once an environment has been created, the next step is to create a model. A Gurobi model holds a single optimization problem. It consists of a set of variables, a set of constraints, and the associated attributes (variable bounds, objective coecients, variable integrality types, constraint senses, constraint right-hand side values, etc.). The rst step towards building a model that contains all of this information is to create an empty model object: GRBModel model = new GRBModel(env); The constructor takes the previously created environment as its argument. Adding variables to the model The next step in our example is to add variables to the model. // Create variables GRBVar x = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "x"); GRBVar y = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "y"); GRBVar z = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "z"); Variables are added through the addvar() method on a model object. A variable is always associated with a particular model. The rst and second arguments to the addvar() call are the variable lower and upper bounds, respectively. The third argument is the linear objective coecient (zero here - we'll set the objective 63

64 later). The fourth argument is the variable type. Our variables are all binary in this example. The nal argument is the name of the variable. The addvar() method has been overloaded to accept several dierent argument lists. Please refer to the Gurobi Reference Manual for further details. Updating the model - lazy modication Model modications in the Gurobi optimizer are done in a lazy fashion, meaning that the eects of the modications are not seen immediately. This approach makes it easier to perform a sequence of model modications, since the model doesn't change while it is being modied. However, lazy modications do require you to manually integrate model changes when needed. This is done with the update method: // Integrate new variables model.update(); Setting the objective The next step in the example is to set the optimization objective: // Set objective: maximize x + y + 2 z GRBLinExpr expr = new GRBLinExpr(); expr.addterm(1.0, x); expr.addterm(1.0, y); expr.addterm(2.0, z); model.setobjective(expr, GRB.MAXIMIZE); The objective must be a linear or quadratic function of the variables in the model. In our example, we build our objective by rst constructing an empty linear expression and adding three terms to it. The second argument to setobjective indicates that the optimization sense is maximization. Adding constraints to the model The next step in the example is to add the constraints. The rst constraint is added here: // Add constraint: x + 2 y + 3 z <= 4 GRBLinExpr expr; expr = new GRBLinExpr(); expr.addterm(1.0, x); expr.addterm(2.0, y); expr.addterm(3.0, z); model.addconstr(expr, GRB.LESS_EQUAL, 4.0, "c0"); 64

65 As with variables, constraints are always associated with a specic model. They are created using the addconstr() or addconstrs() methods on the model object. The rst argument to addconstr() is the left-hand side of the constraint. We built the left-hand side by rst creating an empty linear expression object, and then adding three terms to it. The second argument is the constraint sense (GRB_LESS_EQUAL, GRB_GREATER_EQUAL, or GRB_EQUAL). The third argument is the right-hand side (a constant in our example). The nal argument is the constraint name. Several signatures are available for addconstr(). Please consult the Gurobi Reference Manual for details. The second constraint is created in a similar manner: // Add constraint: x + y >= 1 expr = new GRBLinExpr(); expr.addterm(1.0, x); expr.addterm(1.0, y); model.addconstr(expr, GRB.GREATER_EQUAL, 1.0, "c1"); Optimizing the model Now that the model has been built, the next step is to optimize it: // Optimize model model.optimize(); This routine performs the optimization and populates several internal model attributes (including the status of the optimization, the solution, etc.). Reporting results - attributes Once the optimization is complete, we can query the values of the attributes. In particular, we can query the VarName and X attributes to obtain the name and solution value for each variable: System.out.println(x.get(GRB.StringAttr.VarName) + " " +x.get(grb.doubleattr.x)); System.out.println(y.get(GRB.StringAttr.VarName) + " " +y.get(grb.doubleattr.x)); System.out.println(z.get(GRB.StringAttr.VarName) + " " +z.get(grb.doubleattr.x)); We can also query the ObjVal attribute on the model to obtain the objective value for the current solution: System.out.println("Obj: " + model.get(grb.doubleattr.objval)); The names and types of all model, variable, and constraint attributes can be found in the Attributes section of the Gurobi Reference Manual. 65

66 Cleaning up The example concludes with dispose calls: model.dispose(); env.dispose(); These reclaim the resources associated with the model and environment. Garbage collection would reclaim these eventually, but if your program doesn't exit immediately after performing the optimization, it is best to reclaim them explicitly. Note that all models associated with an environment must be disposed before the environment itself is disposed. Error handling Errors in the Gurobi Java interface are handled through the Java exception mechanism. In the example, all Gurobi statements are enclosed inside a try block, and any associated errors would be caught by the catch block. Building and running the example To build and run the example, please refer to the les in <installdir>/examples/build. For Windows platforms, this directory contains runjava.bat, a simple script to compile and run a java example. Say runjava Mip1 to run this example. For Linux or Mac OS platforms, the <installdir>/examples/build directory contains an example Makele. Typing make Mip1 will build and run this example. The Java example directory <installdir>/examples/java contains a number of examples. We encourage you to browse and modify them in order to become more familiar with the Gurobi Java interface. We also encourage you to read the Gurobi Example Tour for more information. 66

67 .NET Interface (C#) This section will work through a simple C# example in order to illustrate the use of the Gurobi.NET interface. The example builds a model, optimizes it, and outputs the optimal objective value. This section assumes that you are already familiar with the C# programming language. If not, a variety of books and websites are available for learning the language (for example, the Microsoft online C# documentation). Our example optimizes the following model: maximize x + y + 2 z subject to x + 2 y + 3 z 4 x + y 1 x, y, z binary Note that this is the same model that was modeled and optimized in the C Interface section. Example mip1_cs.cs This is the complete source code for our example (also available in <installdir>/examples/c#/mip1_cs.cs)... using System; using Gurobi; class mip1_cs { static void Main() { try { GRBEnv env = new GRBEnv("mip1.log"); GRBModel model = new GRBModel(env); // Create variables GRBVar x = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "x"); GRBVar y = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "y"); GRBVar z = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "z"); // Integrate new variables 67

68 model.update(); // Set objective: maximize x + y + 2 z model.setobjective(x + y + 2 * z, GRB.MAXIMIZE); // Add constraint: x + 2 y + 3 z <= 4 model.addconstr(x + 2 * y + 3 * z <= 4.0, "c0"); // Add constraint: x + y >= 1 model.addconstr(x + y >= 1.0, "c1"); // Optimize model model.optimize(); Console.WriteLine(x.Get(GRB.StringAttr.VarName) + " " + x.get(grb.doubleattr.x)); Console.WriteLine(y.Get(GRB.StringAttr.VarName) + " " + y.get(grb.doubleattr.x)); Console.WriteLine(z.Get(GRB.StringAttr.VarName) + " " + z.get(grb.doubleattr.x)); Console.WriteLine("Obj: " + model.get(grb.doubleattr.objval)); // Dispose of model and env model.dispose(); env.dispose(); } } } catch (GRBException e) { Console.WriteLine("Error code: " + e.errorcode + ". " + e.message); } Example details Let us now walk through the example, line by line, to understand how it achieves the desired result of optimizing the indicated model. The example begins by importing the Gurobi namespace (using Gurobi). Gurobi.NET applications should always start with this line. 68

69 Creating the environment The rst executable statement in our example obtains a Gurobi environment (using the GRBEnv() constructor): GRBEnv env = new GRBEnv("mip1.log"); Later calls to create an optimization model will always require an environment, so environment creation is typically the rst step in a Gurobi application. The constructor argument species the name of the log le. Creating the model Once an environment has been created, the next step is to create a model. A Gurobi model holds a single optimization problem. It consists of a set of variables, a set of constraints, and the associated attributes (variable bounds, objective coecients, variable integrality types, constraint senses, constraint right-hand side values, etc.). The rst step towards building a model that contains all of this information is to create an empty model object: GRBModel model = new GRBModel(env); The constructor takes the previously created environment as its argument. Adding variables to the model The next step in our example is to add variables to the model. // Create variables GRBVar x = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "x"); GRBVar y = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "y"); GRBVar z = model.addvar(0.0, 1.0, 0.0, GRB.BINARY, "z"); Variables are added through the AddVar() method on a model object. A variable is always associated with a particular model. The rst and second arguments to the AddVar() call are the variable lower and upper bounds, respectively. The third argument is the linear objective coecient (zero here - we'll set the objective later). The fourth argument is the variable type. Our variables are all binary in this example. The nal argument is the name of the variable. The AddVar() method has been overloaded to accept several dierent argument lists. Please refer to the Gurobi Reference Manual for further details. 69

70 Updating the model - lazy modication Model modications in the Gurobi optimizer are done in a lazy fashion, meaning that the eects of the modications are not seen immediately. This approach makes it easier to perform a sequence of model modications, since the model doesn't change while it is being modied. However, lazy modications do require you to manually integrate model changes when needed. This is done with the Update method: // Integrate new variables model.update(); Setting the objective The next step in the example is to set the optimization objective: // Set objective: maximize x + y + 2 z model.setobjective(x + y + 2 * z, GRB.MAXIMIZE); The objective is built here using overloaded operators. The C# API overloads the arithmetic operators to allow you to build linear and quadratic expression involving Gurobi variables. The second argument indicates that the sense is maximization. Note that while this simple example builds the objective in a single statement using an explicit list of terms, more complex programs will typically build it incrementally. For example: GRBLinExpr obj = 0.0; obj.addterm(1.0, x); obj.addterm(1.0, y); obj.addterm(2.0, z); model.setobjective(obj, GRB.MAXIMIZE); Adding constraints to the model The next step in the example is to add the constraints: // Add constraint: x + 2 y + 3 z <= 4 model.addconstr(x + 2 * y + 3 * z <= 4.0, "c0"); // Add constraint: x + y >= 1 model.addconstr(x + y >= 1.0, "c1"); As with variables, constraints are always associated with a specic model. They are created using the AddConstr() or AddConstrs() methods on the model object. 70

71 We again use overloaded arithmetic operators to build linear expressions. The comparison operators are also overloaded to make it easy to build constraints. The second argument to AddConstr gives the constraint name. The Gurobi.NET interface also allows you to add constraints by building linear expressions in a term-by-term fashion: GRBLinExpr expr = 0.0; expr.addterm(1.0, x); expr.addterm(2.0, y); expr.addterm(3.0, z); model.addconstr(expr, GRB.LESS_EQUAL, 4.0, "c0"); This particular AddConstr() signature takes a linear expression that captures the left-hand side of the constraint as its rst argument, the sense of the constraint as its second argument, and a linear expression that captures the right-hand side of the constraint as its third argument. The constraint name is given as the fourth argument. Optimizing the model Now that the model has been built, the next step is to optimize it: // Optimize model model.optimize(); This routine performs the optimization and populates several internal model attributes (including the status of the optimization, the solution, etc.). Reporting results - attributes Once the optimization is complete, we can query the values of the attributes. In particular, we can query the VarName and X attributes to obtain the name and solution value for each variable: Console.WriteLine(x.Get(GRB.StringAttr.VarName) + " " + x.get(grb.doubleattr.x)); Console.WriteLine(y.Get(GRB.StringAttr.VarName) + " " + y.get(grb.doubleattr.x)); Console.WriteLine(z.Get(GRB.StringAttr.VarName) + " " + z.get(grb.doubleattr.x)); We can also query the ObjVal attribute on the model to obtain the objective value for the current solution: Console.WriteLine("Obj: " + model.get(grb.doubleattr.objval)); The names and types of all model, variable, and constraint attributes can be found in the Attributes section of the Gurobi Reference Manual. 71

72 Cleaning up The example concludes with Dispose calls: model.dispose(); env.dispose(); These reclaim the resources associated with the model and environment. Garbage collection would reclaim these eventually, but if your program doesn't exit immediately after performing the optimization, it is best to reclaim them explicitly. Note that all models associated with an environment must be disposed before the environment itself is disposed. Error handling Errors in the Gurobi.NET interface are handled through the.net exception mechanism. In the example, all Gurobi statements are enclosed inside a try block, and any associated errors would be caught by the catch block. Building and running the example You can use the CS_examples_2008.sln, CS_examples_2010.sln, or CS_examples_2012.sln solution les in <installdir>/examples/build to build and run the example with Visual Studio 2008, 2010, or 2012, respectively. Clicking on the mip1_cs project, and then selecting Run from the Build menu will compile and run the example. The C# and Visual Basic example directories (<installdir>/examples/c# and <installdir>/examples/vb) contain a number of examples. We encourage you to browse and modify them in order to become more familiar with the Gurobi.NET interface. We also encourage you to read the Gurobi Example Tour for more information. 72

73 Python Interface The Gurobi Python interface can be used in a number of ways. It is the basis of our Interactive Shell, where it is typically used to work with existing models. It can also be used to write standalone programs that create and solve models, in much the same way that you would use our other language interfaces. The Gurobi distribution includes a Python interpreter and a basic set of Python modules. If you'd like additional capabilities, you can also install the Anaconda Python distribution, which includes both a graphical development environment (Spyder) and a notebook-style interface When comparing our Python interface against our other language interfaces, you will nd that our Python interface adds a few higher-level constructs that allow you to build models using a more mathematical syntax, similar to the way you might work with a traditional modeling language. This section will work through two Python modeling examples. The rst will present a Python program that is similar to the C, C++, Java, and C# programs presented in previous sections. The second demonstrates some of the higher-level modeling capabilities of our Python interface. This section assumes that you are already familiar with the Python programming language, and that you have read the preceding section on the Gurobi Interactive Shell. If you would like to learn more about the Python language, we recommend that you visit the Python online tutorial. As we noted, the Gurobi distribution includes all the tools you will need to run Python programs. However, if you would prefer to use your own Python installation, we also provide tools for installing the gurobipy module into your Python environment. You should refer to the instructions for building and running the examples for further details. One big advantage of working within Python is that the Python language is popular and well supported. One aspect of this support is the breadth of powerful Python Integrated Development Environments (IDEs) that are available, most of which can be downloaded for free from the internet. This document includes instructions for setting up Gurobi for use within the Anaconda distribution. Anaconda greatly simplies the task of installing Python packages, and it includes both a graphical development environment (Spyder) and a notebook-style interface (ipython Notebook). If you plan to do signicant Python development, we recommend that you install Anaconda now. You will also nd pointers to other useful Python tools there. Important note for AIX users: due to limited Python support on AIX, our AIX port does not include the Interactive Shell or the Python interface. You can use the C, C++, or Java interfaces. The Python example directory contains a number of examples. We encourage you to browse and modify them in order to become more familiar with the Gurobi Python interface. We also encourage you to read the Gurobi Example Tour for more information. 73

74 12.1 Simple Python Example This section will work through a simple Python example in order to illustrate the use of the Gurobi Python interface. The example builds a model, optimizes it, and outputs the optimal objective value. Our example optimizes the following model: maximize x + y + 2 z subject to x + 2 y + 3 z 4 x + y 1 x, y, z binary Note that this is the same model that was modeled and optimized in the C Interface section. Example mip1.py This is the complete source code for our example (also available in <installdir>/examples/python/mip1.py)... from gurobipy import * try: # Create a new model m = Model("mip1") # Create variables x = m.addvar(vtype=grb.binary, name="x") y = m.addvar(vtype=grb.binary, name="y") z = m.addvar(vtype=grb.binary, name="z") # Integrate new variables m.update() # Set objective m.setobjective(x + y + 2 * z, GRB.MAXIMIZE) # Add constraint: x + 2 y + 3 z <= 4 m.addconstr(x + 2 * y + 3 * z <= 4, "c0") # Add constraint: x + y >= 1 m.addconstr(x + y >= 1, "c1") m.optimize() 74

75 for v in m.getvars(): print v.varname, v.x print 'Obj:', m.objval except GurobiError: print 'Error reported' Example details Let us now walk through the example, line by line, to understand how it achieves the desired result of optimizing the indicated model. The example begins by importing the Gurobi functions and classes: from gurobipy import * Gurobi Python applications should always start with this line. Note that in order for this command to succeed, the Python application needs to know how to nd the Gurobi functions and classes. Recall that you have two options here. The rst is to use the Python les that are included with our distribution. You would run this example by typing gurobi.bat mip1.py (Windows) or gurobi.sh mip1.py (Linux and Mac). The second option is to install the Gurobi functions and classes into your own Python installation. Creating the model The rst step in our example is to create a model. A Gurobi model holds a single optimization problem. It consists of a set of variables, a set of constraints, and the associated attributes (variable bounds, objective coecients, variable integrality types, constraint senses, constraint right-hand side values, etc.). We start this example with an empty model object: m = Model("mip1") This function takes the desired model name as its argument. Adding variables to the model The next step in our example is to add variables to the model. # Create variables x = m.addvar(vtype=grb.binary, name="x") y = m.addvar(vtype=grb.binary, name="y") z = m.addvar(vtype=grb.binary, name="z") 75

76 Variables are added through the addvar() method on a model object. A variable is always associated with a particular model. Python allows you to pass arguments by position or by name. We've passed them by name here. Each variable gets a type (binary), and a name. We use the default values for the other arguments. Please refer to the online help (help(model.addvar) in the Gurobi Shell) for further details on addvar(). Updating the model - lazy modication Model modications in the Gurobi optimizer are done in a lazy fashion, meaning that the eects of the modications are not seen immediately. This approach makes it easier to perform a sequence of model modications, since the model doesn't change while it is being modied. However, lazy modications do require you to manually integrate model changes when needed. This is done with the update method: # Integrate new variables m.update() Setting the objective The next step in the example is to set the optimization objective: # Set objective: maximize x + y + 2 z model.setobjective(x + y + 2 * z, GRB.MAXIMIZE) The objective is built here using overloaded operators. The Python API overloads the arithmetic operators to allow you to build linear and quadratic expression involving Gurobi variables. The second argument indicates that the sense is maximization. Note that while this simple example builds the objective in a single statement using an explicit list of terms, more complex programs will typically build it incrementally. For example: obj = LinExpr(); obj += x; obj += y; obj += 2*z; model.setobjective(obj, GRB.MAXIMIZE); Adding constraints to the model The next step in the example is to add the constraints. The rst constraint is added here: # Add constraint: x + 2 y + 3 z <= 4 m.addconstr(x + 2 * y + 3 * z <= 4, "c0") 76

77 As with variables, constraints are always associated with a specic model. They are created using the addconstr() method on the model object. We again use overloaded arithmetic operators to build linear expressions. The comparison operators are also overloaded to make it easy to build constraints. The second argument to addconstr gives the (optional) constraint name. Again, this simple example builds the linear expression for the constraint in a single statement using an explicit list of terms. More complex programs will typically build the expression incrementally. The second constraint is created in a similar manner: # Add constraint: x + y >= 1 m.addconstr(x + y >= 1, "c1") Optimizing the model Now that the model has been built, the next step is to optimize it: # Optimize model m.optimize() This routine performs the optimization and populates several internal model attributes (including the status of the optimization, the solution, etc.). Reporting results - attributes Once the optimization is complete, we can query the values of the attributes. In particular, we can query the varname and x variable attributes to obtain the name and solution value for each variable: for v in m.getvars(): print v.varname, v.x We can also query the objval attribute on the model to obtain the objective value for the current solution: print 'Obj:', m.objval The names and types of all model, variable, and constraint attributes can be found in the online Python documentation. Type help(grb.attr) in the Gurobi Shell for details. Error handling Errors in the Gurobi Python interface are handled through the Python exception mechanism. In the example, all Gurobi statements are enclosed inside a try block, and any associated errors would be caught by the except block. 77

78 Running the example When you run the example (gurobi.bat mip1.py on Windows, or gurobi.sh mip1.py on Linux or Mac), you should see the following output: Optimize a model with 2 rows, 3 columns and 5 nonzeros Presolve removed 2 rows and 3 columns Presolve time: 0.00s Explored 0 nodes (0 simplex iterations) in 0.00 seconds Thread count was 1 (of 4 available processors) Optimal solution found (tolerance 1.00e-04) Best objective e+00, best bound e+00, gap 0.0% x 1.0 y 0.0 z 1.0 Obj: Python Dictionary Example In order to provide a gentle introduction to our interfaces, the examples so far have demonstrated only very basic capabilities. We will now attempt to demonstrate some of the power of our Python interface by describing a more complex example. This example is intended to capture most of the common ingredients of large, complex optimization models. Implementing this same example in another API would most likely have required hundreds of lines of code (ours is around 70 lines of Python code). We'll need to present a few preliminaries before getting to the example itself. You'll need to learn a bit about the Python language, and we'll need to describe a few custom classes and functions. Our intent is that you will come away from this section with an appreciation for the power and exibility of this interface. It can be used to create quite complex models using what we believe are very concise and natural modeling constructs. Our goal with this interface has been to provide something that feels more like a mathematical modeling language than a programming language API. If you'd like to dig a bit deeper into the Python language constructs described here, we recommend that you visit the online Python tutorial. Motivation At the heart of any optimization model lies a set of decision variables. Finding a convenient way to store and access these variables can often represent the main challenge in implementing the model. While the variables in some models map naturally to simple programming language constructs (e.g., x[i] for contiguous integer values i), other models can present a much greater challenge. 78

79 For example, consider a model that optimizes the ow of multiple dierent commodities through a supply network. You might have a variable x['pens', 'Denver', 'New York'] that captures the ow of a manufactured item (pens in this example) from Denver to New York. At the same time, you might not want to have a variable x['pencils', 'Denver', 'Seattle'], since not all combinations of commodities, source cities, and destination cities represent valid paths through the network. Representing a sparse set of decision variables in a typical programming language can be cumbersome. To compound the challenge, you typically need to build constraints that involve subsets of these decision variables. For example, in our network ow model you might want to put an upper bound on the total ow that enters a particular city. You could certainly collect the relevant decision variables by iterating over all possible cities and selecting only those variables that capture possible ow from that source city into the desired destination city. However, this is clearly wasteful if not all origin-destination pairs are valid. In a large network problem, the ineciency of this approach could lead to major performance issues. Handling this eciently can require complex data structures. The Gurobi Python interface has been designed to make the issues we've just described quite easy to manage. We'll present a specic example of how this is done shortly. Before we do, though, we'll need to describe a few important constructs: lists, tuples, dictionaries, list comprehension, and the tuplelist class. The rst four are standard Python concepts that are particularly important in our interface, while the last is a custom class that we've added to the Gurobi Python interface. A quick reminder: you can consult the online Python documentation for additional information on any of the Python data structures mentioned here. Lists and Tuples The list data structure is central to most Python programs; Gurobi Python programs are no exception. We'll also rely heavily on a similar data structure, the tuple. Tuples are crucial to providing ecient and convenient access to Gurobi decision variables in Gurobi Python programs. The dierence between a list and a tuple is subtle but important. We'll discuss it shortly. Lists and tuples are both simply ordered collections of Python objects. A list is created and displayed as a comma-separated list of member objects, enclosed in square brackets. A tuple is similar, except that the member objects are enclosed in parenthesis. For example, [1, 2, 3] is a list, while (1, 2, 3) is a tuple. Similarly, ['Pens', 'Denver', 'New York'] is a list, while ('Pens', 'Denver', 'New York') is a tuple. You can retrieve individual entries from a list or tuple using square brackets and zero-based indices: gurobi> l = [1, 2.0, 'abc'] gurobi> t = (1, 2.0, 'abc') gurobi> print l[0] 1 gurobi> print t[1] 2.0 gurobi> print l[2] abc 79

80 What's the dierence between a list and a tuple? A tuple is immutable, meaning that you can't modify it once it has been created. By contrast, you can add new members to a list, remove members, change existing members, etc. This immutable property allows you to use tuples as indices for dictionaries. Dictionaries A Python dictionary allows you to map arbitrary key values to pieces of data. Any immutable Python object can be used as a key: an integer, a oating-point number, a string, or even a tuple. To give an example, the following statements create a dictionary x, and then associates a value 1 with key ('Pens', 'Denver', 'New York') gurobi> x = {} # creates an empty dictionary gurobi> x[('pens', 'Denver', 'New York')] = 1 gurobi> print x[('pens', 'Denver', 'New York')] 1 Python allows you to omit the parenthesis when accessing a dictionary using a tuple, so the following is also valid: gurobi> x = {} gurobi> x['pens', 'Denver', 'New York'] = 2 gurobi> print x['pens', 'Denver', 'New York'] 2 We've stored integers in the dictionary here, but dictionaries can hold arbitrary objects. In particular, they can hold Gurobi decision variables: gurobi> x['pens', 'Denver', 'New York'] = model.addvar() gurobi> print x['pens', 'Denver', 'New York'] <gurobi.var *Awaiting Model Update*> To initialize a dictionary, you can of course simply perform assignments for each relevant key: gurobi> values = {} gurobi> values['zero'] = 0 gurobi> values['one'] = 1 gurobi> values['two'] = 2 You can also use the Python dictionary initialization construct: gurobi> values = { 'zero': 0, 'one': 1, 'two': 2 } gurobi> print values['zero'] 0 gurobi> print values['one'] 1 80

81 We have included a utility routine in the Gurobi Python interface that simplies dictionary initialization for a case that arises frequently in mathematical modeling. The multidict function allows you to initialize one or more dictionaries in a single statement. The function takes a dictionary as its argument, where the value associated with each key is a list of length n. The function splits these lists into individual entries, creating n separate dictionaries. The function returns a list. The rst result is the list of shared key values, followed by the n individual dictionaries: gurobi> names, lower, upper = multidict({ 'x': [0, 1], 'y': [1, 2], 'z': [0, 3] }) gurobi> print names ['x', 'y', 'z'] gurobi> print lower {'x': 0, 'y': 1, 'z': 0} gurobi> print upper {'x': 1, 'y': 2, 'z': 3} Note that you can also apply this function to a dictionary where each key maps to a scalar value. In that case, the function simply returns the list of keys as the rst result, and the original dictionary as the second. You will see this function in several of our Python examples. List comprehension List comprehension is an important Python feature that allows you to build lists in a concise fashion. To give a simple example, the following list comprehension builds a list containing the squares of the numbers from 1 through 5: gurobi> print [x*x for x in [1, 2, 3, 4, 5]] [1, 4, 9, 16, 25] A list comprehension can contain more than one for clause, and it can contain one or more if clauses. The following example builds a list of tuples containing all x,y pairs where x and y are both less than 3 and are not equal: gurobi> print [(x,y) for x in range(3) for y in range(3) if x!= y] [(0, 1), (0, 2), (1, 0), (1, 2) (2, 0), (2, 1)] (Details on the range function can be found here). List comprehension is used extensively in our Python examples. The tuplelist class The nal important item we would like to discuss is the tuplelist class. This is a custom sub-class of the Python list class that is designed to allow you to eciently build sub-lists from a list of 81

82 tuples. To be more specic, you can use the select method on a tuplelist object to retrieve all tuples that match one or more specied values in specied elds. Let us give a simple example. We'll begin by creating a simple tuplelist (by passing a list of tuples to the constructor): gurobi> l = tuplelist([(1, 2), (1, 3), (2, 3), (2, 4)]) To select a sub-list where particular tuple entries match desired values, you specify the desired values as arguments to the select method. The number of arguments to select is equal to the number of entries in the members of the tuplelist (they should all have the same number of entries). You use a '*' string to indicate that any value is acceptable in that position in the tuple. Each tuple in our example contains two entries, so we can perform the following selections: gurobi> print l.select(1, '*') [(1, 2), (1, 3)] gurobi> print l.select('*', 3) [(1, 3), (2, 3)] gurobi> print l.select(1, 3) [(1, 3)] gurobi> print l.select('*', '*') [(1, 2), (1, 3), (2, 3), (2, 4)] You may have noticed that similar results could have been achieved using list comprehension. For example: gurobi> print l.select(1, '*') [(1, 2), (1, 3)] gurobi> print [(x,y) for x,y in l if x == 1] [(1, 2), (1, 3)] The problem is that the latter statement considers every member in the list, which can be quite inecient for large lists. The select method builds internal data structures that make these selections quite ecient. Note that tuplelist is a sub-class of list, so you can use the standard list methods to access or modify a tuplelist: gurobi> print l[1] (1,3) gurobi> l += [(3, 4)] gurobi> print l [(1, 2), (1, 3), (2, 3), (2, 4), (3, 4)] Returning to our network ow example, once we've built a tuplelist containing all valid commoditysource-destination combinations on the network (we'll call it flows), we can select all arcs that ow into a specic destination city as follows: 82

83 gurobi> inbound = flows.select('*', '*', 'New York') We now present an example that illustrates the use of all of the concepts discussed so far. netow.py example Our example solves a multi-commodity ow model on a small network. In the example, two commodities (Pencils and Pens) are produced in two cities (Detroit and Denver), and must be shipped to warehouses in three cities (Boston, New York, and Seattle) to satisfy given demand. Each arc in the transportation network has a cost associated with it, and a total capacity. This is the complete source code for our example (also available in <installdir>/examples/python/netflow.py)... from gurobipy import * # Model data commodities = ['Pencils', 'Pens'] nodes = ['Detroit', 'Denver', 'Boston', 'New York', 'Seattle'] arcs, capacity = multidict({ ('Detroit', 'Boston'): 100, ('Detroit', 'New York'): 80, ('Detroit', 'Seattle'): 120, ('Denver', 'Boston'): 120, ('Denver', 'New York'): 120, ('Denver', 'Seattle'): 120 }) arcs = tuplelist(arcs) cost = { ('Pencils', 'Detroit', 'Boston'): 10, ('Pencils', 'Detroit', 'New York'): 20, ('Pencils', 'Detroit', 'Seattle'): 60, ('Pencils', 'Denver', 'Boston'): 40, ('Pencils', 'Denver', 'New York'): 40, ('Pencils', 'Denver', 'Seattle'): 30, ('Pens', 'Detroit', 'Boston'): 20, ('Pens', 'Detroit', 'New York'): 20, ('Pens', 'Detroit', 'Seattle'): 80, ('Pens', 'Denver', 'Boston'): 60, ('Pens', 'Denver', 'New York'): 70, ('Pens', 'Denver', 'Seattle'): 30 } inflow = { 83

84 ('Pencils', 'Detroit'): 50, ('Pencils', 'Denver'): 60, ('Pencils', 'Boston'): -50, ('Pencils', 'New York'): -50, ('Pencils', 'Seattle'): -10, ('Pens', 'Detroit'): 60, ('Pens', 'Denver'): 40, ('Pens', 'Boston'): -40, ('Pens', 'New York'): -30, ('Pens', 'Seattle'): -30 } # Create optimization model m = Model('netflow') # Create variables flow = {} for h in commodities: for i,j in arcs: flow[h,i,j] = m.addvar(ub=capacity[i,j], obj=cost[h,i,j], name='flow_%s_%s_%s' % (h, i, j)) m.update() # Arc capacity constraints for i,j in arcs: m.addconstr(quicksum(flow[h,i,j] for h in commodities) <= capacity[i,j], 'cap_%s_%s' % (i, j)) # Flow conservation constraints for h in commodities: for j in nodes: m.addconstr( quicksum(flow[h,i,j] for i,j in arcs.select('*',j)) + inflow[h,j] == quicksum(flow[h,j,k] for j,k in arcs.select(j,'*')), 'node_%s_%s' % (h, j)) # Compute optimal solution m.optimize() # Print solution if m.status == GRB.Status.OPTIMAL: for h in commodities: print '\noptimal flows for', h, ':' for i,j in arcs: if flow[h,i,j].x > 0: 84

85 print i, '->', j, ':', flow[h,i,j].x netow.py example details Let us now walk through the example, line by line, to understand how it achieves the desired result of computing the optimal network ow. As with the simple Python example presented earlier, this example begins by importing the Gurobi functions and classes: from gurobipy import * We then create a few lists that contain model data: commodities = ['Pencils', 'Pens'] nodes = ['Detroit', 'Denver', 'Boston', 'New York', 'Seattle'] arcs, capacity = multidict({ ('Detroit', 'Boston'): 100, ('Detroit', 'New York'): 80, ('Detroit', 'Seattle'): 120, ('Denver', 'Boston'): 120, ('Denver', 'New York'): 120, ('Denver', 'Seattle'): 120 }) arcs = tuplelist(arcs) The model works with two commodities (Pencils and Pens), and the network contains 5 nodes and 6 arcs. We initialize commodities and nodes as simple Python lists. We use the Gurobi multidict function to initialize arcs (the list of keys) and capacity (a dictionary). In our example, we plan to use arcs to select subsets of the arcs when building constraints later. We therefore pass the list of tuples returned by multidict to the tuplelist constructor to create a tuplelist object instead. The model also requires cost data for each commodity-arc pair: cost = { ('Pencils', 'Detroit', 'Boston'): 10, ('Pencils', 'Detroit', 'New York'): 20, ('Pencils', 'Detroit', 'Seattle'): 60, ('Pencils', 'Denver', 'Boston'): 40, ('Pencils', 'Denver', 'New York'): 40, ('Pencils', 'Denver', 'Seattle'): 30, ('Pens', 'Detroit', 'Boston'): 20, ('Pens', 'Detroit', 'New York'): 20, ('Pens', 'Detroit', 'Seattle'): 80, ('Pens', 'Denver', 'Boston'): 60, ('Pens', 'Denver', 'New York'): 70, ('Pens', 'Denver', 'Seattle'): 30 } 85

86 Once this dictionary has been created, the cost of moving commodity h from node i to j can be queried as cost[(h,i,j)]. Recall that Python allows you to omit the parenthesis when using a tuple to index a dictionary, so this can be shortened to just cost[h,i,j]. A similar construct is used to initialize node demand data: inflow = { ('Pencils', 'Detroit'): 50, ('Pencils', 'Denver'): 60, ('Pencils', 'Boston'): -50, ('Pencils', 'New York'): -50, ('Pencils', 'Seattle'): -10, ('Pens', 'Detroit'): 60, ('Pens', 'Denver'): 40, ('Pens', 'Boston'): -40, ('Pens', 'New York'): -30, ('Pens', 'Seattle'): -30 } Building a multi-dimensional array of variables The next step in our example (after creating an empty Model object) is to add variables to the model. The variables are stored in a dictionary flow: m = Model('netflow') flow = {} for h in commodities: for i,j in arcs: flow[h,i,j] = m.addvar(ub=capacity[i,j], obj=cost[h,i,j], name='flow_%s_%s_%s' % (h, i, j)) m.update() The flow variable is triply subscripted: by commodity, source node, and destination node. Note that the dictionary only contains variables for source, destination pairs that are present in arcs. Arc capacity constraints We begin with a straightforward set of constraints. The sum of the ow variables on an arc must be less than or equal to the capacity of that arc: for i,j in arcs: m.addconstr(quicksum(flow[h,i,j] for h in commodities) <= capacity[i,j], 'cap_%s_%s' % (i, j)) Note that we use list comprehension to build a list of all variables associated with an arc (i,j): 86

87 flow[h,i,j] for h in commodities (To be precise, as we've used it here, this is actually called a generator expression in Python, but it is similar enough to list comprehension that you can safely ignore the dierence for the purpose of understanding this example). The result is passed into the quicksum function to create a Gurobi linear expression that captures the sum of all of these variables. The Gurobi quicksum function is an alternative to the Python sum function that is much faster for building large expressions. Flow conservation constraints The next set of constraints are the ow conservation constraints. They require that, for each commodity and node, the sum of the ow into the node plus the quantity of external inow at that node must be equal to the sum of the ow out of the node: for h in commodities: for j in nodes: m.addconstr( quicksum(flow[h,i,j] for i,j in arcs.select('*',j)) + inflow[h,j] == quicksum(flow[h,j,k] for j,k in arcs.select(j,'*')), 'node_%s_%s' % (h, j)) Results Once we've added the model constraints, we call optimize and then output the optimal solution: if m.status == GRB.Status.OPTIMAL: for h in commodities: print '\noptimal flows for', h, ':' for i,j in arcs: if flow[h,i,j].x > 0: print i, '->', j, ':', flow[h,i,j].x If you run the example (gurobi.bat netflow.py on Windows, or gurobi.sh netflow.py on Linux and Mac), you should see the following output: Optimize a model with 16 rows, 12 columns and 36 nonzeros Presolve removed 16 rows and 12 columns Presolve time: 0.00s Presolve: All rows and columns removed Iteration Objective Primal Inf. Dual Inf. Time e e e+00 0s Solved in 0 iterations and 0.00 seconds Optimal objective e+03 87

88 Optimal flows for Pencils : Detroit -> Boston : 50.0 Denver -> New York : 50.0 Denver -> Seattle : 10.0 Optimal flows for Pens : Detroit -> Boston : 30.0 Detroit -> New York : 30.0 Denver -> Boston : 10.0 Denver -> Seattle : Building and running the examples Python is an interpreted language, so no explicit compilation step is required to run the examples. For Windows platforms, you can simply type the following in the Gurobi Python example directory (<installdir>/examples/python): gurobi.bat mip1.py For Linux or Mac OS platforms, type: gurobi.sh mip1.py If you are a Python user, and wish to use Gurobi from within your own Python environment, you can install the gurobipy module directly into your environment. The steps for doing this depend on your platform. On Windows, you can double-click on the pysetup program in the Gurobi <installdir>/bin directory. This program will prompt you for the location of your Python installation; it handles all of the details of the installation. On Linux or Mac OS, you will need to open a terminal window, change your current directory to the Gurobi <installdir> (the directory that contains the le setup.py), and issue the following command: python setup.py install Unless you are using your own private Python installation, you will need to run this command as super-user. Once gurobipy is successfully installed, you can type python mip1.py (more generally, you can type from gurobipy import * in your Python environment). 88

89 MATLAB Interface This section describes the Gurobi MATLAB interface. We begin with information on how to set up Gurobi for use within MATLAB. An example of how to use the MATLAB interface follows. Setting up Gurobi for MATLAB To begin, you'll need to tell MATLAB where to nd the Gurobi routines. We've provided a script to assist you with this. The Gurobi MATLAB setup script, gurobi_setup.m, can be found in the <installdir>/matlab directory of your Gurobi installation (the default <installdir> for Gurobi is /opt/gurobi650/linux64 for Linux, c:\gurobi650\win64 for 64-bit Windows, and /Library/gurobi650/mac64 for Mac). To get started, type the following commands within MATLAB to change to the matlab directory and call gurobi_setup: >> cd /opt/gurobi650/linux64/matlab >> gurobi_setup You will need to be careful that the MATLAB binary and the Gurobi package you install both use the same instruction set. For example, if you are using the 64-bit version of MATLAB, you'll need to install the 64-bit version of Gurobi, and you'll need to use the 64-bit Gurobi MATLAB libraries (i.e., the ones included with the 64-bit version of Gurobi). This is particularly important on Windows systems, where the error messages that result from instruction set mismatches can be quite cryptic. Example Let us now turn our attention to an example of using Gurobi to solve a simple MIP model. Our example optimizes the following model: maximize x + y + 2 z subject to x + 2 y + 3 z 4 x + y 1 x, y, z binary Note that this is the same model that was modeled and optimized in the C Interface section. This is the complete source code for our example (also available in <installdir>/examples/matlab/mip1.m)... names = {'x'; 'y'; 'z'}; 89

90 try clear model; model.a = sparse([1 2 3; 1 1 0]); model.obj = [1 1 2]; model.rhs = [4; 1]; model.sense = '<>'; model.vtype = 'B'; model.modelsense = 'max'; clear params; params.outputflag = 0; params.resultfile = 'mip1.lp'; result = gurobi(model, params); disp(result) for v=1:length(names) fprintf('%s %d\n', names{v}, result.x(v)); end fprintf('obj: %e\n', result.objval); catch gurobierror fprintf('error reported\n'); end Example details Let us now walk through the example, line by line, to understand how it achieves the desired result of optimizing the indicated model. Building the model The example begins by building an optimization model. The data associated with an optimization model must be stored in a MATLAB struct. Fields in this struct contain the dierent parts of the model. A few elds are mandatory: the constraint matrix (A), the objective vector (obj), the right-hand side vector (rhs), and the constraint sense vector (sense). A model can also include optional elds (e.g., the objective sense modelsense). The example uses the built-in sparse function to build the constraint matrix A. The Gurobi MAT- LAB interface only accepts sparse matrices as input. If you have a dense matrix, use sparse to convert it to a sparse matrix before passing it to our interface. 90

91 Subsequent statements populate other elds of the model variable, including the objective vector, the right-hand-side vector, and the constraint sense vector. In addition to the mandatory elds, this example also sets two optional elds: modelsense and vtype. The former is used to indicate the sense of the objective function. The default is minimization, so we've set the elds equal to 'max' to indicate that we would like to maximize the specied objective. The vtype eld is used to indicate the types of the variables in the model. In our example, all variables are binary ('B'). Note that our interface allows you to specify a scalar value for the sense and vtype arguments. The Gurobi interface will expand that scalar to a constant array of the appropriate length. In this example, the scalar value 'B' will be expanded to an array of length 3, containing one 'B' value for each column of A. Modifying Gurobi parameters The next statements create a struct variable that will be used to modify two Gurobi parameters: params.outputflag = 0; params.resultfile = 'mip1.lp'; In this example, we set the Gurobi OutputFlag parameter to 0 in order to shut o Gurobi output. We also set the ResultFile parameter to request that Gurobi produce a le as output (in this case, a LP format le that contains the optimization model). The Gurobi MATLAB interface allows you to set as many Gurobi parameters as you would like. The eld names in the parameter structure simply need to match Gurobi parameter names, and the values of the elds should be set to the desired parameter value. Please consult the Parameters section of the Gurobi Reference Manual for a complete list of all Gurobi parameters. Solving the model The next statement is where the actual optimization occurs: result = gurobi(model, params); We pass the model and the optional list of parameter changes to the gurobi() function. It computes an optimal solution to the specied model and returns the computed result. Printing the solution The gurobi() function returns a struct as its result. This struct contains a number of elds, where each eld contains information about the computed solution. The available elds depend on the result of the optimization, the type of model that was solved (LP, QP, QCP, SOCP, or MIP), and the algorithm used to solve the model. The returned struct will always contain a status eld, which indicates whether Gurobi was able to compute an optimal solution to the model. You should consult the Status Codes section of the Gurobi Reference Manual for a complete list of all possible 91

92 status codes. If Gurobi was able to nd a solution to the model, the return value will also include objval and x elds. The former gives the objective value for the computed solution, and the latter is the computed solution vector (one entry per column of the constraint matrix). For continuous models, we will also return dual information (reduced costs and dual multipliers), and possibly an optimal basis. In our example, we simply print the optimal objective value (result.objval) and the optimal solution vector (result.x). Running the example The Gurobi MATLAB examples can be found in the <installdir>/examples/matlab/ directory of your Gurobi installation (the default <installdir> for Gurobi is /opt/gurobi650/linux64 for Linux, c:\gurobi650\win64 for 64-bit Windows, and /Library/gurobi650/mac64 for Mac). To run one of the examples, rst change to this directory in MATLAB, then type its name into the MATLAB prompt. For example, to run example mip1, you would say: >> cd /opt/gurobi650/linux64/examples/matlab >> mip1 If Gurobi was successfully set up for use in MATLAB, you should see the following output: status: 'OPTIMAL' versioninfo: [1x1 struct] objval: 3 runtime: x: [3x1 double] slack: [2x1 double] objbound: 3 itercount: 0 baritercount: 0 nodecount: 0 x 1 y 0 z 1 Obj: e+00 The MATLAB example directory contains a number of examples. We encourage you to browse and modify them in order to become more familiar with the Gurobi MATLAB interface. 92

93 R Interface This section describes the Gurobi R interface. We begin with information on how to set up Gurobi for use within R. An example of how to use the R interface follows. Installing the R Package To begin, you'll need to install the Gurobi package in R. The R command for doing this is: install.packages('<r-package-file>', repos=null) The R package le can be found in the <installdir>/r directory of your Gurobi installation. For a default installation of Gurobi 6.5.0, the command would be: Linux: install.packages('/opt/gurobi650/linux64/r/gurobi_6.5-0_r_x86_64-unknown-linux-gnu.tar.gz', repos=null) Windows: install.packages('c:\gurobi650\win64\r\gurobi_6.5-0.zip', repos=null) Mac: install.packages('/library/gurobi650/mac64/r/gurobi_6.5-0.tgz', repos=null) You will need to adjust the path to match your install directory and version. You will need to be careful that the R binary and the Gurobi package you install both use the same instruction set. For example, if you are using the 64-bit version of R, you'll need to install the 64-bit version of Gurobi, and the 64-bit Gurobi R package. This is particularly important on Windows systems, where the error messages that result from instruction set mismatches can be quite cryptic. If you are using R from RStudio Server, and you get an error indicating that R is unable to load the Gurobi DLL or shared object, you may need to set the rsession-ld-library-path entry in the server cong le. Please consult the RStudio documentation for more information. Example Let us now turn our attention to an example of using Gurobi to solve a simple MIP model. Our example optimizes the following model: maximize x + y + 2 z subject to x + 2 y + 3 z 4 x + y 1 x, y, z binary 93

94 Note that this is the same model that was modeled and optimized in the C Interface section. This is the complete source code for our example (also available in <installdir>/examples/r/mip.r)... library('gurobi') model <- list() model$a <- matrix(c(1,2,3,1,1,0), nrow=2, ncol=3, byrow=t) model$obj <- c(1,1,2) model$modelsense <- "max" model$rhs <- c(4,1) model$sense <- c('<', '>') model$vtype <- 'B' params <- list(outputflag=0) result <- gurobi(model, params) print('solution:') print(result$objval) print(result$x) Example details Let us now walk through the example, line by line, to understand how it achieves the desired result of optimizing the indicated model. The example begins by importing the Gurobi package (library('gurobi')). R programs that call Gurobi must include this line. Building the model The example now builds an optimization model. The data associated with an optimization model must be stored in a single list variable. Named components in this list contain the dierent parts of the model. A few components are mandatory: the constraint matrix (A), the objective vector (obj), the right-hand side vector (rhs), and the constraint sense vector (sense). A model variable can also include optional components (e.g., the objective sense modelsense). In our example, we use the built-in R matrix function to build the constraint matrix A. A is stored as a dense matrix here. You can also store A as a sparse matrix, using either the sparse_triplet_matrix function from the slam package or the sparsematrix class from the Matrix package. Sparse input matrices are illustrated in the lp2.r example. Subsequent statements populate other components of the model variable, including the objective 94

95 vector, the right-hand-side vector, and the constraint sense vector. In each case, we use the built-in c function to initialize the array arguments. In addition to the mandatory components, this example also sets two optional components: modelsense and vtype. The former is used to indicate the sense of the objective function. The default is minimization, so we've set the components equal to 'max' to indicate that we would like to maximize the specied objective. The vtype component is used to indicate the types of the variables in the model. In our example, all variables are binary ('B'). Note that our interface allows you to specify a scalar value for any array argument. The Gurobi interface will expand that scalar to a constant array of the appropriate length. In this example, the scalar value 'B' will be expanded to an array of length 3, containing one 'B' value for each column of A. Modifying Gurobi parameters The next statement creates a list variable that will be used to modify a Gurobi parameter: params <- list(outputflag=0) In this example, we wish to set the Gurobi OutputFlag parameter to 0 in order to shut o Gurobi output. The Gurobi R interface allows you to pass a list of the Gurobi parameters you would like to change. Please consult the Parameters section of the Gurobi Reference Manual for a complete list of all Gurobi parameters. Solving the model The next statement is where the actual optimization occurs: result <- gurobi(model, params) We pass the model and the optional list of parameter changes to the gurobi() function. It computes an optimal solution to the specied model and returns the computed result. Printing the solution The gurobi() function returns a list as its result. This list contains a number of components, where each component contains information about the computed solution. The available components depend on the result of the optimization, the type of model that was solved (LP, QP, SOCP, or MIP), and the algorithm used to solve the model. This result list will always contain an integer status component, which indicates whether Gurobi was able to compute an optimal solution to the model. You should consult the Status Codes section of the Gurobi Reference Manual for a complete list of all possible status codes. If Gurobi was able to nd a solution to the model, the return value will also include objval and x components. The former gives the objective value for the computed solution, and the latter is the computed solution vector (one entry per column of the 95

96 constraint matrix). For continuous models, we will also return dual information (reduced costs and dual multipliers), and possibly an optimal basis. In our example, we simply print the optimal objective value (result$objval) and the optimal solution vector (result$x). Running the example To run one of the R examples provided with the Gurobi distribution, you can use the source command in R. For example, if you are running R from the Gurobi R examples directory, you can say: > source('mip.r') If the Gurobi package was successfully installed, you should see the following output: [1] "Solution:" [1] 3 [1] The R example directory <installdir>/examples/r contains a number of examples. We encourage you to browse and modify them in order to become more familiar with the Gurobi R interface. 96

97 Recommended Reading The very basic introduction to mathematical programming and mathematical modeling in this document barely scratches the surface of this very broad and rich eld. We've collected a set of recommended books here that provide more information on various aspects of math programming. If you want more information on the algorithms and mathematics underlying the solution of linear programming problems, we recommend Introduction to Linear Optimization by Bertsimas, Tsitsiklis, and Tsitsiklis, or Linear Programming: Foundations and Extensions by R. Vanderbei. For a detailed treatment of interior-point methods for linear programming, we recommend Primal-Dual Interior-Point Methods by S. Wright. For more information on the algorithms and mathematics underlying the solution of mixed-integer programming problems, we recommend Integer Programming by L. Wolsey. For an introduction to the process of creating mathematical programming representations of business problems, we recommand Model Building in Mathematical Programming by H.P. Williams. 97

98 Installing the Anaconda Python distribution The Gurobi distribution includes a Python interpreter and a basic set of Python modules. While these are sucient for building and running simple optimization models, they provide just a glimpse of the wealth of tools and modules that are available for Python. This section guides you through the steps involved in installing Anaconda, a widely-used Python platform that includes an Integrated Development Environment (Spyder), a notebook-style interface (ipython Notebook), and a broad set of Python modules. These tools can signicantly increase the interactivity and productivity of your Python model building experience. Before we begin, we should note that Anaconda isn't your only choice in Python distributions and/or IDEs. Popular alternatives include Canopy, Eric, iep, and PyDev. We won't be covering the details of installing these other options for use with Gurobi, but the Anaconda instructions that follow should provide a good outline for the steps involved. We've found that Anaconda provides a nice balance between power and complexity, but we realize that people may look for dierent things in their Python environments. Step 1: Download and Install Anaconda The rst step is to download and install Anaconda. You can nd it here. 98

99 Gurobi supports Python 2.7 and Python 3.5, in both 32-bit and 64-bit versions. Click on the download button (Windows 64-Bit Python 2.7 in this case), and then download and run the Anaconda installer. Step 2: Install Gurobi into Anaconda The next step is to install the Gurobi package into Anaconda. You do this by rst adding the Gurobi channel to your Anaconda channels and then installing the gurobi package from this channel. From an Anaconda terminal issue the following command to add the Gurobi channel to your default search list conda config --add channels Now issue the following command to install the Gurobi package conda install gurobi You can remove the Gurobi package at any time by issuing the command conda remove gurobi Step 3: Install a Gurobi License The third step is to install a Gurobi license (if you haven't already done so). You are now ready to use Gurobi from within Anaconda. Your next step is to launch either the Spyder IDE or ipython Notebook Using the Spyder IDE You can launch the Spyder Python IDE from the Windows Program menu (the installer should have placed it in the Anaconda folder). Gurobi Interactive Shell commands can be typed directly into the Spyder Console window: 99

100 Note that a general-purpose Python IDE like Spyder requires one extra step that isn't required when you launch the Gurobi shell from the Gurobi icon or by using the gurobi.bat command: you must manually load the Gurobi module by typing from gurobipy import * before issuing any Gurobi commands. You can also use Spyder to run any of the Gurobi examples. For example, if you use Open under the File menu to open Gurobi example mip1.py, and then click on the Run icon (the green triangle), you should see: 100

101 Some Gurobi examples require command-line arguments. Those can be input from the Configure... item of the Run menu. For example, to run the sudoku.py example with le sudoku1 as input

102 Anaconda Python includes all of the Python modules used in the Gurobi examples, but feel free to explore the vast library of additional Python modules. A list of available modules can be found at the PyPI site. You can use the conda command to install additional modules. Type conda into a terminal window with no arguments to get additional information on this command Using the ipython Notebook You can launch ipython Notebook from the Windows Program menu (the installer should have placed it in the Anaconda folder). You can create a new notebook by clicking on the New icon (in the upper right) and choosing one of the Notebook options. Once your new notebook starts, you can type standard Python commands or Gurobi Interactive Shell commands directly into the In window: Our simple example shows a set of commands that create and solve a simple linear programming model, and then plot the resulting constraints and the computed optimal vertex. For those of you who aren't familiar with notebook-style interfaces, they allow you to mix executable code, text, and graphics to create a self-documenting stream of results. Notebooks can be saved and continued later, which make them particularly well suited for prototyping and experimentation. 102

103 Windows Command Line Setting up and using Gurobi on a Windows system sometimes requires you to type command-line commands. This can be unfamiliar to Windows users, so this section provides a bit of help. Windows provides a few dierent options for inputting commands. For simple commands, you can open a Run window, by pressing the Start key and the letter R simultaneously: A command can be typed or pasted directly into this window. You can also type or paste commands directly into the Search box (available under the Start button on Windows Vista and Windows 7, and toward the bottom left of the desktop on Windows 10): While these two interfaces are useful for issuing simple commands, they aren't suited for extensive interactive usage. If you want to launch Gurobi command-line commands and see the resulting 103

104 output, for example, you'll need a Console window (also known as a Command Prompt window or just a cmd window). To launch a Console window, type cmd into either the Run window or the Search box (as described above). This window will remain open, displaying the output from the previous command and waiting for the next command, until you close it. 104

GUROBI OPTIMIZER QUICK START GUIDE. Version 6.0, Copyright c 2014, Gurobi Optimization, Inc.

GUROBI OPTIMIZER QUICK START GUIDE. Version 6.0, Copyright c 2014, Gurobi Optimization, Inc. GUROBI OPTIMIZER QUICK START GUIDE Version 6.0, Copyright c 2014, Gurobi Optimization, Inc. Contents 1 Introduction 4 2 Obtaining a Gurobi License 6 2.1 Creating a new academic license.............................

More information

FlexSim LAN License Server

FlexSim LAN License Server FlexSim LAN License Server Installation Instructions Rev. 20150318 Table of Contents Introduction... 2 Using lmtools... 2 1. Download the installation files... 3 2. Install the license server... 4 3. Connecting

More information

MITA End-User VPN Troubleshooting Guide

MITA End-User VPN Troubleshooting Guide 01. Introduction MITA VPN users can be assigned one of two types of profiles Client-Based or Web-Based, depending on the type of access required. When logging on to the MITA VPN Portal https://vpn.secure.gov.mt,

More information

Deploying BitDefender Client Security and BitDefender Windows Server Solutions

Deploying BitDefender Client Security and BitDefender Windows Server Solutions Deploying BitDefender Client Security and BitDefender Windows Server Solutions Quick Install Guide Copyright 2011 BitDefender 1. Installation Overview Thank you for selecting BitDefender Business Solutions

More information

User Manual. Onsight Management Suite Version 5.1. Another Innovation by Librestream

User Manual. Onsight Management Suite Version 5.1. Another Innovation by Librestream User Manual Onsight Management Suite Version 5.1 Another Innovation by Librestream Doc #: 400075-06 May 2012 Information in this document is subject to change without notice. Reproduction in any manner

More information

How to Setup and Connect to an FTP Server Using FileZilla. Part I: Setting up the server

How to Setup and Connect to an FTP Server Using FileZilla. Part I: Setting up the server How to Setup and Connect to an FTP Server Using FileZilla The ability to store data on a server and being able to access the data from anywhere in the world has allowed us to get rid of external flash

More information

The Power Loader GUI

The Power Loader GUI The Power Loader GUI (212) 405.1010 info@1010data.com Follow: @1010data www.1010data.com The Power Loader GUI Contents 2 Contents Pre-Load To-Do List... 3 Login to Power Loader... 4 Upload Data Files to

More information

Deploying BitDefender Client Security and BitDefender Windows Server Solutions

Deploying BitDefender Client Security and BitDefender Windows Server Solutions Deploying BitDefender Client Security and BitDefender Windows Server Solutions Quick Install Guide Copyright 2010 BitDefender; 1. Installation Overview Thank you for selecting BitDefender Business Solutions

More information

Pearl Echo Installation Checklist

Pearl Echo Installation Checklist Pearl Echo Installation Checklist Use this checklist to enter critical installation and setup information that will be required to install Pearl Echo in your network. For detailed deployment instructions

More information

Installation Guidelines (MySQL database & Archivists Toolkit client)

Installation Guidelines (MySQL database & Archivists Toolkit client) Installation Guidelines (MySQL database & Archivists Toolkit client) Understanding the Toolkit Architecture The Archivists Toolkit requires both a client and database to function. The client is installed

More information

Cloud Server powered by Mac OS X. Getting Started Guide. Cloud Server. powered by Mac OS X. AKJZNAzsqknsxxkjnsjx Getting Started Guide Page 1

Cloud Server powered by Mac OS X. Getting Started Guide. Cloud Server. powered by Mac OS X. AKJZNAzsqknsxxkjnsjx Getting Started Guide Page 1 Getting Started Guide Cloud Server powered by Mac OS X Getting Started Guide Page 1 Getting Started Guide: Cloud Server powered by Mac OS X Version 1.0 (02.16.10) Copyright 2010 GoDaddy.com Software, Inc.

More information

1. Installation Overview

1. Installation Overview Quick Install Guide 1. Installation Overview Thank you for selecting Bitdefender Business Solutions to protect your business. This document enables you to quickly get started with the installation of Bitdefender

More information

WhatsUp Gold v16.3 Installation and Configuration Guide

WhatsUp Gold v16.3 Installation and Configuration Guide WhatsUp Gold v16.3 Installation and Configuration Guide Contents Installing and Configuring WhatsUp Gold using WhatsUp Setup Installation Overview... 1 Overview... 1 Security considerations... 2 Standard

More information

Data Warehouse Troubleshooting Tips

Data Warehouse Troubleshooting Tips Table of Contents "Can't find the Admin layer "... 1 "Can't locate connection document "... 3 Column Headings are Missing after Copy/Paste... 5 Connection Error: ORA-01017: invalid username/password; logon

More information

Virtual Appliance Setup Guide

Virtual Appliance Setup Guide The Barracuda SSL VPN Vx Virtual Appliance includes the same powerful technology and simple Web based user interface found on the Barracuda SSL VPN hardware appliance. It is designed for easy deployment

More information

Using Virtual Machines

Using Virtual Machines Using Virtual Machines We will use VMs in CIT 130 so that you can access both a Windows 7 and a Linux machine. You will be able to access these from on and off campus (off campus access will require that

More information

Quick Start Guide for VMware and Windows 7

Quick Start Guide for VMware and Windows 7 PROPALMS VDI Version 2.1 Quick Start Guide for VMware and Windows 7 Rev. 1.1 Published: JULY-2011 1999-2011 Propalms Ltd. All rights reserved. The information contained in this document represents the

More information

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code. Content Introduction... 2 Data Access Server Control Panel... 2 Running the Sample Client Applications... 4 Sample Applications Code... 7 Server Side Objects... 8 Sample Usage of Server Side Objects...

More information

imhosted Web Hosting Knowledge Base

imhosted Web Hosting Knowledge Base imhosted Web Hosting Knowledge Base FTP & SSH Category Contents FTP & SSH 1 What is SSH and do you support it? 1 How do I setup and use SSH? 1 Will I have unlimited access to update my pages? 2 What is

More information

Installation Overview

Installation Overview Contents Installation Overview... 2 How to Install Ad-Aware Management Server... 3 How to Deploy the Ad-Aware Security Solutions... 5 General Deployment Conditions... 5 Deploying Ad-Aware Management Agent...

More information

XMPP Instant Messaging and Active Directory

XMPP Instant Messaging and Active Directory XMPP Instant Messaging and Active Directory Quick setup of Isode's XMPP Server, M-Link, using Microsoft's Active Directory for user account provisioning Isode Objectives This document is intended for those

More information

SMART Sync 2011. Windows operating systems. System administrator s guide

SMART Sync 2011. Windows operating systems. System administrator s guide SMART Sync 2011 Windows operating systems System administrator s guide Trademark notice SMART Sync, smarttech and the SMART logo are trademarks or registered trademarks of SMART Technologies ULC in the

More information

Test Automation Integration with Test Management QAComplete

Test Automation Integration with Test Management QAComplete Test Automation Integration with Test Management QAComplete This User's Guide walks you through configuring and using your automated tests with QAComplete's Test Management module SmartBear Software Release

More information

Aspera Connect User Guide

Aspera Connect User Guide Aspera Connect User Guide Windows XP/2003/Vista/2008/7 Browser: Firefox 2+, IE 6+ Version 2.3.1 Chapter 1 Chapter 2 Introduction Setting Up 2.1 Installation 2.2 Configure the Network Environment 2.3 Connect

More information

SSH and Basic Commands

SSH and Basic Commands SSH and Basic Commands In this tutorial we'll introduce you to SSH - a tool that allows you to send remote commands to your Web server - and show you some simple UNIX commands to help you manage your website.

More information

OET Cloud Services Getting Started Guide

OET Cloud Services Getting Started Guide OET Cloud Services Getting Started Guide Introduction OET Cloud Services uses Google Drive to let you store and access OET files anywhere -- on the web, and access them on your PC, or on any device connected

More information

Sophos Anti-Virus for NetApp Storage Systems startup guide

Sophos Anti-Virus for NetApp Storage Systems startup guide Sophos Anti-Virus for NetApp Storage Systems startup guide Runs on Windows 2000 and later Product version: 1 Document date: April 2012 Contents 1 About this guide...3 2 About Sophos Anti-Virus for NetApp

More information

Setting Up Your FTP Server

Setting Up Your FTP Server Requirements:! A computer dedicated to FTP server only! Linksys router! TCP/IP internet connection Steps: Getting Started Configure Static IP on the FTP Server Computer: Setting Up Your FTP Server 1. This

More information

Welcome to the QuickStart Guide

Welcome to the QuickStart Guide QuickStart Guide Welcome to the QuickStart Guide This QuickStart Guide provides the information you need to install and start using Express Software Manager. For more comprehensive help on using Express

More information

JMC Next Generation Web-based Server Install and Setup

JMC Next Generation Web-based Server Install and Setup JMC Next Generation Web-based Server Install and Setup This document will discuss the process to install and setup a JMC Next Generation Web-based Windows Server 2008 R2. These instructions also work for

More information

Installing and Configuring vcloud Connector

Installing and Configuring vcloud Connector Installing and Configuring vcloud Connector vcloud Connector 2.0.0 This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new

More information

Signiant Agent installation

Signiant Agent installation Signiant Agent installation Release 11.3.0 March 2015 ABSTRACT Guidelines to install the Signiant Agent software for the WCPApp. The following instructions are adapted from the Signiant original documentation

More information

How To Use Senior Systems Cloud Services

How To Use Senior Systems Cloud Services Senior Systems Cloud Services In this guide... Senior Systems Cloud Services 1 Cloud Services User Guide 2 Working In Your Cloud Environment 3 Cloud Profile Management Tool 6 How To Save Files 8 How To

More information

Secret Server Installation Windows Server 2008 R2

Secret Server Installation Windows Server 2008 R2 Table of Contents Introduction... 2 ASP.NET Website... 2 SQL Server Database... 2 Administrative Access... 2 Prerequisites... 2 System Requirements Overview... 2 Additional Recommendations... 3 Beginning

More information

How to use FTP Commander

How to use FTP Commander FTP (File Transfer Protocol) software can be used to upload files and complete folders to your web server. On the web, there are a number of free FTP programs that can be downloaded and installed onto

More information

1 Download & Installation... 4. 1 Usernames and... Passwords

1 Download & Installation... 4. 1 Usernames and... Passwords Contents I Table of Contents Part I Document Overview 2 Part II Document Details 3 Part III EventSentry Setup 4 1 Download & Installation... 4 Part IV Configuration 4 1 Usernames and... Passwords 5 2 Network...

More information

Fasthosts Internet Parallels Plesk 10 Manual

Fasthosts Internet Parallels Plesk 10 Manual Fasthosts Internet Parallels Plesk 10 Manual Introduction... 2 Before you begin... 2 Logging in to the Plesk control panel... 2 Securing access to the Plesk 10 control panel... 3 Configuring your new server...

More information

Installation Guide. Novell Storage Manager 3.1.1 for Active Directory. Novell Storage Manager 3.1.1 for Active Directory Installation Guide

Installation Guide. Novell Storage Manager 3.1.1 for Active Directory. Novell Storage Manager 3.1.1 for Active Directory Installation Guide Novell Storage Manager 3.1.1 for Active Directory Installation Guide www.novell.com/documentation Installation Guide Novell Storage Manager 3.1.1 for Active Directory October 17, 2013 Legal Notices Condrey

More information

Hosting Users Guide 2011

Hosting Users Guide 2011 Hosting Users Guide 2011 eofficemgr technology support for small business Celebrating a decade of providing innovative cloud computing services to small business. Table of Contents Overview... 3 Configure

More information

MATLAB Distributed Computing Server with HPC Cluster in Microsoft Azure

MATLAB Distributed Computing Server with HPC Cluster in Microsoft Azure MATLAB Distributed Computing Server with HPC Cluster in Microsoft Azure Introduction This article shows you how to deploy the MATLAB Distributed Computing Server (hereinafter referred to as MDCS) with

More information

Virtual Appliance Setup Guide

Virtual Appliance Setup Guide The Virtual Appliance includes the same powerful technology and simple Web based user interface found on the Barracuda Web Application Firewall hardware appliance. It is designed for easy deployment on

More information

WhatsUp Gold v16.1 Installation and Configuration Guide

WhatsUp Gold v16.1 Installation and Configuration Guide WhatsUp Gold v16.1 Installation and Configuration Guide Contents Installing and Configuring Ipswitch WhatsUp Gold v16.1 using WhatsUp Setup Installing WhatsUp Gold using WhatsUp Setup... 1 Security guidelines

More information

Table of Contents. FleetSoft Installation Guide

Table of Contents. FleetSoft Installation Guide FleetSoft Installation Guide Table of Contents FleetSoft Installation Guide... 1 Minimum System Requirements... 2 Installation Notes... 3 Frequently Asked Questions... 4 Deployment Overview... 6 Automating

More information

Getting Started with ESXi Embedded

Getting Started with ESXi Embedded ESXi 4.1 Embedded vcenter Server 4.1 This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new edition. To check for more recent

More information

Introduction to Operating Systems

Introduction to Operating Systems Introduction to Operating Systems It is important that you familiarize yourself with Windows and Linux in preparation for this course. The exercises in this book assume a basic knowledge of both of these

More information

Using Jive for Outlook

Using Jive for Outlook Using Jive for Outlook TOC 2 Contents Using Jive for Outlook...3 Client System Requirements... 3 Getting Started with Jive for Outlook... 3 Jview and View as email...5 Viewing Social Information... 5 Finding

More information

ez Agent Administrator s Guide

ez Agent Administrator s Guide ez Agent Administrator s Guide Copyright This document is protected by the United States copyright laws, and is proprietary to Zscaler Inc. Copying, reproducing, integrating, translating, modifying, enhancing,

More information

Remote Control 5.1.2. Tivoli Endpoint Manager - TRC User's Guide

Remote Control 5.1.2. Tivoli Endpoint Manager - TRC User's Guide Tivoli Remote Control 5.1.2 Tivoli Endpoint Manager - TRC User's Guide Tivoli Remote Control 5.1.2 Tivoli Endpoint Manager - TRC User's Guide Note Before using this information and the product it supports,

More information

ShoutCast v2 - Broadcasting with Winamp & ShoutCast DSP Plugin

ShoutCast v2 - Broadcasting with Winamp & ShoutCast DSP Plugin ShoutCast v2 - Broadcasting with Winamp & ShoutCast DSP Plugin In this tutorial we are going to explain how to broadcast using the ShoutCast DSP Plugin with Winamp to our ShoutCast v2 running under CentovaCast

More information

WhatsUp Gold v16.2 Installation and Configuration Guide

WhatsUp Gold v16.2 Installation and Configuration Guide WhatsUp Gold v16.2 Installation and Configuration Guide Contents Installing and Configuring Ipswitch WhatsUp Gold v16.2 using WhatsUp Setup Installing WhatsUp Gold using WhatsUp Setup... 1 Security guidelines

More information

QuickBooks 2010 Installation Guide

QuickBooks 2010 Installation Guide QuickBooks 2010 Installation Guide This article provides instructions for installing QuickBooks 2010 on a single computer and in a network environment. QuickBooks Elements Several elements are involved

More information

SIMIAN systems. Setting up a Sitellite development environment on Windows. Sitellite Content Management System

SIMIAN systems. Setting up a Sitellite development environment on Windows. Sitellite Content Management System Setting up a Sitellite development environment on Windows Sitellite Content Management System Introduction For live deployment, it is strongly recommended that Sitellite be installed on a Unix-based operating

More information

PigCHAMP Knowledge Software. Enterprise Edition Installation Guide

PigCHAMP Knowledge Software. Enterprise Edition Installation Guide PigCHAMP Knowledge Software Enterprise Edition Installation Guide Enterprise Edition Installation Guide MARCH 2012 EDITION PigCHAMP Knowledge Software 1531 Airport Rd Suite 101 Ames, IA 50010 Phone (515)

More information

OutDisk 4.0 FTP FTP for Email Users using Microsoft Windows and/or Microsoft Outlook. 5/1/2012 2012 Encryptomatic LLC www.encryptomatic.

OutDisk 4.0 FTP FTP for Email Users using Microsoft Windows and/or Microsoft Outlook. 5/1/2012 2012 Encryptomatic LLC www.encryptomatic. OutDisk 4.0 FTP FTP for Email Users using Microsoft Windows and/or Microsoft Outlook 5/1/2012 2012 Encryptomatic LLC www.encryptomatic.com Contents What is OutDisk?... 3 OutDisk Requirements... 3 How Does

More information

Authentication Node Configuration. WatchGuard XTM

Authentication Node Configuration. WatchGuard XTM Authentication Node Configuration WatchGuard XTM Author: Signify Issue: Version 1.0 Date: xx Month 2013 Contents Introduction... 4 Configuration Prerequisites... 4 Knowledge and Access Rights... 4 Infrastructure...

More information

Quadro Configuration Console User's Guide. Table of Contents. Table of Contents

Quadro Configuration Console User's Guide. Table of Contents. Table of Contents Epygi Technologies Table of Contents Table of Contents About This User s Guide... 3 Introducing the Quadro Configuration Console... 4 Technical Specification... 6 Requirements... 6 System Requirements...

More information

Windows Server Update Services 3.0 SP2 Step By Step Guide

Windows Server Update Services 3.0 SP2 Step By Step Guide Windows Server Update Services 3.0 SP2 Step By Step Guide Microsoft Corporation Author: Anita Taylor Editor: Theresa Haynie Abstract This guide provides detailed instructions for installing Windows Server

More information

Tutorial Guide to the IS Unix Service

Tutorial Guide to the IS Unix Service Tutorial Guide to the IS Unix Service The aim of this guide is to help people to start using the facilities available on the Unix and Linux servers managed by Information Services. It refers in particular

More information

Microsoft XP Professional Remote Desktop Connection

Microsoft XP Professional Remote Desktop Connection Microsoft XP Professional Remote Desktop Connection With Remote Desktop, you get full, secure access to your work computer via an Internet or network connection. For example, you can connect to your office

More information

Using RPC over HTTP with Exchange Server 2003 SP1

Using RPC over HTTP with Exchange Server 2003 SP1 Using RPC over HTTP with Exchange Server 2003 SP1 Author: Bill Boswell Bill Boswell Consulting, Inc. www.billboswellconsulting.com bill@billboswellconsulting.com RCP over HTTP has a lot of moving parts

More information

Device LinkUP + Desktop LP Guide RDP

Device LinkUP + Desktop LP Guide RDP Device LinkUP + Desktop LP Guide RDP Version 2.1 January 2016 Copyright 2015 iwebgate. All Rights Reserved. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval

More information

AVG Business SSO Connecting to Active Directory

AVG Business SSO Connecting to Active Directory AVG Business SSO Connecting to Active Directory Contents AVG Business SSO Connecting to Active Directory... 1 Selecting an identity repository and using Active Directory... 3 Installing Business SSO cloud

More information

12Planet Chat end-user manual

12Planet Chat end-user manual 12Planet Chat end-user manual Document version 1.0 12Planet 12Planet Page 2 / 13 Table of content 1 General... 4 1.1 How does the chat work?... 4 1.2 Browser Requirements... 4 1.3 Proxy / Firewall Info...

More information

Setup and Configuration Guide for Pathways Mobile Estimating

Setup and Configuration Guide for Pathways Mobile Estimating Setup and Configuration Guide for Pathways Mobile Estimating Setup and Configuration Guide for Pathways Mobile Estimating Copyright 2008 by CCC Information Services Inc. All rights reserved. No part of

More information

How to Earn IPv6 Certifications (Windows Version: Fast) Why? Macintosh Instructions Windows Versions Tips for Windows Home Edition Users

How to Earn IPv6 Certifications (Windows Version: Fast) Why? Macintosh Instructions Windows Versions Tips for Windows Home Edition Users How to Earn IPv6 Certifications (Windows Version: Fast) Why? IPv6 is coming, whether we like it or not. We all need to learn it, and the sooner we do that, the better. This page will guide you through

More information

Oracle EXAM - 1Z0-102. Oracle Weblogic Server 11g: System Administration I. Buy Full Product. http://www.examskey.com/1z0-102.html

Oracle EXAM - 1Z0-102. Oracle Weblogic Server 11g: System Administration I. Buy Full Product. http://www.examskey.com/1z0-102.html Oracle EXAM - 1Z0-102 Oracle Weblogic Server 11g: System Administration I Buy Full Product http://www.examskey.com/1z0-102.html Examskey Oracle 1Z0-102 exam demo product is here for you to test the quality

More information

Allworx OfficeSafe Operations Guide Release 6.0

Allworx OfficeSafe Operations Guide Release 6.0 Allworx OfficeSafe Operations Guide Release 6.0 No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopy,

More information

FileMaker Server 13. Getting Started Guide

FileMaker Server 13. Getting Started Guide FileMaker Server 13 Getting Started Guide 2007 2013 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker and Bento are trademarks of FileMaker,

More information

How to Configure Outlook 2010 to connect to Exchange 2010

How to Configure Outlook 2010 to connect to Exchange 2010 How to Configure Outlook 2010 to connect to Exchange 2010 Outlook 2010 will install and work correctly on any version of Windows XP, Vista, Windows 7 or Windows 8. These instructions describe how to setup

More information

Jive Case Escalation for Salesforce

Jive Case Escalation for Salesforce Jive Case Escalation for Salesforce TOC 2 Contents System Requirements... 3 Understanding Jive Case Escalation for Salesforce... 4 Setting Up Jive Case Escalation for Salesforce...5 Installing the Program...

More information

CommandCenter Secure Gateway

CommandCenter Secure Gateway CommandCenter Secure Gateway Quick Setup Guide for CC-SG Virtual Appliance and lmadmin License Server Management This Quick Setup Guide explains how to install and configure the CommandCenter Secure Gateway.

More information

VPN: Virtual Private Network Setup Instructions

VPN: Virtual Private Network Setup Instructions VPN: Virtual Private Network Setup Instructions Virtual Private Network (VPN): For e-journals and web-based databases, plus applications like EndNote's Online Search (formerly "Connect") and business systems.

More information

Web Editing Tutorial. Copyright 1995-2010 Esri All rights reserved.

Web Editing Tutorial. Copyright 1995-2010 Esri All rights reserved. Copyright 1995-2010 Esri All rights reserved. Table of Contents Tutorial: Creating a Web editing application........................ 3 Copyright 1995-2010 Esri. All rights reserved. 2 Tutorial: Creating

More information

Receiver Updater for Windows 4.0 and 3.x

Receiver Updater for Windows 4.0 and 3.x Receiver Updater for Windows 4.0 and 3.x 2015-04-12 05:29:34 UTC 2015 Citrix Systems, Inc. All rights reserved. Terms of Use Trademarks Privacy Statement Contents Receiver Updater for Windows 4.0 and 3.x...

More information

FTP, IIS, and Firewall Reference and Troubleshooting

FTP, IIS, and Firewall Reference and Troubleshooting FTP, IIS, and Firewall Reference and Troubleshooting Although Cisco VXC Manager automatically installs and configures everything you need for use with respect to FTP, IIS, and the Windows Firewall, the

More information

Aventail Connect Client with Smart Tunneling

Aventail Connect Client with Smart Tunneling Aventail Connect Client with Smart Tunneling User s Guide Windows v8.7.0 1996-2006 Aventail Corporation. All rights reserved. Aventail, Aventail Cache Control, Aventail Connect, Aventail Connect Mobile,

More information

BIGPOND ONLINE STORAGE USER GUIDE Issue 1.1.0-18 August 2005

BIGPOND ONLINE STORAGE USER GUIDE Issue 1.1.0-18 August 2005 BIGPOND ONLINE STORAGE USER GUIDE Issue 1.1.0-18 August 2005 PLEASE NOTE: The contents of this publication, and any associated documentation provided to you, must not be disclosed to any third party without

More information

IBM WebSphere Application Server Version 7.0

IBM WebSphere Application Server Version 7.0 IBM WebSphere Application Server Version 7.0 Centralized Installation Manager for IBM WebSphere Application Server Network Deployment Version 7.0 Note: Before using this information, be sure to read the

More information

Kaseya 2. Installation guide. Version 7.0. English

Kaseya 2. Installation guide. Version 7.0. English Kaseya 2 Kaseya Server Setup Installation guide Version 7.0 English September 4, 2014 Agreement The purchase and use of all Software and Services is subject to the Agreement as defined in Kaseya s Click-Accept

More information

Administration Guide. . All right reserved. For more information about Specops Gpupdate and other Specops products, visit www.specopssoft.

Administration Guide. . All right reserved. For more information about Specops Gpupdate and other Specops products, visit www.specopssoft. . All right reserved. For more information about Specops Gpupdate and other Specops products, visit www.specopssoft.com Copyright and Trademarks Specops Gpupdate is a trademark owned by Specops Software.

More information

Tunnels and Redirectors

Tunnels and Redirectors Tunnels and Redirectors TUNNELS AND REDIRECTORS...1 Overview... 1 Security Details... 2 Permissions... 2 Starting a Tunnel... 3 Starting a Redirector... 5 HTTP Connect... 8 HTTPS Connect... 10 LabVNC...

More information

INSTALL AND CONFIGURATION GUIDE. Atlas 5.1 for Microsoft Dynamics AX

INSTALL AND CONFIGURATION GUIDE. Atlas 5.1 for Microsoft Dynamics AX INSTALL AND CONFIGURATION GUIDE Atlas 5.1 for Microsoft Dynamics AX COPYRIGHT NOTICE Copyright 2012, Globe Software Pty Ltd, All rights reserved. Trademarks Dynamics AX, IntelliMorph, and X++ have been

More information

FileMaker Server 15. Getting Started Guide

FileMaker Server 15. Getting Started Guide FileMaker Server 15 Getting Started Guide 2007 2016 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker and FileMaker Go are trademarks

More information

Getting Microsoft Outlook and Salesforce in Sync

Getting Microsoft Outlook and Salesforce in Sync Getting Microsoft Outlook and Salesforce in Sync Salesforce, Summer 15 @salesforcedocs Last updated: July 1, 2015 Copyright 2000 2015 salesforce.com, inc. All rights reserved. Salesforce is a registered

More information

Practice Fusion API Client Installation Guide for Windows

Practice Fusion API Client Installation Guide for Windows Practice Fusion API Client Installation Guide for Windows Quickly and easily connect your Results Information System with Practice Fusion s Electronic Health Record (EHR) System Table of Contents Introduction

More information

Contents Release Notes... ... 3 System Requirements... ... 4 Administering Jive for Office... ... 5

Contents Release Notes... ... 3 System Requirements... ... 4 Administering Jive for Office... ... 5 Jive for Office TOC 2 Contents Release Notes...3 System Requirements... 4 Administering Jive for Office... 5 Getting Set Up...5 Installing the Extended API JAR File... 5 Updating Client Binaries...5 Client

More information

Installation Guide For ChoiceMail Enterprise Edition

Installation Guide For ChoiceMail Enterprise Edition Installation Guide For ChoiceMail Enterprise Edition How to Install ChoiceMail Enterprise On A Server In Front Of Your Company Mail Server August, 2004 Version 2.6x Copyright DigiPortal Software, 2002-2004

More information

How to Create and Send a Froogle Data Feed

How to Create and Send a Froogle Data Feed How to Create and Send a Froogle Data Feed Welcome to Froogle! The quickest way to get your products on Froogle is to send a data feed. A data feed is a file that contains a listing of your products. Froogle

More information

Freshservice Discovery Probe User Guide

Freshservice Discovery Probe User Guide Freshservice Discovery Probe User Guide 1. What is Freshservice Discovery Probe? 1.1 What details does Probe fetch? 1.2 How does Probe fetch the information? 2. What are the minimum system requirements

More information

Reference and Troubleshooting: FTP, IIS, and Firewall Information

Reference and Troubleshooting: FTP, IIS, and Firewall Information APPENDIXC Reference and Troubleshooting: FTP, IIS, and Firewall Information Although Cisco VXC Manager automatically installs and configures everything you need for use with respect to FTP, IIS, and the

More information

Elixir Schedule Designer User Manual

Elixir Schedule Designer User Manual Elixir Schedule Designer User Manual Release 7.3 Elixir Technology Pte Ltd Elixir Schedule Designer User Manual: Release 7.3 Elixir Technology Pte Ltd Published 2008 Copyright 2008 Elixir Technology Pte

More information

IBM SPSS Statistics Version 22. Concurrent License Administrator s Guide

IBM SPSS Statistics Version 22. Concurrent License Administrator s Guide IBM SPSS Statistics Version 22 Concurrent License Administrator s Guide Contents Administrator's guide......... 1 Before you start............. 1 Ghosting............... 1 Citrix and Terminal Services........

More information

Configuring a Check Point FireWall-1 to SOHO IPSec Tunnel

Configuring a Check Point FireWall-1 to SOHO IPSec Tunnel Configuring a Check Point FireWall-1 to SOHO IPSec Tunnel This document describes the procedures required to configure an IPSec VPN tunnel between a WatchGuard SOHO or SOHO tc and a Check Point FireWall-1.

More information

Connection Broker Managing User Connections to Workstations, Blades, VDI, and More. Quick Start with Microsoft Hyper-V

Connection Broker Managing User Connections to Workstations, Blades, VDI, and More. Quick Start with Microsoft Hyper-V Connection Broker Managing User Connections to Workstations, Blades, VDI, and More Quick Start with Microsoft Hyper-V Version 8.1 October 21, 2015 Contacting Leostream Leostream Corporation http://www.leostream.com

More information

Release Notes. Pre-Installation Recommendations... 1 Platform Compatibility... 1 Known Issues... 2 Resolved Issues... 2 Troubleshooting...

Release Notes. Pre-Installation Recommendations... 1 Platform Compatibility... 1 Known Issues... 2 Resolved Issues... 2 Troubleshooting... Global VPN Client SonicWALL Global VPN Client 4.7.3 Release Notes Contents Pre-Installation Recommendations... 1 Platform Compatibility... 1 Known Issues... 2 Resolved Issues... 2 Troubleshooting... 4

More information

Alteryx Predictive Analytics for Oracle R

Alteryx Predictive Analytics for Oracle R Alteryx Predictive Analytics for Oracle R I. Software Installation In order to be able to use Alteryx s predictive analytics tools with an Oracle Database connection, your client machine must be configured

More information

NETASQ SSO Agent Installation and deployment

NETASQ SSO Agent Installation and deployment NETASQ SSO Agent Installation and deployment Document version: 1.3 Reference: naentno_sso_agent Page 1 / 20 Copyright NETASQ 2013 General information 3 Principle 3 Requirements 3 Active Directory user

More information

Note: With v3.2, the DocuSign Fetch application was renamed DocuSign Retrieve.

Note: With v3.2, the DocuSign Fetch application was renamed DocuSign Retrieve. Quick Start Guide DocuSign Retrieve 3.2.2 Published April 2015 Overview DocuSign Retrieve is a windows-based tool that "retrieves" envelopes, documents, and data from DocuSign for use in external systems.

More information

Virtual Appliances. Virtual Appliances: Setup Guide for Umbrella on VMWare and Hyper-V. Virtual Appliance Setup Guide for Umbrella Page 1

Virtual Appliances. Virtual Appliances: Setup Guide for Umbrella on VMWare and Hyper-V. Virtual Appliance Setup Guide for Umbrella Page 1 Virtual Appliances Virtual Appliances: Setup Guide for Umbrella on VMWare and Hyper-V Virtual Appliance Setup Guide for Umbrella Page 1 Table of Contents Overview... 3 Prerequisites... 4 Virtualized Server

More information

FmPro Migrator - FileMaker to SQL Server

FmPro Migrator - FileMaker to SQL Server FmPro Migrator - FileMaker to SQL Server FmPro Migrator - FileMaker to SQL Server 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13 1.14 1.15 FmPro Migrator - FileMaker to SQL Server Migration

More information