Football Manager Optimizer

Posted on: 25 Jan, 2021 MIRO Examples Knapsack


Kicker Manager Interactive is an indispensable tool to prove to your friends and colleagues that you have superior soccer knowledge/expertise. Since we at GAMS are also part of this battle, we decided to take our Kicker Manager game to the next level by doing what we do best! Optimize!

First of all, the rules of the game: each participant has the task of forming a team from the active players of the Bundesliga (the German Soccer League). Good ratings (by the Kicker magazine), scoring goals or giving assists earn a player points. Negative points are awarded for bad ratings or red cards. The goal is for your team’s players to score more points than the opponent’s. As in the world of mathematical optimization, soccer managers are also bound by constraints. For example, your team must consist of 22 players, the number of players per position is predetermined, you can have a maximum of 4 players from the same Bundesliga team in your squad, and the cumulative market value of your team must not exceed 42.5 million euros.

To be able to fix bad player acquisitions, there is a transfer window in the winter break of the season. In this transfer period, a total of four players of the own team can be sold and replaced by new players.

Sounds like a task where an optimization model could support us? We thought so, too! Thus, we went to the drawing board and developed a model formulation for this Knapsack problem, quickly followed by a GAMS model and a MIRO app to interact with it. And here it is!

Model formulation (partial)

A common tactic is to build a squad of 11 or more (in case one of the core players is injured or substituted) expensive core players ("starters") and fill it up with cheap ones ("substitutes"). The task of assembling a good team can be modeled as a Mixed Integer Program. The key decisions are whether a player $p$ is selected or not (modeled by a binary variable $X_p$) and if a selected player belongs to the so-called starters (modeled by a binary variable $S_p$). The difference between starters and substitutes is that the expected points of starters contribute to the objective with weight 1, while the expected points of the substitutes can be weighted with an individual factor $wsubst$ (usually much smaller than 1), depending on how much importance you give them:

$$ \max \sum_p(pts_p \cdot S_p) + \sum_p(pts_p \cdot (X_p - S_p)) \cdot wsubst $$

The rules of the manager game, such as the number of players to be selected for each position (3 goalkeepers, 5 defenders, 8 midfielders and 6 strikers), can be formulated as constraints: $$ \sum_{p \in \mathcal{P_{goal}}} X_p = 3,\ \ \sum_{p \in \mathcal{P_{def}}} X_p = 6,\ \ \sum_{p \in \mathcal{P_{mid}}} X_p = 8\ \ \sum_{p \in \mathcal{P_{fwd}}} X_p = 5\ $$ where $\mathcal{P_{goal}}, \mathcal{P_{def}}, \mathcal{P_{mid}}, \mathcal{P_{fwd}}$ are sets of all available goalkeepers, defenders, midfielders and forwards.

At this point, we skip on covering the full algebraic model in detail and refer to the source code for further details.

Planning transfers

The current Bundesliga season is already underway. Even though you can still create a new team, you won’t be able to catch up with the managers who created a team before the season started. However, if you already have a team, you can exchange up to four players thanks to the transfer window that has just opened. So let’s try to pimp our teams by optimizing transfers!

Let’s start with Robin’s team: unlike Fred and Lutz, who meticulously analyzed the strengths and weaknesses of each player over an extensive period of time before forming their teams, he went with his gut and quickly assembled a team of 11 players who he believed could make it big! While this approach brought him much success last season, he is lagging behind this one. Therefore, it is crucial for him to use the transfer window to his advantage. Still, he sticks to his approach of not spending much time on his decision. With the new tool at hand, he simply uses the player’s statistics from the first half of the season and lets the optimization model find the best transfers for him:

Note that the total price of sold players is slightly higher than that of purchased players, but the points/100,000€ are much higher for purchased players than for those that are sold.

Fred, who is the author of the Football Manager Optimizer, follows a semi-automated/interactive approach. He uses the points players made in the first half of the season, but adjusts them based on his predictions. He fixes players he is especially confident in, computes multiple teams with similar objective function value, compares them and repeats the process until he is happy with what he sees.

Lutz currently leads the scoreboard with 821 points, compared to Fred with 645 and Robin with 619. He spends a lot of time analyzing players and teams, far more than the other two, and doesn’t believe optimization can help him with this highly emotional process. So he sticks with his manual approach and has come up with the following transfers:

It remains to be seen which approach is going to be the most successful!

The ultimate team

Now that the first half of the season is over, wouldn’t it be interesting to know what would have been the best possible team in hindsight? Thanks to the Football Manager Optimizer this is super easy to calculate. We set the number of starters to 11, run the model and get the following team:

Theoretically, there could be even better teams if we take into account that on certain match days one of our substitutes might have scored more points than one of our starters, but that will be pretty close to the global optimum.

Our team would then have reached a total of 1,222 points. The current leader in the nationwide standings has 993 points. Not bad! Interestingly, only 5 players from the team of the current leader and the ultimate team of Football Manager Optimizer overlap!

Do you also want Football Manager Optimizer to support you with your transfer decisions? Give it a try !