A hands-on, open-source collection of solved optimization problems using Pyomo, OR-Tools (CP-SAT), and MILP — from supply chain to puzzles, routing to scheduling.
This repository is a living library of optimization models — each one a fully solved, self-contained Jupyter notebook. Problems range from real-world supply chain challenges to classic combinatorial puzzles, all tackled using the power of mathematical programming.
Whether you're a student stepping into Operations Research, a practitioner solving real business problems, or a puzzle enthusiast who thinks in constraints — there's something here for you.
Tools used across the notebooks:
- 🐍 Pyomo — algebraic modeling in Python
- ⚙️ Google OR-Tools CP-SAT — constraint programming solver
- 🔢 Solvers: Gurobi, CBC, GLPK, NEOS Server
Each notebook includes:
- Problem Description — a clear, intuitive explanation of the challenge
- Mathematical Formulation — the model written out properly (sets, variables, constraints, objective)
- Python Implementation — clean code in Pyomo or OR-Tools CP-SAT
- Solution & Visualization — results displayed with charts, tables, and maps where relevant
- Analysis — interpretation of the solution and key insights
| Problem | Notebook |
|---|---|
| Capacitated VRP (CVRP) | CVRP_CP.ipynb |
| CVRP with Time Windows | CVRPTW_CP.ipynb |
| Clustered CVRP | CCVRP_CP.ipynb |
| TSP with AddCircuit | AddCircuit_Advanced_CP.ipynb |
| Large-scale TSP | Large_TSP_CP.ipynb |
| TSP with Precedence Constraints | precedence_AddCircuit_Advanced_CP.ipynb |
| VRP Wiring (no crossings) | VRP_Circuit_CP_Wiring_nocross.ipynb |
| Boat Tour Optimization | BoatTour.ipynb |
| Optimal Order Pickup from Inventory | storage_routing.ipynb |
| Conquering All Metro Stations | Metro map -V3-github.ipynb |
| Problem | Notebook |
|---|---|
| Job Shop Scheduling (with idle time) | JobShop_CP_ORTools_Idle_time.ipynb |
| RCPSP with Cumulative Constraints | RCPSP_Cummulative_CP.ipynb |
| Airline Crew Scheduling (Two-Stage) | Airliner-twostage.ipynb |
| Movie Shooting Sequence | Movie_shooting.ipynb |
| Team Meeting Scheduling | TeamMeeting.ipynb |
| Hospital Staff Scheduling | Hospital_CP.ipynb |
| Tourist Trip Scheduling (TTP) | TTP_CP.ipynb |
| Project Scheduling (MOO) | Project-Class-module-github-MOO.ipynb |
| Problem | Notebook |
|---|---|
| Critical Node Detection | CND-github.ipynb |
| Graph Island Detection | Graph-Island.ipynb |
| Edge Coloring | Edgecoloring.ipynb |
| Total Coloring | Totalcoloring.ipynb |
| Routing & Wavelength Assignment | Routin_Wavelength_Assignment_CP.ipynb |
| 2D No-Overlap Placement | 2d_no_overlap.ipynb |
| Max Independent Set | April Fools day max independent set.ipynb |
| Problem | Notebook |
|---|---|
| N-Queens | N-Queen.ipynb |
| Magic Square | MagicSquare.ipynb |
| Knight's Tour (MILP) | Knight tour MILP.ipynb |
| Hidato Puzzle | Hidato-git.ipynb |
| Hashi (Bridges) Puzzle | HAshi puzzle-git.ipynb |
| Hitori Puzzle | Hitori_CP.ipynb |
| Bonairo Puzzle | Bonairo puzzle .ipynb |
| Shikaku Puzzle | Shikaku-puzzle-github.ipynb |
| Suguru Puzzle | Suguru_CP.ipynb |
| Numberlink | Numberlink-V3-Git.ipynb |
| Slitherlink | slitherlink_puzzle.py |
| A Puzzle A Day | A_Puzzle_A_Day_git.ipynb |
| LinkedIn Queens Puzzle | Linkedin_CP_Puzzle.ipynb |
| LinkedIn Tango Puzzle | TANGO_of_Linkedin_CP_Puzzle.ipynb |
| LinkedIn ZIP Puzzle | ZIP_LInkedin_CP.ipynb |
| ROGO Puzzle | ROGO_of_AddCircuit_Advanced_CP.ipynb |
| Master Mind Game | game_Master_Mind_CP_Pyomo.ipynb |
| Social Golfer Problem | Social golfer.ipynb |
| Secret Santa Assignment | Secret_Santa_Circuit_Advanced_CP.ipynb |
| 15-Puzzle IBM Challenge | 15_Puzzle_IBM_Git.ipynb |
| Prime Sequence IBM Challenge | Prime_IBM_sequence_March2024.ipynb |
| IBM Max Army Challenge | IBM_max_Army.ipynb |
| Problem | Notebook |
|---|---|
| Cutting Stock Problem (CSP) | CSP-git-V1.ipynb |
| Bilevel Optimization | bilevel-github-single-bilevel-multi-EX2.ipynb |
| Gerrymandering (District Design) | Final_Gerrymandering_CP.ipynb |
| Farmer Resource Allocation | Farmer_CP_V1.ipynb |
| Stable Marriage Problem | stable_marriage_CP.ipynb |
| Student–Professor Assignment | StudenttoProf.ipynb |
| Christmas Gift Happiness Maximization | Gift-Christmas.ipynb |
| Pairing Optimization | Pairing CP.ipynb |
| 7-Seen Modeling | 7seenPyomo.ipynb |
| Pyomo with NEOS Server | NEOS Pyomo.ipynb |
| Pyomo on Google Colab | Pyomo_on_Google_Colab.ipynb |
| Problem | Notebook |
|---|---|
| Largest Box (CP) | Largest_box_CP.ipynb |
| Biggest Circle with Equal Points | blue-green-points-biggest_circle.ipynb |
| Max Distance Between Points | MaxDistance-Github-V2.ipynb |
| Shape Placement (CP) | shape_placement.ipynb |
| SVM Primal & Dual (Classification) | EXample_SVM_Primal_Dual_Classification_.ipynb |
| SVM with Kernel | Class_kernel_Dual_of_SVM_hard_constraint.ipynb |
| K-Means Clustering (Optimization) | Clustering_Kmean_class.ipynb |
| Multi-Curve Regression | regression-multiline-V4.ipynb |
| Longest Common Subsequence | LCS-git.ipynb |
# Clone the repository
git clone https://github.com/OptimizationExpert/Pyomo.git
cd Pyomo
# Install dependencies
pip install pyomo ortools matplotlib pandas numpy
# Install a free solver (CBC)
conda install -c conda-forge coincbc
# Launch Jupyter
jupyter notebookNo local setup needed — open any notebook directly in Colab using the badge at the top of each notebook, or start with the dedicated Colab setup notebook:
| Tool | Purpose |
|---|---|
| Pyomo | Algebraic modeling language for LP, MILP, NLP, Bilevel |
| OR-Tools CP-SAT | Constraint programming for combinatorial problems |
| Gurobi | High-performance commercial solver (free academic license) |
| CBC / GLPK | Open-source solvers, zero setup required |
| NEOS Server | Free cloud-based solver access |
| Jupyter Notebooks | Interactive, documented problem-solving environment |
| Platform | Link |
|---|---|
| 📰 LinkedIn Newsletter | Optimization in Open-Source |
| 💬 Telegram Channel | t.me/PyomoChannel |
| 🎓 Udemy Course | Optimization in Python |
| 👤 LinkedIn Profile | Alireza Soroudi |
Contributions are warmly welcome! To add a new notebook or improve an existing one:
- Fork the repository and create a new branch
- Write clean, well-documented code with problem description and formulation
- Test your notebook end-to-end
- Submit a pull request with a clear description of what you've added
Let's build the most comprehensive open-source optimization library together! 🌍
If this repository has been useful in your research or work, please cite it:
@misc{soroudi2024pyomo,
author = {Alireza Soroudi},
title = {Optimization Expert — Pyomo \& OR-Tools Notebook Library},
year = {2024},
publisher = {GitHub},
url = {https://github.com/OptimizationExpert/Pyomo}
}This project is licensed under the MIT License — use it, fork it, build on it freely.
If this repo helped you solve a hard problem or learn something new — consider giving it a ⭐ star. It helps others find it too!