Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Example Tour

This document provides a quick guided tour of the Gurobi examples; we will try to highlight some of the most important features of these examples. Full source code is provided in this document, so you are free to explore the examples in full detail.

Wherever possible, we try to discuss the examples in a manner that is independent of programming languages. We will refer to each example using a brief, language independent name. You will need to map this name to the specific source file name for your language. For example, the `facility` example corresponds to six different implementations, one in C (facility_c.c), one in C++ (facility_c++.cpp), one in Java (Facility.java), one in C# (facility_cs.cs), one in Visual Basic (facility_vb.vb), and one in Python (facility.py). If you would like to look at the language implementation for a particular example, please refer to the appropriate example source file.

## Topics covered in the examples

The easiest place to start your introduction to the Gurobi examples is probably with the examples that load and solve a model from a file. These demonstrate the most basic capabilities of the Gurobi libraries. They also demonstrate the use of model attributes, which are an important concept in the Gurobi Optimizer.

Once you are comfortable with these examples, you should move on to the examples that build a model from scratch. These show you how to create variables and constraints, and add them to an optimization model.

The next topic covered in this document is model modification. The Gurobi distribution includes examples that add and remove constraints, add variables, and change variable types, bounds and objective coefficients. You modify a model in much the same way that you build a model from scratch, but there are some important differences involving the use of the solution information.

Next, this document covers parameter changes. The `params` example shows you how to change parameters, and in particular how to use different parameter settings for different models.

The infeasibility section considers a few examples that cope with model infeasibility. Some use an Irreducible Inconsistent Subsystem (IIS) to handle the infeasibility, while others relax constraints.

One useful MIP feature that is worth understanding is MIP starts. A MIP start allows you to specify a known feasible solution to the MIP solver. The solution provides a bound on the objective of the best possible solution, which can help to limit the MIP search. The solution also provides a potential start point for the local search heuristics that are utilized by the Gurobi MIP solver.

It is possible to achieve model-data separation when using our Python interface, as is often done in modeling languages, but you need to make use of Python modules to do so. The model-data separation section provides an example of how this is done. It considers three versions of the diet example. All three use the same function to formulate and solve the actual optimization model, but they obtain model data from very different places.

The final topic we cover in this document is Gurobi callbacks. Callbacks allow the user to obtain periodic progress information related to the optimization.

- A list of the Gurobi examples
- Load and solve a model from a file
- Build a model
- Additional modeling elements
- Modify a model
- Change parameters
- Diagnose and cope with infeasibility
- MIP starts
- Model-data separation in Python
- Callbacks

Help and Feedback

Press `/` or click to search this documentation | Gurobi website | Gurobi community forum
Go to other Gurobi documentation | Gurobi download | Contact support