explaingit

google/or-tools

13,476C++Audience · developerComplexity · 4/5LicenseSetup · moderate

TLDR

OR-Tools is Google's free open-source toolkit for solving hard scheduling, routing, and assignment problems by finding the best possible arrangement from millions of options. Available in Python, Java, C#, and C++.

Mindmap

mindmap
  root((repo))
    What it does
      Optimization solver
      Scheduling problems
      Routing problems
    Solver Types
      Constraint programming
      Linear programming
      Traveling salesman
      Bin packing
    Languages
      Python
      Java
      C#
      C++
    Audience
      Developers
      Researchers
      Operations teams
    Resources
      Developer guide
      Jupyter tutorials
      Code examples
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Solve a nurse or employee scheduling problem where shifts must be assigned fairly while respecting availability constraints.

USE CASE 2

Optimize delivery vehicle routes across dozens of locations to minimize total driving distance.

USE CASE 3

Solve a bin-packing problem to fit products into the fewest possible shipping containers.

USE CASE 4

Find the shortest path through a large logistics network using the built-in graph algorithms.

Tech stack

C++PythonJavaC#

Getting it running

Difficulty · moderate Time to first run · 30min

Requires understanding the problem domain, the math can be complex even though the API is straightforward.

Apache 2.0: use freely for any purpose, including commercial products, as long as you include the license and copyright notice.

In plain English

OR-Tools is a free, open-source toolkit from Google for solving a specific class of math problems called combinatorial optimization. These are problems where you need to find the best possible arrangement or assignment from a large number of possibilities, such as scheduling shifts for a workforce, routing delivery vehicles across a city, or packing items into containers as efficiently as possible. The toolkit includes several specialized solvers, each designed for a different type of problem. There are constraint programming solvers that figure out what combinations satisfy a set of rules, linear programming solvers that optimize a goal while respecting numerical limits, and algorithms specifically built for classic problems like the Traveling Salesman Problem (finding the shortest route that visits many locations) and bin packing (fitting items into the fewest possible containers). It also covers graph problems like finding the shortest path between two points in a network. The core code is written in C++, which makes it fast, but the library can be used from Python, Java, and C# as well. This means developers on most popular platforms can plug it into their projects without rewriting anything. Installation packages are available through standard channels for each language. The project is well documented, with an official developer guide, worked examples in multiple languages, and Jupyter notebook tutorials. The examples directory covers C++, Java, Python, and .NET, so there are starting points for most teams regardless of their preferred language. This is a mature, production-grade tool used inside Google and published for general use under the Apache 2.0 open-source license.

Copy-paste prompts

Prompt 1
I need to schedule 10 employees across 5 shifts per day for a week, with each employee working at most 5 days and no back-to-back closing and opening shifts. Write an OR-Tools constraint programming solution in Python.
Prompt 2
I have 20 delivery stops and one vehicle. Use OR-Tools to find the shortest route that visits all stops and returns to the start.
Prompt 3
Explain how the OR-Tools CP-SAT solver works in plain English, then show me a minimal Python example that solves a simple assignment problem.
Prompt 4
I installed OR-Tools in Python but get an import error. Walk me through verifying my install and running the first example from the documentation.
Open on GitHub → Explain another repo

← google on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.