Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ end
@time if _PDF || _IS_GITHUB_ACTIONS
# Copy the src into a new directory for the latex build
cp(joinpath(@__DIR__, "src"), joinpath(@__DIR__, "latex_src"); force = true)
f_latex = Distributed.@spawnat :any make_latex()
f_html = Distributed.@spawnat :any make_html()
fetch(f_latex)
fetch(f_html)
# w = Distributed.workers()
# f_latex = Distributed.remotecall(make_latex, w[1])
# f_html = Distributed.remotecall(make_html, w[2])
# fetch(f_latex)
# fetch(f_html)
make_html()
make_latex()
# Hack for deploying: copy the pdf (and only the PDF) into the HTML build
# directory! We don't want to copy everything in `latex_build` because it
# includes lots of extraneous LaTeX files.
Expand Down
39 changes: 32 additions & 7 deletions docs/src/tutorials/linear/sports_scheduling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
# in 2016 as part of an operations research course at the University of
# Wisconsin-Madison.**

# The purpose of this tutorial is to demonstrate a simple model for scheduling
# round-robin tournaments. As teams, it uses the [Big 10](https://en.wikipedia.org/wiki/Big_Ten_Conference).
# The purpose of this tutorial is to demonstrate a simple mixed-integer linear
# program for scheduling round-robin tournaments. As teams, it uses University
# teams from the [Big Ten Conference](https://en.wikipedia.org/wiki/Big_Ten_Conference).
# (You might notice that there are more than 10 teams. Our example was also
# written before the expansion of the Conference in 2024.)

Expand All @@ -41,10 +42,20 @@ import HiGHS
# Here are the teams in our tournament:

M = [
#!format:off
"Ind", "UMD", "UMich", "MSU", "OSU", "Penn", "Rtgrs", "Ill", "Iowa", "UMN",
"UNL", "NU", "Purd", "UW",
#!format: on
"Ill", # U. Illinois Urbana-Champaign
"Ind", # Indiana University Bloomington
"Iowa", # University of Iowa
"MSU", # Michigan State University
"NU", # Northwestern University
"OSU", # The Ohio State Univesity
"Penn", # Pennsylvania State University
"Purd", # Purdue University
"Rtgrs", # Rutgers University
"UMD", # University of Maryland, College Park
"UMich", # University of Michigan
"UMN", # University of Minnesota Twin Cities
"UNL", # University of Nebraska-Lincoln
"UW", # University of Wisconsin-Madison
];

# For each team to play each other exactly once, we need the number of teams - 1
Expand Down Expand Up @@ -85,6 +96,19 @@ model = Model(HiGHS.Optimizer);
sum(x[m, n, :]) + sum(x[n, m, :]) == 1,
);

# One problem with out model is that there is a lot of symmetry. To make the
# problem easier to solve, we fix the schedule of a random team to play every
# team in order, alternating between home and away:

m = rand(M)
for (t, n) in enumerate(filter(!=(m), M))
if isodd(t)
fix(x[m, n, t], 1)
else
fix(x[n, m, t], 1)
end
end

# Now we can solve our model:

set_silent(model)
Expand Down Expand Up @@ -113,7 +137,8 @@ Y = round.(Bool, value.(x))
print_schedule(M, T, Y)

# This schedule is okay, but it features a large number of back-to-back away
# games. Let's count them:
# games (in which a team plays away from home two weeks in a row). Let's count
# them:

number_of_back_to_back_away_games =
sum(round(Int, value(sum(x[:, m, (t-1):t]))) == 2 for m in M, t in 2:T)
Expand Down
Loading