Skip to content

Instantly share code, notes, and snippets.

@brianhuey
brianhuey / sports_scheduling.py
Last active July 24, 2022 11:03
My Python implementation of a sports scheduling example using Google's Operations Research tool. This may be useful to you if you are trying to work through the google-or documentation since it is written for C# and there are a number of differences. The original code: https://github.com/google/or-tools/blob/master/examples/cpp/sports_scheduling.cc
from ortools.constraint_solver import pywrapcp
# Python Implementation of
# https://github.com/google/or-tools/blob/master/examples/cpp/sports_scheduling.cc
# By Brian Huey
# Sports scheduling problem.
#
# We want to solve the problem of scheduling of team matches in a
# double round robin tournament. Given a number of teams, we want
# each team to encounter all other teams, twice, once at home, and
# once away. Furthermore, you cannot meet the same team twice in the