Gurobi modeling examples is a notebook gallery, sorted by skill level
Gurobi modeling examples
At a glance
- What is it?
- The modeling-examples repository distributes Jupyter Notebooks that build optimization models with the Gurobi Python API, grouped into introductory, beginner and intermediate tiers, and it is a teaching collection rather than a library you install.
- Who is it for?
- modeling-examples suits a data scientist or engineer who knows Python and quantitative methods and wants worked notebooks that show how a model is assembled, and it suits a team preparing internal training because the examples already span many domains and difficulty levels.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 38 days ago.
- What is it written in?
- Mainly Jupyter Notebook, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 22, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Three tiers, and the tier tells you how much modelling you already know
The collection is organised by audience, not by industry, and the tier a notebook sits in tells you what background it assumes. The introductory tier walks through the process of building a model and assumes you know Python plus a discipline that uses quantitative methods. The beginner tier assumes you know Python and have some knowledge of building optimization models. The intermediate tier assumes you know Python, are familiar with the Gurobi Python API, and have background in mathematical optimization modelling. That structure is the most useful thing in the repository, because it lets a reader pick a notebook that matches what they already know instead of wading through a wall of examples. A separate set of tutorial entries sits alongside the tiers, including one on the Gurobi Python API itself, one on mathematical optimization modelling built around a simple assignment problem, and a set of longer walkthroughs that discuss input data and the model step by step.
The notebooks demonstrate the API, not just the mathematics
The stated purpose is twofold: to illustrate the broad applicability of mathematical optimization, and to show how to build mathematical optimization models. The mechanics are consistent throughout. The examples add decision variables, build linear expressions, add constraints, and add an objective function, and the advanced material reaches into generalized constraints, piecewise-linear functions and multi-objective hierarchical optimization. The constraint vocabulary is shared across domains, with allocation constraints, balance constraints, sequencing constraints and precedence constraints called out as the recurring building blocks. That is the pedagogical claim worth taking seriously: a covering model for cell towers and a warehouse network design share a structure once you name the constraint types, and the notebooks demonstrate it rather than asserting it. A reader who learns to spot an allocation constraint in one notebook has something to carry into the next one.
The same problem class shows up in very different disguises
The spread of domains is wide, and it is the reason the collection holds together better than a set of tutorials on one problem. There is a food program example built on real data from the UN World Food Program, a supply network design example in two parts where the second part decides which depots to open or close, a cell tower covering example that configures a network to reach the largest number of people, a facility location example about how many and which warehouses supply a group of supermarkets, and a marketing campaign example from banking and financial services that chooses which products to offer individual customers to maximise expected profit. There are also examples on offshore wind cabling, mining, railway dispatching, drone networks, manpower planning, portfolio selection and index tracking. The point of that range is not variety for its own sake. It is that the same modelling techniques appear under different business names, which is exactly the recognition skill a modeller needs.
Getting the notebooks running is the part the repository does not spell out
Here the collection is thin, and a reader should know it before planning around these notebooks. The examples are coded using the Gurobi Python API and distributed as Jupyter Notebooks, so you need Python, a Jupyter environment and access to the Gurobi optimizer to execute them. The repository does not provide a set of installation commands, a pinned dependency file for a working environment, or instructions for obtaining a Gurobi license, so the practical setup work is on you. The only related file in the repository root is a requirements_test.txt, which suggests a test dependency set rather than a documented install path for learners. The rendered version of the collection lives on the project site at gurobi.github.io/modeling-examples, and each example directory is published as its own page. Read a notebook before running it, because the value is in the modelling walkthrough, not in the cells producing output.
Which model to imitate depends on the model class you face
The collection covers several distinct model classes, and picking the closest analogue to your own problem is a better use of it than copying any single notebook. The linear regression example is a mixed-integer quadratic programming model with feature selection, and the agricultural pricing example is a quadratic optimization problem solved with the Gurobi Optimizer. The market sharing example is a goal programming problem that allocates retailers to two divisions and trades off several goals rather than optimising one. The cell tower example is a covering problem, the supply network design example is a minimum cost flow problem over factories, depots and customers, and the 3D Tic-Tac-Toe example shows a binary programming model capturing simple logical constraints. That is a real difference in approach rather than a change of dataset: a covering model and a flow model share the API and almost nothing else about how you write them.
Why a notebook gallery is the wrong shape for a production model
The limitation is structural. A notebook is a linear narrative, and a production optimization model is not. You need your data access separated from the model, the model in a testable module, an interface for triggering a solve, and a way to handle a model that does not solve. The notebooks here do none of that, and they are not meant to. The repository ships a large set of directories, one per example, with assets and a Jekyll-style site configuration rather than a packaged distribution, so there is no importable module to depend on and no versioned API to code against. The other limit is the solver itself. These models are written against the Gurobi Python API, so the examples teach Gurobi idioms, and a team that later runs the same formulation on a different solver faces a translation problem the notebooks do not address. Treat them as a training ground for formulation thinking, and write the production model from scratch with your own structure.
An Apache licensed corpus with commits but no releases
The repository is published under the Apache 2.0 licence, with LICENSE.txt in the root, which is the permissive licence most often expected for a code corpus that people will copy from, and it carries an explicit patent grant. That matters more here than for an ordinary library, because the intent of the collection is that you will reuse patterns from it. On the maintenance side, the picture is a little unusual. The last push was on 2026-09-15, so the notebooks are being touched, and the project site is generated from the same source. There are no GitHub releases, so there is no tag to pin and no changelog to consult for what changed in a given revision. If you copy a formulation, record the commit you copied it from, because nothing in the repository's release history will tell you later. The topic tags and the LICENSE file together also make clear that this is published by Gurobi itself, which shapes what kind of updates the collection is likely to receive.
Editorial conclusion
modeling-examples suits a data scientist or engineer who knows Python and quantitative methods and wants worked notebooks that show how a model is assembled, and it suits a team preparing internal training because the examples already span many domains and difficulty levels. It is the wrong tool for a production deployment, because the repository is a gallery of teaching notebooks rather than a packaged library with a stable API, and it is the wrong tool for anyone without access to the Gurobi optimizer, since the notebooks are written against the Gurobi Python API. Before using one as a starting point, read the notebook end to end rather than copying the model body, check which solver the model needs against the features it uses, and confirm you have a Gurobi license, since the repository does not document how to obtain one. The last push was on 2026-09-15, and the project has no GitHub releases.
Frequently asked questions
What is the Gurobi modeling-examples repository?
It is a collection of Jupyter Notebooks that teach mathematical optimization modelling with the Gurobi Python API. The examples are grouped into introductory, beginner and intermediate levels depending on the modelling background assumed.
How do I run the notebooks in Gurobi modeling-examples?
The notebooks are written in Python against the Gurobi Python API and are distributed as Jupyter Notebooks, so you need Python, a Jupyter environment and access to the Gurobi optimizer. The repository does not document installation commands or how to obtain a Gurobi license.
Which kinds of optimization problems do the examples cover?
The notebooks cover facility location, supply network design, cell tower covering, food supply chain, marketing campaign selection, offshore wind cabling, quadratic pricing and market sharing by goal programming. The descriptions also list allocation, balance, sequencing and precedence constraints as the recurring constraint types.
What licence is the Gurobi modeling examples code under?
The repository is published under the Apache 2.0 licence, with the terms in a LICENSE.txt file at the repository root.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/gurobi-modeling-examples)Was this useful?