In [1] a simple problem was posted:
- We have a population of \(N=24\) players, each with an ELO rating \(r_i\)
- We need to select \(2 \times 6\) players for 2 teams (each team has \(n=6\) members).
- We want to minimize the difference in average ELO ratings of the teams.
The poster asked for an algorithm. But, of course, this looks like a problem we can solve as a mathematical programming model.
First I generated some random data:
---- 11 PARAMETER r ELO rating
player1 1275, player2 1531, player3 1585, player4 668, player5 1107, player6 1011
player7 1242, player8 1774, player9 1096, player10 1400, player11 1036, player12 1538
player13 1135, player14 1206, player15 2153, player16 1112, player17 880, player18 850
player19 1528, player20 1875, player21 939, player22 1684, player23 1807, player24 1110
I have no idea if these numbers are realistic or not.
It make sense to look at this from an assignment problem point of view. It is amazing how often this concept is encountered in modeling. So we define:\[x_{i,j}=\begin{cases} 1 & \text{if player $i$ is assigned to team $j$}\\ 0 & \text{otherwise}\end{cases}\]
A high-level model can look like:
| High-level Model |
|---|
| \[\begin{align}\min\>& | \color{DarkRed}{\mathit{avg}}_2 - \color{DarkRed}{\mathit{avg}}_1 | \\ & \sum_j \color{DarkRed} x_{i,j} \le 1 && \forall i\\ & \sum_i \color{DarkRed} x_{i,j} = \color{DarkBlue} n && \forall j \\ & \color{DarkRed}{\mathit{avg}}_j = \frac{\displaystyle \sum_i \color{DarkBlue} r_i \color{DarkRed} x_{i,j}}{\color{DarkBlue} n} \\ & \color{DarkRed}x_{i,j} \in \{0,1\}\end{align} \] |
Notes:
- The absolute value is easily linearized, e.g. \[\begin{align} \min\> & z \\ & -z \le \mathit{avg}_2-\mathit{avg}_1\le z\end{align}\]
- We can use the sum instead of the average
Surprisingly, the solution looks like:
---- 43 VARIABLE x.L assignment
team1 team2
player1 1.000
player2 1.000
player4 1.000
player5 1.000
player6 1.000
player7 1.000
player8 1.000
player9 1.000
player10 1.000
player11 1.000
player17 1.000
player18 1.000
---- 43 VARIABLE avg.L average rating of team
team1 1155.833, team2 1155.833
---- 43 PARAMETER report solution report
team1 team2
player1 1275.000
player2 1531.000
player4 668.000
player5 1107.000
player6 1011.000
player7 1242.000
player8 1774.000
player9 1096.000
player10 1400.000
player11 1036.000
player17 880.000
player18 850.000
sum 6935.0006935.000
avg 1155.8331155.833
We achieved a perfect match! (The probability of this must be somewhat low).
References
- Team matchmaking algorithm based on ELO, https://stackoverflow.com/questions/53119389/team-matchmaking-algorithm-based-on-elo
