Gurobi Modeling Examples

repository·master·Indexed 21 days ago

https://github.com/gurobi/modeling-examples

A repository of Jupyter Notebooks demonstrating how to solve various mathematical optimization problems using the Gurobi Python API (gurobipy). Examples cover a range of difficulty levels and problem types, including Linear Programming (LP), Mixed Integer Programming (MIP), Quadratic optimization, and Delayed Column Generation. Featured models include 3D Tic-Tac-Toe, agricultural pricing, airline planning, battery scheduling, car rental optimization, and cell tower coverage.

Tokens
49.4K
Snippets
181
Records
236
Agent score
74%

What's inside gurobi-modeling-examples

  1. Overview of Opti 202 Day 1 Modeling Problems

    master

    The Day 1 exercises cover two primary modeling domains:

    1. Production and Distribution Optimization: A linear programming problem involving demand data (from a hypothetical ML model), transportation costs, and production capacity. The goal is to determine the optimal production and shipment of widgets from facilities to distribution locations to minimize total cost.
    2. Nonlinear Regression: A deep dive into modeling envyme kinetics using nonlinear regression techniques.
  2. Overview of Gurobi Modeling Examples

    master

    The gurobi/modeling-examples repository provides a collection of Jupyter Notebooks designed to illustrate the application of mathematical optimization using the Gurobi Python API (gurobipy).

    Key Capabilities Demonstrated

    • Model Building: Adding decision variables, building linear expressions, adding constraints, and defining objective functions.
    • Advanced Features: Generalized constraints, piecewise-linear functions, and multi-objective hierarchical optimization.
    • Constraint Patterns: Allocation constraints, balance constraints, sequencing constraints, and precedence constraints.

    Target Audience

    • Data scientists, engineers, computer scientists, and economists.
    • Professionals with a background in mathematical modeling and basic Python knowledge.
  3. Overview of Modeling Session 2 Topics

    master

    The exercises in this session focus on expanding classic modeling problems (like the widget problem) by incorporating more complex mathematical structures and practical considerations:

    • Piecewise linear modeling: Modeling functions that are not strictly linear.
    • Nonlinear components: Incorporating nonlinear terms into the model.
    • Uncertainty handling: Practical methods for dealing with uncertain parameters.
    • Portfolio optimization: Solving problems that maximize the worst-case outcome among multiple potential scenarios.
  4. Overview of the 3D Tic-Tac-Toe modeling example

    master

    The 3D Tic-Tac-Toe example demonstrates how to use Mixed Integer Programming (MIP) to capture simple logical constraints. The objective is to arrange X's and 0's on a three-dimensional Tic-Tac-Toe board to minimize the number of completed lines or diagonals.

    This model is based on Example 17 from the book Model Building in Mathematical Programming (5th edition) by H. Paul Williams (pages 272 and 327-328). It is categorized as a beginning level example and assumes familiarity with Python and the Gurobi Python API.

  5. Overview of the Emergency Supply Prepositioning Strategy (ESUPS) Case Study

    master

    The ESUPS case study demonstrates a scenario-based transportation linear programming model with a probabilistic objective. The model is designed to optimize the allocation of emergency resources to minimize expected costs while reducing gaps and overlaps in emergency preparedness.

    Key decision variables include:

    • The quantity of each supply type to store at specific locations.
    • The response strategy for disaster events to ensure minimal cost.
  6. Understand the Decentralization Planning model

    master

    The Decentralization Planning model is an advanced-level example of a facility location problem formulated as a quadratic assignment problem.

    Goal: Given a set of company departments and potential cities, the model determines the optimal location for each department to maximize gross margins.

    Technical Details:

    • Formulation: Quadratic Assignment Problem.
    • API: Gurobi Python API.
    • Solver: Gurobi Optimizer.
    • Source: This is example 10 from Model Building in Mathematical Programming (5th edition) by H. Paul Williams (pages 265, 317-319).

    Prerequisites:

    • Proficiency in Python.
    • Familiarity with the Gurobi Python API.
    • Advanced knowledge of mathematical optimization modeling.
  7. Understand the Farm Planning multi-period production model

    master

    The Farm Planning example demonstrates how to model a multi-period production planning problem. Specifically, it optimizes farm operations over a 5-year horizon.

    This is an advanced-level example. To use it effectively, you should have:

    1. Proficiency in Python.
    2. Experience with the Gurobi Python API.
    3. Advanced knowledge of constructing mathematical optimization models.

    The model's objective function and constraints are designed to be complex, often utilizing advanced features of the Gurobi Python API.

  8. Understand the Yield Management modeling example

    master

    This example demonstrates a Yield Management problem, which is a variable pricing strategy used to maximize revenue or profits from a fixed, time-limited resource (e.g., airline seats) by anticipating consumer behavior.

    Key technical details:

    • Problem Type: Three-period stochastic programming problem.
    • Complexity Level: Advanced. It assumes proficiency in Python, the Gurobi Python API, and advanced mathematical optimization modeling.
    • Implementation: Formulated using the Gurobi Python API and solved with the Gurobi Optimizer.
    • Source Reference: This is example 24 from the fifth edition of Model Building in Mathematical Programming by H. Paul Williams (pages 282-284 and 337-340).
  9. Understand the Refinery production planning model

    master

    The Refinery model is an intermediate-level modeling example representing a production planning problem. It focuses on decision-making regarding resource allocation: determining which resources to use to produce specific products.

    This model is based on example #6 from the fifth edition of Modeling Building in Mathematical Programming by H. P. Williams (pages 258 and 306-310).

    Prerequisites:

    • Proficiency in Python.
    • Familiarity with the Gurobi Python API.
    • Knowledge of building mathematical optimization models.
  10. Browse the index of modeling examples

    master

    The modeling-examples repository contains a wide variety of optimization models categorized by difficulty and business domain. You can explore examples ranging from introductory tutorials to advanced mathematical optimization problems.

    Key categories include:

    • Introductory/Tutorials: intro_to_gurobipy, milp_tutorial, optimization101.
    • Beginner/Intermediate/Advanced: Structured by complexity level.
    • Business Needs: Specialized domains such as aviation_planning, battery_scheduling, supply_network_design, and portfolio_selection_optimization.