Try our new documentation site (beta).
Gurobi Optimizer Example Tour
Version 6.5, Copyright © 2016, Gurobi Optimization, Inc.
The GurobiTM distribution includes an extensive set of examples that illustrate commonly used features of the Gurobi libraries. Most examples have versions for C, C++, C#, Java, Visual Basic, and Python. A few, however, illustrate features that are specific to the Python interface.
The distribution also includes examples for our MATLAB® and R interfaces. Note, however, that our interfaces to these languages are built around the assumption that you will use the rich matrix-oriented capabilities of the underlying languages to build your optimization models. Thus, our examples for these languages don't attempt to show you how to build models. We have instead chosen to provide a few simple examples that demonstrate how to pass matrices into our interface.
This document provides a brief tour of these examples. We won't go
through each example in detail. Instead, we'll start with an
Overview of the set of tasks that you
are likely to want to perform with the Gurobi Optimizer. Later
sections will then describe how specific examples accomplish each of
these tasks. Alternatively, we provide a Structured
List of all of our examples, which you
can use to dive directly into an example of interest to you. In
either case, we suggest that you browse the example source code (in a
text editor, or in another browser window) while reading this
document. This document includes Source
Code for all of the examples, in all available
languages. Source files are also available in the examples
directory of the Gurobi distribution.
If you would like further details on any of the Gurobi routines used in these examples, please consult the Gurobi Reference Manual.
- Example tour
- A list of the Gurobi examples
- Load and solve a model from a file
- Build a model
- Modify a model
- Change parameters
- Automated Parameter Tuning
- Diagnose and cope with infeasibility
- MIP starts
- Model-data separation in Python
- Callbacks
- Example Source Code
- C Examples
- C++ Examples
- callback_c++.cpp
- dense_c++.cpp
- diet_c++.cpp
- facility_c++.cpp
- feasopt_c++.cpp
- fixanddive_c++.cpp
- lp_c++.cpp
- lpmethod_c++.cpp
- lpmod_c++.cpp
- mip1_c++.cpp
- mip2_c++.cpp
- params_c++.cpp
- piecewise_c++.cpp
- sensitivity_c++.cpp
- qcp_c++.cpp
- qp_c++.cpp
- sos_c++.cpp
- sudoku_c++.cpp
- tsp_c++.cpp
- tune_c++.cpp
- workforce1_c++.cpp
- workforce2_c++.cpp
- workforce3_c++.cpp
- workforce4_c++.cpp
- Java Examples
- C# Examples
- callback_cs.cs
- dense_cs.cs
- diet_cs.cs
- facility_cs.cs
- feasopt_cs.cs
- fixanddive_cs.cs
- lp_cs.cs
- lpmethod_cs.cs
- lpmod_cs.cs
- mip1_cs.cs
- mip2_cs.cs
- params_cs.cs
- piecewise_cs.cs
- qcp_cs.cs
- qp_cs.cs
- sensitivity_cs.cs
- sos_cs.cs
- sudoku_cs.cs
- tsp_cs.cs
- tune_cs.cs
- workforce1_cs.cs
- workforce2_cs.cs
- workforce3_cs.cs
- workforce4_cs.cs
- Visual Basic Examples
- callback_vb.vb
- dense_vb.vb
- diet_vb.vb
- facility_vb.vb
- feasopt_vb.vb
- fixanddive_vb.vb
- lp_vb.vb
- lpmethod_vb.vb
- lpmod_vb.vb
- mip1_vb.vb
- mip2_vb.vb
- params_vb.vb
- piecewise_vb.vb
- qcp_vb.vb
- qp_vb.vb
- sensitivity_vb.vb
- sos_vb.vb
- sudoku_vb.vb
- tsp_vb.vb
- tune_vb.vb
- workforce1_vb.vb
- workforce2_vb.vb
- workforce3_vb.vb
- workforce4_vb.vb
- Python Examples
- callback.py
- custom.py
- dense.py
- diet.py
- diet2.py
- diet3.py
- diet4.py
- dietmodel.py
- facility.py
- feasopt.py
- fixanddive.py
- lp.py
- lpmethod.py
- lpmod.py
- mip1.py
- mip2.py
- netflow.py
- params.py
- piecewise.py
- qcp.py
- qp.py
- sensitivity.py
- sos.py
- sudoku.py
- tsp.py
- tune.py
- workforce1.py
- workforce2.py
- workforce3.py
- workforce4.py
- MATLAB Examples
- R Examples