Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

228 Commits

Repository files navigation

🧮 Optimization Expert — Pyomo & OR-Tools Notebook Library

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.

StarsForksLicense: MITLinkedIn NewsletterTelegram


🚀 What Is This Repository?

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

📂 What's Inside

Each notebook includes:

  1. Problem Description — a clear, intuitive explanation of the challenge
  2. Mathematical Formulation — the model written out properly (sets, variables, constraints, objective)
  3. Python Implementation — clean code in Pyomo or OR-Tools CP-SAT
  4. Solution & Visualization — results displayed with charts, tables, and maps where relevant
  5. Analysis — interpretation of the solution and key insights

🗂️ Solved Problems

🚛 Routing & Logistics

ProblemNotebook
Capacitated VRP (CVRP)CVRP_CP.ipynb
CVRP with Time WindowsCVRPTW_CP.ipynb
Clustered CVRPCCVRP_CP.ipynb
TSP with AddCircuitAddCircuit_Advanced_CP.ipynb
Large-scale TSPLarge_TSP_CP.ipynb
TSP with Precedence Constraintsprecedence_AddCircuit_Advanced_CP.ipynb
VRP Wiring (no crossings)VRP_Circuit_CP_Wiring_nocross.ipynb
Boat Tour OptimizationBoatTour.ipynb
Optimal Order Pickup from Inventorystorage_routing.ipynb
Conquering All Metro StationsMetro map -V3-github.ipynb

📅 Scheduling

ProblemNotebook
Job Shop Scheduling (with idle time)JobShop_CP_ORTools_Idle_time.ipynb
RCPSP with Cumulative ConstraintsRCPSP_Cummulative_CP.ipynb
Airline Crew Scheduling (Two-Stage)Airliner-twostage.ipynb
Movie Shooting SequenceMovie_shooting.ipynb
Team Meeting SchedulingTeamMeeting.ipynb
Hospital Staff SchedulingHospital_CP.ipynb
Tourist Trip Scheduling (TTP)TTP_CP.ipynb
Project Scheduling (MOO)Project-Class-module-github-MOO.ipynb

🔗 Graph Theory & Networks

ProblemNotebook
Critical Node DetectionCND-github.ipynb
Graph Island DetectionGraph-Island.ipynb
Edge ColoringEdgecoloring.ipynb
Total ColoringTotalcoloring.ipynb
Routing & Wavelength AssignmentRoutin_Wavelength_Assignment_CP.ipynb
2D No-Overlap Placement2d_no_overlap.ipynb
Max Independent SetApril Fools day max independent set.ipynb

🧩 Puzzles & Combinatorics

ProblemNotebook
N-QueensN-Queen.ipynb
Magic SquareMagicSquare.ipynb
Knight's Tour (MILP)Knight tour MILP.ipynb
Hidato PuzzleHidato-git.ipynb
Hashi (Bridges) PuzzleHAshi puzzle-git.ipynb
Hitori PuzzleHitori_CP.ipynb
Bonairo PuzzleBonairo puzzle .ipynb
Shikaku PuzzleShikaku-puzzle-github.ipynb
Suguru PuzzleSuguru_CP.ipynb
NumberlinkNumberlink-V3-Git.ipynb
Slitherlinkslitherlink_puzzle.py
A Puzzle A DayA_Puzzle_A_Day_git.ipynb
LinkedIn Queens PuzzleLinkedin_CP_Puzzle.ipynb
LinkedIn Tango PuzzleTANGO_of_Linkedin_CP_Puzzle.ipynb
LinkedIn ZIP PuzzleZIP_LInkedin_CP.ipynb
ROGO PuzzleROGO_of_AddCircuit_Advanced_CP.ipynb
Master Mind Gamegame_Master_Mind_CP_Pyomo.ipynb
Social Golfer ProblemSocial golfer.ipynb
Secret Santa AssignmentSecret_Santa_Circuit_Advanced_CP.ipynb
15-Puzzle IBM Challenge15_Puzzle_IBM_Git.ipynb
Prime Sequence IBM ChallengePrime_IBM_sequence_March2024.ipynb
IBM Max Army ChallengeIBM_max_Army.ipynb

🏭 Supply Chain & Operations

ProblemNotebook
Cutting Stock Problem (CSP)CSP-git-V1.ipynb
Bilevel Optimizationbilevel-github-single-bilevel-multi-EX2.ipynb
Gerrymandering (District Design)Final_Gerrymandering_CP.ipynb
Farmer Resource AllocationFarmer_CP_V1.ipynb
Stable Marriage Problemstable_marriage_CP.ipynb
Student–Professor AssignmentStudenttoProf.ipynb
Christmas Gift Happiness MaximizationGift-Christmas.ipynb
Pairing OptimizationPairing CP.ipynb
7-Seen Modeling7seenPyomo.ipynb
Pyomo with NEOS ServerNEOS Pyomo.ipynb
Pyomo on Google ColabPyomo_on_Google_Colab.ipynb

📐 Geometry & Machine Learning

ProblemNotebook
Largest Box (CP)Largest_box_CP.ipynb
Biggest Circle with Equal Pointsblue-green-points-biggest_circle.ipynb
Max Distance Between PointsMaxDistance-Github-V2.ipynb
Shape Placement (CP)shape_placement.ipynb
SVM Primal & Dual (Classification)EXample_SVM_Primal_Dual_Classification_.ipynb
SVM with KernelClass_kernel_Dual_of_SVM_hard_constraint.ipynb
K-Means Clustering (Optimization)Clustering_Kmean_class.ipynb
Multi-Curve Regressionregression-multiline-V4.ipynb
Longest Common SubsequenceLCS-git.ipynb

⚡ Quick Start

Run Locally

# 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 notebook

Run on Google Colab ☁️

No 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:

👉 Pyomo_on_Google_Colab.ipynb


🛠️ Tech Stack

ToolPurpose
PyomoAlgebraic modeling language for LP, MILP, NLP, Bilevel
OR-Tools CP-SATConstraint programming for combinatorial problems
GurobiHigh-performance commercial solver (free academic license)
CBC / GLPKOpen-source solvers, zero setup required
NEOS ServerFree cloud-based solver access
Jupyter NotebooksInteractive, documented problem-solving environment

📡 Stay Connected

PlatformLink
📰 LinkedIn NewsletterOptimization in Open-Source
💬 Telegram Channelt.me/PyomoChannel
🎓 Udemy CourseOptimization in Python
👤 LinkedIn ProfileAlireza Soroudi

🤝 Contributing

Contributions are warmly welcome! To add a new notebook or improve an existing one:

  1. Fork the repository and create a new branch
  2. Write clean, well-documented code with problem description and formulation
  3. Test your notebook end-to-end
  4. Submit a pull request with a clear description of what you've added

Let's build the most comprehensive open-source optimization library together! 🌍


📖 How to Cite

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}
}

📄 License

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!

About

Pyomo respository provides a comprehensive library of solved models in Supply chain management

Topics

Resources

Code of conduct

Stars

305 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages