## Modeling Examples

We know many people like to start out by looking for examples of models that, even though not exact to their situation, give them a starting point that they can work from to build their own model.

One of the best books we have come across to help people think about how to model is the fifth edition of Model Building in Mathematical Programming, by H.Paul Williams.

However, the book does not actually show you the code required to build the example models. As a result, we have created implementations in Python using Gurobi for many of the examples. Our goal is to have you use the H.Paul Williams book to learn more about how to think about modeling, and especially models addressing your particular needs, and then use the resources on these pages to better understand how to implement those models in Python using Gurobi.

As a result, while not including the overview information in the H.Paul Williams book, each of the examples we’ve listed below includes:

- Problem description
- Model formulation
- Python implementation
- Gurobi output and analysis

#### Request a Gurobi Evaluation License or Free Academic License

Modeling examples are coded using the Gurobi Python API in Jupyter Notebook. In order to use the Jupyter Notebooks, you must have a Gurobi License. If you do not have a license, you can request an Evaluation License as a Commercial User or download a free license as an Academic User.

Commercial Users: Free Evaluation Version Academic Users: Free Academic Version

## Contents

### Food Manufacturing I

This model is an example of a blending problem. In blending optimization problems, multiple raw materials are combined in a way the meets the stated constraints for the lowest cost.

This modeling example is at the intermediate level, where we assume that you know Python and are familiar with the Gurobi Python API. In addition, you should have some knowledge about building mathematical optimization models.

#### Access the Jupyter Notebook Modeling Example

Click on the button below to be directed to the GitHub HTML page, where you can download the repository for the Food Manufacture I Jupyter Notebook modeling example.

Food Manufacture I Problem

### Food Manufacturing II

This model extends the Food Manufacture I example above to include new constraints that change the problem from a fairly easy to solve linear programming model to a mixed-integer model that is harder to solve.

This modeling example is at the advanced level, where we assume that you know Python and the Gurobi Python API and that you have advanced knowledge of building mathematical optimization models. Typically, the objective function and/or constraints of these examples are complex or required advanced features of the Gurobi Python API.

#### Access the Jupyter Notebook Modeling Example

Click on the button below to be directed to the GitHub HTML page, where you can download the repository for the Food Manufacture II Jupyter Notebook modeling example.

Food Manufacture II Problem

### Factory Planning I

This model is an example of a production planning problem. In such problems, the goal is to create an optimal production plan to maximize profit.

This modeling example is at the intermediate level, where we assume that you know Python and are familiar with the Gurobi Python API. In addition, you should have some knowledge about building mathematical optimization models.

#### Access the Jupyter Notebook Modeling Example

Click on the button below to be directed to the GitHub HTML page, where you can download the repository for the Factory Planning I Jupyter Notebook modeling example.

Factory Planning I

### Factory Planning II

This model extends the Factory Planning I example above to add complexity whereby the month where each machine is down will, instead of being fixed, be determined as a part of the optimized plan.

This modeling example is at the intermediate level, where we assume that you know Python and are familiar with the Gurobi Python API. In addition, you should have some knowledge about building mathematical optimization models.

#### Access the Jupyter Notebook Modeling Example

Click on the button below to be directed to the GitHub HTML page, where you can download the repository for the Factory Planning I Jupyter Notebook modeling example.

Factory Planning II

### Farm Planning

This model is an example of a multi-period production planning problem. In this case, the application is to optimize the operation of a farm over 5 years.

This modeling example is at the advanced level, where we assume that you know Python and the Gurobi Python API and that you have advanced knowledge of building mathematical optimization models. Typically, the objective function and/or constraints of these examples are complex or required advanced features of the Gurobi Python API.

#### Access the Jupyter Notebook Modeling Example

Click on the button below to be directed to the GitHub HTML page, where you can download the repository for the Farm Planning Jupyter Notebook modeling example.

Farm Planning

### Manpower Planning

This model is an example of a staffing problem. In staffing planning problems, choices must be made regarding recruitment, training, redundancy (retention), and scheduling of staff.

This modeling example is at the advanced level, where we assume that you know Python and the Gurobi Python API and that you have advanced knowledge of building mathematical optimization models. Typically, the objective function and/or constraints of these examples are complex or required advanced features of the Gurobi Python API.

#### Access the Jupyter Notebook Modeling Example

Click on the button below to be directed to the GitHub HTML page, where you can download the repository for the Manpower Planning Jupyter Notebook modeling example.

Manpower Planning

### Mining

This model is an example of a production problem. In production planning problems, choices must be made regarding the what resources to use to produce what products.

This modeling example is at the intermediate level, where we assume that you know Python and are familiar with the Gurobi Python API. In addition, you should have some knowledge about building mathematical optimization models.

#### Access the Jupyter Notebook Modeling Example

Click on the button below to be directed to the GitHub HTML page, where you can download the repository for the Mining Jupyter Notebook modeling example.

Mining

### Refinery

This model is an example of a production problem. In production planning problems, choices must be made regarding the what resources to use to produce what products.

This modeling example is at the intermediate level, where we assume that you know Python and are familiar with the Gurobi Python API. In addition, you should have some knowledge about building mathematical optimization models.

#### Access the Jupyter Notebook Modeling Example

Click on the button below to be directed to the GitHub HTML page, where you can download the repository for the Refinery Jupyter Notebook modeling example.

Refinery