Schedule tennis club matches. This program takes in the following information:
- Player list with division and ranking.
- Available slots for matches, given by a court and a time block.
- Player preferences for slots.
- Player demands for certain time blocks (hard constraint).
- Availability of divisions by slot.
- Ranking of the time blocks in a day (auxiliary information to know how time blocks are ordered chronologically).
- "Raw" preferences for portions of the day (i.e.: morning, afternoon). This information is used to create the player preferences for the slots. This is done so players can pick portions of the day they prefer (or not) to play, and then the program creates the granular preferences by slots. Notice that a portion of the day can be split into multiple time blocks.
With the input information, the program:
- Creates the round-robin groups for each division. The maximum number of
players in a group is given by the
group_size
parameter. To create the groups, the players are seeded by ranking and then assigned to distinct groups. The remaining players are randomly assigned to balanace the number of players in each group. - Creates the possible matches for each group. A group of 4 players produces 6 distinct matches, whereas a group of 3 players produces 3 distinct matches.
- Assigns the matches to the available slots. A mathematical optimization decision model is used to decide which match should be assigned to which slot (given by a time block and a court). Please see the mathematical formulation section for the details.
The input data is provided in multiple sheets of an Excel file. Please refer to
the tennis.xlsx
file for an example. The output data is also
an Excel file containing the groups and the scheduled matches.
Install the requirements:
pip install -r requirements.txt
Get the help for the available options by running:
python main.py --help
Run the program with default options:
python main.py
Pass in custom options such as the input file name, output file name, and maximum solver duration:
python main.py -input tennis.xlsx -output schedule.xlsx -duration 60
The model takes into account the following considerations:
- Only one match can be assigned to a slot.
- The overall preference of the players for the time blocks is maximized. The program tries to assign players to their preferred time blocks, and avoids assigning players to their least preferred time blocks.
- The program tries to not schedule back-to-back matches for the same player.
- Matches are assigned to the slots that their division allows.
- There may be dummy slots that can be used to over-book the club at certain times if needed. The program tries to minimize the number of dummy slots used.
- Some players have special demands regarding the time blocks they can play.
-
$P$ : set of players. -
$M$ : set of matches. -
$S$ : set of slots. -
$T$ : set of time blocks. -
$TD_d$ : subset of time blocks allowed for division$d \in D$ . -
$PM_m$ : subset of players in match$m \in M$ . -
$ST_t$ : subset of slots that have time block$t \in T$ . -
$MP_p$ : subset of matches that player$p \in P$ plays in. -
$TP_p$ : subset of time blocks that player$p \in P$ can play in.
-
$r_t$ : ranking of the time block$t \in T$ . The ranking is an integer number that increases by one for each time block in the same day. The ranking is used to represent the order of the time blocks in a day. -
$b_s$ : 1, if slot$s \in S$ is a dummy slot; 0, otherwise. -
$e_{p,s}$ : the preference of player$p \in P$ for slot$s \in S$ . A preference can be: 1 (preferred), 0 (neutral), -1 (not preferred). -
$i_s$ : time block of slot$s \in S$ . -
$n$ : the penalty for using a dummy slot. -
$n'$ : the penalty for assigning back-to-back matches for the same player. -
$d_m$ : the division of match$m \in M$ .
-
$x_{m,s}$ : 1, if match$m \in M$ is assigned to slot$s \in S$ ; 0, otherwise.
Maximize the overall preference of assignments.
These are the components of the objective function:
- The preference of the players for the slots.
- The use of dummy slots is not preferred.
- The assignments of back-to-back matches for the same player is not preferred.
- Every match must be scheduled in exactly one slot.
- At most one match can be scheduled in a slot.
- Matches can only be assigned to slots that are allowed by the division.
- Each player can only play one match at a time.
- A player with special demands can only play in the allowed time blocks.
-
Three matches can not be schedules in consecutive time blocks.
TBD
-
Variables domain.